Exemplo n.º 1
0
    def setup(self):
        # handle credentials
        uuid = None
        uuidlist = None
        credentials = self._load_credentials_store()
        if credentials is not None:
            uuid = credentials['uuid']
            uuidlist = credentials['list']
        else:
            login = self.settings.get("login", "")
            password = self.settings.get("password", "")
            if login:
                uuid, uuidlist = BringApi.login(login, password)

        if uuid is None:
            self.speak_dialog('bring.error.connect')
            self.log.warning(
                "Loading credentials failed, please check your credentials")
            return

        self.log.info("Loaded credentials")
        self._bring = BringApi(uuid, uuidlist)
        if self._bring is None:
            self.speak_dialog('bring.error.connect')
            self.log.warning("API connect failed")

        self.log.info("API connect succeeded")
        return
Exemplo n.º 2
0
    def bring(self):
        if not self._bring:
            if not self._uuid or not self._uuidlist:
                self._uuid, self._uuidlist = BringApi.login(
                    self.getConfig('bringEmail'),
                    self.getConfig('bringPassword'))
                self.updateConfig('uuid', self._uuid)
                self.updateConfig('listUuid', self._uuidlist)

            self._bring = BringApi(self._uuid, self._uuidlist)
        return self._bring
	def bring(self):
		# check if the credentials have changed. if so, get new login.
		if not self._bring:
			if not self._uuid or not self._uuidlist:
				self.logInfo('New Login required using mail and password')
				self._uuid, self._uuidlist = BringApi.login(self.getConfig('bringEmail'), self.getConfig('bringPassword'))
				self.updateConfig('uuid', self._uuid)
				self.updateConfig('listUuid', self._uuidlist)

			self.logInfo(f'Getting new instance of Bring! with uuid {self._uuid}, default list {self._uuidlist} and custom list {self._overwriteUuidlist}')

			if self._overwriteUuidlist:
				self._bring = BringApi(self._uuid, self._overwriteUuidlist)
			else:
				self._bring = BringApi(self._uuid, self._uuidlist)

			itemlist = ", ".join([f'{item["name"]} ({item["listUuid"]})' for item in self._bring.load_lists().json()["lists"]])
			self.logInfo(f'Available Bring! lists are {itemlist}. Currently using {self._bring.bringListUUID}')

		return self._bring