Commits

Nikolaj Sjujskij  committed dc592a3

Catch exception in netrc handling

In absence of ~/.netrc file authentication-related code fails badly.
Therefore `netrc.netrc()` should be wrapped in `try: ... except: ...` block.

  • Participants
  • Parent commits b44dee0

Comments (0)

Files changed (1)

File scripts/lodgeit.py

 def get_authenticated_url(url):
     import netrc, urlparse
     s = list(urlparse.urlsplit(url))
-    auth = netrc.netrc().authenticators(s[1])
+    try:
+        netrcfile = netrc.netrc()
+    except IOError:
+        return url
+    auth = netrcfile.authenticators(s[1])
     if not auth:
         return url
     s[1] = '%s:%s@%s' % (auth[0], auth[2], s[1])