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

_______________________________________________
gNewSense-dev mailing list
gNewSense-dev@nongnu.org
https://lists.nongnu.org/mailman/listinfo/gnewsense-dev

Reply via email to