def run_func(F, func, pwd=None): if 'pwd' in func[1]: if pwd == None: pwd = withexit_input('输入链接密码:') return F.run(func[0], pwd=pwd) else: return F.run(func[0])
def download(): url = withexit_input('url:') while 1: path = withexit_input('path(默认为output):') if path == '': path = 'output' if os.path.exists(path): if os.path.isdir(path): break else: print('[!]路径必须是文件夹') else: print('[!]路径不存在') file_name = withexit_input('filename:') t_num = withexit_input('thread num(默认6):') if t_num == '': Dld = Aria2_Downloader(path) elif t_num.isdigit(): Dld = Aria2_Downloader(path, int(t_num)) else: print('[!]需要输入数字') Dld.download(url, file_name)
def select_mode(): for i, mode in enumerate(allow_mode): print(i + 1, ':', mode) mode = withexit_input('选择语言模式:') if not mode.isdigit(): print('[!]请输入数字') return False mode = int(mode) if mode <= 0 or mode > len(allow_mode): print('[!]请输入合法范围的数字') return False return allow_mode[mode - 1]
def select_func(F): funcs = F.get_funclist() for i, func in enumerate(funcs): print(i + 1, ':', func[0], func[2]) fno = withexit_input('选择马(数字/all):') if fno.lower() == 'all': return 'all' if not fno.isdigit(): print('[!]请输入数字') return False fno = int(fno) if fno <= 0 or fno > len(funcs): print('[!]请输入合法范围的数字') return False return funcs[fno - 1]
def main(): mode = select_mode() if mode == False: return False F = load_funcs(mode) if F == False: return False func = select_func(F) if func == False: return False elif func == 'all': pwd = withexit_input('输入链接密码:') for f in F.get_funclist(): print('-' * 50) print(run_func(F, f, pwd)) print('-' * 50) else: print(run_func(F, func))
#coding=utf-8 #version 1.0 import os, sys path = os.path.abspath('.') if 'tools' in path.replace('\\', '/').split('/'): #这里是为了便于开发调试 path = path.split('tools', maxsplit=1)[0] + 'Library/utils' else: path = path + '/Library/utils' if not path in (p.replace('\\', '/') for p in sys.path): sys.path.append(path) from env_variable_util import ENVIRONMENT_VARIABLE_UTIL from tool_input import withexit_input print('[+]此模块索引环境变量里的可执行文件') print('[+]输入名称返回绝对路径,例如输入python,返回c:\\pythohn3\python.exe') E = ENVIRONMENT_VARIABLE_UTIL() while 1: for p in E.get_abspath(withexit_input('win env match>')): print(p)