-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_transcript.py
More file actions
37 lines (28 loc) · 863 Bytes
/
run_transcript.py
File metadata and controls
37 lines (28 loc) · 863 Bytes
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
#! /usr/bin/env python
import sys
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "apella_app.settings")
import json
import django
from collections import OrderedDict
django.setup()
from django.core import management
reload(sys)
sys.setdefaultencoding('utf8')
def run_command(command, input=None):
args = []
options = []
if input:
for key in input:
if key.startswith('arg'):
args.append(str(input[key]))
else:
options.append((key, str(input[key])))
management.call_command(command, *args, **dict(options))
with open(sys.argv[1]) as jdata:
data = json.load(jdata, object_pairs_hook=OrderedDict)
for a in data["actions"]:
try:
run_command(command=str(a["action"]), input=a["input"])
except KeyError:
run_command(command=str(a["action"]))