using os.path.join instead of format

This commit is contained in:
Cayo Puigdefabregas 2020-10-09 20:29:02 +02:00
parent 3b93012584
commit 2a53e1672c
2 changed files with 3 additions and 3 deletions

View File

@ -30,7 +30,7 @@ def save_json(req_json):
The file need to be saved with one name format with the stamptime and uuid joins
"""
name_file = "{uuid}_{time}.json".format(uuid=req_json.get('uuid', ''), time=int(time()))
path_name = "{tmp}/{file}".format(tmp=TMP_SNAPSHOTS, file=name_file)
path_name = os.path.join(tmp=TMP_SNAPSHOTS, file=name_file)
if not os.path.isdir(TMP_SNAPSHOTS):
os.system('mkdir -p {}'.format(TMP_SNAPSHOTS))

View File

@ -491,7 +491,7 @@ def test_save_snapshot_in_file():
snapshot = {'software': '', 'version': '', 'uuid': ''}
if files:
path_snapshot = "{dir}/{file}".format(dir=TMP_SNAPSHOTS, file=files[0])
path_snapshot = os.path.join(dir=TMP_SNAPSHOTS, file=files[0])
file_snapshot = open(path_snapshot)
snapshot = json.loads(file_snapshot.read())
file_snapshot.close()
@ -514,7 +514,7 @@ def test_backup_snapshot_with_errors(user: UserClient):
files = [x for x in os.listdir(TMP_SNAPSHOTS) if uuid in x]
if files:
path_snapshot = "{dir}/{file}".format(dir=TMP_SNAPSHOTS, file=files[0])
path_snapshot = os.path.join(dir=TMP_SNAPSHOTS, file=files[0])
file_snapshot = open(path_snapshot)
snapshot = json.loads(file_snapshot.read())
file_snapshot.close()