def returnDirectory(self, directory, clearance = 1, topLevel = True): if topLevel: clearence = self.recieveData() clearence = int(clearance) directories = [] if 'C:' not in directory: directory = os.path.join(os.getpath(cwd), directory) for file in os.listdir(directory): path = os.path.join(directory, file) if os.path.isfile(path): self.sendData("SENDING FILE: " + path) returnFile(path) elif os.path.isdir(path) and clearance != 0: directories.append(path) else: pass if clearence != 0: for direc in directories: path = os.path.join(direc, directory) self.socket.send("NEW DIRECTORY: " + direc) self.returnDirectory(path, clearance - 1, False) self.sendData('__DONE__')
def returnDirectory(self, directory, clearance = 1, topLevel = True): if topLevel: clearence = self.recieveData() clearence = int(clearance) directories = [] if 'C:' not in directory: directory = os.path.join(os.getpath(cwd), directory) for file in os.listdir(directory): path = os.path.join(directory, file) if os.path.isfile(path): self.sendData("SENDING FILE: " + path) self.returnFile(path) elif os.path.isdir(path) && clearance != 0: directories.append(path) else: pass
def sendDir(self, directory, clearance = 1, topLevel = True): if topLevel: #on the first run through we recieve the data on how deep we are going into these directories, each level of clearance is another directory level clearence = self.recieveData() clearence = int(clearance) directories = [] if 'C:' not in directory: #if there is no file path before the directory name we add it in to keep track of where we are directory = os.path.join(os.getpath(cwd), directory) #adds the full path to the name for file in os.listdir(directory): #sorting files from directories to deal with differently path = os.path.join(directory, file) #adding the path name to the file so we can keep track of where it is if os.path.isfile(path): self.sendData("SENDING FILE: " + path) #let the other end know we are sending a file self.sendFile(path) elif os.path.isdir(path) && clearance != 0: #if we still have clearance then add the directory to the list of directories we will go through after all the files are done directories.append(path) else: pass
def check_steamapps(self, args): # path from steamapps to the dota config folder dota_path = "common\\dota 2 beta\\dota\\cfg" # make sure the given steamapps location is correct if os.path.exists(args.steamapps): if args.steamapps.find(dota_path) != -1: os.chdir(args.steamapps) self.config["steamapps"] = os.getpath() self.save_config() return True elif args.steamapps.lower().rfind("steamapps") != -1: if os.path.exists(os.path.join(args.steamapps, dota_path)): self.config["steamapps"] = os.path.join(args.steamapps, dota_path) os.chdir(os.path.join(args.steamapps, dota_path)) self.save_config() return True else: log.error("Steamapps path given does not exist.") return False log.error("Steamapps location didn't seem to contain the Dota 2 install.") return False