# HG changeset patch # User Chris Cannam # Date 1309265040 -3600 # Node ID 765255e9cc921b555c674d1af42353787e8c676b # Parent b7a740eef696d166e78ba61292972d01d44660cc Continue without "remember" feature if the necessary imports fail diff -r b7a740eef696 -r 765255e9cc92 easyhg2.py --- a/easyhg2.py Tue Jun 28 13:27:05 2011 +0100 +++ b/easyhg2.py Tue Jun 28 13:44:00 2011 +0100 @@ -50,14 +50,15 @@ from PyQt4 import Qt, QtGui except ImportError: easyhg_pyqt_ok = False - easyhg_qtapp = None -#!!! same as above for this? or just continue without remember feature? -from Crypto.Cipher import AES -import base64 - -import ConfigParser # Mercurial version won't write files +easyhg_authfile_imports_ok = True +try: + from Crypto.Cipher import AES + import ConfigParser # Mercurial version won't write files + import base64 +except ImportError: + easyhg_authfile_imports_ok = False #!!! should be in a class here @@ -166,11 +167,14 @@ uri = canonical_url(authuri) - pkey = base64.b64encode('%s@@%s' % (uri, user)).replace('=', '_') + pkey = None pekey = self.ui.config('easyhg', 'authkey') pfile = self.ui.config('easyhg', 'authfile') - use_authfile = (pekey and pfile) - if pfile: pfile = os.path.expanduser(pfile) + use_authfile = (easyhg_authfile_imports_ok and pekey and pfile) + if use_authfile: + pkey = base64.b64encode('%s@@%s' % (uri, user)).replace('=', '_') + if pfile: + pfile = os.path.expanduser(pfile) pdata = None self.ui.write("pekey is %s\n" % pekey)