def backup(path, suffix='.bak'): """ Rename a file or directory safely without overwriting an existing backup of the same name. :param path: The path object to the file or directory to make a backup of. :param suffix: The suffix to rename files with. :returns: The new path of backed up file/directory :rtype: str """ count = -1 new_path = None while True: if path.exists() : if count == -1: new_path = Path("{0}{1}".format(path, suffix)) else: new_path = Path("{0}{1}.{2}".format(path, suffix, count)) if new_path.exists(): count += 1 continue else: path.copy(new_path) else: break return new_path
def uploadFile(self, srcPath, destPath): db = self.getClient() srcPath = Path(srcPath) destPath = Path(destPath) destPath.makedirs() if srcPath.exists(): result = db.put_file(destPath, open(srcPath,'rb')) return result return None
def uploadFile(self, srcPath, destPath): db = self.getClient() srcPath = Path(srcPath) destPath = Path(destPath) destPath.makedirs() if srcPath.exists(): result = db.put_file(destPath, open(srcPath, 'rb')) return result return None