diff --git a/ApiManager/__init__.py b/ApiManager/__init__.py index 71d8e10..e69de29 100644 --- a/ApiManager/__init__.py +++ b/ApiManager/__init__.py @@ -1,3 +0,0 @@ -import platform - -separator = '\\' if platform.system() == 'Windows' else '/' \ No newline at end of file diff --git a/ApiManager/utils/operation.py b/ApiManager/utils/operation.py index 2d79280..e86015e 100644 --- a/ApiManager/utils/operation.py +++ b/ApiManager/utils/operation.py @@ -5,7 +5,6 @@ from django.core.exceptions import ObjectDoesNotExist from django.db import DataError -from ApiManager import separator from ApiManager.models import ProjectInfo, ModuleInfo, TestCaseInfo, UserInfo, EnvInfo, TestReports, DebugTalk, \ TestSuite @@ -441,8 +440,8 @@ def add_test_reports(runner, report_name=None): report_name = report_name if report_name else runner.summary['time']['start_datetime'] runner.summary['html_report_name'] = report_name - report_path = os.path.join(os.getcwd(), "reports{}{}.html".format(separator, int(runner.summary['time']['start_at']))) - runner.gen_html_report(html_report_template=os.path.join(os.getcwd(), "templates{}extent_report_template.html".format(separator))) + report_path = os.path.join(os.getcwd(), "reports", "{}.html".format(int(runner.summary['time']['start_at']))) + runner.gen_html_report(html_report_template=os.path.join(os.getcwd(), "templates", "extent_report_template.html")) with open(report_path, encoding='utf-8') as stream: reports = stream.read() diff --git a/ApiManager/views.py b/ApiManager/views.py index b9752f9..29c436f 100644 --- a/ApiManager/views.py +++ b/ApiManager/views.py @@ -11,7 +11,6 @@ from djcelery.models import PeriodicTask from dwebsocket import accept_websocket -from ApiManager import separator from ApiManager.models import ProjectInfo, ModuleInfo, TestCaseInfo, UserInfo, EnvInfo, TestReports, DebugTalk, \ TestSuite from ApiManager.tasks import main_hrun @@ -610,7 +609,7 @@ def upload_file(request): if project_name == '请选择' or module_name == '请选择': return JsonResponse({"status": '项目或模块不能为空'}) - upload_path = sys.path[0] + separator + 'upload' + separator + upload_path = os.path.join(sys.path[0], 'upload') if os.path.exists(upload_path): shutil.rmtree(upload_path) @@ -620,7 +619,7 @@ def upload_file(request): upload_obj = request.FILES.getlist('upload') file_list = [] for i in range(len(upload_obj)): - temp_path = upload_path + upload_obj[i].name + temp_path = os.path.join(upload_path, upload_obj[i].name) file_list.append(temp_path) try: with open(temp_path, 'wb') as data: @@ -661,7 +660,7 @@ def download_report(request, id): shutil.rmtree(os.path.join(os.getcwd(), "reports")) os.makedirs(os.path.join(os.getcwd(), "reports")) - report_path = os.path.join(os.getcwd(), "reports{}{}.html".format(separator, start_at.replace(":", "-"))) + report_path = os.path.join(os.getcwd(), "reports", "{}.html".format(start_at.replace(":", "-"))) with open(report_path, 'w+', encoding='utf-8') as stream: stream.write(reports)