diff --git a/files/config.yaml.docker b/files/config.yaml.docker
deleted file mode 100644
index 496b9a4..0000000
--- a/files/config.yaml.docker
+++ /dev/null
@@ -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: []
diff --git a/files/freeze.txt b/files/freeze.txt
deleted file mode 100644
index 1e14ac3..0000000
--- a/files/freeze.txt
+++ /dev/null
@@ -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
diff --git a/files/requirements_mini.txt b/files/requirements_mini.txt
index b75825d..ef50bde 100644
--- a/files/requirements_mini.txt
+++ b/files/requirements_mini.txt
@@ -18,7 +18,6 @@ discord-webhook
pyyaml
telepot-mod
Flask-Dropzone
-pycryptodome
psutil
# filemanager
diff --git a/files/requirements_useful.txt b/files/requirements_useful.txt
index 709299a..2b4f785 100644
--- a/files/requirements_useful.txt
+++ b/files/requirements_useful.txt
@@ -1,2 +1,3 @@
lxml
selenium
+pycryptodome
\ No newline at end of file
diff --git a/lib/framework/init_declare.py b/lib/framework/init_declare.py
index 006903e..a37048f 100644
--- a/lib/framework/init_declare.py
+++ b/lib/framework/init_declare.py
@@ -63,13 +63,6 @@ class CustomFormatter(logging.Formatter):
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:
def __init__(self, user_id, email=None, passwd_hash=None, authenticated=False):
@@ -88,9 +81,14 @@ class User:
return str(r)
def can_login(self, passwd_hash):
- from support import SupportAES
- tmp = SupportAES.decrypt(self.passwd_hash)
- return passwd_hash == tmp
+ #from support import SupportAES
+ #tmp = SupportAES.decrypt(self.passwd_hash)
+ import hashlib
+ enc = hashlib.md5()
+ enc.update(passwd_hash.encode())
+ hash = enc.hexdigest()
+ #return True
+ return self.passwd_hash == hash
def is_active(self):
return True
diff --git a/lib/framework/init_main.py b/lib/framework/init_main.py
index 1842963..417f830 100644
--- a/lib/framework/init_main.py
+++ b/lib/framework/init_main.py
@@ -8,6 +8,7 @@ import time
import traceback
from datetime import datetime
+import yaml
from flask import Flask
from flask_cors import CORS
from flask_login import LoginManager, login_required
@@ -69,7 +70,6 @@ class Framework:
self.__init_db()
-
if True or self.config['run_flask']:
from .scheduler import Job, Scheduler
self.scheduler = Scheduler(self)
@@ -78,9 +78,6 @@ class Framework:
if self.config['use_gevent']:
self.socketio = SocketIO(self.app, cors_allowed_origins="*")
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')
CORS(self.app)
@@ -208,18 +205,14 @@ class Framework:
from .init_web import jinja_initialize
jinja_initialize(self.app)
- #system.LogicPlugin.custom_plugin_update()
from .init_plugin import PluginManager
self.PluginManager = PluginManager
PluginManager.plugin_update()
PluginManager.plugin_init()
PluginManager.plugin_menus['system'] = {'menu':SP.menu, 'match':False}
-
- #from .init_menu import init_menu, get_menu_map
+
from .init_menu import MenuManager
MenuManager.init_menu()
- #init_menu(self.plugin_menu)
- #system.SystemLogic.apply_menu_link()
if self.config['run_flask']:
if self.config.get('port') == None:
@@ -232,6 +225,7 @@ class Framework:
self.logger.info(f"### PORT: {self.config.get('port')}")
self.logger.info('### Now you can access App by webbrowser!!')
+
def __prepare_starting(self):
# 여기서 monkey.patch시 너무 늦다고 문제 발생
pass
@@ -276,7 +270,9 @@ class Framework:
def __init_define(self):
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):
@@ -306,29 +302,23 @@ class Framework:
#self.config['arg_config'] =
def __load_config(self):
- from .init_declare import read_yaml
-
#if self.config['run_flask']:
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.config['path_working'], 'config.yaml')
else:
self.config['config_filepath'] = self.config['arg_config']
- if not os.path.exists(self.config['config_filepath']):
- # celery는 환경변수 사용불가로 native 판단
- # 도커는 celery가 먼저 진입
- # 추후에 변경할 것!!!!!!!!!!!!!!!!! TODO
- 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']
- )
+ if os.path.exists(self.config['config_filepath']) == False:
+ if self.config.get('running_type').startswith('docker'):
+ with open(self.config['config_filepath'], 'w', encoding='utf8') as f:
+ yaml.dump({'path_data':'/data'}, f, default_flow_style=False, allow_unicode=True)
else:
shutil.copy(
os.path.join(self.path_app_root, 'files', 'config.yaml.template'),
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():
if key == 'running_type' and value not in ['termux', 'entware']:
continue
@@ -509,8 +499,8 @@ class Framework:
def get_recent_version(self):
try:
import requests
- url = f"{self.config['DEFINE']['MAIN_SERVER_URL']}/version"
- self.config['recent_version'] = requests.get(url).text
+ text = requests.get(self.config['DEFINE']['GIT_VERSION_URL']).text
+ self.config['recent_version'] = text.split('=')[1].strip().strip('"')
return True
except Exception as e:
self.logger.error(f'Exception:{str(e)}')
diff --git a/lib/framework/init_route.py b/lib/framework/init_route.py
index c00edb7..ee94855 100644
--- a/lib/framework/init_route.py
+++ b/lib/framework/init_route.py
@@ -1,7 +1,8 @@
import os
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 framework import F
@@ -109,7 +110,26 @@ def upload():
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에서 이거 필수
@F.socketio.on('connect', namespace=f'/framework')
def connect():
pass
+
+
diff --git a/lib/framework/scheduler.py b/lib/framework/scheduler.py
index faeb9ca..948fa62 100644
--- a/lib/framework/scheduler.py
+++ b/lib/framework/scheduler.py
@@ -231,7 +231,9 @@ class Job(object):
self.thread = threading.Thread(target=self.target_function, args=(self.args,))
self.thread.daemon = True
self.thread.start()
+ F.socketio.emit('notify', {'type':'success', 'msg':f"{self.description}
작업을 시작합니다." }, namespace='/framework', broadcast=True)
self.thread.join()
+ F.socketio.emit('notify', {'type':'success', 'msg':f"{self.description}
작업이 종료되었습니다." }, namespace='/framework', broadcast=True)
self.end_time = datetime.now(timezone('Asia/Seoul'))
self.running_timedelta = self.end_time - self.start_time
self.status = 'success'
diff --git a/lib/framework/static/js/ff_common1.js b/lib/framework/static/js/ff_common1.js
index e9a27bd..88c6ec3 100644
--- a/lib/framework/static/js/ff_common1.js
+++ b/lib/framework/static/js/ff_common1.js
@@ -116,10 +116,7 @@ function showModal(data='EMPTY', title='JSON', json=true) {
}
-///////////////////////////////////////
-// camel
-
-function get_formdata(form_id) {
+function getFormdata(form_id) {
// on, off 일수도 있으니 모두 True, False로 통일하고
// 밑에서는 False인 경우 값이 추가되지 않으니.. 수동으로 넣어줌
var checkboxs = $(form_id + ' input[type=checkbox]');
@@ -148,20 +145,23 @@ function get_formdata(form_id) {
return formData;
}
+///////////////////////////////////////
+// camel
+
function use_collapse(div, reverse=false) {
var ret = $('#' + div).prop('checked');
if (reverse) {
if (ret) {
- $('#' + div + '_div').collapse('hide')
+ $('#' + div + '_div').collapse('hide');
} else {
- $('#' + div + '_div').collapse('show')
+ $('#' + div + '_div').collapse('show');
}
} else {
if (ret) {
- $('#' + div + '_div').collapse('show')
+ $('#' + div + '_div').collapse('show');
} else {
- $('#' + div + '_div').collapse('hide')
+ $('#' + div + '_div').collapse('hide');
}
}
}
diff --git a/lib/framework/static/js/ff_global1.js b/lib/framework/static/js/ff_global1.js
index 9e8e471..d4e766c 100644
--- a/lib/framework/static/js/ff_global1.js
+++ b/lib/framework/static/js/ff_global1.js
@@ -78,7 +78,7 @@ $("body").on('click', '#globalSettingSaveBtn', function(e){
});
function globalSettingSave() {
- var formData = get_formdata('#setting');
+ var formData = getFormdata('#setting');
$.ajax({
url: '/' + PACKAGE_NAME + '/ajax/setting_save',
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() {
$("#confirm_title").html("종료 확인");
$("#confirm_body").html("종료 하시겠습니까?");
diff --git a/lib/framework/static/js/ff_ui1.js b/lib/framework/static/js/ff_ui1.js
index 32867af..ee43e42 100644
--- a/lib/framework/static/js/ff_ui1.js
+++ b/lib/framework/static/js/ff_ui1.js
@@ -1,3 +1,74 @@
+function m_button_group(h) {
+ var str = '
';
+ str += h
+ str += '
';
+ 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 = '';
+ return str;
+}
+
+function m_button_small(id, text, data={}, color='success', outline=true) {
+ return m_button(id, text, data, color, outline, true);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// javascript에서 화면 생성
function text_color(text, color='red') {
return '' + text + '';
@@ -89,40 +160,6 @@ function m_col_wide(w, h, align='left') {
}
-function m_button_group(h) {
- var str = '';
- str += h
- str += '
';
- return str;
-}
-
-function m_button(id, text, data) {
- var str = '';
- return str;
-}
-
-function m_button_small(id, text, data, color='danger') {
- var str = '';
- return str;
-}
-
-function m_button2(id, text, data, outline_color) {
- var str = '';
- return str;
-}
-
diff --git a/lib/framework/static/js/sjva_global1.js b/lib/framework/static/js/sjva_global1.js
index f576acd..3e042db 100644
--- a/lib/framework/static/js/sjva_global1.js
+++ b/lib/framework/static/js/sjva_global1.js
@@ -222,7 +222,7 @@ $('#global_scheduler_sub').change(function() {
function global_setting_save_function() {
- var formData = get_formdata('#setting');
+ var formData = getFormdata('#setting');
$.ajax({
url: '/'+package_name+'/ajax/setting_save',
type: "POST",
@@ -372,7 +372,7 @@ function global_db_delete_sub() {
}
function global_sub_request_search(page, move_top=true) {
- var formData = get_formdata('#form_search')
+ var formData = getFormdata('#form_search')
formData += '&page=' + page;
$.ajax({
url: '/' + package_name + '/ajax/' + sub + '/web_list',
diff --git a/lib/framework/static/js/sjva_ui14.js b/lib/framework/static/js/sjva_ui14.js
index fcd44f4..32d76a6 100644
--- a/lib/framework/static/js/sjva_ui14.js
+++ b/lib/framework/static/js/sjva_ui14.js
@@ -57,14 +57,7 @@ function m_button(id, text, data) {
return str;
}
-function m_button2(id, text, data, outline_color) {
- var str = '';
- return str;
-}
+
@@ -163,22 +156,7 @@ function make_page_html(data) {
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(){
diff --git a/lib/framework/templates/base.html b/lib/framework/templates/base.html
index b8f203f..b1de069 100644
--- a/lib/framework/templates/base.html
+++ b/lib/framework/templates/base.html
@@ -23,7 +23,6 @@
-
diff --git a/lib/framework/version.py b/lib/framework/version.py
index d562cf2..d2dd43d 100644
--- a/lib/framework/version.py
+++ b/lib/framework/version.py
@@ -1 +1 @@
-VERSION="4.0.7"
\ No newline at end of file
+VERSION="4.0.8"
\ No newline at end of file
diff --git a/lib/plugin/create_plugin.py b/lib/plugin/create_plugin.py
index a98b4e7..61bfe83 100644
--- a/lib/plugin/create_plugin.py
+++ b/lib/plugin/create_plugin.py
@@ -38,7 +38,7 @@ class PluginBase(object):
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.menu = setting['menu']
- self.setting_menu = setting['setting_menu']
+ self.setting_menu = setting.get('setting_menu', None)
self.ModelSetting = None
if setting.get('use_db', True):
diff --git a/lib/plugin/logic.py b/lib/plugin/logic.py
index c626dfb..ae3c114 100644
--- a/lib/plugin/logic.py
+++ b/lib/plugin/logic.py
@@ -17,10 +17,14 @@ class Logic(object):
def plugin_load(self):
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()
for module in self.P.module_list:
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:
module.plugin_load()
if module.page_list is not None:
@@ -154,7 +158,7 @@ class Logic(object):
except Exception as e:
self.P.logger.error(f'Exception:{str(e)}')
self.P.logger.error(traceback.format_exc())
- ret = {'ret' : 'danger', 'msg':str(exception)}
+ ret = {'ret' : 'danger', 'msg':str(e)}
return ret
def get_module(self, sub):
@@ -239,5 +243,5 @@ class Logic(object):
except Exception as e:
self.P.logger.error(f'Exception:{str(e)}')
self.P.logger.error(traceback.format_exc())
- ret = {'ret' : 'danger', 'msg':str(exception)}
+ ret = {'ret' : 'danger', 'msg':str(e)}
return ret
diff --git a/lib/plugin/logic_module_base.py b/lib/plugin/logic_module_base.py
index 2f8ea15..d83fe84 100644
--- a/lib/plugin/logic_module_base.py
+++ b/lib/plugin/logic_module_base.py
@@ -1,5 +1,8 @@
import traceback
+from flask import render_template
+
+
class PluginModuleBase(object):
db_default = None
@@ -33,8 +36,12 @@ class PluginModuleBase(object):
self.P.logger.error(traceback.format_exc())
- def process_menu(self, sub):
- pass
+ def process_menu(self, page, req):
+ 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):
pass
@@ -96,6 +103,26 @@ class PluginModuleBase(object):
def socketio_disconnect(self):
pass
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
class PluginPageBase(object):
db_default = None
@@ -107,19 +134,42 @@ class PluginPageBase(object):
self.scheduler_desc = scheduler_desc
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):
pass
+
+ def process_api(self, sub, req):
+ pass
+
+ def process_normal(self, sub, req):
+ pass
+
+ def process_command(self, command, arg1, arg2, arg3, req):
+ pass
+
+
+
+ # logic
+ def plugin_load(self):
+ pass
+
+ # logic
+ def plugin_unload(self):
+ pass
def scheduler_function(self):
pass
-
- def plugin_load(self):
- pass
-
- def plugin_unload(self):
- pass
-
def get_scheduler_desc(self):
return self.scheduler_desc
@@ -132,40 +182,16 @@ class PluginPageBase(object):
return f'{self.P.package_name}_{self.parent.name}_{self.name}'
-
-
-
-
-
-
-
-
-
- def process_api(self, sub, req):
- pass
-
- def process_normal(self, sub, req):
+ # logic
+ def migration(self):
pass
-
- def reset_db(self):
- pass
-
-
-
+ # route
def setting_save_after(self, change_list):
pass
def process_telegram_data(self, data, target=None):
pass
- def migration(self):
- pass
-
- #################################################################
-
-
- def process_menu(self, sub):
- pass
diff --git a/lib/plugin/route.py b/lib/plugin/route.py
index 97b5696..25f9857 100644
--- a/lib/plugin/route.py
+++ b/lib/plugin/route.py
@@ -158,6 +158,8 @@ def default_route(P):
elif command == 'immediately_execute':
ret = P.logic.immediately_execute_sub(module_name, page_name)
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:
return ins_page.process_ajax(command, request)
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)
if ret:
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)
elif sub == 'scheduler':
sub = request.form['sub']
@@ -384,32 +389,32 @@ def default_route_socketio_page(page):
if page.socketio_list is None:
page.socketio_list = []
- @socketio.on('connect', namespace=f'/{P.package_name}/{module.name}/{page.name}')
- def connect():
+ @F.socketio.on('connect', namespace=f'/{P.package_name}/{module.name}/{page.name}')
+ def page_socketio_connect():
try:
P.logger.debug(f'socket_connect : {P.package_name}/{module.name}/{page.name}')
page.socketio_list.append(request.sid)
- socketio_callback('start', '')
- except Exception as exception:
- P.logger.error(f'Exception:{str(exception)}', exception)
+ page_socketio_socketio_callback('start', '')
+ except Exception as e:
+ P.logger.error(f'Exception:{str(e)}')
P.logger.error(traceback.format_exc())
- @socketio.on('disconnect', namespace=f'/{P.package_name}/{module.name}/{page.name}')
- def disconnect():
+ @F.socketio.on('disconnect', namespace=f'/{P.package_name}/{module.name}/{page.name}')
+ def page_socketio_disconnect():
try:
P.logger.debug(f'socket_disconnect : {P.package_name}/{module.name}/{page.name}')
page.socketio_list.remove(request.sid)
- except Exception as exception:
- P.logger.error(f'Exception:{str(exception)}', exception)
+ except Exception as e:
+ P.logger.error(f'Exception:{str(e)}')
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 encoding:
data = json.dumps(data, cls=AlchemyEncoder)
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
diff --git a/lib/support/logger.py b/lib/support/logger.py
index 4dd8708..1ca9744 100644
--- a/lib/support/logger.py
+++ b/lib/support/logger.py
@@ -35,17 +35,17 @@ class CustomFormatter(logging.Formatter):
green = "\x1B[32m"
# pathname filename
#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 = {
- 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.WARNING: format.format(color=yellow, 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.DEBUG: __format.format(color=grey, 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.ERROR: __format.format(color=red, reset=reset, yellow=yellow, green=green),
+ logging.CRITICAL: __format.format(color=bold_red, reset=reset, yellow=yellow, green=green)
}
-
def format(self, record):
log_fmt = self.FORMATS.get(record.levelno)
formatter = logging.Formatter(log_fmt)
diff --git a/lib/system/mod_home.py b/lib/system/mod_home.py
index 496eead..6eeca98 100644
--- a/lib/system/mod_home.py
+++ b/lib/system/mod_home.py
@@ -14,7 +14,8 @@ class ModuleHome(PluginModuleBase):
default_route_socketio_module(self)
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):
if command == 'recent_version':
diff --git a/lib/system/mod_setting.py b/lib/system/mod_setting.py
index 3a26dc4..6fcd8a3 100644
--- a/lib/system/mod_setting.py
+++ b/lib/system/mod_setting.py
@@ -17,7 +17,7 @@ class ModuleSetting(PluginModuleBase):
'ddns' : 'http://localhost:9999',
'use_login' : 'False',
'web_id': 'admin',
- 'web_pw': 'Vm51JgZqhpwXc/UPc9CAN1lhj4s65+4ikv7GzNmvN6c=',
+ 'web_pw': '21232f297a57a5a743894a0e4a801fc3',
'web_title': 'Home',
'use_apikey': 'False',
'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)
elif 'notify.yaml' in change_list:
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):
diff --git a/lib/system/mod_tool.py b/lib/system/mod_tool.py
index 2eab1b3..ec90b96 100644
--- a/lib/system/mod_tool.py
+++ b/lib/system/mod_tool.py
@@ -5,39 +5,21 @@ from .setup import *
name = 'tool'
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 = {
'path_upload': os.path.join(F.config['path_data'], 'upload'),
}
-
- def __init__(self, P):
- 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 __init__(self, P, parent):
+ super(PageUpload, self).__init__(P, parent, name='upload')
- 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())
-
-
-
\ No newline at end of file
+class PageCrypt(PluginPageBase):
+ def __init__(self, P, parent):
+ super(PageCrypt, self).__init__(P, parent, name='crypt')
diff --git a/lib/system/templates/system_home.html b/lib/system/templates/system_home.html
index de0a9d1..355961b 100644
--- a/lib/system/templates/system_home.html
+++ b/lib/system/templates/system_home.html
@@ -14,7 +14,7 @@
{{ 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('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']) }}
diff --git a/lib/system/templates/system_plugin_list.html b/lib/system/templates/system_plugin_list.html
index 8cf510f..2ea1473 100644
--- a/lib/system/templates/system_plugin_list.html
+++ b/lib/system/templates/system_plugin_list.html
@@ -42,7 +42,7 @@ function make_plugin_list(data) {
str += m_col_wide(2, '');
str += m_col_wide(2, data[i].package_name);
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 {
str += m_col_wide(2, data[i].title);
@@ -59,9 +59,9 @@ function make_plugin_list(data) {
tmp = ''
- tmp += m_button_small('globalOpenBtn', '홈페이지', [{'key':'url', 'value':data[i].home}], 'primary');
- tmp += m_button_small('uninstall_btn', '삭제', [{'key':'package_name', 'value':data[i].package_name}, {'key':'title', 'value':data[i].title}]);
- tmp += m_button_small('json_btn', 'JSON', [{'key':'idx', 'value':i}], 'info');
+ tmp += m_button_small('globalOpenBtn', '홈페이지', {'url':data[i].home}, 'primary', false, true);
+ 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', {'idx':i}, 'info', false, true);
}
tmp = m_button_group(tmp)
str += m_col_wide(2, tmp, 'right')
diff --git a/lib/system/templates/system_setting_celery.html b/lib/system/templates/system_setting_celery.html
index 21faae6..9841022 100644
--- a/lib/system/templates/system_setting_celery.html
+++ b/lib/system/templates/system_setting_celery.html
@@ -34,10 +34,12 @@ var running_type = "{{arg['running_type']}}";
$(document).ready(function(){
console.log(running_type);
+ /*
if (running_type.startsWith('docker')) {
$('#celery_start_by_web').bootstrapToggle('off');
$('#celery_start_by_web').prop('disabled', true);
}
+ */
});
$("body").on('click', '#celery_excute_btn', function(e){
diff --git a/lib/tool/__init__.py b/lib/tool/__init__.py
index 7594cbd..5fa8b9c 100644
--- a/lib/tool/__init__.py
+++ b/lib/tool/__init__.py
@@ -2,3 +2,4 @@ from framework import logger
from .modal_command import ToolModalCommand
from .notify import ToolNotify
+from .util import ToolUtil
diff --git a/lib/tool/util.py b/lib/tool/util.py
new file mode 100644
index 0000000..5ce9008
--- /dev/null
+++ b/lib/tool/util.py
@@ -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
+
\ No newline at end of file
diff --git a/lib/tool_base/util.py b/lib/tool_base/util.py
index 221a509..0f1575e 100644
--- a/lib/tool_base/util.py
+++ b/lib/tool_base/util.py
@@ -1,26 +1,20 @@
-import os, sys, traceback, json
+import json
+import os
+import sys
+import traceback
from . import logger
+
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
def save_dict(cls, data, filepath):
try:
- import json, codecs
+ import codecs
+ import json
data = json.dumps(data, indent=4, ensure_ascii=False)
ofp = codecs.open(filepath, 'w', encoding='utf8')
ofp.write(data)