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
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"
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')
def set_APIKey(key): Settings().set(apikey=key.strip()) print "API key changed!"
def get_clientID(): return Settings().get("clientID")
def set_clientID(client_id): Settings().set(clientID=client_id.strip()) print "Client ID changed!"
def get_APIKey(): return Settings().get("apikey")
def get_host(): return Settings().get("host", _DEFAULTHOST)
def set_host(url): Settings().set(host=url.strip().rstrip("/"))
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!"