using os.path.join instead of format
This commit is contained in:
parent
3b93012584
commit
2a53e1672c
|
@ -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
|
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()))
|
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):
|
if not os.path.isdir(TMP_SNAPSHOTS):
|
||||||
os.system('mkdir -p {}'.format(TMP_SNAPSHOTS))
|
os.system('mkdir -p {}'.format(TMP_SNAPSHOTS))
|
||||||
|
|
|
@ -491,7 +491,7 @@ def test_save_snapshot_in_file():
|
||||||
|
|
||||||
snapshot = {'software': '', 'version': '', 'uuid': ''}
|
snapshot = {'software': '', 'version': '', 'uuid': ''}
|
||||||
if files:
|
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)
|
file_snapshot = open(path_snapshot)
|
||||||
snapshot = json.loads(file_snapshot.read())
|
snapshot = json.loads(file_snapshot.read())
|
||||||
file_snapshot.close()
|
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]
|
files = [x for x in os.listdir(TMP_SNAPSHOTS) if uuid in x]
|
||||||
if files:
|
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)
|
file_snapshot = open(path_snapshot)
|
||||||
snapshot = json.loads(file_snapshot.read())
|
snapshot = json.loads(file_snapshot.read())
|
||||||
file_snapshot.close()
|
file_snapshot.close()
|
||||||
|
|
Reference in a new issue