195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
if (not os.path.exists(subdir)):
os.mkdir(subdir)
open(subdir+"/.nobackup", "w").close()
# target filename
file = self.dir + "/" + name
# encode as JSON
try:
data = json.dumps(data, indent=(4 if nice else None))
except Exception as e:
log.ERR("JSON encoding failed", e)
return
# .gz or normal file
if gz:
f = gzip.open(file+".gz", "w")
if os.path.exists(file):
|
|
|
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
if (not os.path.exists(subdir)):
os.mkdir(subdir)
open(subdir+"/.nobackup", "w").close()
# target filename
file = self.dir + "/" + name
# encode as JSON
try:
data = json.dumps(data, indent=(4 if nice else None), sort_keys=True)
except Exception as e:
log.ERR("JSON encoding failed", e)
return
# .gz or normal file
if gz:
f = gzip.open(file+".gz", "w")
if os.path.exists(file):
|