def json_print_end(ret, error=False, finished=False): if error: ret['error'] = True ret['finished'] = True if finished: ret['finished'] = True common.print_html(pytan.utils.jsonify(ret)) sys.exit()
# get the form submission form = cgi.FieldStorage() formdict = common.formtodict(form) action_id = formdict.get('action_id', None) computer_id = formdict.get('computer_id', None) if not action_id or not computer_id: status = "ERROR: Missing action_id or computer_id!" else: # connect to Tanium handler = pytan.Handler( username=config['tanium_username'], password=config['tanium_password'], host=config['tanium_host'], ) # this logic assumes only one system should be being deployed to, # more servers is more complicated action_obj = handler.get('action', id=action_id)[0] rd = handler.get_result_data(action_obj, True) if not rd.rows: status = "Waiting to download." else: status = rd.rows[0]['Action Statuses'][0].split(':')[1] status = json.dumps({'status': status}) common.print_html(status)
server=server, application=application, guid=guid, logged_in_user=logged_in_user, deploy_ret=deploy_ret, next_path=next_path, ) return j_render def unsupported(self): # TODO: THROW ERROR PAGE return 'unsupported path' # get the form submission form = cgi.FieldStorage() # common.print_html(form) # connect to Tanium handler = pytan.Handler( username=config['tanium_username'], password=config['tanium_password'], host=config['tanium_host'], ) # instantiate our Paths class, passing in form and handler paths = Paths(form, handler) # TODO: TRY/EXCEPT THROW ERROR PAGE common.print_html(paths.path_return)
def json_print_end(x): common.print_html(pytan.utils.jsonify(x)) sys.exit()