diff --git a/coll_to_so.py b/coll_to_so.py deleted file mode 100644 index 060bb638..00000000 --- a/coll_to_so.py +++ /dev/null @@ -1,106 +0,0 @@ -#coding:utf-8 -import os -import sys -import shutil -import time -from distutils.core import setup -from Cython.Build import cythonize - - -def get_py(base_path=os.path.abspath('.'), parent_path='', name='', excepts=(), copy_other=False, del_c=False, start_time=0.0): - """ - 获取py文件的路径 - :param base_path: 根路径 - :param parent_path: 父路径 - :param name: 文件夹名 - :param excepts: 需要排除的文件 - :param copy_other: 是否copy其他文件 - :param del_c: 是否删除c文件 - :param start_time: 程序开始时间 - :return: py文件的迭代器 - """ - full_path = os.path.join(base_path, parent_path, name) - for fname in os.listdir(full_path): # 列出文件夹下所有路径名称,筛选返回需要的文件名称 - ffile = os.path.join(full_path, fname) - if os.path.isdir(ffile) and not fname.startswith('.'): - for f in get_py(base_path, os.path.join(parent_path, name), fname, excepts, copy_other, del_c): - yield f - elif os.path.isfile(ffile): - ext = os.path.splitext(fname)[1] - if ext == ".c": - if del_c and os.stat(ffile).st_mtime > start_time: - os.remove(ffile) - elif ffile not in excepts and os.path.splitext(fname)[1] not in('.pyc', '.pyx'): # 如果文件不在排除列表中,并且文件不是.c, .pyc, .pyx - if os.path.splitext(fname)[1] in('.py', '.pyx') and not fname.startswith('__'): - yield ffile - elif copy_other: - dst_dir = os.path.join(base_path, parent_path, name) - if not os.path.isdir(dst_dir): - os.makedirs(dst_dir) - shutil.copyfile(ffile, os.path.join(dst_dir, fname)) - else: - pass - - -def build_codes(curr_dir): - """ - 将路径列表下的文件编译成.so文件 - :param path_list - :return: - """ - start_time = time.time() - parent_path = sys.argv[1] if len(sys.argv) > 1 else "" - setup_file = os.path.join(os.path.abspath('.'), __file__) - - # 获取py列表 - module_list = list(get_py(base_path=curr_dir)) - try: - for module in module_list: - to_path = os.path.dirname(module.replace('/test/coll','/coll')) + '/' - if not os.path.exists(to_path): os.makedirs(to_path) - if module.find('crontab_tasks') != -1: - shutil.copyfile(module,module.replace('/test/coll','/coll')) - else: - setup(ext_modules=cythonize(module), script_args=["build_ext", "-b",to_path ]) - except Exception as ex: - print("Error: ", ex) - exit(1) - else: - module_list = list(get_py(base_path=curr_dir, parent_path=parent_path, excepts=(setup_file), copy_other=False, start_time=start_time)) - module_list = list(get_py(base_path=curr_dir, parent_path=parent_path, excepts=(setup_file), del_c=True, start_time=start_time)) # 删除编译过程产生的c文件 - - - if os.path.exists('./build'): # 删除build过程产生的临时文件 - shutil.rmtree('./build') - - inc_path = '/www/coll/inc/inc' - if os.path.exists(inc_path): - os.system("\cp -arf "+inc_path + "/* /www/coll/inc/") - shutil.rmtree(inc_path) - os.system("echo > /www/coll/inc/__init__.py") - print("Complete! time:", time.time()-start_time, 's') - - -def delete_py(path_list): - """ - 删除给定路径下的py文件 - :param path_list: 需要删除的py文件路径列表,可以是文件夹名,也可以是文件名 - :return: - """ - for path in path_list: - base_path = os.path.abspath(path) - counter = 0 # 文件删除计数器 - if os.path.isfile(base_path) and os.path.splitext(base_path)[1] == '.py': - os.remove(base_path) - counter += 1 - if counter == len(path_list): - return # 直到一个文件夹中的文件删除完退出递归 - elif os.path.isdir(base_path): - dirs = [os.path.join(base_path, _dir) for _dir in os.listdir(base_path)] - delete_py(dirs) - - -if __name__ == "__main__": - code_path_list=["/www/test/coll"] - build_codes(code_path_list[0]) - diff --git a/get_ip.py b/get_ip.py deleted file mode 100644 index d22a3a5b..00000000 --- a/get_ip.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/python -#coding: utf-8 -import requests,re -headers = {'User-Agent':"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"} -url = 'https://www.xicidaili.com/wt/' -rep = "(\d+\.\d+\.\d+\.\d+)\n\s+(\d+)" -def get_ip(num = 100): - ip_arr = []; - for i in range(num): - rs = requests.get(url + str(i),headers = headers) - tmp = re.findall(rep,rs.text) - for tmp1 in tmp: - print(tmp1) - if len(tmp1) != 2: continue - ip_arr.append(tmp[0]+':' + tmp[1]) - ip_text = '\n'.join(ip_arr) - return ip_text - -ip_texts = get_ip(100); -f = open('e:/ip_text.txt','w+'); -f.write(ip_texts); -f.close(); diff --git a/test.py b/test.py deleted file mode 100644 index 8c95e7a6..00000000 --- a/test.py +++ /dev/null @@ -1,57 +0,0 @@ -#coding: utf-8 -def extract_zone(domain_name): - domain_name = domain_name.lstrip("*.") - - #处理地区域名 - top_domain_list = ['.ac.cn', '.ah.cn', '.bj.cn', '.com.cn', '.cq.cn', '.fj.cn', '.gd.cn', - '.gov.cn', '.gs.cn', '.gx.cn', '.gz.cn', '.ha.cn', '.hb.cn', '.he.cn', - '.hi.cn', '.hk.cn', '.hl.cn', '.hn.cn', '.jl.cn', '.js.cn', '.jx.cn', - '.ln.cn', '.mo.cn', '.net.cn', '.nm.cn', '.nx.cn', '.org.cn'] - old_domain_name = domain_name - m_count = domain_name.count(".") - top_domain = "."+".".join(domain_name.rsplit('.')[-2:]) - new_top_domain = "." + top_domain.replace(".","") - is_tow_top = False - if top_domain in top_domain_list: - is_tow_top = True - domain_name = domain_name[:-len(top_domain)] + new_top_domain #地区域名后缀去点处理 - - if domain_name.count(".") > 1: - zone, middle, last = domain_name.rsplit(".", 2) - acme_txt = "_acme-challenge.%s" % zone - if is_tow_top: last = top_domain[1:] #还原地区域名 - root = ".".join([middle, last]) - else: - zone = "" - root = old_domain_name - acme_txt = "_acme-challenge" - return root, zone, acme_txt - -def test(domain_name): - domain_name = domain_name.lstrip("*.") - subd = "" - if domain_name.count(".") != 1: # not top level domain - pos = domain_name.rfind(".", 0, domain_name.rfind(".")) - subd = domain_name[:pos] - domain_name = domain_name[pos + 1 :] - if subd != "": - subd = "." + subd - return subd - - -#获取根域名 -def get_root_domain(domain_name): - if domain_name.count(".") != 1: - pos = domain_name.rfind(".", 0, domain_name.rfind(".")) - subd = domain_name[:pos] - domain_name = domain_name[pos + 1 :] - return domain_name - -#获取acmename -def get_acme_name(domain_name): - d_root,tow_name,acme_txt = extract_zone(domain_name) - return acme_txt + '.' + d_root - -domain = "*.archenet.com.cn" -print(extract_zone(domain)) -print(get_acme_name(domain)) \ No newline at end of file