]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
search for keyfile in sys.path as last resort; reword exception
authorGuido van Rossum <guido@python.org>
Sat, 7 Oct 1995 19:35:07 +0000 (19:35 +0000)
committerGuido van Rossum <guido@python.org>
Sat, 7 Oct 1995 19:35:07 +0000 (19:35 +0000)
Demo/pdist/security.py

index a11294a91c0cec7181075ec57da2b87b616d9e91..f9936828a416a85913dc47434e4fc88000670b2d 100755 (executable)
@@ -9,10 +9,17 @@ class Security:
                        keyfile = '.python_keyfile'
                        if env.has_key('HOME'):
                                keyfile = os.path.join(env['HOME'], keyfile)
+                       if not os.path.exists(keyfile):
+                               import sys
+                               for dir in sys.path:
+                                       kf = os.path.join(dir, keyfile)
+                                       if os.path.exists(kf):
+                                               keyfile = kf
+                                               break
                try:
                        self._key = eval(open(keyfile).readline())
                except IOError:
-                       raise IOError, "python keyfile %s not found" % keyfile
+                       raise IOError, "python keyfile %s: cannot open" % keyfile
 
        def _generate_challenge(self):
                import whrandom