def loadXml(self,node): self.getText(node.childNodes) if node.nodeType!=Node.ELEMENT_NODE: for n in node.childNodes: if n.nodeType==Node.ELEMENT_NODE and n.localName == 'xdl_resource_report': self.loadXml(n) else: for n in node.childNodes: if n.nodeType==Node.ELEMENT_NODE and n.localName == 'pin': el=pin() el.loadXml(n) self.set_pin(el) for n in node.childNodes: if n.nodeType==Node.ELEMENT_NODE and n.localName == 'conn': el=conn() el.loadXml(n) self.set_conn(el) for n in node.childNodes: if n.nodeType==Node.ELEMENT_NODE and n.localName == 'cfg': el=cfg() el.loadXml(n) self.set_cfg(el) if node.hasAttributes(): attrs=node.attributes attrId='a1' if attrId in attrs.keys(): self.a1=str(attrs[attrId].value) attrId='a0' if attrId in attrs.keys(): self.a0=str(attrs[attrId].value) attrId='a3' if attrId in attrs.keys(): self.a3=str(attrs[attrId].value) attrId='a2' if attrId in attrs.keys(): self.a2=str(attrs[attrId].value)
print 'No hosts given...' sys.exit(0) ips_to_connect = [] for host in hosts_to_connect: ips_to_connect.append(host_to_ip[host]) shells = [] for ip in ips_to_connect: ip = ip user = logins[ip].keys()[0] passwd = logins[ip][user] if opts.sftp: x = sftp.sftp(user, passwd, ip) else: x = conn.conn(user, passwd, ip) shells.append(x) print ip_to_host[ip] command = raw_input("Command: ") while (command != 'DONE'): for shell in shells: if opts.sftp: shell.runCommand(command) else: shell.runCommand(command) print shell.ip print shell.status print shell.stdout.read() print shell.stderr.read() command = raw_input("Command: ")
from staticurl import staticurl from filelist import filelist from nameslist import nameslist from conn import conn if __name__ == "__main__": # get all links first per directory and per gender # per directory, go to gender file # per gender, add in list all names # return global list and insert into db listofdir = staticurl().listofdir f = filelist() n = nameslist() dbconn = conn() for allitems in listofdir: if 'indian' in allitems: indianboyfilelist = f.getfilelist(allitems + '/Boy') indiangirlfilelist = f.getfilelist(allitems + '/Girl') if 'german' in allitems: germanboyfilelist = f.getfilelist(allitems + '/Boy') germangirlfilelist = f.getfilelist(allitems + '/Girl') if 'french' in allitems: frenchboyfilelist = f.getfilelist(allitems + '/Boy') frenchgirlfilelist = f.getfilelist(allitems + '/Girl') if 'arabic' in allitems: arabicboyfilelist = f.getfilelist(allitems + '/Boy') arabicgirlfilelist = f.getfilelist(allitems + '/Girl') if 'english' in allitems: englishboyfilelist = f.getfilelist(allitems + '/Boy') englishgirlfilelist = f.getfilelist(allitems + '/Girl') if 'australian' in allitems:
print 'No hosts given...' sys.exit(0) ips_to_connect=[] for host in hosts_to_connect: ips_to_connect.append(host_to_ip[host]) shells = [] for ip in ips_to_connect: ip = ip user = logins[ip].keys()[0] passwd = logins[ip][user] if opts.sftp: x = sftp.sftp(user, passwd, ip) else: x = conn.conn(user, passwd, ip) shells.append(x) print ip_to_host[ip] command = raw_input("Command: ") while(command != 'DONE'): for shell in shells: if opts.sftp: shell.runCommand(command) else: shell.runCommand(command) print shell.ip print shell.status print shell.stdout.read() print shell.stderr.read() command = raw_input("Command: ")
with open(f, 'w') as f: return json.dump(f) def read_json(f): with open(f) as f: return json.load(f) if __name__=='__main__': f = 'data/names.csv' headers = ['first', 'last'] r_dict = read_dict(f, headers) dict_ls = conv_reg_dict(r_dict) json_file = 'data/names.json' dump_json(json_file, dict_ls) data = read_json(json_file) obj = conn.conn('test') db = obj.getDB() names = db.names names.drop() for i, row in enumerate(data): row['_id'] = i names.insert_one(row) n = 3 print('1st', n, 'names:') people = names.find() for i, row in enmuerate(people): if i < n: print(row) people.rewind() print('\n1st', n, 'name with rewind:') for i, row in enmuerate(people):
def __init__(self): self.conn = conn.conn('test.db')
with open(f, 'w') as f: json.dump(d, f) def read_json(f): with open(f) as f: return json.load(f) if __name__ == '__main__': f = 'data/names.csv' headers = ['first', 'last'] r_dict = read_dict(f, headers) dict_ls = conv_reg_dict(r_dict) json_file = 'data/names.json' dump_json(json_file, dict_ls) data = read_json(json_file) obj = conn.conn('mcklayne') db = obj.getDB() names = db.names names.drop() for i, row in enumerate(data): row['_id'] = i names.insert_one(row) n = 3 print('1st', n, 'names:') people = names.find() for i, row in enumerate(people): if i < n: print (row) people.rewind() print('\n1st', n, 'names with rewind:') for i, row in enumerate(people):
import conn import math import random #conexão c = conn.conn() connection = conn.connection_() #Assimilando def assimilarPergunta(pergunta): first = False tags = [] ## Pegando as tags for row in c.execute("SELECT * FROM tb_processo"): if (not first): tags.append(row[1]) first = True if (first): n = False for i in range(len(tags)): if (row[1] == tags[i]): n = True if (not n): tags.append(row[1]) #print('nova tag salva!') ######################################################## # Deduzindo as tags da pergunta pergArr = pergunta.split(' ')
import conn mysqlConn = conn.conn() client = mysqlConn.getConn() sql = "select id from source_pic_wotu limit 10" print client.execute(sql) results = client.fetchall() print results
def shellrun(line): global prompts global mode global name global recv_port cmd = line.split() print(cmd) if len(cmd) == 0: return True if mode == 0: if cmd[0] == 'enable': mode += 1 if cmd[0] == 'send': if len(cmd) != 2: print("[E] Invalid Argument") else: conn.send(cmd[1]) elif cmd[0] == 'exit': return False elif mode == 1: if cmd[0] == 'config': mode += 1 elif cmd[0] == 'exit': mode -= 1 elif mode == 2: if cmd[0] == 'sock': if cmd[1] == 'recv': mode += 1 elif cmd[1] == 'send': mode += 2 elif cmd[0] == 'hostname': if len(cmd) == 2: name = cmd[1] else: print("[E] Invalid Argument") elif cmd[0] == 'exit': mode -= 1 elif mode == 3: # configure recv socket if cmd[0] == 'exit': mode = 2 elif cmd[0] == "conn": if len(cmd) != 3: print("[E] Invalid Argument") elif cmd[0] == 'acpt': if len(cmd) == 2: # ポート指定 recv_port = int(cmd[1]) th_recv = threading.Thread(target=recv.recv, args=(recv_port, )) th_recv.setDaemon(True) th_recv.start() elif mode == 4: # configure send socket if cmd[0] == 'exit': mode = 2 elif cmd[0] == 'conn': if len(cmd) != 3: print("[E] Invalid Argument") else: conn.conn(cmd[1], int(cmd[2])) return True """
def __init__(self): self.conn=conn.conn('test.db')