def get_current_deployments(key = 'sentiment-analysis'):
res = requests.get(CAMUNDA + "deployment")
- return [proc for proc in res.json() if proc['name'] == key]
+ #return [proc for proc in res.json() if proc['name'] == key]
+ return res.json()
def cleanup_old_deployments(key='sentiment-analysis'):
print ("Cleaning up old deployments")
else:
print ("Error cleaning old deployment {}: Code: {}".format(deployment['id'], res.status_code))
-def create_deployment(initial=False):
- files = [
+def create_deployment(cleanup=False):
+ parameters = [
("deployment-name", "sentiment-analysis"),
+ #("enable-duplicate-filtering", "true"),
+ #("deploy-changed-only", "true"),
("file1", open("sentiment-analysis.bpmn")),
("file2", open("forms/input-terms.html")),
("file3", open("forms/download-pdf.html")),
]
- if not initial:
+ if cleanup:
cleanup_old_deployments()
- res = requests.post(CAMUNDA + "deployment/create", files=files)
+ res = requests.post(CAMUNDA + "deployment/create", files=parameters)
if (res.status_code == 200):
print ("Successfully deployed Sentiment Analysis")
else:
def submit_terms(terms=[]):
termlist = [{'term': term} for term in terms]
# submit to camunda
- pass
+ params = {
+ 'variables': {
+ 'terms': {
+ 'value': json.dumps(termlist),
+ 'type': "json",
+ 'valueInfo': {
+ 'serializationDataFormat': "application/json",
+ }
+ }
+ }
+ }
+ res = requests.post(CAMUNDA + "process-definition/key/sentiment-analysis/start", json=params)
+ if (res.status_code == 200):
+ print ("Successfully started Sentiment Analysis")
+ else:
+ from pprint import pprint
+ pprint ("Status Code: {}".format(res.status_code))
+ try:
+ pprint(res.json())
+ except:
+ pprint(res.content)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--deploy', dest='deploy', default=True, action='store_false', help="Do deployment step")
- parser.add_argument('--initial', dest='initial', default=False, action='store_true', help="Initial deploy does not need cleanup")
+ parser.add_argument('--cleanup', dest='cleanup', default=True, action='store_false', help="Initial deploy needs cleanup")
parser.add_argument('--autoclick', dest='autoclick', type=int, nargs=1, default=0, help="How many steps to autoclick")
args = parser.parse_args()
if args.deploy:
# initialize camunda process
- create_deployment(initial=args.initial)
+ create_deployment(cleanup=args.cleanup)
- if args.autoclick >= 1:
+ if args.autoclick[0] >= 1:
# start clicking
submit_terms(["voting", "phonegate", "35c3"])