示例#1
0
文件: base.py 项目: masom/Puck
    def setUp(self):
        tables = []
        collections = [
            'Jails', 'Environments', 'Images', 'JailTypes', 'Keys',
            'Users', 'VirtualMachines', 'YumRepositories'
        ]
        for c in collections:
            tables.append(getattr(models, c).table_definition())

        db = ':memory:'
        self._connection = sqlite3.connect(db)
        cherrypy.thread_data.db = self._connection
        cherrypy.thread_data.db.row_factory = sqlite3.Row

        m = Migration(self._connection, tables)
        m.migrate()
示例#2
0
文件: puck.py 项目: masom/Puck
            'tools.staticdir.dir': 'static',
            '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: