Beispiel #1
0
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
Beispiel #2
0
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
Beispiel #3
0
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
Beispiel #4
0
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
Beispiel #5
0
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))
Beispiel #6
0
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));
Beispiel #7
0
def get_sites():
  cookie = login()
  sites = do_curl(config['site_index_url'], cookie=cookie)
  return parse_json(str(sites))
  
Beispiel #8
0
def get_site(site_id):
  cookie = login()
  site = do_curl(config['site_url'] % site_id, cookie=cookie)
  return parse_json(str(site))
Beispiel #9
0
def get_sites():
    cookie = login()
    sites = do_curl(config['site_index_url'], cookie=cookie)
    return parse_json(str(sites))
Beispiel #10
0
def get_site(site_id):
    cookie = login()
    site = do_curl(config['site_url'] % site_id, cookie=cookie)
    return parse_json(str(site))