Optimize error output & adjust code sequence
This commit is contained in:
@@ -4,6 +4,7 @@ import requests
|
||||
from pathlib import Path
|
||||
import secrets
|
||||
import os.path
|
||||
import os
|
||||
import uuid
|
||||
import json
|
||||
import time
|
||||
@@ -50,14 +51,20 @@ def get_html(url, cookies: dict = None, ua: str = None, return_type: str = None,
|
||||
else:
|
||||
result.encoding = encoding or result.apparent_encoding
|
||||
return result.text
|
||||
except requests.exceptions.ProxyError:
|
||||
print("[-]Proxy error! Please check your Proxy")
|
||||
raise requests.exceptions.ProxyError
|
||||
except Exception as e:
|
||||
print("[-]Connect retry {}/{}".format(i + 1, configProxy.retry))
|
||||
errors = str(e)
|
||||
print('[-]Connect Failed! Please check your Proxy or Network!')
|
||||
print("[-]" + errors)
|
||||
if "getaddrinfo failed" in errors:
|
||||
print("[-]Connect Failed! Please Check your proxy config")
|
||||
debug = config.getInstance().debug()
|
||||
if debug:
|
||||
print("[-]" + errors)
|
||||
else:
|
||||
print("[-]" + errors)
|
||||
print('[-]Connect Failed! Please check your Proxy or Network!')
|
||||
print("[-] --- AUTO EXIT AFTER 30s !!! --- ")
|
||||
time.sleep(30)
|
||||
os._exit(-1)
|
||||
raise Exception('Connect Failed')
|
||||
|
||||
|
||||
|
||||
@@ -469,26 +469,13 @@ def main():
|
||||
print('[*]' + version.center(54))
|
||||
print('[*]======================================================')
|
||||
print('[*]' + platform_total)
|
||||
print('[*]================= 严禁在墙内宣传本项目 ===================')
|
||||
print('[*]======================================================')
|
||||
print('[*] - 严禁在墙内宣传本项目 - ')
|
||||
print('[*]======================================================')
|
||||
|
||||
start_time = time.time()
|
||||
print('[+]Start at', time.strftime("%Y-%m-%d %H:%M:%S"))
|
||||
|
||||
if conf.update_check():
|
||||
check_update(version)
|
||||
|
||||
# Download Mapping Table, parallel version
|
||||
def fmd(f):
|
||||
return ('https://raw.githubusercontent.com/yoshiko2/AV_Data_Capture/master/MappingTable/' + f,
|
||||
Path.home() / '.local' / 'share' / 'avdc' / f)
|
||||
map_tab = (fmd('mapping_actor.xml'), fmd('mapping_info.xml'), fmd('c_number.json'))
|
||||
res = parallel_download_files(((k, v) for k, v in map_tab if not v.exists()))
|
||||
for i, fp in enumerate(res, start=1):
|
||||
if fp and len(fp):
|
||||
print(f"[+] [{i}/{len(res)}] Mapping Table Downloaded to {fp}")
|
||||
else:
|
||||
print(f"[-] [{i}/{len(res)}] Mapping Table Download failed")
|
||||
|
||||
print(f"[+]Load Config file '{conf.ini_path}'.")
|
||||
if conf.debug():
|
||||
print('[+]Enable debug')
|
||||
@@ -504,8 +491,24 @@ def main():
|
||||
) if not single_file_path else ('-','Single File', '','',''))
|
||||
)
|
||||
|
||||
if conf.update_check():
|
||||
check_update(version)
|
||||
|
||||
create_failed_folder(conf.failed_folder())
|
||||
|
||||
# Download Mapping Table, parallel version
|
||||
def fmd(f):
|
||||
return ('https://raw.githubusercontent.com/yoshiko2/AV_Data_Capture/master/MappingTable/' + f,
|
||||
Path.home() / '.local' / 'share' / 'avdc' / f)
|
||||
|
||||
map_tab = (fmd('mapping_actor.xml'), fmd('mapping_info.xml'), fmd('c_number.json'))
|
||||
res = parallel_download_files(((k, v) for k, v in map_tab if not v.exists()))
|
||||
for i, fp in enumerate(res, start=1):
|
||||
if fp and len(fp):
|
||||
print(f"[+] [{i}/{len(res)}] Mapping Table Downloaded to {fp}")
|
||||
else:
|
||||
print(f"[-] [{i}/{len(res)}] Mapping Table Download failed")
|
||||
|
||||
# create OpenCC converter
|
||||
ccm = conf.cc_convert_mode()
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user