linkkf 로직수정중
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import base64
|
||||
from Crypto.Cipher import AES
|
||||
|
||||
from Crypto import Random
|
||||
from Crypto.Cipher import AES
|
||||
from framework import app, logger
|
||||
|
||||
BS = 16
|
||||
@@ -13,8 +14,8 @@ class ToolAESCipher(object):
|
||||
def encrypt(raw, mykey=None):
|
||||
try:
|
||||
Random.atfork()
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
raw = pad(raw)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import traceback
|
||||
import shutil
|
||||
import traceback
|
||||
|
||||
from framework import app, celery, logger
|
||||
|
||||
|
||||
class ToolShutil(object):
|
||||
# run_in_celery=True 이미 celery안에서 실행된다. 바로 콜한다.
|
||||
@staticmethod
|
||||
@@ -15,8 +16,8 @@ class ToolShutil(object):
|
||||
return result.get()
|
||||
else:
|
||||
return ToolShutil._move_task(source_path, target_path)
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return ToolShutil._move_task(source_path, target_path)
|
||||
|
||||
@@ -28,8 +29,8 @@ class ToolShutil(object):
|
||||
shutil.move(source_path, target_path)
|
||||
logger.debug('_move_task end')
|
||||
return True
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return False
|
||||
|
||||
@@ -41,8 +42,8 @@ class ToolShutil(object):
|
||||
return result.get()
|
||||
else:
|
||||
return ToolShutil._move_exist_remove_task(source_path, target_path)
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return ToolShutil._move_exist_remove_task(source_path, target_path)
|
||||
|
||||
@@ -58,8 +59,8 @@ class ToolShutil(object):
|
||||
shutil.move(source_path, target_path)
|
||||
logger.debug('_move_exist_remove end')
|
||||
return True
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return False
|
||||
|
||||
@@ -71,8 +72,8 @@ class ToolShutil(object):
|
||||
return result.get()
|
||||
else:
|
||||
return ToolShutil._copytree_task(source_path, target_path)
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return ToolShutil._copytree_task(source_path, target_path)
|
||||
|
||||
@@ -82,8 +83,8 @@ class ToolShutil(object):
|
||||
try:
|
||||
shutil.copytree(source_path, target_path)
|
||||
return True
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return False
|
||||
|
||||
@@ -96,8 +97,8 @@ class ToolShutil(object):
|
||||
return result.get()
|
||||
else:
|
||||
return ToolShutil._copy_task(source_path, target_path)
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return ToolShutil._copy_task(source_path, target_path)
|
||||
|
||||
@@ -107,8 +108,8 @@ class ToolShutil(object):
|
||||
try:
|
||||
shutil.copy(source_path, target_path)
|
||||
return True
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return False
|
||||
|
||||
@@ -121,8 +122,8 @@ class ToolShutil(object):
|
||||
return result.get()
|
||||
else:
|
||||
return ToolShutil._rmtree_task(source_path)
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return ToolShutil._rmtree_task(source_path)
|
||||
|
||||
@@ -132,8 +133,8 @@ class ToolShutil(object):
|
||||
try:
|
||||
shutil.rmtree(source_path)
|
||||
return True
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return False
|
||||
|
||||
@@ -146,8 +147,8 @@ class ToolShutil(object):
|
||||
return result.get()
|
||||
else:
|
||||
return ToolShutil._remove_task(remove_path)
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return ToolShutil._remove_task(remove_path)
|
||||
finally:
|
||||
@@ -159,7 +160,7 @@ class ToolShutil(object):
|
||||
try:
|
||||
os.remove(remove_path)
|
||||
return True
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return False
|
||||
@@ -1,9 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#########################################################
|
||||
import os, sys, traceback, subprocess, json, platform
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from framework import app, logger, path_data
|
||||
|
||||
from ..support.base.subprocess import ToolSubprocess
|
||||
|
||||
|
||||
class ToolFfmpeg(object):
|
||||
|
||||
@classmethod
|
||||
@@ -15,7 +23,7 @@ class ToolFfmpeg(object):
|
||||
logger.warning(' '.join(command))
|
||||
ret = ToolSubprocess.execute_command_return(command, format='json')
|
||||
return ret
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ class ToolBaseFile(object):
|
||||
ofp.write(data)
|
||||
ofp.close()
|
||||
return True
|
||||
except Exception as exception:
|
||||
logger.debug('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.debug(f"Exception:{str(e)}")
|
||||
logger.debug(traceback.format_exc())
|
||||
return False
|
||||
|
||||
@@ -41,23 +41,7 @@ class ToolBaseFile(object):
|
||||
total_size += os.path.getsize(fp)
|
||||
return total_size
|
||||
|
||||
@classmethod
|
||||
def file_move(cls, source_path, target_dir, target_filename):
|
||||
try:
|
||||
import shutil
|
||||
import time
|
||||
if os.path.exists(target_dir) == False:
|
||||
os.makedirs(target_dir)
|
||||
target_path = os.path.join(target_dir, target_filename)
|
||||
if source_path != target_path:
|
||||
if os.path.exists(target_path):
|
||||
tmp = os.path.splitext(target_filename)
|
||||
new_target_filename = f"{tmp[0]} {str(time.time()).split('.')[0]}{tmp[1]}"
|
||||
target_path = os.path.join(target_dir, new_target_filename)
|
||||
shutil.move(source_path, target_path)
|
||||
except Exception as exception:
|
||||
logger.debug('Exception:%s', exception)
|
||||
logger.debug(traceback.format_exc())
|
||||
|
||||
|
||||
|
||||
@classmethod
|
||||
@@ -81,8 +65,8 @@ class ToolBaseFile(object):
|
||||
import shutil
|
||||
shutil.rmtree(zip_path)
|
||||
return zipfilepath
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return
|
||||
|
||||
@@ -120,8 +104,8 @@ class ToolBaseFile(object):
|
||||
os.makedirs(os.path.dirname(filepath))
|
||||
with open(filepath, "w", encoding='utf8') as json_file:
|
||||
json.dump(data, json_file, indent=4, ensure_ascii=False)
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
@classmethod
|
||||
@@ -130,8 +114,8 @@ class ToolBaseFile(object):
|
||||
with open(filepath, "r", encoding='utf8') as json_file:
|
||||
data = json.load(json_file)
|
||||
return data
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
@@ -142,8 +126,8 @@ class ToolBaseFile(object):
|
||||
ofp = codecs.open(filename, 'w', encoding='utf8')
|
||||
ofp.write(data)
|
||||
ofp.close()
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
@classmethod
|
||||
@@ -153,8 +137,8 @@ class ToolBaseFile(object):
|
||||
data = ifp.read()
|
||||
ifp.close()
|
||||
return data
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
import os
|
||||
import traceback
|
||||
|
||||
from discord_webhook import DiscordWebhook, DiscordEmbed
|
||||
from discord_webhook import DiscordEmbed, DiscordWebhook
|
||||
from telepot2 import Bot, glance
|
||||
from telepot2.loop import MessageLoop
|
||||
|
||||
from . import logger
|
||||
|
||||
|
||||
class ToolBaseNotify(object):
|
||||
|
||||
@classmethod
|
||||
@@ -46,8 +47,8 @@ class ToolBaseNotify(object):
|
||||
tmp2 = tmp.split(',')
|
||||
cls.send_telegram_message(text, image_url=image_url, bot_token=tmp2[0], chat_id=tmp2[1])
|
||||
return True
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
#logger.debug('Chatid:%s', chat_id)
|
||||
return False
|
||||
@@ -66,8 +67,8 @@ class ToolBaseNotify(object):
|
||||
continue
|
||||
ret[tmp2[0].strip()] = [x.strip() for x in tmp2[1].split('|')]
|
||||
return ret
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return False
|
||||
|
||||
@@ -88,8 +89,8 @@ class ToolBaseNotify(object):
|
||||
#discord = response.json()
|
||||
#logger.debug(discord)
|
||||
return True
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
return False
|
||||
|
||||
@@ -114,8 +115,8 @@ class ToolBaseNotify(object):
|
||||
#elif mime == 'video':
|
||||
# bot.sendVideo(chat_id, text, disable_notification=disable_notification)
|
||||
return True
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
logger.debug('Chatid:%s', chat_id)
|
||||
return False
|
||||
|
||||
@@ -25,8 +25,8 @@ class ToolRclone(object):
|
||||
if ret is not None:
|
||||
ret = list(sorted(ret, key=lambda k:k['Path']))
|
||||
return ret
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ class ToolRclone(object):
|
||||
command += option
|
||||
ret = ToolSubprocess.execute_command_return(command, format='json')
|
||||
return ret
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ class ToolRclone(object):
|
||||
if ret is not None and (len(ret.split(' ')) > 1 or ret == ''):
|
||||
ret = None
|
||||
return ret
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ class ToolRclone(object):
|
||||
command += option
|
||||
ret = ToolSubprocess.execute_command_return(command)
|
||||
return ret
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
@classmethod
|
||||
@@ -78,8 +78,8 @@ class ToolRclone(object):
|
||||
command += option
|
||||
ret = ToolSubprocess.execute_command_return(command)
|
||||
return ret
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
@@ -94,8 +94,8 @@ class ToolRclone(object):
|
||||
if 'token' in value and value['token'].startswith('{'):
|
||||
value['token'] = json.loads(value['token'])
|
||||
return ret
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
@@ -112,8 +112,8 @@ class ToolRclone(object):
|
||||
logger.debug(' '.join(command))
|
||||
ret = ToolSubprocess.execute_command_return(command)
|
||||
return ret
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
@@ -124,8 +124,8 @@ class ToolRclone(object):
|
||||
data = cls.config_list(rclone_path=rclone_path, config_path=config_path, option=option)
|
||||
return data.get(remote_name, None)
|
||||
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
@@ -138,6 +138,6 @@ class ToolRclone(object):
|
||||
logger.debug(' '.join(command))
|
||||
ret = ToolSubprocess.execute_command_return(command)
|
||||
return ret
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
@@ -19,8 +19,8 @@ class ToolUtil(object):
|
||||
ofp = codecs.open(filepath, 'w', encoding='utf8')
|
||||
ofp.write(data)
|
||||
ofp.close()
|
||||
except Exception as exception:
|
||||
logger.debug('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.debug(f"Exception:{str(e)}")
|
||||
logger.debug(traceback.format_exc())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user