def build_config(self): log.trace("build_config") #store1 = FTPStore("teststore1", "4MB", True, "localhost", "store1", "ftpuser", "ftpuserX9", False) #store2 = FTPStore("teststore2", "4MB", True, "localhost", "store2", "ftpuser", "ftpuserX9", False) if self.options.store: store1 = self.config.storage[self.options.store].copy() store2 = store1 else: # Make the store about 3x the options size s, dummy, dummy = utils.from_readable_form(self.options.size) store_size = utils.readable_form(s * 3) store1 = FolderStore("teststore1", store_size, True, os.path.join(self.store_folder, "teststore1")) store2 = FolderStore("teststore2", store_size, True, os.path.join(self.store_folder, "teststore2")) self.config.storage[store1.name] = store1 self.config.storage[store2.name] = store2 backup1 = Backup("testbackup1") backup1.include_folders = [self.files_folder] backup1.include_packages = True backup1.exclude_types = ["Music"] backup1.exclude_patterns = [] backup1.store = store1.name backup1.notify_msg = False self.config.backups[backup1.name] = backup1 backup2 = Backup("testbackup2") backup2.include_folders = [self.files_folder] backup2.include_packages = True backup2.exclude_patterns = [] backup1.exclude_types = ["Videos", "Programs"] backup2.store = store2.name backup2.notify_msg = False self.config.backups[backup2.name] = backup2
def fill_files(self, remaining=None, root=None): log.trace("fill_files") if not remaining: # First time in... remaining, dummy, dummy = utils.from_readable_form(self.options.size) root = self.files_folder list = [root] done = False while not done: newlist = [] for folder in list: for dname in ["dir1", "dir2", "dir3"]: path = os.path.join(folder, dname) utils.makedirs(path) newlist.append(path) for fname in ["f1.avi", "f2.mp3", "f3.exe", "f4.txt"]: path = os.path.join(folder, fname) with open(path, "w") as f: f.write(self.teststring1) remaining -= len(self.teststring1) if remaining < 0: done = True break list = newlist return
def limit_details(self): """ Return the tuple of: number of bytes total number units So 1024MB would be returned as: 1024*1024*1024 1024 MB """ log.trace("limit_details") if not self.auto_manage or not self.limit: return (0, 0, "MB") total, num, units = utils.from_readable_form(self.limit) log.trace("done limit_details", total, num, units) return (total, num, units)