def addToArchive(tarArchive, srcObject, dstDir): savedPath = os.getcwd() os.chdir(srcDir) if (os.path.isdir(srcObject)): for f in os.listdirs("."): #skip all hidden files if f.startswith("."): continue shutil.copy(f, dstDir) else: pass os.chdir(savedPath)
def getbinary(self): if os.path.exists(self.folder + "firefox/firefox.exe"): return self.folder + "firefox/firefox.exe" if os.path.exists(self.folder + "firefox/firefox"): return self.folder + "firefox/firefox" files = os.listdirs() assert len(files) == 1 if files[0].endswith(".apk"): return files[0] if files[0].endswith(".dmg"): return files[0] assert False
async def search_person(message, client): with open("C:\\Users\\kille\\Desktop\\work space\\Afton\\Omegle\\Searching\\{}".format(message.author.id), + "w+") as file: file.writelines("searching") file.close() await client.send_message(message.author, "Searching...") if len(os.listdirs("C:\\Users\\kille\\Desktop\\work space\\Afton\\Omegle\\Searching")) > 1: create_chat(message.author.id, os.listdirs[1]) await client.send_message(message.author, "You are connected to a random stranger!") user = await client.get_user_info(os.listdirs[]) await client.send_message(user, "You are connected to a random stranger!")
def data_split(src, des): all_pit = [] for usg in os.listdirs(src): fin = src+os.sep+usg data = load_data(fin) for line in data: all_pit.append(line) tot = len(all_pit) trn_tot = int(tot*0.8) dev_tot = int(tot*0.1) random.shuffle(all_pit) trn = all_pit[:trn_tot] dev = all_pit[trn_tot: trn_tot+dev_tot] tes = all_pit[trn_tot+dev_tot:] save2file(des+"/train" trn) save2file(des+"/dev", dev) save2file(tes+"/test", tes)
def getInfinibandStats(self,stats): if os.path.exists('/sys/class/infiniband'): items = os.listdirs('/sys/class/infiniband')
def getInfinibandStats(self, stats): if os.path.exists('/sys/class/infiniband'): items = os.listdirs('/sys/class/infiniband')
# Mad libs # Reading text files and let user add their own text anywhere the word adjective,noun,verb or adverb appears import os word = ['adjective', 'adverb', 'noun', 'verb'] key = [] # Listing all the '.txt' files present in current working directories for filename in os.listdirs('.'): if filename.endswith('.txt'): file_object1 = open(filename, r) # Print the content of text files for easyness object2 = file_object1.read() print object2 # Loop through read object for searching the word and appending it with user input for i in object2: if i in word: key.append(raw_input("Enter the {0}:".format(i))) else: key.append(i) # Writing all the words to the file and saving it file_object1 = open(filename, 'w') file_object1.write(''.join(key)) file_object1.close()
# Mad libs # Reading text files and let user add their own text anywhere the word adjective,noun,verb or adverb appears import os word = ['adjective','adverb','noun','verb'] key = [] # Listing all the '.txt' files present in current working directories for filename in os.listdirs('.'): if filename.endswith('.txt'): file_object1 = open(filename,r) # Print the content of text files for easyness object2 = file_object1.read() print object2 # Loop through read object for searching the word and appending it with user input for i in object2: if i in word: key.append(raw_input("Enter the {0}:".format(i))) else: key.append(i) # Writing all the words to the file and saving it file_object1 = open(filename,'w') file_object1.write(''.join(key)) file_object1.close()
def find_directories(path): l=[] for each in os.listdirs(path): if os.path.isdir(each): l.append(each) return l
def find_files(path): l=[] for each in os.listdirs(path): if os.path.isfile(each): l.append(each) return l