Commit 2167c216 authored by 王超's avatar 王超

修改代码中涉及到硬编码路径位置,根据操作系统类型来进行适配

parent 0c6052ef
# Default ignored files
/shelf/
/workspace.xml
# GitHub Copilot persisted chat sessions
/copilot/chatSessions
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.idea/copilot/chatSessions" />
</content>
<orderEntry type="jdk" jdkName="Python 3.9 (venv)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
<component name="Black">
<option name="sdkName" value="Python 3.9 (venv)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (venv)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
......@@ -4,7 +4,16 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="5f6c517d-e672-488b-afa7-3ef19e47d096" name="Changes" comment="更新" />
<list default="true" id="5f6c517d-e672-488b-afa7-3ef19e47d096" name="Changes" comment="更新">
<change beforePath="$PROJECT_DIR$/.idea/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/EOS_API_AUTOMATION_TEST.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/EOS_API_AUTOMATION_TEST.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/common/logger_util.py" beforeDir="false" afterPath="$PROJECT_DIR$/common/logger_util.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/common/parameters_util.py" beforeDir="false" afterPath="$PROJECT_DIR$/common/parameters_util.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/common/requests_util.py" beforeDir="false" afterPath="$PROJECT_DIR$/common/requests_util.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/common/yaml_util.py" beforeDir="false" afterPath="$PROJECT_DIR$/common/yaml_util.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
......@@ -20,6 +29,9 @@
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectColorInfo"><![CDATA[{
"associatedIndex": 7
}]]></component>
<component name="ProjectId" id="2h2RckHYyLyW2EM2h97cdy5lPyG" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="2" id="Add" />
......@@ -33,9 +45,15 @@
"ASKED_ADD_EXTERNAL_FILES": "true",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
"git-widget-placeholder": "master",
"last_opened_file_path": "D:/CMS2.0_API/EOS_API_AUTOMATION_TEST/testcase/6_ViewManagement",
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="RecentsManager">
......@@ -47,7 +65,7 @@
<recent name="D:\CMS2.0_API\EOS_API_AUTOMATION_TEST\logs2" />
</key>
</component>
<component name="RunManager" selected="Python.all_test">
<component name="RunManager" selected="Python.yaml_util">
<configuration name="all_test" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="EOS_API_AUTOMATION_TEST" />
<option name="INTERPRETER_OPTIONS" value="" />
......@@ -60,6 +78,7 @@
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/all_test.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
......@@ -81,6 +100,7 @@
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/debug_talk.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
......@@ -90,7 +110,7 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="requests_util" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<configuration name="testlmes" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="EOS_API_AUTOMATION_TEST" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
......@@ -98,11 +118,12 @@
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/common" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/testcase/test" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/common/requests_util.py" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/testcase/test/testlmes.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
......@@ -111,7 +132,7 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="testlmes" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<configuration name="yaml_util" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="EOS_API_AUTOMATION_TEST" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
......@@ -119,11 +140,12 @@
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/testcase/test" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/common" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/testcase/test/testlmes.py" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/common/yaml_util.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
......@@ -141,6 +163,7 @@
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
......@@ -150,11 +173,11 @@
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.yaml_util" />
<item itemvalue="Python.all_test" />
<item itemvalue="Python.testlmes" />
<item itemvalue="Python tests.pytest in 223mode3_run.py" />
<item itemvalue="Python.debug_talk" />
<item itemvalue="Python.requests_util" />
</list>
</recent_temporary>
</component>
......@@ -166,6 +189,7 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1716790267585</updated>
<workItem from="1733360166391" duration="2670000" />
</task>
<task id="LOCAL-00001" summary="更新">
<option name="closed" value="true" />
......@@ -178,6 +202,9 @@
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
......@@ -194,4 +221,7 @@
<MESSAGE value="更新" />
<option name="LAST_COMMIT_MESSAGE" value="更新" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/EOS_API_AUTOMATION_TEST$yaml_util.coverage" NAME="yaml_util Coverage Results" MODIFIED="1733362011606" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/common" />
</component>
</project>
\ No newline at end of file
import logging
import os.path
import time
from common.yaml_util import get_object_path, read_config_file
......@@ -14,7 +15,9 @@ class LoggerUtil:
if not self.logger.handlers:
#-----------文件日志----------
#获得日志文件的名称
self.file_log_path = get_object_path()+'/logs/'+ read_config_file('log','log_name')+str(int(time.time()))+'.log'
log_file_name = read_config_file('log','log_name')+str(int(time.time()))+'.log'
log_root_path = os.path.join(get_object_path(),'logs')
self.file_log_path = os.path.join(log_root_path,log_file_name)
# print(self.file_log_path)
#创建文件日志的控制器
self.file_hander = logging.FileHandler(self.file_log_path,encoding='utf-8')
......
import csv
import json
import os
import traceback
import yaml
......@@ -10,7 +11,7 @@ from common.yaml_util import get_object_path
#读取csv数据文件
def read_csv_file(csv_path):
csv_data_list = []
with open(get_object_path()+'/'+csv_path,encoding='utf-8') as f:
with open(get_object_path()+os.path.sep+csv_path,encoding='utf-8') as f:
csv_data = csv.reader(f)
for row in csv_data:
csv_data_list.append(row)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -4,28 +4,28 @@ import os
#获取项目路径
def get_object_path():
return os.path.abspath(os.getcwd().split('common')[0])
return os.path.split(os.path.split(__file__)[0])[0]
#读取config.yml文件
def read_config_file(one_node,two_node):
with open(get_object_path()+"\\config.yml",encoding='utf-8') as f:
with open(get_object_path()+os.path.sep+"config.yml",encoding='utf-8') as f:
value = yaml.load(stream=f, Loader=yaml.FullLoader)
return value[one_node][two_node]
#读取extract.yml文件
def read_extract_file(one_node):
with open(get_object_path()+"\\extract.yml",encoding='utf-8') as f:
with open(get_object_path()+os.path.sep+"extract.yml",encoding='utf-8') as f:
value = yaml.load(stream=f, Loader=yaml.FullLoader)
return value[one_node]
#写入extract.yml文件a
def write_extract_file(data):
with open(get_object_path()+"\\extract.yml",encoding='utf-8',mode='a') as f:
with open(get_object_path()+os.path.sep+"extract.yml",encoding='utf-8',mode='a') as f:
yaml.dump(data=data, stream=f,allow_unicode=True )
#清空extract.yml文件a
def clear_extract_file():
with open(get_object_path()+"\\extract.yml",encoding='utf-8',mode='w') as f:
with open(get_object_path()+os.path.sep+"extract.yml",encoding='utf-8',mode='w') as f:
f.truncate()
if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment