def dumpToImpala(self, pcap_data, src='/tmp/test.pcap'): print 'dumpToImpala' sm = StoreManager('ast12.recerca.intranet.urv.es', 21050, 'lab144', 'lab144') sm.connect() sm.execute('use benchbox') for idx, data in pcap_data: ts = '{},{}'.format(idx.getts()[0], idx.getts()[1] ) ether = dpkt.ethernet.Ethernet(data) if ether.type != dpkt.ethernet.ETH_TYPE_IP: raise ip = ether.data #print ip.data dst = socket.inet_ntoa(ip.dst) src = socket.inet_ntoa(ip.src) udp = ip.data line = (ts, src, udp.sport, dst, udp.dport, ip.v, ip.len) insert_into_logger = "insert into logger_pcap values ('{}', '{}', '{}', {}, {}, {}, {})".format(ts, src, dst, udp.sport, udp.dport, ip.v, ip.len) sm.execute(insert_into_logger) sm.quit()
def addToEditHistory(self): filePath = vim.current.buffer.name if not os.path.exists(filePath): return history = StoreManager.load(self.editHistoryKey) for i, historyFileName in enumerate(history): if historyFileName == filePath: del history[i] break history.append(filePath) StoreManager.save(self.editHistoryKey , history)
def showEditHistory(self): editHistory = StoreManager.load(self.editHistoryKey) editHistory.reverse() if editHistory: candidates = [FileCandidate(str(path)) for path in editHistory] SearchBackend.showSearchResult(candidates) else: print "empty history"
def setLoggerId(self, dummy_hostname, pc_server_name, profile, test_definition): self.logger_id = time() self.hostname = dummy_hostname sm = StoreManager('ast12.recerca.intranet.urv.es', 21050, 'lab144', 'lab144') sm.connect() sm.execute('use benchbox') insert_into_logger = "insert into logger_id values ('{}', '{}', '{}', '{}', '{}')" \ .format(self.logger_id, dummy_hostname, pc_server_name, profile, test_definition) sm.execute(insert_into_logger) sm.quit()
def pushToLogger(self): print 'Store to impala' sm = StoreManager('ast12.recerca.intranet.urv.es', 21050, 'lab144', 'lab144') sm.connect() sm.execute('use benchbox') for value in enumerate(self.diskValues): print value items = value[1].split(' ') insert_into_logger = "insert into logger_hdd values ('{}', {}, {}, '{}', '{}')" \ .format(items[0], items[1], items[2], self.loggerId, self.hostname) sm.execute(insert_into_logger) sm.quit()
def editCdHistory(self): StoreManager.editSavedValue(self.storeKey)
def addToCdHistory(self, dirPath): history = StoreManager.load(self.storeKey) if dirPath not in history: history.append(dirPath) StoreManager.save(self.storeKey, history)
def showFilterCdHistory(self, symbol): history = StoreManager.load(self.storeKey) candidates = [LocateCdCandidate(str(path)) for path in history if symbol in path] SearchBackend.showSearchResult(candidates, filterCheck=locatefilterCheck)
def editHistory(self): StoreManager.editSavedValue(self.editHistoryKey);