File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import urllib3
1010from ocflib .misc .shell import green
1111from ocflib .misc .shell import red
1212from ocflib .printing .printers import PRINTERS
13+ from urllib3 .exceptions import TimeoutError
1314
1415
1516class Printer :
@@ -100,14 +101,21 @@ def main():
100101 end = ' ' )
101102 sys .stdout .flush ()
102103 with Printer (printer_name ) as printer :
103- if not printer .log_in (password ):
104- print (red ('Error:' ), 'the password is not correct. Try again.' )
105- return 1
106- if printer .change_economode (args .setting .title ()):
107- print (green ('OK' ))
108- else :
104+ try :
105+ printer .log_in (password )
106+ if not printer .logged_in :
107+ print (red ('Error:' ), 'the password is not correct. Try again.' )
108+ return 1
109+ if printer .change_economode (args .setting .title ()):
110+ print (green ('OK' ))
111+ else :
112+ print (red ('Failure' ))
113+ return 1
114+ except (OSError , TimeoutError ) as e :
115+ # If no route to host (e.g. out of rotation) or timeout, we still
116+ # want to set economode on other printers
109117 print (red ('Failure' ))
110- return 1
118+ print ( e )
111119
112120
113121if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments