def POST(self, IP_Address, Payload, Timeout=5):
     try:
         r = requests.post('http://%s:80/iWsService' % IP_Address,
                           headers=self.Header,
                           data=Payload,
                           timeout=Timeout)
         # print r.content
         return ET.fromstring(r.content)
         # return ET.fromstring(r.content)
         # PIN, Name, Password, Group, Privilege, Card, PIN2, TZ0, TZ1, TZ2, TZ3 = [], [], [], [], [], [], [], [], [], [], []
         # for row in root.findall('Row'):
         #     PIN2.append (row.find('PIN').text)
         #     Name.append (row.find('Name').text)
         #     Privilege.append (row.find('Privilege').text)
         # #         PIN.append(data.findall('PIN').text)
         # data = [{'PIN' : pin, 'Name' : name, 'Privilege' : privilege} for pin, name, privilege in zip (PIN2, Name, Privilege)]
         # return json.dumps(data)
         # return None
         # if r.content == 'Successfully':
         #     return True
         # else :
         #     return False
     except (requests.exceptions.RequestException, ET.ParseError,
             ValueError, TypeError, IndexError) as err:
         logging.debug(err)
         print 'Fingerprint', err.__class__.__name__
         error = {
             'instansi_id':
             instansi_id.ID_INSTANSI,
             'keterangan':
             'Fingerprint ' + IP_Address + ' ' + err.__class__.__name__
         }
         send_error(error)
         pass
示例#2
0
 def POST(self, URL, Payload, Timeout):
     try:
         r = requests.post(self.URL + URL,
                           headers=self.Header,
                           json=Payload,
                           timeout=Timeout)
         if r.status_code == requests.codes.ok:
             return True
         else:
             return False
     except (requests.exceptions.RequestException, ValueError,
             TypeError) as err:
         logging.debug(err)
         print "Server", err.__class__.__name__
         error = {
             'instansi_id': instansi_id.ID_INSTANSI,
             'keterangan': err.__class__.__name__
         }
         send_error(error)
         pass
示例#3
0
 def GET(self, URL, Timeout):
     try:
         r = requests.get(self.URL + URL,
                          headers=self.Header,
                          timeout=Timeout)
         if r.status_code == requests.codes.ok:
             Data = json.loads(r.content)
             return Data
         else:
             return None
     except (requests.exceptions.RequestException, ValueError,
             TypeError) as err:
         logging.debug(err)
         print "Server", err.__class__.__name__
         error = {
             'instansi_id': instansi_id.ID_INSTANSI,
             'keterangan': err.__class__.__name__
         }
         send_error(error)
         pass
示例#4
0
 def POST(self, URL, Payload, Timeout=10):
     try:
         r = requests.post(self.URL + URL,
                           headers=self.Header,
                           json=Payload,
                           timeout=Timeout)
         if r.status_code == requests.codes.ok and str(
                 r.content) != str('Success'):
             return True
         else:
             return False
     except (requests.exceptions.RequestException, ValueError,
             TypeError) as err:
         # tampil.teks( text1="Server", text2=err.__class__.__name__)
         error = {
             'instansi_id': instansi_id.ID_INSTANSI,
             'keterangan': err.__class__.__name__
         }
         send_error(error)
         logger.error(err)
         pass