-
Notifications
You must be signed in to change notification settings - Fork 0
/
object_dump.py
executable file
·67 lines (51 loc) · 1.49 KB
/
object_dump.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
import sys
from nebula import *
result = {
"assets" : [],
"items" : [],
"bins" : [],
"events" : [],
"users" : [],
"cs" : [],
"folders" : [],
"settings" : [],
"views" : [],
"channels" : [],
}
sets = [
["assets", Asset],
["items", Item],
["bins", Bin],
["events", Event],
["users", User]
]
start_time = time.time()
db = DB()
for name, oclass in sets:
print ("exporting {}".format(name))
db.query("SELECT id_object FROM nx_{} ORDER by id_object DESC".format(name))
for id_object, in db.fetchall():
obj = oclass(id_object, db=db)
result[name].append(obj.meta)
db.query("SELECT id_folder, title, color, meta_set, validator FROM nx_folders ")
for row in db.fetchall():
result["folders"].append(row)
db.query("SELECT cs, value, label FROM nx_cs")
for row in db.fetchall():
result["cs"].append(row)
db.query("SELECT key, value FROM nx_settings")
for row in db.fetchall():
result["settings"].append(row)
db.query("SELECT id_view, title, owner, config, position FROM nx_views")
for row in db.fetchall():
result["views"].append(row)
db.query("SELECT id_channel, channel_type, title, config FROM nx_channels")
for row in db.fetchall():
result["channels"].append(row)
if len(sys.argv) > 1:
fname = sys.argv[-1]
else:
fname = "dump.json"
json.dump(result, open(fname, "w"))
logging.goodnews ("Export finished in {:.02f}".format(time.time() - start_time))