def init_path_vars(): cur_date = WinSysUtils.get_current_date() global g_log_root_path global g_log_dir_path_for_win global g_log_dir_path_for_shell g_log_root_path = os.path.join(os.getcwd(), 'MonkeyReprots', cur_date) g_log_dir_path_for_win = r'%s\%s_%s' % (g_log_root_path, cur_date, g_run_num) g_log_dir_path_for_shell = '/sdcard/monkey_test_logs' # profile log path global g_profile_log_dir_path g_profile_log_dir_path = os.path.join(g_log_dir_path_for_win, 'profile_logs') # screen captures path global g_captures_dir_path_for_win global g_captures_dir_path_for_shell global g_capture_path_for_shell g_captures_dir_path_for_win = r'%s\captures' % g_log_dir_path_for_win g_captures_dir_path_for_shell = '%s/captures' % g_log_dir_path_for_shell g_capture_path_for_shell = '%s/capture_%s' % (g_captures_dir_path_for_shell, cur_date) # logcat log path global g_logcat_log_path_for_shell g_logcat_log_path_for_shell = '%s/logcat_log.log' % g_log_dir_path_for_shell # monkey log, local global g_monkey_log_path g_monkey_log_path = r'%s\monkey_log.log' % g_log_dir_path_for_win # rom props path, local global g_rom_props_file_path g_rom_props_file_path = r'%s\rom_props.log' % g_log_dir_path_for_win # whitelist path global g_whitelist_file_path_for_win global g_whitelist_file_path_for_shell g_whitelist_file_path_for_win = os.path.join(os.getcwd(), 'whitelist.txt') g_whitelist_file_path_for_shell = '%s/whitelist.txt' % g_log_dir_path_for_shell
''' import os import time import logging from ZJPyUtils import HttpJsonUtils, FileUtils, WinSysUtils, LogUtils # ---------------------------------------------------- # Variables # ---------------------------------------------------- g_city_ids = ('101010100', '101200101', '101200105', '101200601' ) # 北京,武汉,江夏,黄石 g_log_dir = os.path.join(os.getcwd(), 'logs', 'baidu_weather_data_update_freq') g_cur_date = WinSysUtils.get_current_date() # ---------------------------------------------------- # Collect weather data # ---------------------------------------------------- def init_log(): FileUtils.create_dir(g_log_dir) log_name = 'baidu_weather_data_update_freq_run_log_%s.log' % g_cur_date log_file = os.path.join(g_log_dir, log_name) LogUtils.init_log_config(logging.DEBUG, logging.INFO, log_file) def send_reuqest_and_write_response(): city_ids = g_city_ids
2) Parse the collected weather data to show the data refresh frequency. ''' import os import time import logging from ZJPyUtils import HttpJsonUtils, FileUtils, WinSysUtils, LogUtils # ---------------------------------------------------- # Variables # ---------------------------------------------------- g_city_ids = ('101010100', '101200101', '101200105', '101200601') # 北京,武汉,江夏,黄石 g_log_dir = os.path.join(os.getcwd(), 'logs', 'baidu_weather_data_update_freq') g_cur_date = WinSysUtils.get_current_date() # ---------------------------------------------------- # Collect weather data # ---------------------------------------------------- def init_log(): FileUtils.create_dir(g_log_dir) log_name = 'baidu_weather_data_update_freq_run_log_%s.log' % g_cur_date log_file = os.path.join(g_log_dir, log_name) LogUtils.init_log_config(logging.DEBUG, logging.INFO, log_file) def send_reuqest_and_write_response(): city_ids = g_city_ids url = 'http://apis.baidu.com/apistore/weatherservice/recentweathers'