代码拉取完成,页面将自动刷新
同步操作将从 Jack/openssh 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
__author__ = 'JackSong'
import sys
import os.path
import tornado.ioloop
import tornado.web
import tornado.httpserver
import tornado.options
import logging
from tornado.options import options
from tornado.gen import coroutine
from sqlalchemy.orm import sessionmaker
from config import init_config
from urls import handlers
from ioloop import IOloop
from utils.tools import check_python_version_is_2
from utils.data import get_engine
from utils.redis import get_redis_pool
from tornado.queues import Queue
queues = Queue(maxsize = 10)
if sys.version_info.major == 2:
reload(sys)
sys.setdefaultencoding('utf-8')
else:
import tornado.platform.asyncio
import asyncio
settings = dict(
template_path = os.path.join(os.path.dirname(__file__),"templates"),
static_path = os.path.join(os.path.dirname(__file__),"templates/dist/static"),
)
class Application(tornado.web.Application):
def __init__(self):
engine = get_engine()
tornado.web.Application.__init__(self,handlers,**settings)
self.session = sessionmaker(bind = engine)
self.queues = queues
self.redis = get_redis_pool()
self.access_log = logging.getLogger("tornado.access")
streamhandler = logging.StreamHandler()
self.access_log.removeHandler(streamhandler)
@coroutine
def write_file_queues():
while True:
item = yield queues.get()
try:
item()
finally:
queues.task_done()
def main():
http_server = tornado.httpserver.HTTPServer(Application())
http_server.listen(options.port)
print('Server Starting port on %s' % (options.port,))
instance = IOloop.instance(queues).ioloop
instance.run_sync(write_file_queues)
instance.start()
def migrate_database():
from model import Base
engine = get_engine()
Base.metadata.create_all(engine)
def create_admin():
from model import User
engine = get_engine()
session=sessionmaker(bind = engine)()
user = User()
user.username = "admin"
user.set_password("admin")
user.is_superuser = True
session.add(user)
session.commit()
if __name__ == "__main__":
import sys
init_config()
if not check_python_version_is_2():
asyncio.set_event_loop(asyncio.new_event_loop())
options.parse_config_file("openssh.conf")
options.parse_command_line()
command_len = len(sys.argv)
if command_len == 1:
main()
else:
{"migrate":migrate_database,"create_admin":create_admin}[sys.argv[1]]()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。