Beispiel #1
0
 def run_connect_dialog(self, pipe_manager, server_address, transport_type, username):
     dialog = ATSvcConnectDialog(server_address, transport_type, username)
     dialog.show_all()
     
     # loop to handle the failures
     while True:
         response_id = dialog.run()
         
         if (response_id != gtk.RESPONSE_OK):
             dialog.hide()
             return None
         else:
             try:
                 self.server_address = dialog.get_server_address()
                 self.transport_type = dialog.get_transport_type()
                 self.username = dialog.get_username()
                 password = dialog.get_password()
                 
                 pipe_manager = ATSvcPipeManager(self.server_address, self.transport_type, self.username, password)
                 
                 break
             
             except RuntimeError, re:
                 msg = "Failed to connect: " + re.args[1] + "."
                 print msg
                 traceback.print_exc()                        
                 self.run_message_dialog(gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, msg, dialog)
                 
             except Exception, ex:
                 msg = "Failed to connect: " + str(ex) + "."
                 print msg
                 traceback.print_exc()
                 self.run_message_dialog(gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, msg, dialog)
Beispiel #2
0
 def run_connect_dialog(self, pipe_manager, server_address, transport_type, username, password = "", connect_now = False):
     dialog = ATSvcConnectDialog(server_address, transport_type, username, password) 
     dialog.show_all()
     
     # loop to handle the failures
     while True:
         if (connect_now):
             connect_now = False
             response_id = gtk.RESPONSE_OK
         else:
             response_id = dialog.run()
         
         if (response_id != gtk.RESPONSE_OK):
             dialog.hide()
             return None
         else:
             try:
                 server_address = dialog.get_server_address()
                 self.server_address = server_address
                 transport_type = dialog.get_transport_type()
                 self.transport_type = transport_type
                 username = dialog.get_username()
                 self.username = username
                 password = dialog.get_password()
                 
                 pipe_manager = ATSvcPipeManager(server_address, transport_type, username, password)
                 break
             
             except RuntimeError, re:
                 if re.args[1] == 'Logon failure': #user got the password wrong
                     self.run_message_dialog(gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, "Failed to connect: Invalid username or password.", dialog)
                     dialog.password_entry.grab_focus()
                     dialog.password_entry.select_region(0, -1) #select all the text in the password box
                 elif re.args[0] == 5 or re.args[1] == 'Access denied':
                     self.run_message_dialog(gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, "Failed to connect: Access Denied.", dialog)
                     dialog.username_entry.grab_focus()
                     dialog.username_entry.select_region(0, -1)
                 elif re.args[1] == 'NT_STATUS_HOST_UNREACHABLE':
                     self.run_message_dialog(gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, "Failed to connect: Could not contact the server.", dialog)
                     dialog.server_address_entry.grab_focus()
                     dialog.server_address_entry.select_region(0, -1)
                 elif re.args[1] == 'NT_STATUS_NETWORK_UNREACHABLE':
                     self.run_message_dialog(gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, "Failed to connect: The network is unreachable.\n\nPlease check your network connection.", dialog)
                 elif re.args[1] == 'NT_STATUS_CONNECTION_REFUSED':
                     self.run_message_dialog(gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, "Failed to connect: The connection was refused.", dialog)
                 else:
                     msg = "Failed to connect: %s." % (re.args[1])
                     print msg
                     traceback.print_exc()                        
                     self.run_message_dialog(gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, msg, dialog)
                 
             except Exception, ex:
                 msg = "Failed to connect: %s." % (str(ex))
                 print msg
                 traceback.print_exc()
                 self.run_message_dialog(gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, msg, dialog)