def login(): global cookie if cookie == '': data = do_curl(config['login_url'], username=config['user'], password=config['password']) data = parse_json(str(data)) cookie = data['session_name'] + "=" + data['sessid'] return cookie
def civicrm_api_raw(entity, action, **kw): params = { "entity": entity, "action": action, "version": 3, "key": config["key"], "api_key": config["api_key"], "json": 1, } args = dict(kw, **params) if "_return" in args: args["return"] = args.pop("_return") data = do_curl(config["path"], **args) return data
def civicrm_api_raw(entity, action, **kw): params = { 'entity': entity, 'action': action, 'version': 3, 'key': config['key'], 'api_key': config['api_key'], 'json': 1, } args = dict(kw, **params) if '_return' in args: args['return'] = args.pop('_return') data = do_curl(config['path'], **args) return data
def send_pushover(user, event, message, **kw): if not user in config['pushover']['user_keys']: return if not 'app' in kw: kw['app'] = config['default_app'] token = config['pushover']['tokens'][kw['app']] args = { 'token': token, 'user': config['pushover']['user_keys'][user], 'message': message, } args = dict(args, **kw) result = do_curl(config['pushover']['path'], **args) print "Sent %s Pushover notification to %s" % (event, user) return simplejson.loads(str(result))
def send_pushover(user, event, message, **kw): if not user in config['pushover']['user_keys']: return if not 'app' in kw: kw['app'] = config['default_app'] token = config['pushover']['tokens'][kw['app']] args = { 'token': token, 'user': config['pushover']['user_keys'][user], 'message': message, } args = dict(args, **kw); result = do_curl(config['pushover']['path'], **args) print "Sent %s Pushover notification to %s" % (event, user) return simplejson.loads(str(result));
def get_sites(): cookie = login() sites = do_curl(config['site_index_url'], cookie=cookie) return parse_json(str(sites))
def get_site(site_id): cookie = login() site = do_curl(config['site_url'] % site_id, cookie=cookie) return parse_json(str(site))