gnewsense-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnewsense-dev] Debderive


From: Karl Goetz
Subject: Re: [Gnewsense-dev] Debderive
Date: Mon, 20 Feb 2012 10:19:30 +1100

On Mon, 20 Feb 2012 01:20:37 +0300
Stayvoid <address@hidden> wrote:

Please stop using reply-all. it means every time i 'reply' i have to
manually fix up the To:.
I'm subscribed to the list, I don't need to be CC:d.

> I wrote another patch:
> 
> --- debderive.py
> +++ debderive_patch2.py
> @@ -477,9 +477,17 @@
> 
> 
>  if __name__ == "__main__":
> -    # Check for reprepro
> -    if not os.path.exists('/usr/bin/reprepro'):
> -        raise IOError, 'Missing dependency: install reprepro and try
> again.'
> +    try:
> +        open('/usr/bin/reprepro')
> +    except IOError:
> +        sys.stderr.write('Missing dependency: install reprepro and
> try again.\n')
> +#        raise

Are you able (Is python able) to (conveniently) check if something is in
your path, rather then at a fixed point in the filesystem?

> +    try:
> +        open('/etc/debderiver/debderiver.yaml')
> +    except IOError:
> +        sys.stderr.write('Copy `debderiver.yaml\' to
> `/etc/debderiver\' and edit it to suit your needs.\n')
> +#        raise
> 
>      CONF_DIR_PATH = '/etc/debderiver'

Sam commented that deriver might support a per user config too, so that
would need to be checked for at the same time.

> Which one should I use: "sys.exit(1)" or "raise"? I've read some
> discussions, but it's unclear to me.
> I'd used "raise" because it provides more information. I'm not sure
> that it's necessary to stop the script this way. That's why I
> commented it out.
> Maybe we should uncomment it if those checks are "critical."

otoh, does it provide useful information that catching the message and
printing it wont?

>>> import sys
>>> try:
...  open('/usr/bin/reprepradsfadfo')
... except IOError:
...  sys.stderr.write('Missing dependency: install reprepro')
...  raise
... 
Missing dependency: install repreproTraceback (most recent call last):
  File "<stdin>", line 2, in <module>
IOError: [Errno 2] No such file or directory: '/usr/bin/reprepradsfadfo'


>>> try:    open('/usr/bin/reprepradsfadfo')
... except IOError, e:
...     print e
...     sys.stderr.write('Missing dependency: install reprepro\n')
... 
[Errno 2] No such file or directory: '/usr/bin/reprepradsfadfo'
Missing dependency: install reprepro

(I have reprepro installed, so i couldn't use the code as-is)

> I used "sys.stderr.write" because (AFAIK) it's compatible with the
> third version of Python. Maybe we should replace every "print" with it
> ("print" statements are only used for the error handling). What do you
> think?
> 
> What is the name of the program: "debderive" or "debderiver"?
> You use different names for the directory and for the script.
> Is there a reason for this or it's just a typo?

afaik its debderiver, others may be typos or left overs from an earlier
name.

> > I'm not a python buff, but isn't The Done Thing to use try blah:,
> > except IOError?
> What about this?
> 
> try:
>   open('/usr/local/bin/debderiver.py')
> except IOError:
>   print 'Copy `debderiver.py\' to `/usr/local/bin\'\n'
> 
> I've looked through the docs and this one looks right. But it doesn't
> check the actual file.

'the actual file'?
thanks,
kk

> And I don't know how to use "if" and "os.path.abspath" with "try."
> 
> Cheers


-- 
Karl Goetz, (Kamping_Kaiser / VK7FOSS)
http://www.kgoetz.id.au
No, I won't join your social networking group

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]