Skip to content

Commit

Permalink
异常日志增加详细文件行号输出
Browse files Browse the repository at this point in the history
  • Loading branch information
sleikang committed Feb 3, 2023
1 parent 52fcb64 commit 7f98e71
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 96 deletions.
25 changes: 14 additions & 11 deletions api/douban.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from api.network import network
import json
import html2text
import re

import html2text

from api.network import network


class douban:
host = None
key = None
Expand Down Expand Up @@ -52,7 +55,7 @@ def get_movie_info(self, movieid : str):
iteminfo['info'][info[0]] = re.sub(pattern='\s+', repl='', string=info[1])
return True, iteminfo
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def get_movie_celebrities_info(self, movieid : str):
Expand All @@ -69,7 +72,7 @@ def get_movie_celebrities_info(self, movieid : str):
iteminfo = json.loads(p.text)
return True, iteminfo
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def get_tv_info(self, tvid : str):
Expand Down Expand Up @@ -104,7 +107,7 @@ def get_tv_info(self, tvid : str):
iteminfo['info'][info[0]] = re.sub(pattern='\s+', repl='', string=info[1])
return True, iteminfo
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def get_tv_celebrities_info(self, tvid : str):
Expand All @@ -121,7 +124,7 @@ def get_tv_celebrities_info(self, tvid : str):
iteminfo = json.loads(p.text)
return True, iteminfo
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def get_celebrity_info(self, celebrityid : str):
Expand All @@ -139,7 +142,7 @@ def get_celebrity_info(self, celebrityid : str):
iteminfo = json.loads(p.text)
return True, iteminfo
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def search_media_pc(self, title : str):
Expand All @@ -162,7 +165,7 @@ def search_media_pc(self, title : str):
iteminfo['items'] = medialist
return True, iteminfo
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def search_media(self, title : str):
Expand All @@ -180,7 +183,7 @@ def search_media(self, title : str):
iteminfo = json.loads(p.text)
return True, iteminfo
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def search_media_weixin(self, title : str):
Expand All @@ -198,7 +201,7 @@ def search_media_weixin(self, title : str):
iteminfo = json.loads(p.text)
return True, iteminfo
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def __get_status__(self, p, err):
Expand All @@ -215,7 +218,7 @@ def __get_status__(self, p, err):
return False
return True
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)

return False

