示例#1
0
 def test_init_db(self):
     init_db()
     table_names = self.inspector.get_table_names()
     self.assertItemsEqual(
         ["host_meta", "deploy_meta", "user_meta", "ssh_permission_meta"],
         table_names
     )
示例#2
0
文件: app.py 项目: TheSophon/sophon
def main():
    init_db()
    application = tornado.web.Application(
        URL_PATTERNS, **TORNADO_SETTINGS
    )
    application.listen(8888, address=LISTEN_ADDR)
    tornado.ioloop.IOLoop.current().start()
示例#3
0
def cron_tasks():
    init_db()
    schedule.every(SCHEDULER_JOB_PERIOD).minutes.do(cron_get_host_status)
    schedule.every(SCHEDULER_JOB_PERIOD).minutes.do(
        cron_get_host_docker_status
    )
    schedule.every(SCHEDULER_JOB_PERIOD).minutes.do(
        cron_get_host_process_status
    )
    while schedule.run_pending() is None:
        time.sleep(1)
示例#4
0
    def fixed_func(self, *args, **kwargs):
        init_db()
        connection = engine.connect()
        transaction = connection.begin()
        session = scoped_session(db_session)

        fixed_args = tuple(list(args) + [session])

        try:
            func(self, *fixed_args, **kwargs)
        finally:
            session.remove()
            session.close()
            transaction.rollback()
            connection.close()
示例#5
0
 def test_drop_db(self):
     init_db()
     drop_db()
     table_names = self.inspector.get_table_names()
     self.assertListEqual([], table_names)