Commit 162ce557 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

better printing of errors when reading and sending user login information from...

better printing of errors when reading and sending user login information from bindctl to cmdctl; ticket #260
(coded by tingting, reviewed partly by shane, the rest by me)


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@2681 e5f2f494-b856-4b98-b285-d166d9295462
parent 53992ca8
......@@ -38,7 +38,6 @@ import csv
import json
import pwd
import getpass
import traceback
try:
from collections import OrderedDict
......@@ -123,7 +122,6 @@ class BindCmdInterpreter(Cmd):
except FailToLogin as err:
print(err)
print(FAIL_TO_CONNECT_WITH_CMDCTL)
traceback.print_exc()
except KeyboardInterrupt:
print('\nExit from bindctl')
......@@ -142,8 +140,8 @@ class BindCmdInterpreter(Cmd):
users_info = csv.reader(csvfile)
for row in users_info:
users.append([row[0], row[1]])
except (IOError, IndexError) as e:
pass
except (IOError, IndexError) as err:
print("Error reading saved username and password from %s%s: %s" % (dir, file_name, err))
finally:
if csvfile:
csvfile.close()
......@@ -162,8 +160,9 @@ class BindCmdInterpreter(Cmd):
writer = csv.writer(csvfile)
writer.writerow([username, passwd])
csvfile.close()
except Exception as e:
print(e, "\nCannot write %s%s; default user is not stored" % (dir, file_name))
except IOError as err:
print("Error saving user information:", err)
print("user info file name: %s%s" % (dir, file_name))
return False
return True
......@@ -183,8 +182,8 @@ class BindCmdInterpreter(Cmd):
try:
response = self.send_POST('/login', param)
data = response.read().decode()
except socket.error:
traceback.print_exc()
except socket.error as err:
print("Socket error while sending login information:", err)
raise FailToLogin()
if response.status == http.client.OK:
......@@ -206,8 +205,8 @@ class BindCmdInterpreter(Cmd):
response = self.send_POST('/login', param)
data = response.read().decode()
print(data)
except socket.error as e:
traceback.print_exc()
except socket.error as err:
print("Socket error while sending login information:", err)
raise FailToLogin()
if response.status == http.client.OK:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment