Skip to content
This repository was archived by the owner on Jul 11, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ApiManager/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
import platform

separator = '\\' if platform.system() == 'Windows' else '/'
5 changes: 2 additions & 3 deletions ApiManager/utils/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
7 changes: 3 additions & 4 deletions ApiManager/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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)

Expand Down