def launch(self):
     try:
         if Connector.launch(self) != 'fail':
             if self.connect():
                 print '+ Connection Established'
                 print ''
                 if self.db == '':
                     sql = 'show schemas;'
                 else:
                     sql = 'show tables;'
                 while sql != 'exit':
                     pattern = re.search(r'use .*', sql)
                     if pattern:
                         self.selectDb(pattern.group()[4:].split(';')[0])
                         print 'Database changed'
                         sql = raw_input('> ')
                     else:
                         result = self.requestSql(sql)
                         try:
                             self.printResult(result)
                         except IndexError:
                             print 'Empty Set'
                         sql = raw_input('> ')
             else:
                 print '- Error: Can not connect to DBMS'
                 print ''
         else:
             print '- Error: Can not connect to DBMS'
             print ''
     except KeyboardInterrupt:
         pass
Exemple #2
0
 def launch(self):
     try:
         if Connector.launch(self) != 'fail':
             if self.connect():
                 print '+ Connection Established'
                 print ''
                 if self.db == '':
                     sql = 'show schemas;'
                 else:
                     sql = 'show tables;'
                 while sql != 'exit':
                     pattern = re.search(r'use .*', sql)
                     if pattern:
                         self.selectDb(pattern.group()[4:].split(';')[0])
                         print 'Database changed'
                         sql = raw_input('> ')
                     else:
                         result = self.requestSql(sql)
                         try:
                             self.printResult(result)
                         except IndexError:
                             print 'Empty Set'
                         sql = raw_input('> ')
             else:
                 print '- Error: Can not connect to DBMS'
                 print ''
         else:
             print '- Error: Can not connect to DBMS'
             print ''
     except KeyboardInterrupt:
         pass
Exemple #3
0
 def launch(self):
     try:
         if Connector.launch(self) != 'fail':
             self.setOsType()
             if self.osType == 'unix':
                 cmd = 'uname -a'
             else:
                 cmd = 'ver'
             pwd = '.'
             print '+ Connection Established'
             print ''
             while cmd != 'exit':
                 result, newPwd = self.runCmd(cmd, pwd)
                 print result
                 pwd = newPwd
                 cmd = raw_input('$ ')
         else:
             print '- Error: Can not get shell'
             print ''
     except KeyboardInterrupt:
         pass
     except AttributeError:
         print '- Error: Command can not run'
         print '- Check if the password or server type is incorrect'
         print ''
     except Exception:
         print '- Error: Can not get shell'
         print '- Check if the URL is incorrect'
         print ''
Exemple #4
0
 def launch(self):
     try:
         if Connector.launch(self) != 'fail':
             self.setOsType()
             if self.osType == 'unix':
                 cmd = 'uname -a'
             else:
                 cmd = 'ver'
             pwd = '.'
             print '+ Connection Established'
             print ''
             while cmd != 'exit':
                 result, newPwd = self.runCmd(cmd, pwd)
                 print result
                 pwd = newPwd
                 cmd = raw_input('$ ')
         else:
             print '- Error: Can not get shell'
             print ''
     except KeyboardInterrupt:
         pass
     except AttributeError:
         print '- Error: Command can not run'
         print '- Check if the password or server type is incorrect'
         print ''
     except Exception:
         print '- Error: Can not get shell'
         print '- Check if the URL is incorrect'
         print ''
Exemple #5
0
    def launch(self):
        try:
            print "Logfile is saved in " + self.logfileName
            print "File/dir completion activated [Tab]\n"
            if Connector.launch(self) != 'fail':
                self.setOsType()
                if self.osType == 'unix':
                    cmd = 'uname -a'
                else:
                    cmd = 'ver & net user'
                pwd = self.REDBOLD+'.'+self.ENDC
                pwd = '.'
                opwd = pwd
                print '+ Connection Established'
                print ''
                uname = ""
                #pdb.set_trace()###DEBUGING
                while cmd != 'exit':
                    if cmd != '':
                       result, pwd = self.runCmd(cmd, pwd)
                       if not opwd == pwd:
                           opwd = pwd
                           self.getCurrentFiles(pwd)
                                                     
                       print self.GREEN + result + self.ENDC
                       if uname == '':
                          uname = result
                       self.saveCmdHistory(uname,cmd,pwd,result)
                    cmd = raw_input('['+self.REDBOLD+pwd+self.ENDC+']$ ')
                    if '"' in cmd: ## Escape all user supplied double quotes
                       cmd = cmd.replace('"','\\"')
            else:
                print '- Error: Can not get shell'
                print ''
        except KeyboardInterrupt:
            pass

        except AttributeError:
            print '- Error: Command can not run'
            print '- Check syntax of command'
            print '- Check if the password correct'
            print '- Check if the server type is correct'
            print '- Check if the server is reachable'
            print ''
        except Exception:
            print '- Error: Can not get shell'
            print '- Check if the URL is incorrect'
            print ''
Exemple #6
0
 def launch(self):
     return Connector.launch(self)