reformatting
This commit is contained in:
104
logic.py
104
logic.py
@@ -18,61 +18,61 @@ from .model import ModelSetting
|
||||
#########################################################
|
||||
|
||||
class Logic(object):
|
||||
db_default = {
|
||||
'db_version': '1',
|
||||
'temp_path': os.path.join(path_data, 'download_tmp'),
|
||||
'save_path': os.path.join(path_data, 'download'),
|
||||
'default_filename': '%(title)s-%(id)s.%(ext)s',
|
||||
'proxy': '',
|
||||
'activate_cors': False
|
||||
}
|
||||
db_default = {
|
||||
'db_version': '1',
|
||||
'temp_path': os.path.join(path_data, 'download_tmp'),
|
||||
'save_path': os.path.join(path_data, 'download'),
|
||||
'default_filename': '%(title)s-%(id)s.%(ext)s',
|
||||
'proxy': '',
|
||||
'activate_cors': False
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def db_init():
|
||||
try:
|
||||
for key, value in Logic.db_default.items():
|
||||
if db.session.query(ModelSetting).filter_by(key=key).count() == 0:
|
||||
db.session.add(ModelSetting(key, value))
|
||||
db.session.commit()
|
||||
# Logic.migration()
|
||||
except Exception as e:
|
||||
logger.error('Exception:%s', e)
|
||||
logger.error(traceback.format_exc())
|
||||
@staticmethod
|
||||
def db_init():
|
||||
try:
|
||||
for key, value in Logic.db_default.items():
|
||||
if db.session.query(ModelSetting).filter_by(key=key).count() == 0:
|
||||
db.session.add(ModelSetting(key, value))
|
||||
db.session.commit()
|
||||
# Logic.migration()
|
||||
except Exception as e:
|
||||
logger.error('Exception:%s', e)
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
@staticmethod
|
||||
def plugin_load():
|
||||
try:
|
||||
logger.debug('%s plugin_load', package_name)
|
||||
Logic.db_init() # DB 초기화
|
||||
@staticmethod
|
||||
def plugin_load():
|
||||
try:
|
||||
logger.debug('%s plugin_load', package_name)
|
||||
Logic.db_init()
|
||||
|
||||
try:
|
||||
import glob2
|
||||
except ImportError:
|
||||
# glob2 설치
|
||||
logger.debug('glob2 install')
|
||||
logger.debug(subprocess.check_output([sys.executable, '-m', 'pip', 'install', 'glob2'], universal_newlines=True))
|
||||
try:
|
||||
import flask_cors
|
||||
except ImportError:
|
||||
# flask-cors 설치
|
||||
logger.debug('flask-cors install')
|
||||
logger.debug(subprocess.check_output([sys.executable, '-m', 'pip', 'install', 'flask-cors'], universal_newlines=True))
|
||||
try:
|
||||
import glob2
|
||||
except ImportError:
|
||||
# glob2 설치
|
||||
logger.debug('glob2 install')
|
||||
logger.debug(subprocess.check_output([sys.executable, '-m', 'pip', 'install', 'glob2'], universal_newlines=True))
|
||||
try:
|
||||
import flask_cors
|
||||
except ImportError:
|
||||
# flask-cors 설치
|
||||
logger.debug('flask-cors install')
|
||||
logger.debug(subprocess.check_output([sys.executable, '-m', 'pip', 'install', 'flask-cors'], universal_newlines=True))
|
||||
|
||||
# youtube-dl 업데이트
|
||||
logger.debug('youtube-dl upgrade')
|
||||
logger.debug(subprocess.check_output([sys.executable, '-m', 'pip', 'install', '--upgrade', 'youtube-dl'], universal_newlines=True))
|
||||
# youtube-dl 업데이트
|
||||
logger.debug('youtube-dl upgrade')
|
||||
logger.debug(subprocess.check_output([sys.executable, '-m', 'pip', 'install', '--upgrade', 'youtube-dl'], universal_newlines=True))
|
||||
|
||||
# 편의를 위해 json 파일 생성
|
||||
from plugin import plugin_info
|
||||
Util.save_from_dict_to_json(plugin_info, os.path.join(os.path.dirname(__file__), 'info.json'))
|
||||
except Exception as e:
|
||||
logger.error('Exception:%s', e)
|
||||
logger.error(traceback.format_exc())
|
||||
# 편의를 위해 json 파일 생성
|
||||
from plugin import plugin_info
|
||||
Util.save_from_dict_to_json(plugin_info, os.path.join(os.path.dirname(__file__), 'info.json'))
|
||||
except Exception as e:
|
||||
logger.error('Exception:%s', e)
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
@staticmethod
|
||||
def plugin_unload():
|
||||
try:
|
||||
logger.debug('%s plugin_unload', package_name)
|
||||
except Exception as e:
|
||||
logger.error('Exception:%s', e)
|
||||
logger.error(traceback.format_exc())
|
||||
@staticmethod
|
||||
def plugin_unload():
|
||||
try:
|
||||
logger.debug('%s plugin_unload', package_name)
|
||||
except Exception as e:
|
||||
logger.error('Exception:%s', e)
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
Reference in New Issue
Block a user