-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_restore_insert.py
37 lines (30 loc) · 1.06 KB
/
test_restore_insert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import json
import platform
import sys
json_file_name = "config.json"
def insert_for_test_restore():
list=[]
list.append("/test_Files_Backup/jewel")
list.append("/test_Files_Backup/jewel2")
list.append("/test_Files_Backup/jewel3")
table_name='jewel_sources'
key=platform.node()
data=list
write_json(table_name, key, data)
table_name='destination'
data2="test_Files_Backup/backup_Location"
write_json(table_name,key, data2)
table_name='restore_destination'
data3="test_Files_Backup/restore_Location"
write_json(table_name,key, data3)
print("done with test_restore_insert.py")
def write_json(table_name, key, value, filename=json_file_name):
with open(filename,'r+') as file:
# First we load existing data into a dict.
file_data = json.load(file)
# Join new_data with file_data inside emp_details
file_data[table_name][key] = value
# Sets file's current position at offset.
file.seek(0)
# convert back to json.
json.dump(file_data, file, indent = 4)