def write_conf_file(self): conf = read_path(self.conf_path_file) conf_execl_object = xlrd.open_workbook(conf.read_superior_path()) conf_sheet = conf_execl_object.sheet_by_index(0) rows = conf_sheet.nrows w_xls = copy(conf_execl_object) sheet_write = w_xls.get_sheet(0) return w_xls, sheet_write, rows
def write_accounts_file(self): accounts = read_path(self.accounts_file) accounts_execl_object = xlrd.open_workbook( accounts.read_superior_path()) accounts_sheet = accounts_execl_object.sheet_by_index(0) rows = accounts_sheet.nrows w_xls = copy(accounts_execl_object) sheet_write = w_xls.get_sheet(0) return w_xls, sheet_write, rows
def write_task_file(self): task = read_path(self.task_path_file) task_execl_object = xlrd.open_workbook(task.read_superior_path()) task_sheet = task_execl_object.sheet_by_index(0) rows = task_sheet.nrows w_xls = copy(task_execl_object) sheet_write = w_xls.get_sheet(0) return w_xls, sheet_write, rows
def read_file(self): #读取配置文件 conf_path = read_path('\pingtest\Email_conf.ini') config = configparser.ConfigParser() # 从配置文件中读取数据 config.read(conf_path.read_superior_path(), encoding='utf-8') self.Email_ser = config['Email_Service']['Email_ser'] self.Email_port = int(config['Email_Service']['Email_port']) self.username = config['send_user_pwd']['username'] self.password = config['send_user_pwd']['password'] self.to_list = config['to_list']['to_list']
class read_file(): def __init__(self): self.case_path_file = "\pingtest\Data\TestCase.xls" self.conf_path_file = "\pingtest\Data\project_conf.xls" self.task_path_file = "\pingtest\Data\Task.xls" self.accounts_file = "\pingtest\Data\Accounts.xls" self.save_task_file = ".\Data\Task.xls" self.save_case_file = ".\Data\TestCase.xls" self.save_conf_file = ".\Data\project_conf.xls" self.save_accounts_file = ".\Data\Accounts.xls" def read_case_file(self): case = read_path(self.case_path_file) case_execl_object = xlrd.open_workbook(case.read_superior_path()) case_sheet = case_execl_object.sheet_by_index(0) return case_sheet
def _set_result_filedir(self, file_name): self.file_name = file_name ws_path = read_path("/pingtest/Report") self.report_dir = ws_path.read_superior_path() # 获取工作空间路径 if os.path.exists(self.report_dir) is False: os.makedirs(self.report_dir) self.parent.show_log.insert( END, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ":" + "已自动建立测试报告路径:%s\n" % self.report_dir) self.parent.show_log.update() self.parent.show_log.see("end") loggers.info("已自动建立测试报告路径:%s" % self.report_dir) if '' == self.file_name: self.parent.show_log.insert( END, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ":" + 'filename can not be empty\n') self.parent.show_log.update() self.parent.show_log.see("end") loggers.error('filename can not be empty') # 判断是否为目录 elif os.path.isdir(self.report_dir): parent_path, ext = os.path.splitext(file_name) tm = time.strftime('%Y%m%d%H%M%S', time.localtime()) self.file_name = parent_path + "_" + tm + ext self.file_name_fail = parent_path + 'Fail' + "_" + tm + ext os.chdir(self.report_dir) # 转换目录 else: self.parent.show_log.insert( END, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ":" + "%s must point to a dir\n" % self.report_dir) self.parent.show_log.update() self.parent.show_log.see("end") raise loggers.error("%s must point to a dir" % self.report_dir)
def read_accounts_file(self): accounts = read_path(self.accounts_file) accounts_execl_object = xlrd.open_workbook( accounts.read_superior_path()) accounts_sheet = accounts_execl_object.sheet_by_index(0) return accounts_sheet
def read_conf_file(self): conf = read_path(self.conf_path_file) conf_execl_object = xlrd.open_workbook(conf.read_superior_path()) conf_sheet = conf_execl_object.sheet_by_index(0) return conf_sheet
def read_task(self): task = read_path(self.task_path_file) task_execl_object = xlrd.open_workbook(task.read_superior_path()) task_sheet = task_execl_object.sheet_by_index(0) return task_sheet
self.save_task_file = ".\Data\Task.xls" self.save_case_file = ".\Data\TestCase.xls" self.save_conf_file = ".\Data\project_conf.xls" self.save_accounts_file = ".\Data\Accounts.xls" def read_case_file(self): case = read_path(self.case_path_file) case_execl_object = xlrd.open_workbook(case.read_superior_path()) case_sheet = case_execl_object.sheet_by_index(0) return case_sheet def write_case_file(self): case = read_path(self.case_path_file) case_execl_object = xlrd.open_workbook(case.read_superior_path()) case_sheet = case_execl_object.sheet_by_index(0) rows = case_sheet.nrows w_xls = copy(case_execl_object) sheet_write = w_xls.get_sheet(0) return w_xls, sheet_write, rows def write_task_file(self): task = read_path(self.task_path_file) task_execl_object = xlrd.open_workbook(task.read_superior_path()) task_sheet = task_execl_object.sheet_by_index(0) rows = task_sheet.nrows w_xls = copy(task_execl_object)