first commit
This commit is contained in:
commit
cd1e91bb99
287 changed files with 86425 additions and 0 deletions
30
rasta_exp/utils/couch_to_dir.py
Executable file
30
rasta_exp/utils/couch_to_dir.py
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
import couchdb
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
import configparser
|
||||
_config = configparser.ConfigParser()
|
||||
_config.read("settings.ini")
|
||||
_cfg = _config["Couch"]
|
||||
couch_srv = couchdb.Server(f"http://{_cfg.get('user')}:{_cfg.get('password')}@{_cfg.get('host')}:{_cfg.getint('port')}/")
|
||||
|
||||
|
||||
db_name = sys.argv[1]
|
||||
dir_name = sys.argv[2]
|
||||
|
||||
couch_db = couch_srv['rasta-' + db_name]
|
||||
|
||||
if os.path.isdir(dir_name):
|
||||
raise Exception(f"Path {dir_name} already exists. Aborting")
|
||||
|
||||
os.makedirs(dir_name)
|
||||
|
||||
for uid in couch_db:
|
||||
(sha, task) = uid.split('_-_')
|
||||
report = couch_db[uid]
|
||||
with open(os.path.join(dir_name, uid), 'w') as f_out:
|
||||
json.dump(report, f_out)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue