update
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)}')
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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}<br>작업을 시작합니다." }, namespace='/framework', broadcast=True)
|
||||
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.running_timedelta = self.end_time - self.start_time
|
||||
self.status = 'success'
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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("종료 하시겠습니까?");
|
||||
|
||||
@@ -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에서 화면 생성
|
||||
function text_color(text, color='red') {
|
||||
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() {
|
||||
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',
|
||||
|
||||
@@ -57,14 +57,7 @@ function m_button(id, text, data) {
|
||||
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;
|
||||
}
|
||||
|
||||
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(){
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
<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/sjva_ui14.js') }}"></script>
|
||||
|
||||
<script src="{{ url_for('static', filename='js/ff_common1.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/ff_ui1.js') }}"></script>
|
||||
|
||||
@@ -1 +1 @@
|
||||
VERSION="4.0.7"
|
||||
VERSION="4.0.8"
|
||||
Reference in New Issue
Block a user