Catchier error messages.

Signed-off-by: Arun Prakash Jana <engineerarun@gmail.com>
This commit is contained in:
Arun Prakash Jana 2016-03-25 12:04:32 +05:30
parent a56fa0381d
commit eae1237ea7

16
buku
View File

@ -196,7 +196,7 @@ def fetchTitle(url):
print("\x1b[1mREDIRECTION:\x1b[21m %s" % url) print("\x1b[1mREDIRECTION:\x1b[21m %s" % url)
if redirurl.find("sorry/IndexRedirect?") >= 0: # graecefully handle Google blocks if redirurl.find("sorry/IndexRedirect?") >= 0: # graecefully handle Google blocks
print("ERROR: Connection blocked due to unusual activity.") print("\x1b[1mERROR:\x1b[21m Connection blocked due to unusual activity.")
break break
marker = redirurl.find("redirectUrl=") marker = redirurl.find("redirectUrl=")
@ -205,14 +205,14 @@ def fetchTitle(url):
# break same URL redirection loop # break same URL redirection loop
if url == redirurl: if url == redirurl:
print("ERROR: Detected repeated reirection to same URL") print("\x1b[1mERROR:\x1b[21m Detected repeated reirection to same URL")
break break
url = redirurl url = redirurl
urlconn.close() urlconn.close()
resp, urlconn = getPageResp(url, True) resp, urlconn = getPageResp(url, True)
else: else:
print("ERROR in response:", str(resp.status), ": ", resp.reason) print("\x1b[1mERROR:\x1b[21m [", str(resp.status), "] ", resp.reason)
break break
except Exception as e: except Exception as e:
print("Exception: %s" % e) print("Exception: %s" % e)
@ -617,7 +617,7 @@ def encrypt_file():
# If both encrypted file and flat file exist, error out # If both encrypted file and flat file exist, error out
if os.path.exists(dbpath) and os.path.exists(encpath): if os.path.exists(dbpath) and os.path.exists(encpath):
print("ERROR: Both encrypted and flat DB files exist!") print("\x1b[1mERROR:\x1b[21m Both encrypted and flat DB files exist!")
sys.exit(1) sys.exit(1)
password = '' password = ''
@ -672,12 +672,12 @@ def decrypt_file():
dbpath = os.path.join(os.environ.get('HOME'), '.cache', 'buku', 'bookmarks.db') dbpath = os.path.join(os.environ.get('HOME'), '.cache', 'buku', 'bookmarks.db')
encpath = dbpath + '.enc' encpath = dbpath + '.enc'
if not os.path.exists(encpath): if not os.path.exists(encpath):
print("Error: %s missing" % encpath) print("\x1b[1mERROR:\x1b[21m %s missing" % encpath)
sys.exit(1) sys.exit(1)
# If both encrypted file and flat file exist, error out # If both encrypted file and flat file exist, error out
if os.path.exists(dbpath) and os.path.exists(encpath): if os.path.exists(dbpath) and os.path.exists(encpath):
print("ERROR: Both encrypted and flat DB files exist!") print("\x1b[1mERROR:\x1b[21m Both encrypted and flat DB files exist!")
sys.exit(1) sys.exit(1)
password = '' password = ''
@ -790,13 +790,13 @@ try:
addurl = True addurl = True
elif opt[0] == "-k": elif opt[0] == "-k":
if no_crypto == True: if no_crypto == True:
print("Error: PyCrypto missing") print("\x1b[1mERROR:\x1b[21m PyCrypto missing")
sys.exit(0) sys.exit(0)
decrypt = True decrypt = True
elif opt[0] == "-l": elif opt[0] == "-l":
if no_crypto == True: if no_crypto == True:
print("Error: PyCrypto missing") print("\x1b[1mERROR:\x1b[21m PyCrypto missing")
sys.exit(0) sys.exit(0)
encrypt = True encrypt = True