Пример #1
0
def init(config):
    """
    Establish the commands.
    """

    @make_command()
    def info(args):
        """Display info about TiddlyWeb."""
        print """This is TiddlyWeb version %s.
    The current store is: %s.""" % (VERSION, config['server_store'][0])
        if config['system_plugins']:
            print 'System Plugins:'
            for plugin in config['system_plugins']:
                module = __import__(plugin)
                print '\t%s (%s)' % (plugin,
                        getattr(module, '__version__', 'unknown'))

    @make_command()
    def server(args):
        """Start the server using config settings. Provide <host name or IP number> <port> to override."""
        hostname = port = ''
        try:
            hostname, port = args[0:2]
        except(IndexError, ValueError), exc:
            if 0 < len(args) < 2:
                usage('you must include both a hostname or ip '
                    'number and a port if using arguments: %s' % exc)
            else:
                pass

        if hostname and port:
            config['server_host'] = {
                    'scheme': 'http',
                    'host': hostname,
                    'port': port,
                    }

        from tiddlyweb.web import serve
        serve.start_cherrypy(config)
Пример #2
0
def init(config):
    """
    Establish the commands.
    """
    @make_command()
    def info(args):
        """Display info about TiddlyWeb."""
        print """This is TiddlyWeb version %s.
    The current store is: %s.""" % (VERSION, config['server_store'][0])
        if config['system_plugins']:
            print 'System Plugins:'
            for plugin in config['system_plugins']:
                module = __import__(plugin)
                print '\t%s (%s)' % (plugin,
                                     getattr(module, '__version__', 'unknown'))

    @make_command()
    def server(args):
        """Start the server using config settings. Provide <host name or IP number> <port> to override."""
        hostname = port = ''
        try:
            hostname, port = args[0:2]
        except (IndexError, ValueError), exc:
            if 0 < len(args) < 2:
                usage('you must include both a hostname or ip '
                      'number and a port if using arguments: %s' % exc)
            else:
                pass

        if hostname and port:
            config['server_host'] = {
                'scheme': 'http',
                'host': hostname,
                'port': port,
            }

        from tiddlyweb.web import serve
        serve.start_cherrypy(config)
Пример #3
0
    except(IndexError, ValueError), exc:
        if 0 < len(args) < 2:
            usage('you must include both a hostname or ip '
                'number and a port if using arguments: %s' % exc)
        else:
            pass

    if hostname and port:
        config['server_host'] = {
                'scheme': 'http',
                'host': hostname,
                'port': port,
                }

    from tiddlyweb.web import serve
    serve.start_cherrypy()


@make_command()
def userpass(args):
    """Change the password of an existing user. <username> <password>"""
    try:
        username, password = args[0:2]
    except (IndexError, ValueError), exc:
        usage('you must provide both a user and a password')

    try:
        store = _store()
        user = User(username)
        user = store.get(user)
        user.set_password(password)