def __init__(self, url, password, server, dbms, dbHost, dbUserName, dbPassword, db = ''): Connector.__init__(self, url, password, server) self.dbms = dbms self.dbHost = dbHost self.dbUserName = dbUserName self.dbPassword = dbPassword self.db = db
def __init__(self, url, password, server, timeout): Connector.__init__(self, url, password, server, timeout) self.osType = '' self.logfileName = expanduser("~") + "/" + ".blade_logfile-"+(time.strftime("%d_%m_%Y"))+"__"+url[url.find("://")+3:][:url[url.find("://")+3:].find("/")]+".log" self.HISTORY_FILE = expanduser("~") + "/" + ".blade_command_history" self.volcab = [''] self.initHistory() self.GREEN = '\033[92m' self.REDBOLD = '\033[91m'+'\033[1m' self.ENDC = '\033[0m'
def __init__(self, url, password, server, dbms, dbHost, dbUserName, dbPassword, db=''): Connector.__init__(self, url, password, server) self.dbms = dbms self.dbHost = dbHost self.dbUserName = dbUserName self.dbPassword = dbPassword self.db = db
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
def getConnector(self, config): if config['shell'] == True: connector = WebShellConnector(config['url'], config['password'], config['server']) elif len(config['pull']) > 0: connector = PullConnector(config['url'], config['password'], config['server'], config['pull']) elif len(config['push']) > 0: connector = PushConnector(config['url'], config['password'], config['server'], config['push']) elif config['database'] == 'mysql' or config[ 'database'] == 'sqlserver' or config[ 'database'] == 'oracle' or config['database'] == 'access': print '+ Enter database configuration' host = raw_input('+ Database host: ') userName = raw_input('+ User name: ') password = raw_input('+ Password: '******'------------------------------------------------------------' if config['database'] == 'oracle': db = raw_input('+ Database name: ') connector = DatabaseConnector(config['url'], config['password'], config['server'], config['database'], host, userName, password, db) else: connector = DatabaseConnector(config['url'], config['password'], config['server'], config['database'], host, userName, password) else: connector = Connector(config['url'], config['password'], config['server']) return connector
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 ''
def getConnector(self, config): if config['shell'] == True: connector = WebShellConnector(config['url'], config['password'], config['server']) elif len(config['pull']) > 0: connector = PullConnector(config['url'], config['password'], config['server'], config['pull']) elif len(config['push']) > 0: connector = PushConnector(config['url'], config['password'], config['server'], config['push']) else: connector = Connector(config['url'], config['password'], config['server']) return connector
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 ''
def launch(self): return Connector.launch(self)
def __init__(self, url, password, server, fileList, timeout): Connector.__init__(self, url, password, server, timeout) self.fileList = fileList
def __init__(self, url, password, server): Connector.__init__(self, url, password, server) self.osType = ''