Ejemplo n.º 1
0
 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'
                   })
Ejemplo n.º 2
0
Archivo: url.py Proyecto: roeiba/xbmc
 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)
Ejemplo n.º 3
0
	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
Ejemplo n.º 4
0
	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
Ejemplo n.º 5
0
 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
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
 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 )
Ejemplo n.º 8
0
	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'})
Ejemplo n.º 9
0
	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'})
Ejemplo n.º 10
0
 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'})