From e4cf093b4b77ef4fc64ce71d0dc85c99380d2780 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 14 Oct 2020 13:41:28 +0200 Subject: [PATCH 01/14] test of case when the time mark need to be updated --- tests/test_snapshot.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index 4482e66e..707577af 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -98,6 +98,26 @@ def test_snapshot_post(user: UserClient): assert rate['snapshot']['id'] == snapshot['id'] +@pytest.mark.mvp +def test_snapshot_update_timeupdated(user: UserClient): + """ + Tests for check if one computer have the time mark updated when one component of it is updated + """ + computer1 = file('1-device-with-components.snapshot') + snapshot = snapshot_and_check(user, + computer1, + action_types=(BenchmarkProcessor.t, + RateComputer.t), + perform_second_snapshot=False) + computer2 = file('2-second-device-with-components-of-first.snapshot') + snapshot_and_check(user, computer2, action_types=('Remove', 'RateComputer'), + perform_second_snapshot=False) + # import pdb; pdb.set_trace() + pc1_id = snapshot['device']['id'] + pc1, _ = user.get(res=m.Device, item=pc1_id) + assert pc1['updated'] != snapshot['updated'] + + @pytest.mark.mvp def test_snapshot_component_add_remove(user: UserClient): """Tests adding and removing components and some don't generate HID. From 76806299cd3e7093a08d91f68476e0d8cd8b5ed8 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 16 Oct 2020 15:08:54 +0200 Subject: [PATCH 02/14] update devices when there are a new action --- ereuse_devicehub/resources/action/views.py | 5 +++++ tests/test_action.py | 2 ++ tests/test_snapshot.py | 21 +++++++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/resources/action/views.py b/ereuse_devicehub/resources/action/views.py index ba727dc3..eb975e18 100644 --- a/ereuse_devicehub/resources/action/views.py +++ b/ereuse_devicehub/resources/action/views.py @@ -1,4 +1,5 @@ from distutils.version import StrictVersion +from datetime import datetime from typing import List from uuid import UUID @@ -37,6 +38,8 @@ class ActionView(View): return self.transfer_ownership() Model = db.Model._decl_class_registry.data[json['type']]() action = Model(**a) + for d in action.devices: + d.updated = datetime.now() db.session.add(action) db.session().final_flush() ret = self.schema.jsonify(action) @@ -109,6 +112,8 @@ class ActionView(View): if snapshot.device.hid is None: snapshot.severity = Severity.Warning db.session.add(snapshot) + for action in snapshot.actions: + action.device.updated = datetime.now() db.session().final_flush() ret = self.schema.jsonify(snapshot) # transform it back ret.status_code = 201 diff --git a/tests/test_action.py b/tests/test_action.py index ba99996d..ba095685 100644 --- a/tests/test_action.py +++ b/tests/test_action.py @@ -238,6 +238,8 @@ def test_generic_action(action_model_state: Tuple[models.Action, states.Trading] device, _ = user.get(res=Device, item=snapshot['device']['id']) assert device['actions'][-1]['id'] == action['id'] assert device['physical'] == state.name + # Check if the update of device is changed + assert snapshot['device']['updated'] != device['updated'] @pytest.mark.mvp diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index 707577af..db00d16b 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -99,7 +99,7 @@ def test_snapshot_post(user: UserClient): @pytest.mark.mvp -def test_snapshot_update_timeupdated(user: UserClient): +def test_snapshot_update_timefield_updated(user: UserClient): """ Tests for check if one computer have the time mark updated when one component of it is updated """ @@ -110,9 +110,10 @@ def test_snapshot_update_timeupdated(user: UserClient): RateComputer.t), perform_second_snapshot=False) computer2 = file('2-second-device-with-components-of-first.snapshot') + pc1_id = snapshot['device']['id'] + pc1, _ = user.get(res=m.Device, item=pc1_id) snapshot_and_check(user, computer2, action_types=('Remove', 'RateComputer'), perform_second_snapshot=False) - # import pdb; pdb.set_trace() pc1_id = snapshot['device']['id'] pc1, _ = user.get(res=m.Device, item=pc1_id) assert pc1['updated'] != snapshot['updated'] @@ -144,6 +145,7 @@ def test_snapshot_component_add_remove(user: UserClient): perform_second_snapshot=False) pc1_id = snapshot1['device']['id'] pc1, _ = user.get(res=m.Device, item=pc1_id) + update1_pc1 = pc1['updated'] # Parent contains components assert tuple(c['serialNumber'] for c in pc1['components']) == ('p1c1s', 'p1c2s', 'p1c3s') # Components contain parent @@ -166,6 +168,10 @@ def test_snapshot_component_add_remove(user: UserClient): pc2_id = snapshot2['device']['id'] pc1, _ = user.get(res=m.Device, item=pc1_id) pc2, _ = user.get(res=m.Device, item=pc2_id) + # Check if the update_timestamp is updated + update1_pc2 = pc2['updated'] + update2_pc1 = pc1['updated'] + assert update1_pc1 != update2_pc1 # PC1 assert tuple(c['serialNumber'] for c in pc1['components']) == ('p1c1s', 'p1c3s') assert all(c['parent'] == pc1_id for c in pc1['components']) @@ -188,6 +194,12 @@ def test_snapshot_component_add_remove(user: UserClient): snapshot_and_check(user, s3, ('Remove', 'RateComputer'), perform_second_snapshot=False) pc1, _ = user.get(res=m.Device, item=pc1_id) pc2, _ = user.get(res=m.Device, item=pc2_id) + # Check if the update_timestamp is updated + update2_pc2 = pc2['updated'] + update3_pc1 = pc1['updated'] + assert not update3_pc1 in [update1_pc1, update2_pc1] + assert update1_pc2 != update2_pc2 + # PC1 assert {c['serialNumber'] for c in pc1['components']} == {'p1c2s', 'p1c3s'} assert all(c['parent'] == pc1_id for c in pc1['components']) @@ -228,6 +240,11 @@ def test_snapshot_component_add_remove(user: UserClient): snapshot_and_check(user, s4, ('RateComputer',), perform_second_snapshot=False) pc1, _ = user.get(res=m.Device, item=pc1_id) pc2, _ = user.get(res=m.Device, item=pc2_id) + # Check if the update_timestamp is updated + update3_pc2 = pc2['updated'] + update4_pc1 = pc1['updated'] + assert not update4_pc1 in [update1_pc1, update2_pc1, update3_pc1] + assert update3_pc2 == update2_pc2 # PC 0: p1c3s, p1c4s. PC1: p2c1s assert {c['serialNumber'] for c in pc1['components']} == {'p1c3s', 'p1c4s'} assert all(c['parent'] == pc1_id for c in pc1['components']) From 14d4d0aed0116d0bb4effce0d75c7dddf33da37d Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 16 Oct 2020 15:26:12 +0200 Subject: [PATCH 03/14] fixed view --- ereuse_devicehub/resources/action/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/resources/action/views.py b/ereuse_devicehub/resources/action/views.py index 6bdaa8f8..f96d50c7 100644 --- a/ereuse_devicehub/resources/action/views.py +++ b/ereuse_devicehub/resources/action/views.py @@ -70,8 +70,9 @@ class ActionView(View): return self.transfer_ownership() Model = db.Model._decl_class_registry.data[json['type']]() action = Model(**a) - for d in action.devices: - d.updated = datetime.now() + if hasattr(action, 'devices'): + for d in action.devices: + d.updated = datetime.now() db.session.add(action) db.session().final_flush() ret = self.schema.jsonify(action) From c7abf29706e766ac632b7818ea0da742053bd1e4 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 16 Oct 2020 16:24:48 +0200 Subject: [PATCH 04/14] clean all previus modifications --- ereuse_devicehub/resources/action/views.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ereuse_devicehub/resources/action/views.py b/ereuse_devicehub/resources/action/views.py index f96d50c7..689cb942 100644 --- a/ereuse_devicehub/resources/action/views.py +++ b/ereuse_devicehub/resources/action/views.py @@ -70,9 +70,6 @@ class ActionView(View): return self.transfer_ownership() Model = db.Model._decl_class_registry.data[json['type']]() action = Model(**a) - if hasattr(action, 'devices'): - for d in action.devices: - d.updated = datetime.now() db.session.add(action) db.session().final_flush() ret = self.schema.jsonify(action) @@ -146,8 +143,6 @@ class ActionView(View): if snapshot.device.hid is None: snapshot.severity = Severity.Warning db.session.add(snapshot) - for action in snapshot.actions: - action.device.updated = datetime.now() db.session().final_flush() ret = self.schema.jsonify(snapshot) # transform it back ret.status_code = 201 From ae1ecb59e2642ec18ec905682d0104c000663f20 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 16 Oct 2020 16:25:13 +0200 Subject: [PATCH 05/14] add listener a event --- ereuse_devicehub/resources/models.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ereuse_devicehub/resources/models.py b/ereuse_devicehub/resources/models.py index 721e9258..74e1e6b4 100644 --- a/ereuse_devicehub/resources/models.py +++ b/ereuse_devicehub/resources/models.py @@ -1,4 +1,5 @@ from datetime import datetime, timezone +from flask_sqlalchemy import event from ereuse_devicehub.db import db @@ -34,3 +35,9 @@ class Thing(db.Model): # to be able to use sorted containers self.created = kwargs.get('created', datetime.now(timezone.utc)) super().__init__(**kwargs) + +def on_update_time(mapper, connection, thing_obj): + thing_obj.updated = datetime.now() + +def update_timestamp(thing_obj): + event.listen(thing_obj, 'before_update', on_update_time) From 9a488887f585733eb9b61dd963f553d561947523 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 16 Oct 2020 16:25:46 +0200 Subject: [PATCH 06/14] modify devices models for add listeners --- ereuse_devicehub/resources/device/models.py | 58 ++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 028a8bf6..3eb445d9 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -28,7 +28,7 @@ from teal.resource import url_for_resource from ereuse_devicehub.db import db from ereuse_devicehub.resources.enums import BatteryTechnology, CameraFacing, ComputerChassis, \ DataStorageInterface, DisplayTech, PrinterTechnology, RamFormat, RamInterface, Severity, TransferState -from ereuse_devicehub.resources.models import STR_SM_SIZE, Thing +from ereuse_devicehub.resources.models import STR_SM_SIZE, Thing, update_timestamp from ereuse_devicehub.resources.user.models import User @@ -881,3 +881,59 @@ class Manufacturer(db.Model): 'COPY common.manufacturer FROM STDIN (FORMAT csv)', f ) + + + +update_timestamp(Computer) +update_timestamp(Desktop) +update_timestamp(Laptop) +update_timestamp(Server) +update_timestamp(Monitor) +update_timestamp(ComputerMonitor) +update_timestamp(TelevisionSet) +update_timestamp(Projector) +update_timestamp(Mobile) +update_timestamp(Smartphone) +update_timestamp(Tablet) +update_timestamp(Cellphone) +update_timestamp(Component) +update_timestamp(GraphicCard) +update_timestamp(DataStorage) +update_timestamp(HardDrive) +update_timestamp(SolidStateDrive) +update_timestamp(Motherboard) +update_timestamp(NetworkAdapter) +update_timestamp(Processor) +update_timestamp(RamModule) +update_timestamp(SoundCard) +update_timestamp(Display) +update_timestamp(Battery) +update_timestamp(Camera) +update_timestamp(ComputerAccessory) +update_timestamp(SAI) +update_timestamp(Keyboard) +update_timestamp(Mouse) +update_timestamp(MemoryCardReader) +update_timestamp(Networking) +update_timestamp(Router) +update_timestamp(Switch) +update_timestamp(Hub) +update_timestamp(WirelessAccessPoint) +update_timestamp(Printer) +update_timestamp(LabelPrinter) +update_timestamp(Sound) +update_timestamp(Microphone) +update_timestamp(Video) +update_timestamp(VideoScaler) +update_timestamp(Videoconference) +update_timestamp(Cooking) +update_timestamp(Mixer) +update_timestamp(DIYAndGardening) +update_timestamp(Drill) +update_timestamp(PackOfScrewdrivers) +update_timestamp(Home) +update_timestamp(Dehumidifier) +update_timestamp(Stairs) +update_timestamp(Recreation) +update_timestamp(Bike) +update_timestamp(Racket) From 7313f7cf73f124082560bc3a9546cae1a6f87b87 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 16 Oct 2020 16:26:37 +0200 Subject: [PATCH 07/14] fixed test --- tests/test_snapshot.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index 10ec93d2..ead63703 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -115,13 +115,11 @@ def test_snapshot_update_timefield_updated(user: UserClient): RateComputer.t), perform_second_snapshot=False) computer2 = file('2-second-device-with-components-of-first.snapshot') - pc1_id = snapshot['device']['id'] - pc1, _ = user.get(res=m.Device, item=pc1_id) snapshot_and_check(user, computer2, action_types=('Remove', 'RateComputer'), perform_second_snapshot=False) pc1_id = snapshot['device']['id'] pc1, _ = user.get(res=m.Device, item=pc1_id) - assert pc1['updated'] != snapshot['updated'] + assert pc1['updated'] != snapshot['device']['updated'] @pytest.mark.mvp From 195c5265e4d0df16c3059f4eb46fde21bb973a54 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 16 Oct 2020 16:30:53 +0200 Subject: [PATCH 08/14] document new function --- ereuse_devicehub/resources/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ereuse_devicehub/resources/models.py b/ereuse_devicehub/resources/models.py index 74e1e6b4..d6fafc78 100644 --- a/ereuse_devicehub/resources/models.py +++ b/ereuse_devicehub/resources/models.py @@ -36,8 +36,11 @@ class Thing(db.Model): self.created = kwargs.get('created', datetime.now(timezone.utc)) super().__init__(**kwargs) + def on_update_time(mapper, connection, thing_obj): + """ This function update the stamptime of field updated """ thing_obj.updated = datetime.now() def update_timestamp(thing_obj): + """ This function launch a event than listen like a signal when some object is saved """ event.listen(thing_obj, 'before_update', on_update_time) From e00c3f576c82c96be921c515ed3abdb945862f58 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 16 Oct 2020 16:31:54 +0200 Subject: [PATCH 09/14] document new function --- tests/test_snapshot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index ead63703..c0b56686 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -393,6 +393,7 @@ def test_erase_privacy_standards_endtime_sort(user: UserClient): assert _snapshot1['type'] == _snapshot2['type'] == 'Snapshot' get_snapshot, _ = user.get(res=Action, item=_snapshot2['id']) assert get_snapshot['actions'][0]['endTime'] == '2018-06-01T07:14:00+00:00' + import pdb; pdb.set_trace() assert snapshot == get_snapshot erasure, _ = user.get(res=Action, item=erasure1['id']) assert len(erasure['steps']) == 2 From 3988079b01368c01ecb443cefee29a873d170744 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 16 Oct 2020 16:32:16 +0200 Subject: [PATCH 10/14] drop pdb --- tests/test_snapshot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index c0b56686..ead63703 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -393,7 +393,6 @@ def test_erase_privacy_standards_endtime_sort(user: UserClient): assert _snapshot1['type'] == _snapshot2['type'] == 'Snapshot' get_snapshot, _ = user.get(res=Action, item=_snapshot2['id']) assert get_snapshot['actions'][0]['endTime'] == '2018-06-01T07:14:00+00:00' - import pdb; pdb.set_trace() assert snapshot == get_snapshot erasure, _ = user.get(res=Action, item=erasure1['id']) assert len(erasure['steps']) == 2 From 0c5897a06c463e6293a19ce9e9f2d168ab22c4ad Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 16 Oct 2020 16:42:43 +0200 Subject: [PATCH 11/14] fixed test of devices --- tests/test_device.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_device.py b/tests/test_device.py index 685b08b0..60389d8f 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -53,7 +53,7 @@ def test_device_model(): # Removing a component from pc doesn't delete the component pc.components.remove(net) db.session.commit() - pc = d.Device.query.first() # this is the same as querying for d.Desktop directly + pc = d.Device.query.filter_by(id=pc.id).first() # this is the same as querying for d.Desktop directly assert pc.components == {graphic} network_adapter = d.NetworkAdapter.query.one() assert network_adapter not in pc.components From 1400d292ce61c0b9f57dbc3a6162ee1ecaa4a527 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 27 Oct 2020 21:29:38 +0100 Subject: [PATCH 12/14] refactoring --- ereuse_devicehub/resources/device/models.py | 57 +-------------------- ereuse_devicehub/resources/models.py | 8 +-- 2 files changed, 6 insertions(+), 59 deletions(-) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 3eb445d9..682327bb 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -28,7 +28,7 @@ from teal.resource import url_for_resource from ereuse_devicehub.db import db from ereuse_devicehub.resources.enums import BatteryTechnology, CameraFacing, ComputerChassis, \ DataStorageInterface, DisplayTech, PrinterTechnology, RamFormat, RamInterface, Severity, TransferState -from ereuse_devicehub.resources.models import STR_SM_SIZE, Thing, update_timestamp +from ereuse_devicehub.resources.models import STR_SM_SIZE, Thing, listener_reset_field_updated_in_actual_time from ereuse_devicehub.resources.user.models import User @@ -883,57 +883,4 @@ class Manufacturer(db.Model): ) - -update_timestamp(Computer) -update_timestamp(Desktop) -update_timestamp(Laptop) -update_timestamp(Server) -update_timestamp(Monitor) -update_timestamp(ComputerMonitor) -update_timestamp(TelevisionSet) -update_timestamp(Projector) -update_timestamp(Mobile) -update_timestamp(Smartphone) -update_timestamp(Tablet) -update_timestamp(Cellphone) -update_timestamp(Component) -update_timestamp(GraphicCard) -update_timestamp(DataStorage) -update_timestamp(HardDrive) -update_timestamp(SolidStateDrive) -update_timestamp(Motherboard) -update_timestamp(NetworkAdapter) -update_timestamp(Processor) -update_timestamp(RamModule) -update_timestamp(SoundCard) -update_timestamp(Display) -update_timestamp(Battery) -update_timestamp(Camera) -update_timestamp(ComputerAccessory) -update_timestamp(SAI) -update_timestamp(Keyboard) -update_timestamp(Mouse) -update_timestamp(MemoryCardReader) -update_timestamp(Networking) -update_timestamp(Router) -update_timestamp(Switch) -update_timestamp(Hub) -update_timestamp(WirelessAccessPoint) -update_timestamp(Printer) -update_timestamp(LabelPrinter) -update_timestamp(Sound) -update_timestamp(Microphone) -update_timestamp(Video) -update_timestamp(VideoScaler) -update_timestamp(Videoconference) -update_timestamp(Cooking) -update_timestamp(Mixer) -update_timestamp(DIYAndGardening) -update_timestamp(Drill) -update_timestamp(PackOfScrewdrivers) -update_timestamp(Home) -update_timestamp(Dehumidifier) -update_timestamp(Stairs) -update_timestamp(Recreation) -update_timestamp(Bike) -update_timestamp(Racket) +listener_reset_field_updated_in_actual_time(Device) diff --git a/ereuse_devicehub/resources/models.py b/ereuse_devicehub/resources/models.py index d6fafc78..e079269f 100644 --- a/ereuse_devicehub/resources/models.py +++ b/ereuse_devicehub/resources/models.py @@ -37,10 +37,10 @@ class Thing(db.Model): super().__init__(**kwargs) -def on_update_time(mapper, connection, thing_obj): +def update_object_timestamp(mapper, connection, thing_obj): """ This function update the stamptime of field updated """ - thing_obj.updated = datetime.now() + thing_obj.updated = datetime.now(timezone.utc) -def update_timestamp(thing_obj): +def listener_reset_field_updated_in_actual_time(thing_obj): """ This function launch a event than listen like a signal when some object is saved """ - event.listen(thing_obj, 'before_update', on_update_time) + event.listen(thing_obj, 'before_update', update_object_timestamp, propagate=True) From 954dfa95a1ef8659fcf1a797d13b0f920196f0a2 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 29 Oct 2020 11:59:53 +0100 Subject: [PATCH 13/14] check in test this bug about time in the filename --- tests/test_snapshot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index 42792c2f..4348d408 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -493,6 +493,7 @@ def test_save_snapshot_in_file(app: Devicehub, user: UserClient): snapshot = {'software': '', 'version': '', 'uuid': ''} if files: path_snapshot = os.path.join(tmp_snapshots, files[0]) + assert not "0001-01-01 00:00:00" in path_snapshot with open(path_snapshot) as file_snapshot: snapshot = json.loads(file_snapshot.read()) From b2c258b69929fb12ce2a49a85fcfa0294307c0df Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 29 Oct 2020 12:10:12 +0100 Subject: [PATCH 14/14] fixed mark time correctly in the name file of json --- ereuse_devicehub/resources/action/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ereuse_devicehub/resources/action/views.py b/ereuse_devicehub/resources/action/views.py index 689cb942..de99781c 100644 --- a/ereuse_devicehub/resources/action/views.py +++ b/ereuse_devicehub/resources/action/views.py @@ -32,7 +32,7 @@ def save_json(req_json, tmp_snapshots, user): month = now.month day = now.day hour = now.hour - minutes = now.min + minutes = now.minute name_file = f"{year}-{month}-{day}-{hour}-{minutes}_{user}_{uuid}.json" path_name = os.path.join(tmp_snapshots, name_file)