28 changes: 14 additions & 14 deletions api/mediasql.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def search_douban_media(self, mediatype : int, title : str):
return True, iteminfo
return False, None
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def write_douban_media(self, mediatype : int, id : str, iteminfo):
Expand Down Expand Up @@ -74,7 +74,7 @@ def write_douban_media(self, mediatype : int, id : str, iteminfo):
ret = self.execution(sql="insert into douban_movie(id, media_id, media_name, media_brief, media_data, media_celebrities, update_time) values(null, ?, ?, ?, '', '', ?);", data=(id, iteminfo['title'], json.dumps(iteminfo), datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
return ret
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False

def get_douban_media_info(self, mediatype : int, id : str):
Expand Down Expand Up @@ -102,7 +102,7 @@ def get_douban_media_info(self, mediatype : int, id : str):
return True, iteminfo
return False, None
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def write_douban_media_info(self, mediatype : int, id : str, iteminfo):
Expand Down Expand Up @@ -133,7 +133,7 @@ def write_douban_media_info(self, mediatype : int, id : str, iteminfo):
ret = self.execution(sql="insert into douban_movie(id, media_id, media_name, media_brief, media_data, media_celebrities, update_time) values(null, ?, ?, '', ?, '', ?);", data=(id, iteminfo['title'], json.dumps(iteminfo), datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
return ret
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False

def get_douban_celebrities_info(self, mediatype : int, id : str):
Expand Down Expand Up @@ -161,7 +161,7 @@ def get_douban_celebrities_info(self, mediatype : int, id : str):
return True, iteminfo
return False, None
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def write_douban_celebrities_info(self, mediatype : int, id : str, iteminfo):
Expand Down Expand Up @@ -192,7 +192,7 @@ def write_douban_celebrities_info(self, mediatype : int, id : str, iteminfo):
ret = self.execution(sql="insert into douban_movie(id, media_id, media_name, media_brief, media_data, media_celebrities, update_time) values(null, ?, '', '', '', ?, ?);", data=(id, json.dumps(iteminfo), datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
return ret
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False

def get_douban_people_info(self, id : str):
Expand All @@ -217,7 +217,7 @@ def get_douban_people_info(self, id : str):
return True, iteminfo
return False, None
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def write_douban_people_info(self, id : str, iteminfo):
Expand All @@ -238,7 +238,7 @@ def write_douban_people_info(self, id : str, iteminfo):
ret = self.execution(sql="insert into douban_people(id, people_id, people_name, people_data, update_time) values(null, ?, ?, ?, ?)", data=(id, iteminfo['title'], json.dumps(iteminfo), datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
return ret
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False


Expand Down Expand Up @@ -277,7 +277,7 @@ def get_tmdb_media_info(self, mediatype : int, id : str, language):
return True, json.loads(item)
return False, None
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, None

def write_tmdb_media_info(self, mediatype : int, id : str, language, iteminfo):
Expand Down Expand Up @@ -320,7 +320,7 @@ def write_tmdb_media_info(self, mediatype : int, id : str, language, iteminfo):
ret = self.execution(sql="insert into tmdb_movie(id, media_id, media_name, {}, update_time) values(null, ?, ?, ?, ?);".format(key), data=(id, iteminfo['title'], json.dumps(iteminfo), datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
return ret
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False

def get_tmdb_season_info(self, id : str, seasonid, language):
Expand Down Expand Up @@ -362,7 +362,7 @@ def get_tmdb_season_info(self, id : str, seasonid, language):

return False, None
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}][{}]异常错误:".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, None

def write_tmdb_season_info(self, id : str, seasonid, language, iteminfo):
Expand Down Expand Up @@ -419,7 +419,7 @@ def write_tmdb_season_info(self, id : str, seasonid, language, iteminfo):
ret = self.execution(sql="insert into tmdb_tv(id, media_id, {}, update_time) values(null, ?, ?, ?);".format(key), data=(id, json.dumps(data_array), datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
return ret
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False

def get_tmdb_people_info(self, id : str, language):
Expand Down Expand Up @@ -453,7 +453,7 @@ def get_tmdb_people_info(self, id : str, language):
return True, json.loads(item)
return False, None
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, None

def write_tmdb_people_info(self, id : str, language, iteminfo):
Expand Down Expand Up @@ -486,5 +486,5 @@ def write_tmdb_people_info(self, id : str, language, iteminfo):
ret = self.execution(sql="insert into tmdb_people(id, people_id, people_name, {}, update_time) values(null, ?, ?, ?, ?);".format(key), data=(id, iteminfo['name'], json.dumps(iteminfo), datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
return ret
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False
12 changes: 7 additions & 5 deletions api/nastools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from api.network import network
import json
from urllib import parse

from api.network import network


class nastools:
client = None
host = None
Expand Down Expand Up @@ -36,7 +38,7 @@ def name_test(self, name):
iteminfo = json.loads(p.text)['data']['data']
return True, iteminfo
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def media_info(self, name, year = None, type = 'MOV'):
Expand All @@ -62,7 +64,7 @@ def media_info(self, name, year = None, type = 'MOV'):
iteminfo = json.loads(p.text)['data']
return True, iteminfo
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def __login__(self):
Expand All @@ -83,7 +85,7 @@ def __login__(self):
self.headers['Authorization'] = self.token
return True
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False

def __get_status__(self, p, err):
Expand All @@ -100,7 +102,7 @@ def __get_status__(self, p, err):
return False
return True
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)

return False

Expand Down
20 changes: 11 additions & 9 deletions api/server/emby.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import json

from api.server.serverbase import serverbase


class emby(serverbase):

def get_items(self, parentid : str = '', type = None):
Expand All @@ -22,7 +24,7 @@ def get_items(self, parentid : str = '', type = None):
items = json.loads(p.text)
return True, items
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, items

def get_items_count(self):
Expand All @@ -39,7 +41,7 @@ def get_items_count(self):
iteminfo = json.loads(p.text)
return True, iteminfo
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def get_item_info(self, itemid : str):
Expand All @@ -57,7 +59,7 @@ def get_item_info(self, itemid : str):
iteminfo = json.loads(p.text)
return True, iteminfo
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def set_item_info(self, itemid : str, iteminfo):
Expand All @@ -74,7 +76,7 @@ def set_item_info(self, itemid : str, iteminfo):
return False
return True
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False

def set_item_image(self, itemid : str, imageurl : str):
Expand All @@ -91,7 +93,7 @@ def set_item_image(self, itemid : str, imageurl : str):
return False
return True
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False

def search_movie(self, itemid, tmdbid, name = None, year = None):
Expand All @@ -113,7 +115,7 @@ def search_movie(self, itemid, tmdbid, name = None, year = None):
iteminfo = json.loads(p.text)
return True, iteminfo
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False, iteminfo

def apply_search(self, itemid, iteminfo):
Expand All @@ -131,7 +133,7 @@ def apply_search(self, itemid, iteminfo):
return False
return True
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False

def refresh(self, itemid):
Expand All @@ -147,7 +149,7 @@ def refresh(self, itemid):
return False
return True
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)
return False

def __get_status__(self, p, err):
Expand All @@ -160,6 +162,6 @@ def __get_status__(self, p, err):
return False
return True
except Exception as result:
self.err = "异常错误:{}".format(result)
self.err = "文件[{}]行[{}]异常错误:{}".format(result.__traceback__.tb_frame.f_globals["__file__"], result.__traceback__.tb_lineno, result)

return False
Loading

0 comments on commit 7f98e71

Please sign in to comment.