예제 #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
예제 #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"
예제 #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')
예제 #4
0
def set_APIKey(key):
    Settings().set(apikey=key.strip())
    print "API key changed!"
예제 #5
0
def get_clientID():
    return Settings().get("clientID")
예제 #6
0
def set_clientID(client_id):
    Settings().set(clientID=client_id.strip())
    print "Client ID changed!"
예제 #7
0
def get_APIKey():
    return Settings().get("apikey")
예제 #8
0
def get_host():
    return Settings().get("host", _DEFAULTHOST)
예제 #9
0
def set_host(url):
    Settings().set(host=url.strip().rstrip("/"))
예제 #10
0
def set_APIKey(key):
    Settings().set(apikey=key.strip())
예제 #11
0
def get_host(trailing_slash=False):
    host = Settings().get("host", _DEFAULTHOST)
    if trailing_slash and not host.endswith('/'):
        host += '/'
    return host
예제 #12
0
def set_host(url):
    Settings().set(host=url.strip().rstrip("/"))
    print "Host URL changed!"