From 902bfdc700edf5417c9655e5646a3886b1f14422 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Fri, 28 Dec 2018 11:31:08 +0800 Subject: [PATCH] update --- class/core/common.py | 37 +++++++++++++++++++++++++++++- route/__init__.py | 13 ++--------- route/templates/default/login.html | 3 ++- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/class/core/common.py b/class/core/common.py index 26131327b..05c3a67fc 100755 --- a/class/core/common.py +++ b/class/core/common.py @@ -11,7 +11,42 @@ import datetime import subprocess import re import hashlib +from random import Random +import public import db -from random import Random + +def init(): + initDB() + initInitD() + + +def initDB(): + try: + sql = db.Sql().dbfile('default') + csql = public.readFile('data/sql/default.sql') + csql_list = csql.split(';') + for index in range(len(csql_list)): + sql.execute(csql_list[index], ()) + except Exception, ex: + print str(ex) + + +def initInitD(): + script = public.getRunDir() + '/scripts/init.d/mw.tpl' + script_bin = public.getRunDir() + '/scripts/init.d/mw' + if os.path.exists(script_bin): + return + + content = public.readFile(script) + content = content.replace("{$SERVER_PATH}", public.getRunDir()) + + public.writeFile(script_bin, content) + public.execShell('chmod +x ' + script_bin) + + if public.getOs() != 'darwin': + initd_bin = '/etc/init.d/mw' + if not os.path.exists(initd_bin): + shutil.copyfile(script_bin, initd_bin) + public.execShell('chmod +x ' + initd_bin) diff --git a/route/__init__.py b/route/__init__.py index 44d1f71ce..c582d6910 100755 --- a/route/__init__.py +++ b/route/__init__.py @@ -53,17 +53,8 @@ app.config['SESSION_COOKIE_NAME'] = "MW_VER_1" Session(app) -def initDB(): - try: - sql = db.Sql().dbfile('default') - csql = public.readFile('data/sql/default.sql') - csql_list = csql.split(';') - for index in range(len(csql_list)): - sql.execute(csql_list[index], ()) - except Exception, ex: - print str(ex) - -initDB() +import common +common.init() def funConvert(fun): diff --git a/route/templates/default/login.html b/route/templates/default/login.html index 2d311b15f..9f21f1113 100755 --- a/route/templates/default/login.html +++ b/route/templates/default/login.html @@ -146,7 +146,8 @@
- +
+