def modifyPush(self, data): requests.post(self.baseURL.format('pushes/{0}'.format( data.get('iden'))), auth=(self.token, ''), data=json.dumps(data), headers={ 'Content-type': 'application/json', 'Accept': 'text/plain' })
def _urlcall(self, url, params, data, urltype): loglines = [] urldata = '' try: if urltype == "get": urldata = _requests.get(url, params=params, timeout=self.timeout) elif urltype == "post": urldata = _requests.post(url, params=params, data=data, headers=self.headers, timeout=self.timeout) elif urltype == "delete": urldata = _requests.delete(url, params=params, data=data, headers=self.headers, timeout=self.timeout) loglines.append("the url is: " + urldata.url) loglines.append('the params are: ') loglines.append(params) loglines.append('the data are: ') loglines.append(data) except _requests.exceptions.ConnectionError, e: loglines.append('site unreachable at ' + url) loglines.append(e)
def updateDevice(self,device,**kwargs): assert device.ID != None, 'Invalid Device' req = requests.post(self.baseURL.format('devices/{0}'.format(device.ID)),auth=(self.token,''),data=kwargs) data = req.json() if 'error' in data: LOG(data['error']) raise PushbulletException(data['error']) device.name = data.get('nickname',device.name) return True
def addDevice(self,device): if device.ID: return req = requests.post(self.baseURL.format('devices'),auth=(self.token,''),data={'nickname':device.name,'type':'stream'}) data = req.json() if 'error' in data: LOG(data['error']) raise PushbulletException(data['error']) device.ID = data.get('iden') return True
def updateDevice(self, device, **kwargs): assert device.ID != None, 'Invalid Device' req = requests.post(self.baseURL.format('devices/{0}'.format( device.ID)), auth=(self.token, ''), data=kwargs) data = req.json() if 'error' in data: LOG(data['error']) raise PushbulletException(data['error']) device.name = data.get('nickname', device.name) return True
def addDevice(self, device): if device.ID: return req = requests.post(self.baseURL.format('devices'), auth=(self.token, ''), data={ 'nickname': device.name, 'type': 'stream' }) data = req.json() if 'error' in data: LOG(data['error']) raise PushbulletException(data['error']) device.ID = data.get('iden') return True
def _urlcall( self, url, params, data, urltype ): loglines = [] urldata = '' try: if urltype == "get": urldata = _requests.get( url, params=params, timeout=self.timeout ) elif urltype == "post": urldata = _requests.post( url, params=params, data=data, headers=self.headers, timeout=self.timeout ) elif urltype == "delete": urldata = _requests.delete( url, params=params, data=data, headers=self.headers, timeout=self.timeout ) loglines.append( "the url is: " + urldata.url ) loglines.append( 'the params are: ') loglines.append( params ) loglines.append( 'the data are: ') loglines.append( data ) except _requests.exceptions.ConnectionError, e: loglines.append( 'site unreachable at ' + url ) loglines.append( e )
def dismissPush(self,ID): if isinstance(ID,dict): ID = ID.get('iden') requests.post(self.baseURL.format('pushes/{0}'.format(ID)),auth=(self.token,''),data={'dismissed':'true'})
def modifyPush(self,data): requests.post(self.baseURL.format('pushes/{0}'.format(data.get('iden'))),auth=(self.token,''),data=json.dumps(data),headers={'Content-type': 'application/json', 'Accept': 'text/plain'})
def dismissPush(self, ID): if isinstance(ID, dict): ID = ID.get('iden') requests.post(self.baseURL.format('pushes/{0}'.format(ID)), auth=(self.token, ''), data={'dismissed': 'true'})