processScan(<% import sys import saturn import Cookie import string import commands #req.headers_out.add('Content-type', 'application/json') req.content_type = 'application/json' req.headers_out['Access-Control-Allow-Origin'] = 'https://app.kitcheck.com' fldstorage = util.FieldStorage(req) command = fldstorage['command'] cmdchannel = saturn.Command() try: cookies = Cookie.get_cookies(req) login = cookies['login'] pwd = cookies['pwd'] login=str(cookies['login']).split("=")[1] if (login.startswith('guest')): # logout of the reader, making us 'guest' strcommand = "reader.logout()" else: # use the login/pwd to log into the reader. strcommand = "reader.login("+str(cookies['login'])+","+str(cookies['pwd'])+")" response = cmdchannel.rawsendcommand(strcommand) except: # login failed, try the command anyway. try: if (fldstorage.get('purge','No') == 'Yes'): cmdchannel.rawsendcommand('tag.db.purge()') if (fldstorage.get('fields', 'None') != 'None' ): cmdchannel.rawsendcommand('tag.reporting.taglist_fields=' + fldstorage.get('fields','tag_id').replace(',',' ')) data = cmdchannel.rawsendcommand(command) # START JSON PARSE new_response = data.replace('(', '{') new_response = new_response.replace('ok','[') new_response = new_response.replace(')', '}') new_response = new_response.replace(',', '\",\"') new_response = new_response.replace('=', '\" : \"') new_response = new_response.replace('{','{\"') new_response = new_response.replace('}', '\"},') new_response = new_response.rstrip(',') new_response = new_response.replace('\" ','\"') new_response = new_response + ']' # END JSON PARSE req.write(new_response) cmdchannel.close() except: req.write("Error") else: try: if (fldstorage.get('purge','No') == 'Yes'): cmdchannel.rawsendcommand('tag.db.purge()') if (fldstorage.get('fields', 'None') != 'None' ): cmdchannel.rawsendcommand('tag.reporting.taglist_fields=' + fldstorage.get('fields','tag_id').replace(',',' ')) data = cmdchannel.rawsendcommand(command) # START JSON PARSE new_response = data.replace('(', '{') new_response = new_response.replace('ok','[') new_response = new_response.replace(')', '}') new_response = new_response.replace(',', '\",\"') new_response = new_response.replace('=', '\" : \"') new_response = new_response.replace('{','{\"') new_response = new_response.replace('}', '\"},') new_response = new_response.rstrip(',') new_response = new_response.replace('\" ','\"') new_response = new_response + ']' # END JSON PARSE req.write(new_response) cmdchannel.close() except: req.write("Error") %>);