gnewsense-dev
[Top][All Lists]
Advanced

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

Re: [Gnewsense-dev] Debderive


From: Stayvoid
Subject: Re: [Gnewsense-dev] Debderive
Date: Mon, 20 Feb 2012 01:20:37 +0300

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
+
+    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'

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."

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?

> 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.
And I don't know how to use "if" and "os.path.abspath" with "try."

Cheers



reply via email to

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