update all subscriptions in the given list of mailboxes. mailboxes - list of mailboxes to update (slugs) update_all - update all mailboxes """ for mb in self._get_mailboxes(mailboxes, get_all=update_all): for sub in Subscription.view(mb, Subscription.by_type, include_docs=True): try: self._update_subscription(mb, sub) except KeyboardInterrupt: log.error("Exiting at user request...") return except: log.error('%s: error updating subscription "%s" of type "%s": %s' % (mb.name, sub.id, sub.subscription_type, traceback.format_exc())) plugins.register(UpdateSubscriptionsCommand, COMMANDLINE_PLUGIN) class ResetSubscriptionsCommand(MailboxesCommand): command_name = 'reset' description = 'discard items and reset all subscriptions in a set of mailboxes' def __call__(self, mailboxes=None, update_all=False): """ update all subscriptions in the given list of mailboxes. mailboxes - list of mailboxes to update (slugs) update_all - update all mailboxes """ for mb in self._get_mailboxes(mailboxes, get_all=update_all): for sub in Subscription.view(mb, Subscription.by_type, include_docs=True): try:
return sum(values); } else { return values.length; } } """, }, "messages_by_subscription": { "map": """ function(doc) { if (doc.type == 'message') { emit([doc.source.subscription_id, doc.timestamp], {'_rev': doc._rev}); } } """ }, "subscriptions_by_type": { "map": """ function(doc) { if (doc.type == 'subscription') { emit(doc.subscription_type, {'_rev': doc._rev}); } } """ }, }, "filters": {}, } plugins.register(DESIGN_DOC, DESIGN_DOC_PLUGIN)
done = False while(not done): password = getpass(prompt="Password for %s: " % username) password2 = getpass(prompt="Repeat password: "******"Passwords did not match, try again.\n" new_user.set_password(password) if is_admin: new_user.roles = [ROLE_ADMIN] new_user.store(udb) print 'Created user "%s"' % username plugins.register(CreateUserCommand, COMMANDLINE_PLUGIN) class ResetPasswordCommand(BasicCommand): command_name = 'reset_password' description = "reset a user's password" @classmethod def setup_options(cls, parser): parser.set_usage(r"%prog" + "%s <username> [options]" % cls.command_name) parser.add_option('--locked', action="store_true", dest="is_locked", default=False, help="lock the user's password, do not prompt for password.")
def __call__(self, command_name=None): if command_name is None: get_basic_option_parser().print_usage() print "Commands:" for Command in sorted(plugins.get(COMMANDLINE_PLUGIN), key=attrgetter('command_name')): print " %s %s" % (Command.command_name.ljust(20), Command.description) else: Command = find_command_type(command_name) if Command is None: print_unknown_command(command_name) return else: command = Command(self.config) command.print_usage() plugins.register(HelpCommand, COMMANDLINE_PLUGIN) class ShowConfig(BasicCommand): command_name = 'show_config' description = 'print configuration' @classmethod def setup_options(cls, parser): parser.set_usage(r"%prog " + "%s [config pattern] [options]" % cls.command_name) def __call__(self, key_pattern=None): """ Print the current configuration """
""" start development web server address - where to serve, [interface:]port """ if address is not None: interface = '127.0.0.1' port = address if ':' in port: interface, port = port.split(':') try: port = int(port) except: raise InvalidArguments('Unable to parse port "%s"' % address) else: interface = '127.0.0.1' port = DEFAULT_RADAR_PORT from cherrypy.wsgiserver import CherryPyWSGIServer as WSGIServer app = RequestLogger(make_app(self.config)) cherry_opts = config_section('cherrypy', self.config) server = WSGIServer((interface, port), app, **cherry_opts) print "* serving on %s:%d" % (interface, port) try: server.start() except KeyboardInterrupt: server.stop() plugins.register(StartDevWebServer, COMMANDLINE_PLUGIN)
def __call__(self, mailboxes=None, update_all=False): """ update all subscriptions in the given list of mailboxes. mailboxes - list of mailboxes to update (slugs) update_all - update all mailboxes """ for mb in self._get_mailboxes(mailboxes, get_all=update_all): for sub in Subscription.view(mb, Subscription.by_type, include_docs=True): try: self._update_subscription(mb, sub) except: log.error('%s: error updating subscription "%s" of type "%s": %s' % (mb.name, sub.id, sub.subscription_type, traceback.format_exc())) plugins.register(UpdateSubscriptionsCommand, COMMANDLINE_PLUGIN) class UpdateSubscriptionCommand(BasicCommand, MailboxHelper): command_name = 'update_sub' description = 'update a particular subscription in a mailbox' @classmethod def setup_options(cls, parser): parser.set_usage(r"%prog " + "%s mailbox [options]" % cls.command_name) parser.add_option('--id', dest="sub_id", help="specify subscription by id") parser.add_option('--feed', dest="feed_url", help="specify subscription by feed url") def __call__(self, mailbox, sub_id=None, feed_url=None): """ update the specified subscription in the mailbox specified