Ejemplo n.º 1
0
 def getDeviceTags(self, registrationId):
     if registrationId.strip() == '':
         return {'status': -1, 'error': 'registrationId is null'}
     path = '%s%s%s' % (self.deviceUrl, '/tags/', registrationId)
     req = tools().web_get(path, '')
     tags = req.get("tags")
     return tags
Ejemplo n.º 2
0
 def cleanDeviceTags(self, registrationId):
     if registrationId.strip() == '':
         return {'status': -1, 'error': 'registrationId is null'}
     path = '%s%s' % (self.deviceUrl, '/tags')
     jsondata = {'registrationId': registrationId, "opType": 3}
     req = tools().web_post(path, jsondata)
     error = req.get("error")
     if error is None or error.strip() == '':
         return json.dumps({'status': 200})
     else:
         return req
Ejemplo n.º 3
0
 def setDeviceAlias(self, registrationId, alias):
     if registrationId.strip() == '':
         return {'status': -1, 'error': 'registrationId is null'}
     path = '%s%s' % (self.deviceUrl, '/alias')
     jsondata = {'alias': alias, 'registrationId': registrationId}
     req = tools().web_post(path, jsondata)
     error = req.get("error")
     if error is None or error.strip() == '':
         return json.dumps({'status': 200})
     else:
         return req
Ejemplo n.º 4
0
 def sendPush(self, pushwork):
     if pushwork is None:
         return {'status': -1, 'error': 'pushwork is null'}
     appkey = pushwork['appkey']
     if appkey is None or appkey.strip() == '':
         return {'status': -1, 'error': 'appkey is null'}
     target = pushwork['target']
     if target is None:
         return {'status': -1, 'error': 'target is null'}
     type = pushwork['type']
     if type is None:
         return {'status': -1, 'error': 'type is null'}
     content = pushwork['content']
     if content is None:
         return {'status': -1, 'error': 'content is null'}
     path = '%s%s' % (self.pushUrl, "/v2/push")
     result = tools().web_post(path, pushwork)
     return result
Ejemplo n.º 5
0
 def getStatsByBatchId(self, batchId):
     if batchId.strip() == '':
         return {'status': -1, 'error': 'batchId is null'}
     path = '%s%s%s' % (self.statsUrl, "/stats/id/", batchId)
     result = tools().web_get(path, '')
     return result
Ejemplo n.º 6
0
 def getStatsByWorkno(self, workno):
     if workno.strip() == '':
         return {'status': -1, 'error': 'workno is null'}
     path = '%s%s%s' % (self.statsUrl, "/stats/workno/", workno)
     result = tools().web_get(path, '')
     return result