def get_mobile_cache(category='0', limit='10', filepath='./http/cache/mobilecache'): """ 在mobilecache这个表里根据category和limit选择uri :param category: :param limit: :param filepath: :return: """ information = init_config_file().read().split() host = information[3] database_user = information[5] database_pwd = information[4] str1 = "SELECT uri,cache_size, md5 FROM mobile_cache WHERE cache_size < 52428800 AND category=" # 修改数据库中的资源大小 str1_5 = " and expires> '" str1_6 = "'" current_time = str(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')) str2 = " ORDER BY create_time DESC LIMIT " execute = str1 + category + str1_5 + current_time + str1_6 + str2 + limit # print execute filepath += 'mobilecache' res = execute_mysql_get_cache_info(execute, filepath, category, host, database_user, database_pwd) log.info(u'采集到的放入/http/cache_info的mobile信息为' + str(res)) return res
def get_http_cache(category, limit, filepath='./http/cache/httpcache'): """ 在httpcache这个表里根据category和limit选择uri :param filepath: :param category:种类 :param limit:限定条数,从根据createtime来排序,取最新的limit条数 :return: """ information = init_config_file().read().split() host = information[3] database_user = information[5] database_pwd = information[4] str1 = "SELECT uri,cache_size,md5 FROM http_cache WHERE cache_size < 12428800 AND category=" str2 = " ORDER BY create_time DESC LIMIT " str1_5 = " and expires> '" str1_6 = "'" current_time = str(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')) command = str1 + category + str1_5 + current_time + str1_6 + str2 + limit filepath += 'httpcache' log.info(u'host:' + str(host) + u'database_user:'******'database_pwd' + database_pwd) res = execute_mysql_get_cache_info(command, filepath, category, host, database_user, database_pwd) log.info(u'采集到的放入/http/cache_info的http信息为' + str(res)) return res
def kind0(time_stamp, limit, time_line, is_sleep=True): information = init_config_file().read().split() src_system = information[7] need_assert = information[8] if need_assert == 'True': need_assert = True if is_sleep: # for i in range(5): # curl_resource_verbose(time_stamp, 0, i, limit, src_system, 'iphone', True, True) # for i in range(3): # curl_resource_verbose(time_stamp, 1, i, limit, src_system, 'iphone', True, True) # for i in range(20): # curl_resource_verbose(time_stamp, 2, i, limit, src_system, 'iphone', True, True) # 上面三行的作用是单线程执行全部的资源 log.info(u'开始多线程的kind0的操作') threadpool = [] for t in range(0, 1): # 如果此处改为2的话 会存现问题 for i in range(5): th = threading.Thread(target=curl_resource_verbose, args=(time_stamp, 0, i, limit, src_system, 'windows', need_assert, True)) threadpool.append(th) for i in range(2): th = threading.Thread(target=curl_resource_verbose, args=(time_stamp, 1, i, limit, src_system, 'windows', need_assert, True)) threadpool.append(th) for i in range(20): th = threading.Thread(target=curl_resource_verbose, args=(time_stamp, 2, i, limit, src_system, 'windows', need_assert, True)) threadpool.append(th) for ths in threadpool: log.info(u" ths.start()所执行的线程为:" + str(ths)) ths.start() for ths in threadpool: log.info(u" ths.join()所join的线程为:" + str(ths)) threading.Thread.join(ths) log.info(u'等待' + str(time_line) + u'秒后开始执行') # time.sleep(time_line) # # 以下代码是用来制造vpe服务流量的 # do_curl(time_stamp, # 'curl --connect-timeout 5 -m 10 -o test666 -L "http://avideo.ifengcdn.com/mappa/2017/02/21/561cdb51bc6ee1d3804a9fc7f0fc5d1b.mp4" --user-agent "windows"', # system=src_system, really_do=True) else: for i in range(0, 5): curl_resource_verbose(time_stamp, 0, i, limit, 'linux', 'windows', False, False) for y in (0, 2): curl_resource_verbose(time_stamp, 1, y, limit, 'linux', 'windows', False, False) for x in range(0, 20): curl_resource_verbose(time_stamp, 2, x, limit, 'linux', 'windows', False, False)
def do_curl(time_stamp, command, system, really_do, classes, category, i): """ 执行curl命令,目前只支持windows系统和linux系统 :param really_do: 默认是真的要执行curl操作 :param time_stamp: :param command:命令语句 :param system:linux or windows :return: """ linux_config = init_config_file().readline().split() src_ip = linux_config[0] user = linux_config[1] pwd = linux_config[2] current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') log.info(u'当前时间为:' + unicode(current_time)) if system == 'windows' or 'linux_self': log.info(u'选择的是windows设备执行curl操作' + str(command)) curl_log = "./curl_log/curl_log_" + time_stamp if really_do: p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) p.wait() info = p.stdout.read() log.info(u'windows上执行的命令返回值为:' + str(info)) curl_log = "./curl_log/curl_log_" + time_stamp with open(curl_log, "a") as f: now_over_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') f.write(current_time + ':\t' + str(classes) + '\t' + str(category) + '\t' + str(i) + '\n' + command + '\n' + "" + info + now_over_time + '\n' + '------------------------------' + '\n') f.flush() else: x1 = open(curl_log, 'a+') x1.write(current_time + '\n' + command + '\n') elif system == 'linux': # 此处编写linux下的命令 log.info(u'选择的是linux设备执行curl操作') curl_log = "./curl_log/curl_log_" + time_stamp # 在此增加读取linux配置的语句 log.info(u"linux的信息如下所示:ip address:" + src_ip + ' user:'******'并且写入到curl_log中') log.info(u"获取到的info信息为" + unicode(info) + u'并且写入到curl_log中') with open(curl_log, "a") as f: now_over_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') f.write(current_time + '\n' + command + '\n' + "" + info + now_over_time + '\n' + '------------------------------' + '\n') f.flush() else: x1 = open(curl_log, 'a+') x1.write(current_time + '\n' + command + '\n')
def get_service_log(classes, md5): # connect_linux('service iptables stop', cds_host, cds_user, cds_pwd) # 初始化 免得数据库无法连上(执行关闭防火墙的操作) information = init_config_file().read().split() cds_host = information[3] cds_user = information[5] database_pwd = information[4] if int(classes) == 0: classes = "http_service_log" elif int(classes) == 1: classes = 'mobile_service_log' elif int(classes) == 2: classes = "video_service_log" cmd1 = 'SELECT category,cache_size,service_size,create_time FROM ' cmd2 = ' WHERE md5="' cmd3 = '" ORDER BY create_time DESC' cmd = cmd1 + classes + cmd2 + md5 + cmd3 log.info(u"执行的获取服务日志信息的cmd为:" + unicode(cmd)) return execute_mysql(cmd, cds_host, cds_user, database_pwd)
def get_location_log(url): """ 根据url获取location资料后,下一步对比 :param url: :return: """ information = init_config_file().read().split() cds_host = information[3] cds_user = information[5] database_pwd = information[4] cds_pwd = information[6] log.info(u"此处的linux链接信息如下所示:" + cds_host + ' ' + cds_user + ' ' + cds_pwd) # connect_linux('service iptables stop', cds_host, cds_user, cds_pwd) # 初始化 免得数据库无法连上(执行关闭防火墙的操作) cmd1 = 'SELECT class,category,cache_size,create_time FROM location_log WHERE req_uri = "' cmd2 = '" ORDER BY create_time DESC' cmd = cmd1 + url + cmd2 log.info(u"执行的获取重定向日志信息的cmd为:" + unicode(cmd)) log.info(u'cds_host cds_user database_pwd信息 分别为:' + cds_host + ' ' + cds_user + ' ' + database_pwd + ' ') return execute_mysql(cmd, cds_host, cds_user, database_pwd)
def get_resource_size(url): """ 根据资源的url来获取资源的大小用来计算热榜(注意分类) :param url: :return:class category size组成的列表 """ information_file = init_config_file().read().split() host = information_file[3] user = information_file[5] database_pwd = information_file[4] pwd = information_file[2] info = [] command1 = 'SELECT cache_size,category FROM ' kind1 = 'http_cache' kind2 = 'mobile_cache' kind3 = 'video_cache' command2 = ' WHERE uri like"%' command3 = '%"' command = command1 + kind1 + command2 + url + command3 log.info(u'输入uri获取他的cache_size和category:' + command) res = execute_mysql(command, host, user, database_pwd) log.info(u"执行的筛选数据res为:" + unicode(res)) if res is None: command = command1 + kind2 + command2 + url + command3 res = execute_mysql(command, host, user, database_pwd) if res is None: command = command1 + kind3 + command2 + url + command3 res = execute_mysql(command, host, user, database_pwd) info.append("videocache") info.append(res[1]) info.append(res[0]) else: info.append("mobilecache") info.append(res[1]) info.append(res[0]) else: info.append("httpcache") info.append(res[1]) info.append(res[0]) return info
def get_uri_by_md5(md5): """ 输入md5值后返回他的uri地址 :param md5: :return: """ information = init_config_file().read().split() cds_host = information[3] cds_user = information[5] database_pwd = information[4] cmd1 = 'SELECT uri FROM ' cmd2 = ' WHERE md5="' cmd3 = '"' cmd = cmd1 + 'http_cache' + cmd2 + md5 + cmd3 res = execute_mysql(cmd, cds_host, cds_user, database_pwd) if res is None: cmd = cmd1 + 'video_cache' + cmd2 + md5 + cmd3 res = execute_mysql(cmd, cds_host, cds_user, database_pwd) if res is None: cmd = cmd1 + 'mobile_cache' + cmd2 + md5 + cmd3 res = execute_mysql(cmd, cds_host, cds_user, database_pwd) return res
def get_video_cache(category='1', limit='10', filepath='./http/cache/videocache'): """ 在videocache这个表里根据category和limit选择uri :param category: :param limit: :param filepath: :return: """ information = init_config_file().read().split() host = information[3] database_user = information[5] database_pwd = information[4] str1 = "SELECT uri,cache_size,md5 FROM video_cache WHERE cache_size < 12428800 AND category=" str2 = " ORDER BY create_time DESC LIMIT " execute = str1 + category + str2 + limit # print execute filepath += 'videocache' res = execute_mysql_get_cache_info(execute, filepath, category, host, database_user, database_pwd) log.info(u'采集到的放入/http/cache_info的video信息为' + str(res)) return res
def timer_customize(timestamp, expect_start_time, expect_end_time, limit, kind_timeline, do_all=False): """ 输入期望开始的时间随后每隔五分钟会调用一次 :param do_all: :param kind_timeline: :param limit: :param timestamp: :param expect_end_time: :param expect_start_time: :return: """ information = init_config_file().read().split() cds_host = information[3] cds_database_user = information[5] cds_pwd = information[6] # 从配置文件中读取相关的信息 expect_start_time = datetime.datetime.strptime( expect_start_time, '%Y-%m-%d %H:%M:%S') + datetime.timedelta( seconds=30) # 说明加上从0或者5分钟后加上30秒后再执行curl操作 expect_end_time = datetime.datetime.strptime( expect_end_time, '%Y-%m-%d %H:%M:%S') # 预期结束的时间 now_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') # 显示现在的时间 now_time = datetime.datetime.strptime(now_time, '%Y-%m-%d %H:%M:%S') # 格式化当前的时间 log.info(u'判断当前的时间和开始时间结束时间:') log.info(u'expect_start_time' + unicode(expect_start_time)) log.info(u'expect_end_time' + unicode(expect_end_time)) log.info(u'now_time' + unicode(now_time)) if now_time > expect_start_time: log.info(u'预期开始时间不能大于现在的时间' + '\n' + u'结束进程') sys.exit() if expect_end_time < expect_start_time: log.info(u'结束时间不能小于开始时间' + '\n' + u'结束进程') sys.exit() expect_end_time = expect_end_time + datetime.timedelta( minutes=5) # 此处填写的是执行两次kind之间的时间间隔 node = 1 curl_log = "./curl_log/curl_log_" + timestamp log.info(u'清除指定的时间戳的curl_log文件中的内容,之前的内容都是测试kind_info中的信息而产生的') f = open(curl_log, 'w+') f.close() init_debug_info = connect_linux(' /home/icache/icached debug', cds_host, cds_database_user, cds_pwd) log.info(u'debug信息如下所示:' + '\n' + init_debug_info) f = open(curl_log, 'a') f.write(init_debug_info) f.flush() count_kind1 = 1 count_kind2 = 1 count_kind3 = 1 count_kind4 = 1 count_kind5 = 1 count_kind0 = 1 log.info(u'开始执行循环操作') while True: del_operation_log(timestamp) now_time = datetime.datetime.now().strftime( '%Y-%m-%d %H:%M:%S') # 显示现在的时间 log.info(u'当前的时间是:' + unicode(now_time)) now_time = datetime.datetime.strptime(now_time, '%Y-%m-%d %H:%M:%S') # 格式化当前的时间 log.info(u'期望结束的时间加上五分钟是:' + str(expect_end_time)) # 离结束还有多久 wait_to_end = (expect_end_time - now_time) # 期望结束的时间+5分钟-当前的时间 即剩下多少时间 if wait_to_end < datetime.timedelta(seconds=0.5): log.info(u"执行完时间已经超过结束时间,结束进程") exit() wait_to_end = str(wait_to_end) log.info(u'离结束的时间还有几分几秒(请自行减去五分钟):' + str(wait_to_end)) # 离结束还有几分几秒 if 'day' not in wait_to_end: end_day = 0 end_hour = int(wait_to_end.split(':')[0]) end_minute = int(wait_to_end.split(':')[1]) end_second = int(wait_to_end.split(':')[2]) else: end_day = int(wait_to_end.split()[0]) wait_to_end = wait_to_end.split(',')[1] end_hour = int(wait_to_end.split(':')[0]) end_minute = int(wait_to_end.split(':')[1]) end_second = int(wait_to_end.split(':')[2]) seconds_to_wait_end = end_day * 3600 * 24 + end_hour * 3600 + end_minute * 60 + end_second # 离跳出循环还有几秒钟 log.info(u'离结束时间还有几秒(seconds_to_wait_end):' + str(seconds_to_wait_end)) log.info(u"expect_start_time的值为:" + unicode(expect_start_time)) log.info(u"now_time的值为:" + unicode(now_time)) if abs( seconds_to_wait_end ) < 300 or seconds_to_wait_end < 0 or expect_start_time < now_time: log.info(u'马上自动退出程序,请查看基础日志') log.info(u"seconds_to_wait_end:" + unicode(seconds_to_wait_end)) log.info(u"expect_start_time:" + unicode(expect_start_time)) log.info(u"now_time:" + unicode(now_time)) log.info(u'此时执行的是kind' + str(node)) break else: log.info(u"倒计时还没结束,等待倒计时") wait_time = str(expect_start_time - now_time) log.info(u"wait_time的值为:" + unicode(wait_time)) hours = int(wait_time.split(':')[0]) minute = int(wait_time.split(':')[1]) seconds = int(wait_time.split(':')[2]) seconds_to_wait = hours * 3600 + minute * 60 + seconds log.info(u"等待时间为" + str(seconds_to_wait) + u'秒后开始执行') time.sleep(seconds_to_wait) if not do_all: # 在此处添加自定义的kind if node == 1: log.info(u'开始执行kind1的实际curl操作') kind1(timestamp, limit=limit, time_line=kind_timeline) log.info(u'kind1执行了' + str(count_kind1) + u"次") count_kind1 += 1 elif node == 2: log.info(u'开始执行kind2的实际curl操作') kind2(timestamp, limit=limit, time_line=kind_timeline) log.info(u'kind2执行了' + str(count_kind2) + u"次") count_kind2 += 1 elif node == 3: log.info(u'开始执行kind3的实际curl操作') kind3(timestamp, limit=limit, time_line=kind_timeline) log.info(u'kind3执行了' + str(count_kind3) + u"次") count_kind3 += 1 elif node == 4: log.info(u'开始执行kind4的实际curl操作') kind4(timestamp, limit=limit, time_line=kind_timeline) log.info(u'kind4执行了' + str(count_kind4) + u"次") count_kind4 += 1 elif node == 5: log.info(u'开始执行kind5的实际curl操作') kind5(timestamp, limit=limit, time_line=kind_timeline) log.info(u'kind5执行了' + str(count_kind5) + u"次") count_kind5 += 1 else: log.info(u'开始执行kind0的实际curl操作') kind0(timestamp, limit=limit, time_line=kind_timeline) log.info(u'kind0执行了' + str(count_kind5) + u"次") count_kind0 += 1 time_line = datetime.timedelta(minutes=5) # 两个kind之间每次curl间隔的时间,要求为5分钟 expect_start_time = expect_start_time + time_line log.info(u'下一次的curl_kind操作开始时间为:' + unicode(expect_start_time)) node += 1 if node == 6: # node就是执行的kind数+1 node = 1 end_debug_info = connect_linux('/home/icache/icached debug', cds_host, cds_database_user, cds_pwd) log.info(u'结束所有的curl操作,debug_info如下所示:' + end_debug_info) f.write(end_debug_info + '\n' + u'kind0一共执行了' + str(count_kind0) + u'次') log.info(u'kind执行的次数写入到curl_log文件中') f.write('count_kind1:' + str(count_kind1) + '\n') f.write('count_kind2:' + str(count_kind2) + '\n') f.write('count_kind3:' + str(count_kind3) + '\n') f.write('count_kind4:' + str(count_kind4) + '\n') f.write('count_kind5:' + str(count_kind5) + '\n') f.close() current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') log.info(u'当前的时间为:' + unicode(current_time))
def timer_customize_all_kind(timestamp, expect_start_time='2017-03-21 17:04:00', expect_end_time='2017-03-21 17:20:00', limit=10, kind_timeline=120): """ 输入期望开始的时间随后每隔五分钟会调用一次 :param kind_timeline: :param limit: :param timestamp: :param expect_end_time: :param expect_start_time: :return: """ information = init_config_file().read().split() cds_host = information[3] cds_database_user = information[5] cds_database_pwd = information[4] cds_pwd = information[6] expect_start_time = datetime.datetime.strptime( expect_start_time, '%Y-%m-%d %H:%M:%S') + datetime.timedelta( seconds=15) # 说明加上从0或者5分钟后加上30秒后再执行curl操作 expect_end_time = datetime.datetime.strptime(expect_end_time, '%Y-%m-%d %H:%M:%S') now_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') # 显示现在的时间 now_time = datetime.datetime.strptime(now_time, '%Y-%m-%d %H:%M:%S') # 格式化当前的时间 log.info(u'判断当前的时间和开始时间结束时间:') log.info(u'expect_start_time' + unicode(expect_start_time)) log.info(u'expect_end_time' + unicode(expect_end_time)) log.info(u'now_time' + unicode(now_time)) if now_time > expect_start_time: log.info(u'预期开始时间不能大于现在的时间' + '\n' + u'结束进程') sys.exit() if expect_end_time < expect_start_time: log.info(u'结束时间不能小于开始时间' + '\n' + u'结束进程') sys.exit() expect_end_time = expect_end_time + datetime.timedelta(minutes=5) node = 1 curl_log = "./curl_log/curl_log_" + timestamp log.info(u'清除指定的时间戳的curl_log文件中的内容,之前的内容都是测试kind_info中的信息而产生的') f = open(curl_log, 'w+') f.close() init_debug_info = connect_linux(' /home/icache/icached debug', cds_host, cds_database_user, cds_pwd) log.info(u'debug信息如下所示:' + '\n' + init_debug_info) f = open(curl_log, 'a') f.write(init_debug_info) f.flush() count_kind1 = 1 count_kind2 = 1 count_kind3 = 1 count_kind4 = 1 count_kind5 = 1 log.info(u'开始执行循环操作') while True: del_operation_log(timestamp) now_time = datetime.datetime.now().strftime( '%Y-%m-%d %H:%M:%S') # 显示现在的时间 log.info(u'当前的时间是:' + unicode(now_time)) now_time = datetime.datetime.strptime(now_time, '%Y-%m-%d %H:%M:%S') # 格式化当前的时间 log.info(u'期望结束的时间加上五分钟是:' + str(expect_end_time)) # 离结束还有多久 wait_to_end = (expect_end_time - now_time) # 期望结束的时间+5分钟-当前的时间 即剩下多少时间 if wait_to_end < datetime.timedelta(seconds=0.5): log.info(u"执行完时间已经超过结束时间,结束进程") exit() wait_to_end = str(wait_to_end) log.info(u'离结束的时间还有几分几秒(请自行减去五分钟):' + str(wait_to_end)) # 离结束还有几分几秒 end_hour = int(wait_to_end.split(':')[0]) end_minute = int(wait_to_end.split(':')[1]) end_second = int(wait_to_end.split(':')[2]) seconds_to_wait_end = end_hour * 3600 + end_minute * 60 + end_second # 离跳出循环还有几秒钟 log.info(u'离结束时间还有几秒(seconds_to_wait_end):' + str(seconds_to_wait_end)) log.info(u"expect_start_time的值为:" + unicode(expect_start_time)) log.info(u"now_time的值为:" + unicode(now_time)) if abs( seconds_to_wait_end ) < 300 or seconds_to_wait_end < 0 or expect_start_time < now_time: log.info(u'马上自动退出程序,请查看基础日志') log.info(u"seconds_to_wait_end:" + unicode(seconds_to_wait_end)) log.info(u"expect_start_time:" + unicode(expect_start_time)) log.info(u"now_time:" + unicode(now_time)) log.info(u'此时执行的是kind' + str(node)) break else: log.info(u"倒计时还没结束,等待倒计时") wait_time = str(expect_start_time - now_time) log.info(u"wait_time的值为:" + unicode(wait_time)) hours = int(wait_time.split(':')[0]) minute = int(wait_time.split(':')[1]) seconds = int(wait_time.split(':')[2]) seconds_to_wait = hours * 3600 + minute * 60 + seconds log.info(u"等待时间为" + str(seconds_to_wait) + u'秒后开始执行') time.sleep(seconds_to_wait) kind0(timestamp, True, limit, kind_timeline) time_line = datetime.timedelta(minutes=5) # 两个kind之间每次curl间隔的时间,要求为5分钟 expect_start_time = expect_start_time + time_line log.info(u'下一次的curl_kind操作开始时间为:' + unicode(expect_start_time)) node += 1 # 自加1 if node == 6: node = 1 end_debug_info = connect_linux('/home/icache/icached debug', cds_host, cds_database_user, cds_pwd) log.info(u'结束所有的curl操作,debug_info如下所示:' + end_debug_info) f.write(end_debug_info) log.info(u'kind执行的次数写入到curl_log文件中') f.write('count_kind1:' + str(count_kind1) + '\n') f.write('count_kind2:' + str(count_kind2) + '\n') f.write('count_kind3:' + str(count_kind3) + '\n') f.write('count_kind4:' + str(count_kind4) + '\n') f.write('count_kind5:' + str(count_kind5) + '\n') f.close() current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') log.info(u'当前的时间为:' + unicode(current_time))
def kind1(time_stamp, limit, time_line, is_sleep=True): """ :return: """ information = init_config_file().read().split() src_system = information[7] if is_sleep: # log.info(u"开始执行kind1的操作") # curl_resource_verbose(time_stamp, 0, 0, limit, src_system, 'windows', True, True) # log.info(u'curl httpcache category=0 成功') # curl_resource_verbose(time_stamp, 1, 0, limit, src_system, 'windows', True, True) # log.info(u'curl mobilecache category=0 成功') # curl_resource_verbose(time_stamp, 2, 1, limit, src_system, 'iphone', True, True) # log.info(u'curl videocache category=1 成功') # log.info(u'现在的时间是' + str(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))) # log.info(u'等待两分钟后继续执行') # time.sleep(time_line) # log.info(u'现在的时间是' + str(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))) # log.info(u"开始执行kind1的下半部分操作") # curl_resource_verbose(time_stamp, 0, 1, limit, src_system, 'windows', True, True) # log.info(u'curl httpcache category=1 成功') # curl_resource_verbose(time_stamp, 2, 2, limit, src_system, 'windows', True, True) # log.info(u'curl videocache category=2 成功') # curl_resource_verbose(time_stamp, 2, 14, limit, src_system, 'iphone', True, True) # log.info(u'curl videocache category=14 成功') # log.info(u"kind1的操作执行完成") log.info(u'开始多线程') for i in range(0, 2): t1 = threading.Thread(target=curl_resource_verbose, args=(time_stamp, 0, 0, limit, src_system, 'windows', True, True)) t1.start() t2 = threading.Thread(target=curl_resource_verbose, args=(time_stamp, 1, 0, limit, src_system, 'windows', True, True)) t2.start() t3 = threading.Thread(target=curl_resource_verbose, args=(time_stamp, 2, 1, limit, src_system, 'windows', True, True)) t3.start() t4 = threading.Thread(target=curl_resource_verbose, args=(time_stamp, 0, 1, limit, src_system, 'windows', True, True)) t4.start() t5 = threading.Thread(target=curl_resource_verbose, args=(time_stamp, 2, 2, limit, src_system, 'windows', True, True)) t5.start() t1.join() t2.join() t3.join() t4.join() t5.join() log.info(u'等待两分钟后继续执行') time.sleep(time_line) log.info(u"结束多线程") else: curl_resource_verbose(time_stamp, 0, 0, limit, 'linux', 'windows', False, False) curl_resource_verbose(time_stamp, 1, 0, limit, 'linux', 'windows', False, False) curl_resource_verbose(time_stamp, 2, 1, limit, 'linux', 'iphone', False, False) curl_resource_verbose(time_stamp, 0, 1, limit, 'linux', 'windows', False, False) curl_resource_verbose(time_stamp, 2, 2, limit, 'linux', 'windows', False, False) curl_resource_verbose(time_stamp, 2, 14, limit, 'linux', 'windows', False, False) message = u"kind1 的curl_log伪造成功" log.info(message)