不知道能不能跑通。。。最大的坑在于,如何让python找到指定的文件路径,而又不需要扫描全盘。。。经过高人指点,尝试了os.getcwd()的方法首先确定当前的工作路径,然后周一去找老大确认一下可能的绝对路径再拼凑吧
try:
import sys
import time
import os
import platform
import linecache
os.chdir('../res')
sys.path.append(os.getcwd())
from adb import ADB
except ImportError as e:
print("[f] Required module missing. %s" % e.args[0])
sys.exit(-1)
work_space = r'E:\工作\Python_practice\Cienet_Monkey\monkey\configFile.txt'
class check_parameters:
def __init__(self):
self.serial_no = serial_no
self.test_hour = test_hour
self.cycle_time = cycle_time
self.target_project = target_project
self.test_type = test_type
self.pkg_file = pkg_file
self.execute_method = execute_method
self.jira_project = jira_project
self.change_profile_hour = change_profile_hour
self.get_all_parameters = get_all_parameters
self.get_configfile_path = get_configfile_path
def get_cofigfile_path(self):
base_dir = os.getcwd\..\test
configfile_path = os.path.join(base_dir, 'configfile.txt')
configfile = open(configfile_path, 'r')
return configfile
def _get_serial_no():
linecache.clear()
serial_no = linecache.getline(configfile,1)
return serial_no
def _get_test_hour():
linecache.clear()
test_hour = linecache.getline(configfile,2)
return test_hour
def _get_cycle_time():
linecache.clear()
cycle_time = linecache.getline(configfile,3)
return cycle_time
def _get_target_project():
linecache.clear()
target_project = linecache.getline(configfile,4)
return target_project
def _get_test_type():
linecache.clear()
test_type = linecache.getline(configfile,5)
return test_type
def _get_pkg_file():
linecache.clear()
pkg_file = linecache.getline(configfile,6)
return pkg_file
def _get_execute_method():
linecache.clear()
execute_method = linecache.getline(configfile,7)
return execute_method
def _get_jira_project():
linecache.clear()
jira_project = linecache.getline(configfile,8)
return jira_project
def _get_change_profile_hour():
linecache.clear()
change_profile_hour = linecache.getline(configfile,9)
return change_profile_hour
def _get_all_parameters():
linecache.clear()
get_all_parameters = configfile.readlines()
return get_all_parameters