Skip to content

Commit b99655e

Browse files
committed
Exception message field and raw_input()
1 parent 5a128cf commit b99655e

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

bessctl/bessctl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class BESSCLI(cli.CLI):
6969

7070
except self.bess.RPCError as e:
7171
self.err('RPC failed to {}:{} - {}'.format(
72-
self.bess.peer[0], self.bess.peer[1], e.message))
72+
self.bess.peer[0], self.bess.peer[1], str(e)))
7373

7474
self._handle_broken_connection()
7575
raise self.HandledError()
@@ -121,7 +121,7 @@ def run_cli(instream=sys.stdin):
121121
s.connect()
122122
except BESS.APIError as e:
123123
if cli.interactive:
124-
cli.ferr.write(e.message + '\n')
124+
cli.ferr.write(str(e) + '\n')
125125
cli.ferr.write('Perhaps bessd daemon is not running locally? '
126126
'Try "daemon start".\n')
127127

bessctl/cli.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,12 @@ def print_banner(self):
370370

371371
def process_one_line(self):
372372
if self.interactive:
373-
try: # Hack for Python 2/3 compatibility
374-
input = raw_input
375-
except NameError:
376-
pass
377373
try:
378-
line = input(self.get_prompt())
374+
# Hack for Python 2/3 compatibility
375+
if hasattr(__builtins__, 'raw_input'):
376+
line = raw_input(self.get_prompt())
377+
else:
378+
line = input(self.get_prompt())
379379
except KeyboardInterrupt:
380380
self.fout.write('\n')
381381
return

bessctl/commands.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,13 @@ def warn(cli, msg, func, *args):
545545
if cli.rl:
546546
cli.rl.set_completer(cli.complete_dummy)
547547

548-
try: # Hack for compatibility
549-
input = raw_input
550-
except NameError:
551-
pass
552-
553548
try:
554-
resp = input('WARNING: %s Are you sure? (type "yes") ' % msg)
549+
# Hack for Python 2/3 compatibility
550+
if hasattr(__builtins__, 'raw_input'):
551+
resp = raw_input(
552+
'WARNING: %s Are you sure? (type "yes") ' % msg)
553+
else:
554+
resp = input('WARNING: %s Are you sure? (type "yes") ' % msg)
555555

556556
if resp.strip() == 'yes':
557557
func(cli, *args)

0 commit comments

Comments
 (0)