示例#1
0
文件: puck.py 项目: masom/Puck
            'tools.staticdir.root': os.getcwd(),
            'tools.staticdir.index': 'index.html'
        }
    }

    connect(None)

    import libs.controller
    cherrypy.tools.myauth = cherrypy.Tool("before_handler", libs.controller.auth)

    import models, controllers
    if args.init:
        cherrypy.log("Initializing persistent storage.")
        from libs.model import Migration
        m = Migration(cherrypy.thread_data.db, [])
        m.init()

        models.Users.load()
        if models.Users.first(username='******'):
            cherrypy.log('Admin account already created, skipping.')
            os._exit(0)

        user = models.Users.new(username='******', user_group='admin', name='Administrator')
        user.password = models.Users.hash_password('puck')
        if models.Users.add(user):
            cherrypy.log('Admin account added.')
            cherrypy.log('\tUsername: admin')
            cherrypy.log('\tPassword: puck')
            os._exit(0)
        else:
            cherrypy.log('An error occured while creating the admin account.')