Parcourir la source

[trac588] fix a bug(bindctl traceback on shutdown) and hide some log while using non-interactive bindctl

chenzhengzhang il y a 14 ans
Parent
commit
f009a63758
1 fichiers modifiés avec 6 ajouts et 2 suppressions
  1. 6 2
      src/bin/bindctl/bindcmd.py

+ 6 - 2
src/bin/bindctl/bindcmd.py

@@ -123,8 +123,10 @@ class BindCmdInterpreter(Cmd):
         except FailToLogin as err:
             # error already printed when this was raised, ignoring
             pass
-        except KeyboardInterrupt:
+        except (KeyboardInterrupt, socket.error):
             print('\nExit from bindctl')
+        except http.client.CannotSendRequest:
+            print('Failed to send request, the connection is busy')
 
     def _get_saved_user_info(self, dir, file_name):
         ''' Read all the available username and password pairs saved in 
@@ -188,7 +190,9 @@ class BindCmdInterpreter(Cmd):
                 raise FailToLogin()
 
             if response.status == http.client.OK:
-                print(data + ' login as ' + row[0] )
+                # Is interactive?
+                if sys.stdin.isatty():
+                    print(data + ' login as ' + row[0] )
                 return True 
 
         count = 0