def postOptions(self): if self.recursing: return debug = progress = None if self["debug"]: debug = self._reportDebug if self["progress"]: progress = self._reportProgress self.pb = util.makeStatBar(60, 1.0) try: self.tapLookup = loadPlugins(debug, progress) except IOError: raise usage.UsageError("Couldn't load the plugins file!") self.init(self.tapLookup) self.recursing = 1 self.parseOptions(self.params) if not hasattr(self, "subOptions") or self["help"]: raise usage.UsageError(str(self)) if hasattr(self, "subOptions") and self.subOptions.get("help"): raise usage.UsageError(str(self.subOptions)) if not self.tapLookup.has_key(self.subCommand): raise usage.UsageError("Please select one of: " + " ".join(self.tapLookup))
def postOptions(self): if self.recursing: return debug = progress = None if self['debug']: debug = self._reportDebug if self['progress']: progress = self._reportProgress self.pb = util.makeStatBar(60, 1.0) try: self.tapLookup = loadPlugins(debug, progress) except IOError: raise usage.UsageError("Couldn't load the plugins file!") self.init(self.tapLookup) self.recursing = 1 self.parseOptions(self.params) if not hasattr(self, 'subOptions') or self['help']: raise usage.UsageError(str(self)) if hasattr(self, 'subOptions') and self.subOptions.get('help'): raise usage.UsageError(str(self.subOptions)) if not self.tapLookup.has_key(self.subCommand): raise usage.UsageError("Please select one of: " + ' '.join(self.tapLookup))
def main(username, sharer, wlist, num): """Create UDFs, folders and files for the given user using a wordlist.""" user = get_storage_user(None, username=utf2unicode(username)) sharer = get_storage_user(None, username=utf2unicode(sharer)) folders = [user.root] with open(wlist) as f: names = [utf2unicode(i.strip()) for i in f.readlines() if i.strip()] sample = random.sample(names, num) if sys.stdout.isatty(): import curses curses.setupterm() cols = curses.tigetnum('cols') - 1 progbar = makeStatBar(cols, cols - 2) home = curses.tigetstr('cr') def progress(ll): """progress bar writer.""" sys.stdout.write( home + progbar((cols - 2) * (num - len(ll)) / num)) sys.stdout.flush() else: def progress(ll): return # UDF udf = user.make_udf('~/abundant-files') folders.append(user.volume(udf.id).get_node(udf.root_id)) # some UDFs for i in range(num / 100): progress(sample) folders.append(make_udf(user, sample)) for i in range(num / 4): progress(sample) name = sample.pop() folders.append(random.choice(folders).make_subdirectory(name)) sh_folders = [sharer.root] for i in range(num / 10): progress(sample) sh_folders.append(make_udf(sharer, sample)) for i in range(num / 10): progress(sample) name = sample.pop() sh_folders.append(random.choice(sh_folders).make_subdirectory(name)) for i in range(num / 20): progress(sample) name = sample.pop() filename = 'shared by ' + sharer.username readonly = random.choice((False, True)) if readonly: name += ' (ro)' filename += ' (ro)' folder = random.choice(sh_folders).make_subdirectory(name) folder.make_file(filename) share = folder.share(user.id, folder.name, readonly) user.get_share(share.id).accept() for i in random.sample(folders, len(folders) / 4): progress(sample) name = sample.pop() filename = 'shared by ' + user.username readonly = random.choice((False, True)) if readonly: name += ' (ro)' filename += ' (ro)' folder = random.choice(folders).make_subdirectory(name) folder.make_file(filename) share = folder.share(sharer.id, folder.name, readonly) sharer.get_share(share.id).accept() for i in range(num / 20): progress(sample) name = sample.pop() random.choice(folders).make_file(name) fake_hash = Factory().get_fake_hash() while sample: progress(sample) name = sample.pop() random.choice(folders).make_file_with_content( name, fake_hash, 12345, 100, 10000, uuid.uuid4(), 'image/tiff') if sys.stdout.isatty(): sys.stdout.write(home + curses.tigetstr('el'))
def main(username, sharer, wlist, num): """Create UDFs, folders and files for the given user using a wordlist.""" user = get_storage_user(None, username=utf2unicode(username)) sharer = get_storage_user(None, username=utf2unicode(sharer)) folders = [user.root] names = [utf2unicode(i.strip()) for i in file(wlist) if i.strip()] sample = random.sample(names, num) if sys.stdout.isatty(): import curses curses.setupterm() cols = curses.tigetnum('cols') - 1 progbar = makeStatBar(cols, cols - 2) home = curses.tigetstr('cr') def progress(l): """progress bar writer.""" sys.stdout.write(home + progbar((cols - 2) * (num - len(l)) / num)) sys.stdout.flush() else: progress = lambda l: None # UDF udf = user.make_udf('~/abundant-files') folders.append(user.volume(udf.id).get_node(udf.root_id)) # some UDFs for i in range(num / 100): progress(sample) folders.append(make_udf(user, sample)) for i in range(num / 4): progress(sample) name = sample.pop() folders.append(random.choice(folders).make_subdirectory(name)) sh_folders = [sharer.root] for i in range(num / 10): progress(sample) sh_folders.append(make_udf(sharer, sample)) for i in range(num / 10): progress(sample) name = sample.pop() sh_folders.append(random.choice(sh_folders).make_subdirectory(name)) for i in range(num / 20): progress(sample) name = sample.pop() filename = 'shared by ' + sharer.username readonly = random.choice((False, True)) if readonly: name += ' (ro)' filename += ' (ro)' folder = random.choice(sh_folders).make_subdirectory(name) folder.make_file(filename) share = folder.share(user.id, folder.name, readonly) user.get_share(share.id).accept() for i in random.sample(folders, len(folders) / 4): progress(sample) name = sample.pop() filename = 'shared by ' + user.username readonly = random.choice((False, True)) if readonly: name += ' (ro)' filename += ' (ro)' folder = random.choice(folders).make_subdirectory(name) folder.make_file(filename) share = folder.share(sharer.id, folder.name, readonly) sharer.get_share(share.id).accept() for i in range(num / 20): progress(sample) name = sample.pop() random.choice(folders).make_file(name) fake_hash = get_fake_hash() while sample: progress(sample) name = sample.pop() random.choice(folders).make_file_with_content( name, fake_hash, 12345, 100, 10000, uuid.uuid4(), 'image/tiff') if sys.stdout.isatty(): sys.stdout.write(home + curses.tigetstr('el'))