mirror of
https://github.com/hyper-neptune/yuuki.git
synced 2024-11-10 08:26:06 +08:00
Add webadmin option to configure file
This commit is contained in:
parent
1b8ddd8c3d
commit
5f69752c44
6 changed files with 26 additions and 18 deletions
|
@ -6,7 +6,7 @@ This Source Code Form is subject to the terms of the Mozilla Public
|
|||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
"""
|
||||
from .yuuki import Yuuki
|
||||
from .config import Yuuki_Config
|
||||
from .yuuki import Yuuki
|
||||
|
||||
__all__ = ['connection', 'data', 'data_mds', 'thread_control', 'Yuuki', 'Yuuki_Config']
|
||||
|
|
|
@ -7,6 +7,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this
|
|||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
"""
|
||||
import os
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
|
@ -46,6 +47,7 @@ class Yuuki_Config:
|
|||
"Seq": 0,
|
||||
"Admin": [],
|
||||
"Advanced": False,
|
||||
"WebAdmin": False, # Advanced Mode Required
|
||||
"SecurityService": False,
|
||||
"Hour_KickLimit": 10,
|
||||
"Hour_CancelLimit": 10,
|
||||
|
|
|
@ -20,11 +20,6 @@ auth_code = 0
|
|||
|
||||
|
||||
# Functions
|
||||
def mds_exit(data):
|
||||
if data:
|
||||
exit(0)
|
||||
|
||||
|
||||
def update(data):
|
||||
global switch_data
|
||||
# noinspection PyBroadException
|
||||
|
@ -98,7 +93,6 @@ def yuukiLimitDecrease(data):
|
|||
|
||||
# Works
|
||||
_work = {
|
||||
"EXT": mds_exit,
|
||||
"UPT": update,
|
||||
"DEL": delete,
|
||||
"GET": query,
|
||||
|
@ -135,10 +129,22 @@ class IndexHandler(RequestHandler):
|
|||
|
||||
|
||||
# Main
|
||||
app = Application([
|
||||
('/', IndexHandler)
|
||||
])
|
||||
server = HTTPServer(app)
|
||||
async_lock = IOLoop.current()
|
||||
|
||||
|
||||
def listen(code):
|
||||
global auth_code
|
||||
auth_code = code
|
||||
app = Application([('/', IndexHandler)])
|
||||
server = HTTPServer(app)
|
||||
server.listen(2019)
|
||||
IOLoop.current().start()
|
||||
async_lock.start()
|
||||
|
||||
|
||||
def mds_exit():
|
||||
server.stop()
|
||||
yield server.close_all_connections()
|
||||
async_lock.stop()
|
||||
async_lock.close()
|
||||
|
|
|
@ -78,7 +78,7 @@ class Yuuki_Poll:
|
|||
self.Yuuki.exit()
|
||||
|
||||
def init(self):
|
||||
self.Yuuki.data.updateData(["Global", "self.Power"], self.Power)
|
||||
self.Yuuki.data.updateData(["Global", "Power"], self.Power)
|
||||
|
||||
if "LastResetLimitTime" not in self.Yuuki.data.getData(["Global"]):
|
||||
self.Yuuki.data.updateData(["Global", "LastResetLimitTime"], None)
|
||||
|
|
|
@ -188,5 +188,5 @@ class Yuuki_WebAdmin:
|
|||
self.http_server.serve_forever()
|
||||
|
||||
def stop(self):
|
||||
self.http_server.close()
|
||||
self.http_server.stop()
|
||||
self.http_server.close()
|
||||
|
|
|
@ -21,6 +21,7 @@ from .i18n import Yuuki_LangSetting
|
|||
from .poll import Yuuki_Poll
|
||||
from .thread_control import Yuuki_Multiprocess
|
||||
from .webadmin.server import Yuuki_WebAdmin
|
||||
from .data_mds import mds_exit
|
||||
|
||||
|
||||
class Yuuki:
|
||||
|
@ -112,7 +113,7 @@ class Yuuki:
|
|||
self._Setup_WebAdmin()
|
||||
|
||||
def _Setup_WebAdmin(self):
|
||||
if self.Threading:
|
||||
if self.Threading and self.YuukiConfigs.get("WebAdmin"):
|
||||
password = str(hash(random.random()))
|
||||
self.webAdmin = Yuuki_WebAdmin(self)
|
||||
self.Thread_Control.add(self.webAdmin.start, (password,))
|
||||
|
@ -126,13 +127,12 @@ class Yuuki:
|
|||
|
||||
def exit(self, restart=False):
|
||||
print("System Exit")
|
||||
self.data.updateData(["Global", "Power"], False)
|
||||
while self.data.getData(["Global", "Power"]):
|
||||
self.data.updateData(["Global", "Power"], False)
|
||||
if self.Threading:
|
||||
try:
|
||||
self.data.mdsShake("EXT", "")
|
||||
mds_exit()
|
||||
if self.YuukiConfigs.get("WebAdmin"):
|
||||
self.webAdmin.stop()
|
||||
except:
|
||||
pass
|
||||
if restart:
|
||||
if platform.system() == "Windows":
|
||||
with open("cache.bat", "w") as c:
|
||||
|
|
Loading…
Reference in a new issue