Exemple #1
0
def load_keyfiles():
    s = Settings()
    raw_k = s.get('keyfiles', {})
    keyfiles = []
    for name in raw_k:
        try:
            k = Keyfile.load(raw_k[name])
            k.name = name
            keyfiles.append(k)
        except:
            pass
    return keyfiles
Exemple #2
0
def set_APIKey(key=""):
    if key:
        Settings().set(api_key=key.strip())
        print "API key changed!"
    else:
        data = get_data()
        success = data['success']
        if success:
            Settings().set(api_key=data['api_key'])
            print "API key grabbed from CouchPotato"
        else:
            print "CouchPotato is password protected. Enter API key manually"
Exemple #3
0
def create(name, keyfile_path=None, database_path=None, length=Keyfile.LENGTH, characters=Keyfile.CHARACTERS):
    try:
        if keyfile_path is None:
            keyfile_path = '%s.pkf' % name
        if database_path is None:
            database_path = '%s.pdb' % name
        keyfile = Keyfile.create(
            keyfile_path,
            database_path,
            length=length,
            characters=characters)
        Database.create(keyfile)
        s = Settings()
        keyfiles = s.get('keyfiles', {})
        keyfiles[name] = keyfile.path
        s.set(keyfiles=keyfiles)
        notify('Created the keyfile', 'and initialised a database')
    except:
        notify('Error', 'Could not create the keyfile')
Exemple #4
0
def set_APIKey(key):
    Settings().set(apikey=key.strip())
    print "API key changed!"
Exemple #5
0
def get_clientID():
    return Settings().get("clientID")
Exemple #6
0
def set_clientID(client_id):
    Settings().set(clientID=client_id.strip())
    print "Client ID changed!"
Exemple #7
0
def get_APIKey():
    return Settings().get("apikey")
Exemple #8
0
def get_host():
    return Settings().get("host", _DEFAULTHOST)
Exemple #9
0
def set_host(url):
    Settings().set(host=url.strip().rstrip("/"))
Exemple #10
0
def set_APIKey(key):
    Settings().set(apikey=key.strip())
def get_host(trailing_slash=False):
    host = Settings().get("host", _DEFAULTHOST)
    if trailing_slash and not host.endswith('/'):
        host += '/'
    return host
def set_host(url):
    Settings().set(host=url.strip().rstrip("/"))
    print "Host URL changed!"