def handle_command_list(self, *args, **options): acc_keys = self.vumi_api.redis.smembers("disabled_metrics_accounts") if not acc_keys: self.stderr.write("No accounts have metric collection disabled.\n") else: for i, acc_key in enumerate(acc_keys): user = get_user_by_account_key(acc_key) output = u"%s. %s\n" % (i, user_details_as_string(user)) self.stdout.write(output.encode(self.encoding))
def handle_command_list(self, *args, **options): acc_keys = self.vumi_api.redis.smembers('disabled_metrics_accounts') if not acc_keys: self.stderr.write('No accounts have metric collection disabled.\n') else: for i, acc_key in enumerate(acc_keys): user = get_user_by_account_key(acc_key) output = u"%s. %s\n" % (i, user_details_as_string(user)) self.stdout.write(output.encode(self.encoding))
def _apply_to_accounts(self, func, dry_run=None): if dry_run is None: dry_run = self.options.get('dry_run') for user, user_api in self._get_user_apis(): self.stdout.write( "Performing %s on account %s ...\n" % ( func.__name__, user_details_as_string(user) )) if not dry_run: func(user_api) self.stdout.write("done.\n")
def print_account(self, index, user, options): output = u"%s. %s\n" % (index, user_details_as_string(user)) self.stdout.write(output.encode(self.encoding)) user_api = vumi_api_for_user(user) if options.get('show-pools'): self.stdout.write(" Pools:\n") user_account = user_api.get_user_account() for tp_bunch in user_account.tagpools.load_all_bunches(): for tp in tp_bunch: self.stdout.write( " %r (max-keys: %s)" % (tp.tagpool, tp.max_keys)) if options.get('show-tags'): self.stdout.write(" Tags:\n") for channel in user_api.active_channels(): self.stdout.write( " (%r, %r)\n" % (channel.tagpool, channel.tag))
def print_account(self, index, user, options): output = u"%s. %s\n" % (index, user_details_as_string(user)) self.stdout.write(output.encode(self.encoding)) user_api = vumi_api_for_user(user) if options.get('show-pools'): self.stdout.write(" Pools:\n") user_account = user_api.get_user_account() for tp_bunch in user_account.tagpools.load_all_bunches(): for tp in tp_bunch: self.stdout.write(" %r (max-keys: %s)" % (tp.tagpool, tp.max_keys)) if options.get('show-tags'): self.stdout.write(" Tags:\n") for channel in user_api.active_channels(): self.stdout.write(" (%r, %r)\n" % (channel.tagpool, channel.tag))
def _apply_to_batches(self, func, dry_run=None): if dry_run is None: dry_run = self.options.get('dry_run') for user, user_api in self._get_user_apis(): batches = self._get_batches(user_api) if not batches: continue self.stdout.write("Processing account %s ...\n" % user_details_as_string(user)) for batch_id in sorted(batches): self.stdout.write(" Performing %s on batch %s ...\n" % (func.__name__, batch_id)) if not dry_run: func(user_api, batch_id) self.stdout.write("done.\n")
def _apply_to_batches(self, func, dry_run=None): if dry_run is None: dry_run = self.options.get('dry_run') for user, user_api in self._get_user_apis(): batches = self._get_batches(user_api) if not batches: continue self.stdout.write( "Processing account %s ...\n" % user_details_as_string(user)) for batch_id in sorted(batches): self.stdout.write( " Performing %s on batch %s ...\n" % (func.__name__, batch_id)) if not dry_run: func(user_api, batch_id) self.stdout.write("done.\n")