def runMe(): global finalString; global ftp; finalString = '[' ftp=FTP('ftp.ncnr.nist.gov') ftp.login() ftp.cwd('pub') root = FTPfile(id_counter,ftp.pwd(),[],False) children = getChildren(root.path) ftp.quit() if children: root.setChildren(children) else: root.isLeaf() #isLeaf sets to leaf #print root #for i in root.children: # print i.id, i #print root.children #print ftp.nlst() #setupTree(root) toJson(root) finalString += ']' #write=open('ftpDir.txt','w') #write.write(finalString) #write.close() #print finalString #return finalString return ast.literal_eval(finalString)
def runMe(): global finalString global ftp finalString = '[' ftp = FTP('ftp.ncnr.nist.gov') ftp.login() ftp.cwd('pub') root = FTPfile(id_counter, ftp.pwd(), [], False) children = getChildren(root.path) ftp.quit() if children: root.setChildren(children) else: root.isLeaf() #isLeaf sets to leaf #print root #for i in root.children: # print i.id, i #print root.children #print ftp.nlst() #setupTree(root) toJson(root) finalString += ']' #write=open('ftpDir.txt','w') #write.write(finalString) #write.close() #print finalString #return finalString return ast.literal_eval(finalString)
def runFTP(address, directory, username='', password=''): """ FTP into a given ``address`` and change into the directory ``directory``. This will provide the set of files and directories within ``directory``. """ global finalString; global ftp; finalString = '[' ftp = FTP(address) ftp.login(user=username, passwd=password) ftp.cwd(directory) root = FTPfile(id_counter, ftp.pwd(), [], False) children = getChildren(root.path) if children: root.setChildren(children) else: root.isLeaf() #sets root as a leaf ftp.quit() toJson(root, isexpanded=True) finalString += ']' return ast.literal_eval(finalString)
def runFTP(address, directory, username='', password=''): """ FTP into a given ``address`` and change into the directory ``directory``. This will provide the set of files and directories within ``directory``. """ global finalString global ftp finalString = '[' ftp = FTP(address) ftp.login(user=username, passwd=password) ftp.cwd(directory) root = FTPfile(id_counter, ftp.pwd(), [], False) children = getChildren(root.path) if children: root.setChildren(children) else: root.isLeaf() #sets root as a leaf ftp.quit() toJson(root, isexpanded=True) finalString += ']' return ast.literal_eval(finalString)