Compare commits
2 Commits
f874ed1206
...
7dbc4ae55c
Author | SHA1 | Date | |
---|---|---|---|
7dbc4ae55c | |||
401572996d |
15
confdump.py
15
confdump.py
@ -23,6 +23,7 @@ import MySQLdb as mysql
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
|
import civicrmapi4
|
||||||
from civicrmapi4.civicrmapi4 import APIv4
|
from civicrmapi4.civicrmapi4 import APIv4
|
||||||
|
|
||||||
import phpserialize
|
import phpserialize
|
||||||
@ -222,6 +223,16 @@ def parse_arguments() -> argparse.Namespace:
|
|||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def wrap_api_get(api, obj, args=None):
|
||||||
|
if args is None:
|
||||||
|
args = []
|
||||||
|
try:
|
||||||
|
return api.get(obj, args)
|
||||||
|
except civicrmapi4.civicrmapi4.CallFailed:
|
||||||
|
logging.error("Could not fetch {}".format(obj))
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
@ -261,14 +272,14 @@ def main() -> int:
|
|||||||
|
|
||||||
for table in DUMP_TRIVIAL:
|
for table in DUMP_TRIVIAL:
|
||||||
output = args.output / (table + ".json")
|
output = args.output / (table + ".json")
|
||||||
data = api.get(table)
|
data = wrap_api_get(api, table)
|
||||||
if data:
|
if data:
|
||||||
print("dumping", table)
|
print("dumping", table)
|
||||||
with output.open("w") as of:
|
with output.open("w") as of:
|
||||||
of.write(json.dumps(data))
|
of.write(json.dumps(data))
|
||||||
# dump org contacts
|
# dump org contacts
|
||||||
output = args.output / ("Contact.json")
|
output = args.output / ("Contact.json")
|
||||||
data = api.get("Contact", where=[["contact_sub_type", "CONTAINS", "Political_Party"]])
|
data = wrap_api_get(api, "Contact", where=[["contact_sub_type", "CONTAINS", "Political_Party"]])
|
||||||
if data:
|
if data:
|
||||||
print("dumping parties")
|
print("dumping parties")
|
||||||
with output.open("w") as of:
|
with output.open("w") as of:
|
||||||
|
Loading…
Reference in New Issue
Block a user