update
This commit is contained in:
@@ -1,12 +0,0 @@
|
|||||||
path_data: "/data"
|
|
||||||
|
|
||||||
#use_gevent: true
|
|
||||||
#use_celery: true
|
|
||||||
#debug: false
|
|
||||||
#redis_port: 46379
|
|
||||||
#port: 9999
|
|
||||||
#plugin_update: false
|
|
||||||
#running_type: "docker"
|
|
||||||
#plugin_loading_only_devpath: true
|
|
||||||
#plugin_loading_list: []
|
|
||||||
#plugin_except_list: []
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
amqp==5.1.1
|
|
||||||
APScheduler==3.9.1
|
|
||||||
async-generator==1.10
|
|
||||||
async-timeout==4.0.2
|
|
||||||
attrs==22.1.0
|
|
||||||
bidict==0.22.0
|
|
||||||
billiard==3.6.4.0
|
|
||||||
celery==5.2.7
|
|
||||||
certifi==2022.9.24
|
|
||||||
cffi==1.15.1
|
|
||||||
charset-normalizer==2.1.1
|
|
||||||
click==8.1.3
|
|
||||||
click-didyoumean==0.3.0
|
|
||||||
click-plugins==1.1.1
|
|
||||||
click-repl==0.2.0
|
|
||||||
colorama==0.4.5
|
|
||||||
Deprecated==1.2.13
|
|
||||||
discord-webhook==0.17.0
|
|
||||||
exceptiongroup==1.0.0rc9
|
|
||||||
Flask==2.2.2
|
|
||||||
Flask-Cors==3.0.10
|
|
||||||
Flask-Dropzone==1.6.0
|
|
||||||
Flask-Login==0.6.2
|
|
||||||
Flask-Markdown==0.3
|
|
||||||
Flask-SocketIO==5.3.1
|
|
||||||
Flask-SQLAlchemy==3.0.1
|
|
||||||
gevent==22.8.0
|
|
||||||
gevent-websocket==0.10.1
|
|
||||||
greenlet==1.1.3.post0
|
|
||||||
h11==0.14.0
|
|
||||||
idna==3.4
|
|
||||||
itsdangerous==2.1.2
|
|
||||||
Jinja2==3.1.2
|
|
||||||
kombu==5.2.4
|
|
||||||
lxml==4.9.1
|
|
||||||
Markdown==3.4.1
|
|
||||||
MarkupSafe==2.1.1
|
|
||||||
outcome==1.2.0
|
|
||||||
packaging==21.3
|
|
||||||
Pillow==9.2.0
|
|
||||||
prompt-toolkit==3.0.31
|
|
||||||
psutil==5.9.2
|
|
||||||
pycparser==2.21
|
|
||||||
pycryptodome==3.15.0
|
|
||||||
pyparsing==3.0.9
|
|
||||||
PySocks==1.7.1
|
|
||||||
python-engineio==4.3.4
|
|
||||||
python-socketio==5.7.1
|
|
||||||
pytz==2022.4
|
|
||||||
pytz-deprecation-shim==0.1.0.post0
|
|
||||||
PyYAML==6.0
|
|
||||||
redis==4.3.4
|
|
||||||
requests==2.28.1
|
|
||||||
selenium==4.5.0
|
|
||||||
six==1.16.0
|
|
||||||
sniffio==1.3.0
|
|
||||||
sortedcontainers==2.4.0
|
|
||||||
SQLAlchemy==1.4.41
|
|
||||||
telepot-mod==0.0.1
|
|
||||||
trio==0.22.0
|
|
||||||
trio-websocket==0.9.2
|
|
||||||
tzdata==2022.4
|
|
||||||
tzlocal==4.2
|
|
||||||
urllib3==1.26.12
|
|
||||||
vine==5.0.0
|
|
||||||
wcwidth==0.2.5
|
|
||||||
Werkzeug==2.2.2
|
|
||||||
wrapt==1.14.1
|
|
||||||
wsproto==1.2.0
|
|
||||||
zope.event==4.5.0
|
|
||||||
zope.interface==5.5.0
|
|
||||||
@@ -18,7 +18,6 @@ discord-webhook
|
|||||||
pyyaml
|
pyyaml
|
||||||
telepot-mod
|
telepot-mod
|
||||||
Flask-Dropzone
|
Flask-Dropzone
|
||||||
pycryptodome
|
|
||||||
psutil
|
psutil
|
||||||
|
|
||||||
# filemanager
|
# filemanager
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
lxml
|
lxml
|
||||||
selenium
|
selenium
|
||||||
|
pycryptodome
|
||||||
@@ -63,13 +63,6 @@ class CustomFormatter(logging.Formatter):
|
|||||||
return formatter.format(record)
|
return formatter.format(record)
|
||||||
|
|
||||||
|
|
||||||
# Suuport를 logger 생성전에 쓰지 않기 위해 중복 선언
|
|
||||||
def read_yaml(filepath):
|
|
||||||
import yaml
|
|
||||||
with open(filepath, encoding='utf8') as file:
|
|
||||||
data = yaml.load(file, Loader=yaml.FullLoader)
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
class User:
|
class User:
|
||||||
def __init__(self, user_id, email=None, passwd_hash=None, authenticated=False):
|
def __init__(self, user_id, email=None, passwd_hash=None, authenticated=False):
|
||||||
@@ -88,9 +81,14 @@ class User:
|
|||||||
return str(r)
|
return str(r)
|
||||||
|
|
||||||
def can_login(self, passwd_hash):
|
def can_login(self, passwd_hash):
|
||||||
from support import SupportAES
|
#from support import SupportAES
|
||||||
tmp = SupportAES.decrypt(self.passwd_hash)
|
#tmp = SupportAES.decrypt(self.passwd_hash)
|
||||||
return passwd_hash == tmp
|
import hashlib
|
||||||
|
enc = hashlib.md5()
|
||||||
|
enc.update(passwd_hash.encode())
|
||||||
|
hash = enc.hexdigest()
|
||||||
|
#return True
|
||||||
|
return self.passwd_hash == hash
|
||||||
|
|
||||||
def is_active(self):
|
def is_active(self):
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
import yaml
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
from flask_login import LoginManager, login_required
|
from flask_login import LoginManager, login_required
|
||||||
@@ -69,7 +70,6 @@ class Framework:
|
|||||||
|
|
||||||
self.__init_db()
|
self.__init_db()
|
||||||
|
|
||||||
|
|
||||||
if True or self.config['run_flask']:
|
if True or self.config['run_flask']:
|
||||||
from .scheduler import Job, Scheduler
|
from .scheduler import Job, Scheduler
|
||||||
self.scheduler = Scheduler(self)
|
self.scheduler = Scheduler(self)
|
||||||
@@ -78,9 +78,6 @@ class Framework:
|
|||||||
if self.config['use_gevent']:
|
if self.config['use_gevent']:
|
||||||
self.socketio = SocketIO(self.app, cors_allowed_origins="*")
|
self.socketio = SocketIO(self.app, cors_allowed_origins="*")
|
||||||
else:
|
else:
|
||||||
#if self.config['running_type'] == 'termux':
|
|
||||||
# self.socketio = SocketIO(self.app, cors_allowed_origins="*", async_mode='eventlet')
|
|
||||||
#else:
|
|
||||||
self.socketio = SocketIO(self.app, cors_allowed_origins="*", async_mode='threading')
|
self.socketio = SocketIO(self.app, cors_allowed_origins="*", async_mode='threading')
|
||||||
|
|
||||||
CORS(self.app)
|
CORS(self.app)
|
||||||
@@ -208,18 +205,14 @@ class Framework:
|
|||||||
from .init_web import jinja_initialize
|
from .init_web import jinja_initialize
|
||||||
jinja_initialize(self.app)
|
jinja_initialize(self.app)
|
||||||
|
|
||||||
#system.LogicPlugin.custom_plugin_update()
|
|
||||||
from .init_plugin import PluginManager
|
from .init_plugin import PluginManager
|
||||||
self.PluginManager = PluginManager
|
self.PluginManager = PluginManager
|
||||||
PluginManager.plugin_update()
|
PluginManager.plugin_update()
|
||||||
PluginManager.plugin_init()
|
PluginManager.plugin_init()
|
||||||
PluginManager.plugin_menus['system'] = {'menu':SP.menu, 'match':False}
|
PluginManager.plugin_menus['system'] = {'menu':SP.menu, 'match':False}
|
||||||
|
|
||||||
#from .init_menu import init_menu, get_menu_map
|
|
||||||
from .init_menu import MenuManager
|
from .init_menu import MenuManager
|
||||||
MenuManager.init_menu()
|
MenuManager.init_menu()
|
||||||
#init_menu(self.plugin_menu)
|
|
||||||
#system.SystemLogic.apply_menu_link()
|
|
||||||
|
|
||||||
if self.config['run_flask']:
|
if self.config['run_flask']:
|
||||||
if self.config.get('port') == None:
|
if self.config.get('port') == None:
|
||||||
@@ -232,6 +225,7 @@ class Framework:
|
|||||||
self.logger.info(f"### PORT: {self.config.get('port')}")
|
self.logger.info(f"### PORT: {self.config.get('port')}")
|
||||||
self.logger.info('### Now you can access App by webbrowser!!')
|
self.logger.info('### Now you can access App by webbrowser!!')
|
||||||
|
|
||||||
|
|
||||||
def __prepare_starting(self):
|
def __prepare_starting(self):
|
||||||
# 여기서 monkey.patch시 너무 늦다고 문제 발생
|
# 여기서 monkey.patch시 너무 늦다고 문제 발생
|
||||||
pass
|
pass
|
||||||
@@ -276,7 +270,9 @@ class Framework:
|
|||||||
def __init_define(self):
|
def __init_define(self):
|
||||||
self.config['DEFINE'] = {}
|
self.config['DEFINE'] = {}
|
||||||
# 이건 필요 없음
|
# 이건 필요 없음
|
||||||
self.config['DEFINE']['MAIN_SERVER_URL'] = 'https://server.sjva.me'
|
self.config['DEFINE']['GIT_VERSION_URL'] = 'https://raw.githubusercontent.com/flaskfarm/flaskfarm/main/lib/framework/version.py'
|
||||||
|
self.config['DEFINE']['CHANGELOG'] = 'https://flaskfarm.github.io/posts/changelog'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __process_args(self):
|
def __process_args(self):
|
||||||
@@ -306,29 +302,23 @@ class Framework:
|
|||||||
#self.config['arg_config'] =
|
#self.config['arg_config'] =
|
||||||
|
|
||||||
def __load_config(self):
|
def __load_config(self):
|
||||||
from .init_declare import read_yaml
|
|
||||||
|
|
||||||
#if self.config['run_flask']:
|
#if self.config['run_flask']:
|
||||||
if self.config['arg_config'] == '.':
|
if self.config['arg_config'] == '.':
|
||||||
#self.config['config_filepath'] = os.path.join(self.path_app_root, 'config.yaml')
|
#self.config['config_filepath'] = os.path.join(self.path_app_root, 'config.yaml')
|
||||||
self.config['config_filepath'] = os.path.join(self.config['path_working'], 'config.yaml')
|
self.config['config_filepath'] = os.path.join(self.config['path_working'], 'config.yaml')
|
||||||
else:
|
else:
|
||||||
self.config['config_filepath'] = self.config['arg_config']
|
self.config['config_filepath'] = self.config['arg_config']
|
||||||
if not os.path.exists(self.config['config_filepath']):
|
if os.path.exists(self.config['config_filepath']) == False:
|
||||||
# celery는 환경변수 사용불가로 native 판단
|
if self.config.get('running_type').startswith('docker'):
|
||||||
# 도커는 celery가 먼저 진입
|
with open(self.config['config_filepath'], 'w', encoding='utf8') as f:
|
||||||
# 추후에 변경할 것!!!!!!!!!!!!!!!!! TODO
|
yaml.dump({'path_data':'/data'}, f, default_flow_style=False, allow_unicode=True)
|
||||||
if self.config.get('running_type').startswith('docker'):# or os.path.exists('/data'):
|
|
||||||
shutil.copy(
|
|
||||||
os.path.join(self.path_app_root, 'files', 'config.yaml.docker'),
|
|
||||||
self.config['config_filepath']
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
shutil.copy(
|
shutil.copy(
|
||||||
os.path.join(self.path_app_root, 'files', 'config.yaml.template'),
|
os.path.join(self.path_app_root, 'files', 'config.yaml.template'),
|
||||||
self.config['config_filepath']
|
self.config['config_filepath']
|
||||||
)
|
)
|
||||||
data = read_yaml(self.config['config_filepath'])
|
with open(self.config['config_filepath'], encoding='utf8') as file:
|
||||||
|
data = yaml.load(file, Loader=yaml.FullLoader)
|
||||||
for key, value in data.items():
|
for key, value in data.items():
|
||||||
if key == 'running_type' and value not in ['termux', 'entware']:
|
if key == 'running_type' and value not in ['termux', 'entware']:
|
||||||
continue
|
continue
|
||||||
@@ -509,8 +499,8 @@ class Framework:
|
|||||||
def get_recent_version(self):
|
def get_recent_version(self):
|
||||||
try:
|
try:
|
||||||
import requests
|
import requests
|
||||||
url = f"{self.config['DEFINE']['MAIN_SERVER_URL']}/version"
|
text = requests.get(self.config['DEFINE']['GIT_VERSION_URL']).text
|
||||||
self.config['recent_version'] = requests.get(url).text
|
self.config['recent_version'] = text.split('=')[1].strip().strip('"')
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error(f'Exception:{str(e)}')
|
self.logger.error(f'Exception:{str(e)}')
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from flask import jsonify, redirect, request, send_from_directory
|
from flask import (jsonify, redirect, render_template, request,
|
||||||
|
send_from_directory)
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
|
|
||||||
from framework import F
|
from framework import F
|
||||||
@@ -109,7 +110,26 @@ def upload():
|
|||||||
return jsonify('fail')
|
return jsonify('fail')
|
||||||
|
|
||||||
|
|
||||||
|
@F.app.route("/videojs", methods=['GET', 'POST'])
|
||||||
|
def videojs():
|
||||||
|
data = {}
|
||||||
|
data['play_title'] = request.form['play_title']
|
||||||
|
data['play_source_src'] = request.form['play_source_src']
|
||||||
|
data['play_source_type'] = request.form['play_source_type']
|
||||||
|
if 'play_subtitle_src' in request.form:
|
||||||
|
data['play_subtitle_src'] = request.form['play_subtitle_src']
|
||||||
|
return render_template('videojs.html', data=data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 3.10에서 이거 필수
|
# 3.10에서 이거 필수
|
||||||
@F.socketio.on('connect', namespace=f'/framework')
|
@F.socketio.on('connect', namespace=f'/framework')
|
||||||
def connect():
|
def connect():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -231,7 +231,9 @@ class Job(object):
|
|||||||
self.thread = threading.Thread(target=self.target_function, args=(self.args,))
|
self.thread = threading.Thread(target=self.target_function, args=(self.args,))
|
||||||
self.thread.daemon = True
|
self.thread.daemon = True
|
||||||
self.thread.start()
|
self.thread.start()
|
||||||
|
F.socketio.emit('notify', {'type':'success', 'msg':f"{self.description}<br>작업을 시작합니다." }, namespace='/framework', broadcast=True)
|
||||||
self.thread.join()
|
self.thread.join()
|
||||||
|
F.socketio.emit('notify', {'type':'success', 'msg':f"{self.description}<br>작업이 종료되었습니다." }, namespace='/framework', broadcast=True)
|
||||||
self.end_time = datetime.now(timezone('Asia/Seoul'))
|
self.end_time = datetime.now(timezone('Asia/Seoul'))
|
||||||
self.running_timedelta = self.end_time - self.start_time
|
self.running_timedelta = self.end_time - self.start_time
|
||||||
self.status = 'success'
|
self.status = 'success'
|
||||||
|
|||||||
@@ -116,10 +116,7 @@ function showModal(data='EMPTY', title='JSON', json=true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////
|
function getFormdata(form_id) {
|
||||||
// camel
|
|
||||||
|
|
||||||
function get_formdata(form_id) {
|
|
||||||
// on, off 일수도 있으니 모두 True, False로 통일하고
|
// on, off 일수도 있으니 모두 True, False로 통일하고
|
||||||
// 밑에서는 False인 경우 값이 추가되지 않으니.. 수동으로 넣어줌
|
// 밑에서는 False인 경우 값이 추가되지 않으니.. 수동으로 넣어줌
|
||||||
var checkboxs = $(form_id + ' input[type=checkbox]');
|
var checkboxs = $(form_id + ' input[type=checkbox]');
|
||||||
@@ -148,20 +145,23 @@ function get_formdata(form_id) {
|
|||||||
return formData;
|
return formData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////
|
||||||
|
// camel
|
||||||
|
|
||||||
|
|
||||||
function use_collapse(div, reverse=false) {
|
function use_collapse(div, reverse=false) {
|
||||||
var ret = $('#' + div).prop('checked');
|
var ret = $('#' + div).prop('checked');
|
||||||
if (reverse) {
|
if (reverse) {
|
||||||
if (ret) {
|
if (ret) {
|
||||||
$('#' + div + '_div').collapse('hide')
|
$('#' + div + '_div').collapse('hide');
|
||||||
} else {
|
} else {
|
||||||
$('#' + div + '_div').collapse('show')
|
$('#' + div + '_div').collapse('show');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ret) {
|
if (ret) {
|
||||||
$('#' + div + '_div').collapse('show')
|
$('#' + div + '_div').collapse('show');
|
||||||
} else {
|
} else {
|
||||||
$('#' + div + '_div').collapse('hide')
|
$('#' + div + '_div').collapse('hide');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ $("body").on('click', '#globalSettingSaveBtn', function(e){
|
|||||||
});
|
});
|
||||||
|
|
||||||
function globalSettingSave() {
|
function globalSettingSave() {
|
||||||
var formData = get_formdata('#setting');
|
var formData = getFormdata('#setting');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/' + PACKAGE_NAME + '/ajax/setting_save',
|
url: '/' + PACKAGE_NAME + '/ajax/setting_save',
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@@ -119,6 +119,11 @@ $("body").on('click', '#globalEditBtn', function(e) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("body").on('click', '#globalCliboardBtn', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
window.navigator.clipboard.writeText($(this).data('text'));
|
||||||
|
notify("클립보드에 복사하였습니다.", "success");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
@@ -144,6 +149,25 @@ function globalSendCommand(command, arg1, arg2, arg3, modal_title, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function globalSendCommandPage(command, arg1, arg2, arg3, modal_title, callback) {
|
||||||
|
console.log("globalSendCommandPage [" + command + '] [' + arg1 + '] [' + arg2 + '] [' + arg3 + '] [' + modal_title + '] [' + callback + ']');
|
||||||
|
console.log('/' + PACKAGE_NAME + '/ajax/' + MODULE_NAME + '/command');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/' + PACKAGE_NAME + '/ajax/' + MODULE_NAME + '/' + PAGE_NAME + '/command',
|
||||||
|
type: "POST",
|
||||||
|
cache: false,
|
||||||
|
data:{command:command, arg1:arg1, arg2:arg2, arg3},
|
||||||
|
dataType: "json",
|
||||||
|
success: function (ret) {
|
||||||
|
if (ret.msg != null) notify(ret.msg, ret.ret);
|
||||||
|
if (ret.modal != null) m_modal(ret.modal, modal_title, false);
|
||||||
|
if (ret.json != null) m_modal(ret.json, modal_title, true);
|
||||||
|
if (callback != null) callback(ret);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function shutdown_confirm() {
|
function shutdown_confirm() {
|
||||||
$("#confirm_title").html("종료 확인");
|
$("#confirm_title").html("종료 확인");
|
||||||
$("#confirm_body").html("종료 하시겠습니까?");
|
$("#confirm_body").html("종료 하시겠습니까?");
|
||||||
|
|||||||
@@ -1,3 +1,74 @@
|
|||||||
|
function m_button_group(h) {
|
||||||
|
var str = '<div class="btn-group btn-group-sm flex-wrap mr-2" role="group">';
|
||||||
|
str += h
|
||||||
|
str += '</div>';
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
// primary, secondary, success, danger, warning, info, light, dark, white
|
||||||
|
function m_button(id, text, data={}, color='success', outline=true, small=false) {
|
||||||
|
var str = '<button id="'+id+'" name="'+id+'" class="btn btn-sm btn';
|
||||||
|
if (outline) {
|
||||||
|
str += '-outline';
|
||||||
|
}
|
||||||
|
str += '-' + color+'';
|
||||||
|
if (small) {
|
||||||
|
str += ' py-0" style="font-size: 0.8em;"';
|
||||||
|
} else {
|
||||||
|
str += '" ';
|
||||||
|
}
|
||||||
|
for ( var key in data) {
|
||||||
|
str += ' data-' + key + '="' + data[key]+ '" '
|
||||||
|
}
|
||||||
|
str += '>' + text + '</button>';
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
function m_button_small(id, text, data={}, color='success', outline=true) {
|
||||||
|
return m_button(id, text, data, color, outline, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// javascript에서 화면 생성
|
// javascript에서 화면 생성
|
||||||
function text_color(text, color='red') {
|
function text_color(text, color='red') {
|
||||||
return '<span style="color:'+color+'; font-weight:bold">' + text + '</span>';
|
return '<span style="color:'+color+'; font-weight:bold">' + text + '</span>';
|
||||||
@@ -89,40 +160,6 @@ function m_col_wide(w, h, align='left') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function m_button_group(h) {
|
|
||||||
var str = '<div class="btn-group btn-group-sm flex-wrap mr-2" role="group">';
|
|
||||||
str += h
|
|
||||||
str += '</div>';
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function m_button(id, text, data) {
|
|
||||||
var str = '<button id="'+id+'" name="'+id+'" class="btn btn-sm btn-outline-success" '
|
|
||||||
for ( var i in data) {
|
|
||||||
str += ' data-' + data[i].key + '="' + data[i].value+ '" '
|
|
||||||
}
|
|
||||||
str += '>' + text + '</button>';
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function m_button_small(id, text, data, color='danger') {
|
|
||||||
var str = '<button id="'+id+'" name="'+id+'" class="btn btn-sm btn-'+color+' py-0" style="font-size: 0.8em;" '
|
|
||||||
for ( var i in data) {
|
|
||||||
str += ' data-' + data[i].key + '="' + data[i].value+ '" '
|
|
||||||
}
|
|
||||||
str += '>' + text + '</button>';
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function m_button2(id, text, data, outline_color) {
|
|
||||||
var str = '<button id="'+id+'" name="'+id+'" class="btn btn-sm btn-outline-'+outline_color+'" '
|
|
||||||
for ( var i in data) {
|
|
||||||
str += ' data-' + data[i].key + '="' + data[i].value+ '" '
|
|
||||||
}
|
|
||||||
str += '>' + text + '</button>';
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ $('#global_scheduler_sub').change(function() {
|
|||||||
|
|
||||||
|
|
||||||
function global_setting_save_function() {
|
function global_setting_save_function() {
|
||||||
var formData = get_formdata('#setting');
|
var formData = getFormdata('#setting');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/'+package_name+'/ajax/setting_save',
|
url: '/'+package_name+'/ajax/setting_save',
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@@ -372,7 +372,7 @@ function global_db_delete_sub() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function global_sub_request_search(page, move_top=true) {
|
function global_sub_request_search(page, move_top=true) {
|
||||||
var formData = get_formdata('#form_search')
|
var formData = getFormdata('#form_search')
|
||||||
formData += '&page=' + page;
|
formData += '&page=' + page;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/' + package_name + '/ajax/' + sub + '/web_list',
|
url: '/' + package_name + '/ajax/' + sub + '/web_list',
|
||||||
|
|||||||
@@ -57,14 +57,7 @@ function m_button(id, text, data) {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function m_button2(id, text, data, outline_color) {
|
|
||||||
var str = '<button id="'+id+'" name="'+id+'" class="btn btn-sm btn-outline-'+outline_color+'" '
|
|
||||||
for ( var i in data) {
|
|
||||||
str += ' data-' + data[i].key + '="' + data[i].value+ '" '
|
|
||||||
}
|
|
||||||
str += '>' + text + '</button>';
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -163,22 +156,7 @@ function make_page_html(data) {
|
|||||||
document.getElementById("page2").innerHTML = str;
|
document.getElementById("page2").innerHTML = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function use_collapse(div, reverse=false) {
|
|
||||||
var ret = $('#' + div).prop('checked');
|
|
||||||
if (reverse) {
|
|
||||||
if (ret) {
|
|
||||||
$('#' + div + '_div').collapse('hide')
|
|
||||||
} else {
|
|
||||||
$('#' + div + '_div').collapse('show')
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (ret) {
|
|
||||||
$('#' + div + '_div').collapse('show')
|
|
||||||
} else {
|
|
||||||
$('#' + div + '_div').collapse('hide')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function(){
|
document.addEventListener("DOMContentLoaded", function(){
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/bootstrap-notify.min.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/bootstrap-notify.min.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/sjva_ui14.js') }}"></script>
|
|
||||||
|
|
||||||
<script src="{{ url_for('static', filename='js/ff_common1.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/ff_common1.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/ff_ui1.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/ff_ui1.js') }}"></script>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
VERSION="4.0.7"
|
VERSION="4.0.8"
|
||||||
@@ -38,7 +38,7 @@ class PluginBase(object):
|
|||||||
self.logger = F.get_logger(self.package_name)
|
self.logger = F.get_logger(self.package_name)
|
||||||
self.blueprint = Blueprint(self.package_name, self.package_name, url_prefix=f'/{self.package_name}', template_folder=os.path.join(os.path.dirname(setting['filepath']), 'templates'), static_folder=os.path.join(os.path.dirname(setting['filepath']), 'static'))
|
self.blueprint = Blueprint(self.package_name, self.package_name, url_prefix=f'/{self.package_name}', template_folder=os.path.join(os.path.dirname(setting['filepath']), 'templates'), static_folder=os.path.join(os.path.dirname(setting['filepath']), 'static'))
|
||||||
self.menu = setting['menu']
|
self.menu = setting['menu']
|
||||||
self.setting_menu = setting['setting_menu']
|
self.setting_menu = setting.get('setting_menu', None)
|
||||||
|
|
||||||
self.ModelSetting = None
|
self.ModelSetting = None
|
||||||
if setting.get('use_db', True):
|
if setting.get('use_db', True):
|
||||||
|
|||||||
@@ -17,10 +17,14 @@ class Logic(object):
|
|||||||
|
|
||||||
def plugin_load(self):
|
def plugin_load(self):
|
||||||
try:
|
try:
|
||||||
#self.P.logger.debug('%s plugin_load', self.P.package_name)
|
self.P.logger.debug('%s plugin_load', self.P.package_name)
|
||||||
self.db_init()
|
self.db_init()
|
||||||
for module in self.P.module_list:
|
for module in self.P.module_list:
|
||||||
module.migration()
|
module.migration()
|
||||||
|
if module.page_list is not None:
|
||||||
|
for page_instance in module.page_list:
|
||||||
|
page_instance.migration()
|
||||||
|
|
||||||
for module in self.P.module_list:
|
for module in self.P.module_list:
|
||||||
module.plugin_load()
|
module.plugin_load()
|
||||||
if module.page_list is not None:
|
if module.page_list is not None:
|
||||||
@@ -154,7 +158,7 @@ class Logic(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.P.logger.error(f'Exception:{str(e)}')
|
self.P.logger.error(f'Exception:{str(e)}')
|
||||||
self.P.logger.error(traceback.format_exc())
|
self.P.logger.error(traceback.format_exc())
|
||||||
ret = {'ret' : 'danger', 'msg':str(exception)}
|
ret = {'ret' : 'danger', 'msg':str(e)}
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def get_module(self, sub):
|
def get_module(self, sub):
|
||||||
@@ -239,5 +243,5 @@ class Logic(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.P.logger.error(f'Exception:{str(e)}')
|
self.P.logger.error(f'Exception:{str(e)}')
|
||||||
self.P.logger.error(traceback.format_exc())
|
self.P.logger.error(traceback.format_exc())
|
||||||
ret = {'ret' : 'danger', 'msg':str(exception)}
|
ret = {'ret' : 'danger', 'msg':str(e)}
|
||||||
return ret
|
return ret
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
from flask import render_template
|
||||||
|
|
||||||
|
|
||||||
class PluginModuleBase(object):
|
class PluginModuleBase(object):
|
||||||
db_default = None
|
db_default = None
|
||||||
|
|
||||||
@@ -33,8 +36,12 @@ class PluginModuleBase(object):
|
|||||||
self.P.logger.error(traceback.format_exc())
|
self.P.logger.error(traceback.format_exc())
|
||||||
|
|
||||||
|
|
||||||
def process_menu(self, sub):
|
def process_menu(self, page, req):
|
||||||
pass
|
if self.page_list is not None:
|
||||||
|
page_ins = self.get_page(page)
|
||||||
|
if page_ins != None:
|
||||||
|
return page_ins.process_menu(req)
|
||||||
|
return render_template('sample.html', title=f"PluginModuleBase-process_menu{self.P.package_name}/{self.name}/{page}")
|
||||||
|
|
||||||
def process_ajax(self, sub, req):
|
def process_ajax(self, sub, req):
|
||||||
pass
|
pass
|
||||||
@@ -96,6 +103,26 @@ class PluginModuleBase(object):
|
|||||||
def socketio_disconnect(self):
|
def socketio_disconnect(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PluginPageBase(object):
|
class PluginPageBase(object):
|
||||||
db_default = None
|
db_default = None
|
||||||
@@ -107,19 +134,42 @@ class PluginPageBase(object):
|
|||||||
self.scheduler_desc = scheduler_desc
|
self.scheduler_desc = scheduler_desc
|
||||||
self.socketio_list = None
|
self.socketio_list = None
|
||||||
|
|
||||||
|
def process_menu(self, req):
|
||||||
|
try:
|
||||||
|
arg = {}
|
||||||
|
if self.P.ModelSetting != None:
|
||||||
|
arg = self.P.ModelSetting.to_dict()
|
||||||
|
return render_template(f'{__package__}_{self.parent.name}_{self.name}.html', arg=arg)
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return render_template('sample.html', title=f"PluginPageBase-process_menu {self.P.package_name}/{self.parent.name}/{self.name}")
|
||||||
|
|
||||||
|
|
||||||
def process_ajax(self, sub, req):
|
def process_ajax(self, sub, req):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def scheduler_function(self):
|
def process_api(self, sub, req):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def process_normal(self, sub, req):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def process_command(self, command, arg1, arg2, arg3, req):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# logic
|
||||||
def plugin_load(self):
|
def plugin_load(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# logic
|
||||||
def plugin_unload(self):
|
def plugin_unload(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def scheduler_function(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def get_scheduler_desc(self):
|
def get_scheduler_desc(self):
|
||||||
return self.scheduler_desc
|
return self.scheduler_desc
|
||||||
@@ -132,40 +182,16 @@ class PluginPageBase(object):
|
|||||||
return f'{self.P.package_name}_{self.parent.name}_{self.name}'
|
return f'{self.P.package_name}_{self.parent.name}_{self.name}'
|
||||||
|
|
||||||
|
|
||||||
|
# logic
|
||||||
|
def migration(self):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def process_api(self, sub, req):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def process_normal(self, sub, req):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# route
|
||||||
def reset_db(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def setting_save_after(self, change_list):
|
def setting_save_after(self, change_list):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def process_telegram_data(self, data, target=None):
|
def process_telegram_data(self, data, target=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def migration(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
#################################################################
|
|
||||||
|
|
||||||
|
|
||||||
def process_menu(self, sub):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|||||||
@@ -158,6 +158,8 @@ def default_route(P):
|
|||||||
elif command == 'immediately_execute':
|
elif command == 'immediately_execute':
|
||||||
ret = P.logic.immediately_execute_sub(module_name, page_name)
|
ret = P.logic.immediately_execute_sub(module_name, page_name)
|
||||||
return jsonify(ret)
|
return jsonify(ret)
|
||||||
|
elif command == 'command':
|
||||||
|
return ins_page.process_command(request.form['command'], request.form.get('arg1'), request.form.get('arg2'), request.form.get('arg3'), request)
|
||||||
else:
|
else:
|
||||||
return ins_page.process_ajax(command, request)
|
return ins_page.process_ajax(command, request)
|
||||||
P.logger.error(f"not process ajax : {P.package_name} {module_name} {page_name} {command}")
|
P.logger.error(f"not process ajax : {P.package_name} {module_name} {page_name} {command}")
|
||||||
@@ -251,6 +253,9 @@ def default_route_single_module(P):
|
|||||||
ret, change_list = P.ModelSetting.setting_save(request)
|
ret, change_list = P.ModelSetting.setting_save(request)
|
||||||
if ret:
|
if ret:
|
||||||
P.module_list[0].setting_save_after(change_list)
|
P.module_list[0].setting_save_after(change_list)
|
||||||
|
if P.module_list[0].page_list is not None:
|
||||||
|
for page_ins in P.module_list[0].page_list:
|
||||||
|
page_ins.setting_save_after(change_list)
|
||||||
return jsonify(ret)
|
return jsonify(ret)
|
||||||
elif sub == 'scheduler':
|
elif sub == 'scheduler':
|
||||||
sub = request.form['sub']
|
sub = request.form['sub']
|
||||||
@@ -384,32 +389,32 @@ def default_route_socketio_page(page):
|
|||||||
if page.socketio_list is None:
|
if page.socketio_list is None:
|
||||||
page.socketio_list = []
|
page.socketio_list = []
|
||||||
|
|
||||||
@socketio.on('connect', namespace=f'/{P.package_name}/{module.name}/{page.name}')
|
@F.socketio.on('connect', namespace=f'/{P.package_name}/{module.name}/{page.name}')
|
||||||
def connect():
|
def page_socketio_connect():
|
||||||
try:
|
try:
|
||||||
P.logger.debug(f'socket_connect : {P.package_name}/{module.name}/{page.name}')
|
P.logger.debug(f'socket_connect : {P.package_name}/{module.name}/{page.name}')
|
||||||
page.socketio_list.append(request.sid)
|
page.socketio_list.append(request.sid)
|
||||||
socketio_callback('start', '')
|
page_socketio_socketio_callback('start', '')
|
||||||
except Exception as exception:
|
except Exception as e:
|
||||||
P.logger.error(f'Exception:{str(exception)}', exception)
|
P.logger.error(f'Exception:{str(e)}')
|
||||||
P.logger.error(traceback.format_exc())
|
P.logger.error(traceback.format_exc())
|
||||||
|
|
||||||
|
|
||||||
@socketio.on('disconnect', namespace=f'/{P.package_name}/{module.name}/{page.name}')
|
@F.socketio.on('disconnect', namespace=f'/{P.package_name}/{module.name}/{page.name}')
|
||||||
def disconnect():
|
def page_socketio_disconnect():
|
||||||
try:
|
try:
|
||||||
P.logger.debug(f'socket_disconnect : {P.package_name}/{module.name}/{page.name}')
|
P.logger.debug(f'socket_disconnect : {P.package_name}/{module.name}/{page.name}')
|
||||||
page.socketio_list.remove(request.sid)
|
page.socketio_list.remove(request.sid)
|
||||||
except Exception as exception:
|
except Exception as e:
|
||||||
P.logger.error(f'Exception:{str(exception)}', exception)
|
P.logger.error(f'Exception:{str(e)}')
|
||||||
P.logger.error(traceback.format_exc())
|
P.logger.error(traceback.format_exc())
|
||||||
|
|
||||||
|
|
||||||
def socketio_callback(cmd, data, encoding=True):
|
def page_socketio_socketio_callback(cmd, data, encoding=True):
|
||||||
if page.socketio_list:
|
if page.socketio_list:
|
||||||
if encoding:
|
if encoding:
|
||||||
data = json.dumps(data, cls=AlchemyEncoder)
|
data = json.dumps(data, cls=AlchemyEncoder)
|
||||||
data = json.loads(data)
|
data = json.loads(data)
|
||||||
socketio.emit(cmd, data, namespace=f'/{P.package_name}/{module.name}/{page.name}', broadcast=True)
|
F.socketio.emit(cmd, data, namespace=f'/{P.package_name}/{module.name}/{page.name}', broadcast=True)
|
||||||
|
|
||||||
page.socketio_callback = socketio_callback
|
page.socketio_callback = page_socketio_socketio_callback
|
||||||
|
|||||||
@@ -35,17 +35,17 @@ class CustomFormatter(logging.Formatter):
|
|||||||
green = "\x1B[32m"
|
green = "\x1B[32m"
|
||||||
# pathname filename
|
# pathname filename
|
||||||
#format = "[%(asctime)s|%(name)s|%(levelname)s - %(message)s (%(filename)s:%(lineno)d)"
|
#format = "[%(asctime)s|%(name)s|%(levelname)s - %(message)s (%(filename)s:%(lineno)d)"
|
||||||
format = '[{yellow}%(asctime)s{reset}|{color}%(levelname)s{reset}|{green}%(name)s{reset}|%(pathname)s:%(lineno)s] {color}%(message)s{reset}'
|
|
||||||
|
__format = '[{yellow}%(asctime)s{reset}|{color}%(levelname)s{reset}|{green}%(name)s{reset} %(pathname)s:%(lineno)s] {color}%(message)s{reset}' if os.environ.get('LOGGER_PATHNAME', "False") == "True" else '[{yellow}%(asctime)s{reset}|{color}%(levelname)s{reset}|{green}%(name)s{reset} %(filename)s:%(lineno)s] {color}%(message)s{reset}'
|
||||||
|
|
||||||
FORMATS = {
|
FORMATS = {
|
||||||
logging.DEBUG: format.format(color=grey, reset=reset, yellow=yellow, green=green),
|
logging.DEBUG: __format.format(color=grey, reset=reset, yellow=yellow, green=green),
|
||||||
logging.INFO: format.format(color=green, reset=reset, yellow=yellow, green=green),
|
logging.INFO: __format.format(color=green, reset=reset, yellow=yellow, green=green),
|
||||||
logging.WARNING: format.format(color=yellow, reset=reset, yellow=yellow, green=green),
|
logging.WARNING: __format.format(color=yellow, reset=reset, yellow=yellow, green=green),
|
||||||
logging.ERROR: format.format(color=red, reset=reset, yellow=yellow, green=green),
|
logging.ERROR: __format.format(color=red, reset=reset, yellow=yellow, green=green),
|
||||||
logging.CRITICAL: format.format(color=bold_red, reset=reset, yellow=yellow, green=green)
|
logging.CRITICAL: __format.format(color=bold_red, reset=reset, yellow=yellow, green=green)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def format(self, record):
|
def format(self, record):
|
||||||
log_fmt = self.FORMATS.get(record.levelno)
|
log_fmt = self.FORMATS.get(record.levelno)
|
||||||
formatter = logging.Formatter(log_fmt)
|
formatter = logging.Formatter(log_fmt)
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ class ModuleHome(PluginModuleBase):
|
|||||||
default_route_socketio_module(self)
|
default_route_socketio_module(self)
|
||||||
|
|
||||||
def process_menu(self, page, req):
|
def process_menu(self, page, req):
|
||||||
return render_template(f'{__package__}_{name}.html', info=self.get_info('static'))
|
arg = {'changelog':F.config['DEFINE']['CHANGELOG']}
|
||||||
|
return render_template(f'{__package__}_{name}.html', info=self.get_info('static'), arg=arg)
|
||||||
|
|
||||||
def process_command(self, command, arg1, arg2, arg3, req):
|
def process_command(self, command, arg1, arg2, arg3, req):
|
||||||
if command == 'recent_version':
|
if command == 'recent_version':
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class ModuleSetting(PluginModuleBase):
|
|||||||
'ddns' : 'http://localhost:9999',
|
'ddns' : 'http://localhost:9999',
|
||||||
'use_login' : 'False',
|
'use_login' : 'False',
|
||||||
'web_id': 'admin',
|
'web_id': 'admin',
|
||||||
'web_pw': 'Vm51JgZqhpwXc/UPc9CAN1lhj4s65+4ikv7GzNmvN6c=',
|
'web_pw': '21232f297a57a5a743894a0e4a801fc3',
|
||||||
'web_title': 'Home',
|
'web_title': 'Home',
|
||||||
'use_apikey': 'False',
|
'use_apikey': 'False',
|
||||||
'apikey': ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10)),
|
'apikey': ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10)),
|
||||||
@@ -175,6 +175,11 @@ class ModuleSetting(PluginModuleBase):
|
|||||||
F.socketio.emit("refresh", {}, namespace='/framework', broadcast=True)
|
F.socketio.emit("refresh", {}, namespace='/framework', broadcast=True)
|
||||||
elif 'notify.yaml' in change_list:
|
elif 'notify.yaml' in change_list:
|
||||||
SupportFile.write_file(F.config['notify_yaml_filepath'], SystemModelSetting.get('notify.yaml'))
|
SupportFile.write_file(F.config['notify_yaml_filepath'], SystemModelSetting.get('notify.yaml'))
|
||||||
|
elif 'web_pw' in change_list:
|
||||||
|
import hashlib
|
||||||
|
enc = hashlib.md5()
|
||||||
|
enc.update(SystemModelSetting.get('web_pw').encode())
|
||||||
|
SystemModelSetting.set('web_pw', enc.hexdigest())
|
||||||
|
|
||||||
|
|
||||||
def __set_restart_scheduler(self):
|
def __set_restart_scheduler(self):
|
||||||
|
|||||||
@@ -5,39 +5,21 @@ from .setup import *
|
|||||||
name = 'tool'
|
name = 'tool'
|
||||||
|
|
||||||
class ModuleTool(PluginModuleBase):
|
class ModuleTool(PluginModuleBase):
|
||||||
|
def __init__(self, P):
|
||||||
|
super(ModuleTool, self).__init__(P, name=name, first_menu='upload')
|
||||||
|
self.set_page_list([PageUpload])
|
||||||
|
|
||||||
|
|
||||||
|
class PageUpload(PluginPageBase):
|
||||||
db_default = {
|
db_default = {
|
||||||
'path_upload': os.path.join(F.config['path_data'], 'upload'),
|
'path_upload': os.path.join(F.config['path_data'], 'upload'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def __init__(self, P, parent):
|
||||||
def __init__(self, P):
|
super(PageUpload, self).__init__(P, parent, name='upload')
|
||||||
super(ModuleTool, self).__init__(P, name=name, first_menu='upload')
|
|
||||||
|
|
||||||
|
|
||||||
def process_menu(self, page, req):
|
|
||||||
arg = P.ModelSetting.to_dict()
|
|
||||||
try:
|
|
||||||
return render_template(f'{__package__}_{name}_{page}.html', arg=arg)
|
|
||||||
except Exception as e:
|
|
||||||
P.logger.error(f'Exception:{str(e)}')
|
|
||||||
P.logger.error(traceback.format_exc())
|
|
||||||
return render_template('sample.html', title=f"{__package__}/{name}/{page}")
|
|
||||||
|
|
||||||
|
|
||||||
def process_command(self, command, arg1, arg2, arg3, req):
|
|
||||||
ret = {'ret':'success'}
|
|
||||||
if command == 'plugin_install':
|
|
||||||
ret = F.PluginManager.plugin_install(arg1)
|
|
||||||
|
|
||||||
return jsonify(ret)
|
|
||||||
|
|
||||||
|
|
||||||
def plugin_load(self):
|
|
||||||
try:
|
|
||||||
pass
|
|
||||||
except Exception as e:
|
|
||||||
P.logger.error(f'Exception:{str(e)}')
|
|
||||||
P.logger.error(traceback.format_exc())
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class PageCrypt(PluginPageBase):
|
||||||
|
def __init__(self, P, parent):
|
||||||
|
super(PageCrypt, self).__init__(P, parent, name='crypt')
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
{{ macros.info_text_and_buttons('python_version', 'Python', [['globalLinkBtn', '패키지 관리', [('url','/system/python')]]], info['python_version']) }}
|
{{ macros.info_text_and_buttons('python_version', 'Python', [['globalLinkBtn', '패키지 관리', [('url','/system/python')]]], info['python_version']) }}
|
||||||
{{ macros.info_text('platform', 'Platform', info['platform']) }}
|
{{ macros.info_text('platform', 'Platform', info['platform']) }}
|
||||||
{{ macros.info_text('processor', 'Processor', info['processor']) }}
|
{{ macros.info_text('processor', 'Processor', info['processor']) }}
|
||||||
{{ macros.info_text_and_buttons('version_str', '버전', [['globalOpenBtn', '업데이트 내역', [('url','https://sjva.me/wiki/public/changelog')]], ['recent_version_btn', '최신버전 확인']], info['version']) }}
|
{{ macros.info_text_and_buttons('version_str', '버전', [['globalOpenBtn', '업데이트 내역', [('url',arg['changelog'])]], ['recent_version_btn', '최신버전 확인']], info['version']) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ function make_plugin_list(data) {
|
|||||||
str += m_col_wide(2, '');
|
str += m_col_wide(2, '');
|
||||||
str += m_col_wide(2, data[i].package_name);
|
str += m_col_wide(2, data[i].package_name);
|
||||||
str += m_col_wide(5, '');
|
str += m_col_wide(5, '');
|
||||||
tmp = m_button_small('uninstall_btn', '삭제', [{'key':'package_name', 'value':data[i].package_name}]);
|
tmp = m_button('uninstall_btn', '삭제', {'package_name':data[i].package_name}, 'danger', false, true);
|
||||||
} else {
|
} else {
|
||||||
str += m_col_wide(2, data[i].title);
|
str += m_col_wide(2, data[i].title);
|
||||||
|
|
||||||
@@ -59,9 +59,9 @@ function make_plugin_list(data) {
|
|||||||
|
|
||||||
tmp = ''
|
tmp = ''
|
||||||
|
|
||||||
tmp += m_button_small('globalOpenBtn', '홈페이지', [{'key':'url', 'value':data[i].home}], 'primary');
|
tmp += m_button_small('globalOpenBtn', '홈페이지', {'url':data[i].home}, 'primary', false, true);
|
||||||
tmp += m_button_small('uninstall_btn', '삭제', [{'key':'package_name', 'value':data[i].package_name}, {'key':'title', 'value':data[i].title}]);
|
tmp += m_button_small('uninstall_btn', '삭제', {'package_name':data[i].package_name, 'title':data[i].title}, 'danger', false, true);
|
||||||
tmp += m_button_small('json_btn', 'JSON', [{'key':'idx', 'value':i}], 'info');
|
tmp += m_button_small('json_btn', 'JSON', {'idx':i}, 'info', false, true);
|
||||||
}
|
}
|
||||||
tmp = m_button_group(tmp)
|
tmp = m_button_group(tmp)
|
||||||
str += m_col_wide(2, tmp, 'right')
|
str += m_col_wide(2, tmp, 'right')
|
||||||
|
|||||||
@@ -34,10 +34,12 @@ var running_type = "{{arg['running_type']}}";
|
|||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
console.log(running_type);
|
console.log(running_type);
|
||||||
|
/*
|
||||||
if (running_type.startsWith('docker')) {
|
if (running_type.startsWith('docker')) {
|
||||||
$('#celery_start_by_web').bootstrapToggle('off');
|
$('#celery_start_by_web').bootstrapToggle('off');
|
||||||
$('#celery_start_by_web').prop('disabled', true);
|
$('#celery_start_by_web').prop('disabled', true);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
|
|
||||||
$("body").on('click', '#celery_excute_btn', function(e){
|
$("body").on('click', '#celery_excute_btn', function(e){
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ from framework import logger
|
|||||||
|
|
||||||
from .modal_command import ToolModalCommand
|
from .modal_command import ToolModalCommand
|
||||||
from .notify import ToolNotify
|
from .notify import ToolNotify
|
||||||
|
from .util import ToolUtil
|
||||||
|
|||||||
18
lib/tool/util.py
Normal file
18
lib/tool/util.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
from . import logger
|
||||||
|
|
||||||
|
|
||||||
|
class ToolUtil(object):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def make_apikey_url(cls, url):
|
||||||
|
from framework import F
|
||||||
|
if not url.startswith('http'):
|
||||||
|
url = F.SystemModelSetting.get('ddns') + url
|
||||||
|
if F.SystemModelSetting.get_bool('use_apikey'):
|
||||||
|
if url.find('?') == -1:
|
||||||
|
url += '?'
|
||||||
|
else:
|
||||||
|
url += '&'
|
||||||
|
url += f"apikey={F.SystemModelSetting.get('apikey')}"
|
||||||
|
return url
|
||||||
|
|
||||||
@@ -1,26 +1,20 @@
|
|||||||
import os, sys, traceback, json
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import traceback
|
||||||
|
|
||||||
from . import logger
|
from . import logger
|
||||||
|
|
||||||
|
|
||||||
class ToolUtil(object):
|
class ToolUtil(object):
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def make_apikey_url(cls, url):
|
|
||||||
from framework import SystemModelSetting
|
|
||||||
if not url.startswith('http'):
|
|
||||||
url = SystemModelSetting.get('ddns') + url
|
|
||||||
if SystemModelSetting.get_bool('auth_use_apikey'):
|
|
||||||
if url.find('?') == -1:
|
|
||||||
url += '?'
|
|
||||||
else:
|
|
||||||
url += '&'
|
|
||||||
url += 'apikey=%s' % SystemModelSetting.get('auth_apikey')
|
|
||||||
return url
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def save_dict(cls, data, filepath):
|
def save_dict(cls, data, filepath):
|
||||||
try:
|
try:
|
||||||
import json, codecs
|
import codecs
|
||||||
|
import json
|
||||||
data = json.dumps(data, indent=4, ensure_ascii=False)
|
data = json.dumps(data, indent=4, ensure_ascii=False)
|
||||||
ofp = codecs.open(filepath, 'w', encoding='utf8')
|
ofp = codecs.open(filepath, 'w', encoding='utf8')
|
||||||
ofp.write(data)
|
ofp.write(data)
|
||||||
|
|||||||
Reference in New Issue
Block a user