class JsonTest(unittest.TestCase): def setUp(self): self.lexer = JsonLexer() def testBasic(self): fragment = u'{"foo": "bar", "foo2": [1, 2, 3]}\n' tokens = [ (Token.Punctuation, u'{'), (Token.Name.Tag, u'"foo"'), (Token.Punctuation, u':'), (Token.Text, u' '), (Token.Literal.String.Double, u'"bar"'), (Token.Punctuation, u','), (Token.Text, u' '), (Token.Name.Tag, u'"foo2"'), (Token.Punctuation, u':'), (Token.Text, u' '), (Token.Punctuation, u'['), (Token.Literal.Number.Integer, u'1'), (Token.Punctuation, u','), (Token.Text, u' '), (Token.Literal.Number.Integer, u'2'), (Token.Punctuation, u','), (Token.Text, u' '), (Token.Literal.Number.Integer, u'3'), (Token.Punctuation, u']'), (Token.Punctuation, u'}'), (Token.Text, u'\n'), ] self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
def jinja_pygments_formatter(data): formatter = HtmlFormatter(cssclass='codehilite') if isinstance(data, dict) or isinstance(data, list): data = jsonutils.dumps(data, indent=4, sort_keys=True) lexer = JsonLexer() elif six.string_types or six.text_type: try: data = jsonutils.dumps(jsonutils.loads(data), indent=4, sort_keys=True) lexer = JsonLexer() except (ValueError, TypeError): lexer = TextLexer() else: lexer = TextLexer() lexer.stripall = True return highlight(Markup(data).unescape(), lexer, formatter)
print(json.dumps(search)) if args.stats: get_stats(search) elif not args.raw and not args.phonebook: quick_search_results(ix, search, int(args.limit)) elif not args.raw and args.phonebook: if args.emails: print() pb_search_results_emails(ix, search) else: print() pb_search_results(ix, search) if args.download: fname = args.download + ".bin" if args.name: fname = args.name if(ix.FILE_READ(args.download, filename=fname)): print(colored(f"[{rightnow()}] Successfully downloaded the file '{fname}'.\n", 'green')) else: print(colored(f"[{rightnow()}] Failed to download item {args.download}.\n", 'red')) if args.capabilities: print(colored(f"[{rightnow()}] Getting your API capabilities.\n", 'green')) capabilities = ix.GET_CAPABILITIES() print(highlight(json.dumps(capabilities, indent=4), JsonLexer(), TerminalFormatter()))
f = open(file, "r") for line in f: requests.packages.urllib3.disable_warnings() try: line = line.rstrip("\n") http = "http://" + line https = "https://" + line r1 = requests.get(http, timeout=2) r2 = requests.get(https, verify=False, timeout=2) r1h = dict(r1.headers) r2h = dict(r2.headers) dict1 = json.dumps(r1h, indent=4) dict2 = json.dumps(r2h, indent=4) print("\n") print("-" * 50) print("\n") print("[*] IP: " + line) print("[*] HTTP Response Headers") print("\n") print(highlight(dict1, JsonLexer(), TerminalFormatter())) print("\n") print("[*] HTTPS Response Headers") print("\n") print(highlight(dict2, JsonLexer(), TerminalFormatter())) print("\n\n") except requests.exceptions.Timeout: print("[!] Request Timed Out") pass else: print("[!] Error! Must Input File Parameter")
def highlight_json(json_data): return highlight(json_data, JsonLexer(indent=2), Terminal256Formatter(bg="dark"))
def pprint_dict(_dict): json_str = json.dumps(i, indent=4) print(highlight(json_str, JsonLexer(), TerminalFormatter()))
for textfield in [ 'rawText', 'strippedText', 'cleanText', 'header', 'footer' ]: try: whoisRecord.pop(textfield) except: pass for subfield in whoisRecord.keys(): for textfield in [ 'rawText', 'strippedText', 'cleanText', 'header', 'footer' ]: try: whoisRecord[subfield].pop(textfield) except: pass json_str = json.dumps(whoisRecord, indent=1, sort_keys=False) if ARGS.history: print("Historic record no. %d of %d for %s:\n------------\n" % (recordno, recordCount, ARGS.domainName)) if ARGS.text: raw_str = "" dictstr(whoisRecord, 0) print(raw_str) elif ARGS.nocolor or sys.platform in {'win32', 'win64'}: print(json_str) else: print(highlight(json_str, JsonLexer(), TerminalFormatter())) exit(0)
def pretty_json(value): return highlight(json.dumps(value, indent=4), JsonLexer(), HtmlFormatter())
def pprint_json(dics): json_str = json.dumps(dics, sort_keys=True, indent=2) print(highlight(to_unicode(json_str), JsonLexer(), TerminalFormatter()))
if args.emails: print() pb_search_results_emails(ix, search) else: print() pb_search_results(ix, search) if args.download: fname = args.download + ".bin" if args.name: fname = args.name if (ix.FILE_READ(args.download, filename=fname)): print( colored( f"[{rightnow()}] Successfully downloaded the file '{fname}'.\n", 'green')) else: print( colored( f"[{rightnow()}] Failed to download item {args.download}.\n", 'red')) if args.capabilities: print( colored(f"[{rightnow()}] Getting your API capabilities.\n", 'green')) capabilities = ix.GET_CAPABILITIES() print( highlight(json.dumps(capabilities, indent=4), JsonLexer(), TerminalFormatter()))
def lexer_json(): yield JsonLexer()
def PygmentsPrint(dict_obj): json_obj = json.dumps(dict_obj, sort_keys=True, indent=4) print(highlight(json_obj, JsonLexer(), TerminalFormatter()))
def pretty_print(string): print(highlight(string, JsonLexer(), TerminalFormatter()))
from prompt_toolkit.styles.pygments import style_from_pygments_cls from prompt_toolkit.lexers import PygmentsLexer from prompt_toolkit.shortcuts import PromptSession, print_formatted_text from prompt_toolkit.history import FileHistory from prompt_toolkit.formatted_text import HTML, PygmentsTokens from prompt_toolkit.key_binding import KeyBindings from sql_mojo_parser import yacc import sql_mojo.sql as sql import sql_mojo.backends as backends from sql_mojo.pager import pager from tabulate import tabulate json_lexer = JsonLexer() style = style_from_pygments_cls(get_style_by_name("monokai")) def tabularize(list_of_dicts): if not list_of_dicts: return [] header = list(list_of_dicts[0].keys()) def row_iterator(): for row in list_of_dicts: yield [row[key] for key in header] return row_iterator(), header
import json from pygments import highlight from pygments.lexers import JsonLexer from pygments.formatters import HtmlFormatter from django.contrib import admin from django.utils.safestring import mark_safe from django.template.defaultfilters import truncatechars from drflog.models import Entry STYLE = 'friendly' HTML_FORMATTER = HtmlFormatter(style=STYLE) JSON_LEXER = JsonLexer() class InputFilter(admin.SimpleListFilter): template = 'admin/input_filter.html' def lookups(self, request, model_admin): # Dummy, required to show the filter. return ((), ) def choices(self, changelist): # Grab only the "all" option. all_choice = next(super().choices(changelist)) all_choice['query_parts'] = (( k, v) for k, v in changelist.get_filters_params().items() if k != self.parameter_name) yield all_choice class UserFilter(InputFilter):
def prettyPrintJson(d_dict): print(highlight(json.dumps(d_dict, indent=4, sort_keys=True, default=datetime_converter), JsonLexer(), TerminalFormatter()))
# additional files can be used with {% include "file" %} dirs = [ os.getcwd(), os.path.dirname(os.path.realpath(__file__)) + "/../top" ] loader = jinja2.FileSystemLoader(dirs) env = jinja2.Environment(loader=loader) i = env.from_string(i).render() # render jinja2 # i = jinja2.Template(i).render() # render jinja2 d = json.loads(i) if "mcloop" in d or "version" in d: validate_input(d) if args.alwaysjson: if pygments: i = highlight(out, JsonLexer(), formatter()) print(i) else: out = yaml.safe_dump(d, indent=args.indent, allow_unicode=True) if pygments: out = highlight(out, YamlLexer(), formatter()) print(out) except json.decoder.JSONDecodeError: try: # ... to read yaml d = yaml.safe_load(i) # plain load was deprecated in PyYAML if "mcloop" in d or "version" in d: validate_input(d) out = json.dumps(d, indent=args.indent) if pygments: out = highlight(out, JsonLexer(), formatter()) print(out)
def _get_pretty_json(self, data): to_prettify = json.dumps(data, indent=4) formatter = HtmlFormatter(style="colorful") highlighted = highlight(to_prettify, JsonLexer(), formatter) style = "<style>{}</style><br>".format(formatter.get_style_defs()) return mark_safe(style + highlighted)
def show(self): j = json.dumps(dict(self), indent=2, sort_keys=True) print(highlight(j, JsonLexer(), TerminalFormatter()))
def json_formatter(obj): return highlight(json_dumps(obj), JsonLexer(), Terminal256Formatter())
def prettyPrint(parsed_json): json_str = json.dumps(parsed_json, indent=4, sort_keys=True, ensure_ascii=False) print(highlight(json_str, JsonLexer(), TerminalFormatter()))
def colorize(self, json_data): return highlight(json_data, JsonLexer(indent=2), Terminal256Formatter(bg="dark"))
def delete(fsid, url, head): url = url + '/' + fsid req = requests.delete(url, headers=head) details = json.dumps(req.json(), indent=4) print('Deleting ' + args.mountpoint[0]) print(highlight(details, JsonLexer(), TerminalFormatter()))
def setUp(self): self.lexer = JsonLexer()
def main(data=None, query='_', initialize=None, version_info=None, helpme=None, compact=None, nulls=None, raw=None, lines=None, mono=None, schema=None): # break on ctrl-c keyboard interrupt signal.signal(signal.SIGINT, ctrlc) # break on pipe error. need try/except for windows compatibility try: signal.signal(signal.SIGPIPE, signal.SIG_DFL) except AttributeError: pass commandline = False if data is None: commandline = True data = get_stdin() # for debugging # data = r'''["word", null, false, 1, 3.14, true, "multiple words", false, "words\nwith\nnewlines", 42]''' options = [] long_options = {} for arg in sys.argv[1:]: if arg.startswith('-') and not arg.startswith('--'): options.extend(arg[1:]) elif arg.startswith('--'): try: k, v = arg[2:].split('=') long_options[k] = int(v) except Exception: helptext() else: if commandline: query = arg compact = compact if not commandline else'c' in options initialize = initialize if not commandline else 'i' in options lines = lines if not commandline else 'l' in options mono = mono if not commandline else 'm' in options nulls = nulls if not commandline else 'n' in options raw = raw if not commandline else 'r' in options schema = schema if not commandline else 's' in options version_info = version_info if not commandline else 'v' in options helpme = helpme if not commandline else 'h' in options keyname_color = keyword_color = number_color = string_color = arrayid_color = arraybracket_color = None if helpme: helptext() if version_info: print_error(f'jello: version {__version__}\n') if data is None: print_error('jello: missing piped JSON or JSON Lines data\n') # lines() function is deprecated. Warn and quit if detected. if query and 'lines(' in query: print_error('jello: Error: lines() function is deprecated. Please use the -l option instead.\n') # only process if there is data if data and not data.isspace(): list_dict_data = load_json(data) # pulling variables back from pyquery since the user may have defined intialization options # in their .jelloconf.py file (response, compact, nulls, raw, lines, mono, schema, keyname_color, keyword_color, number_color, string_color, arrayid_color, arraybracket_color) = pyquery(list_dict_data, query, initialize=initialize, compact=compact, nulls=nulls, raw=raw, lines=lines, mono=mono, schema=schema, keyname_color=keyname_color, keyword_color=keyword_color, number_color=number_color, string_color=string_color, arrayid_color=arrayid_color, arraybracket_color=arraybracket_color) set_env_colors(keyname_color, keyword_color, number_color, string_color, arrayid_color, arraybracket_color) # create JelloStyle class with user values from set_env_colors() or default values # need to do this here (not at global level), otherwise default values will not be updated class JelloStyle(Style): styles = { Name.Tag: f'bold {JelloTheme.colors["key_name"][0]}', # key names Keyword: f'{JelloTheme.colors["keyword"][0]}', # true, false, null Number: f'{JelloTheme.colors["number"][0]}', # int, float String: f'{JelloTheme.colors["string"][0]}' # string } if schema: if not stdout_is_tty(): mono = True print_schema(response, mono=mono) exit() else: output = create_json(response, compact=compact, nulls=nulls, raw=raw, lines=lines) try: if commandline: if not mono and not lines and stdout_is_tty(): lexer = JsonLexer() formatter = Terminal256Formatter(style=JelloStyle) highlighted_json = highlight(output, lexer, formatter) print(highlighted_json[0:-1]) else: print(output) else: return output except Exception as e: print_error(textwrap.dedent(f'''\ jello: Output Exception: {e} list_dict_data: {list_dict_data} response: {response} output: {output} '''))
def jprint(js): json_str = json.dumps(js, indent=4, sort_keys=True) print(highlight(json_str, JsonLexer(), TerminalFormatter()).strip())
def json(cls, value) -> json: response = json.dumps(value, sort_keys=True, indent=4, default=str) formatter = HtmlFormatter(style="colorful") response = highlight(response, JsonLexer(), formatter) style = "<style>" + formatter.get_style_defs() + "</style>" return mark_safe(style + response)
def show_tx(txid, more_details=False): lmq, oxend = lmq_connection() info = FutureJSON(lmq, oxend, 'rpc.get_info', 1) txs = tx_req(lmq, oxend, [txid]).get() if 'txs' not in txs or not txs['txs']: return flask.render_template( 'not_found.html', info=info.get(), type='tx', id=txid, ) tx = parse_txs(txs)[0] # If this is a state change, see if we have the quorum stored to provide context testing_quorum = None if tx['info']['version'] >= 4 and 'sn_state_change' in tx['extra']: testing_quorum = FutureJSON( lmq, oxend, 'rpc.get_quorum_state', 60, cache_key='tx_state_change', args={ 'quorum_type': 0, 'start_height': tx['extra']['sn_state_change']['height'] }) kindex_info = {} # { amount => { keyindex => {output-info} } } block_info_req = None if 'vin' in tx['info']: if len(tx['info']['vin']) == 1 and 'gen' in tx['info']['vin'][0]: tx['coinbase'] = True elif tx['info']['vin'] and config.enable_mixins_details: # Load output details for all outputs contained in the inputs outs_req = [] for inp in tx['info']['vin']: # Key positions are stored as offsets from the previous index rather than indices, # so de-delta them back into indices: if 'key_offsets' in inp['key'] and 'key_indices' not in inp[ 'key']: kis = [] inp['key']['key_indices'] = kis kbase = 0 for koff in inp['key']['key_offsets']: kbase += koff kis.append(kbase) del inp['key']['key_offsets'] outs_req = [{ "amount": inp['key']['amount'], "index": ki } for inp in tx['info']['vin'] for ki in inp['key']['key_indices']] outputs = FutureJSON(lmq, oxend, 'rpc.get_outs', args={ 'get_txid': True, 'outputs': outs_req, }).get() if outputs and 'outs' in outputs and len( outputs['outs']) == len(outs_req): outputs = outputs['outs'] # Also load block details for all of those outputs: block_info_req = FutureJSON( lmq, oxend, 'rpc.get_block_header_by_height', args={'heights': [o["height"] for o in outputs]}) i = 0 for inp in tx['info']['vin']: amount = inp['key']['amount'] if amount not in kindex_info: kindex_info[amount] = {} ki = kindex_info[amount] for ko in inp['key']['key_indices']: ki[ko] = outputs[i] i += 1 if more_details: formatter = HtmlFormatter(cssclass="syntax-highlight", style="paraiso-dark") more_details = { 'details_css': formatter.get_style_defs('.syntax-highlight'), 'details_html': highlight(json.dumps(tx, indent="\t", sort_keys=True), JsonLexer(), formatter), } else: more_details = {} block_info = {} # { height => {block-info} } if block_info_req: bi = block_info_req.get() if 'block_headers' in bi: for bh in bi['block_headers']: block_info[bh['height']] = bh if testing_quorum: testing_quorum = testing_quorum.get() if testing_quorum: if 'quorums' in testing_quorum and testing_quorum['quorums']: testing_quorum = testing_quorum['quorums'][0]['quorum'] else: testing_quorum = None return flask.render_template( 'tx.html', info=info.get(), tx=tx, kindex_info=kindex_info, block_info=block_info, testing_quorum=testing_quorum, **more_details, )
def main(data=None, query='_'): # break on ctrl-c keyboard interrupt signal.signal(signal.SIGINT, ctrlc) # break on pipe error. need try/except for windows compatibility try: signal.signal(signal.SIGPIPE, signal.SIG_DFL) except AttributeError: pass # enable colors for Windows cmd.exe terminal if sys.platform.startswith('win32'): os.system('') if data is None: data = get_stdin() # for debugging # data = r'''["word", null, false, 1, 3.14, true, "multiple words", false, "words\nwith\nnewlines", 42]''' options = [] long_options = {} for arg in sys.argv[1:]: if arg.startswith('-') and not arg.startswith('--'): options.extend(arg[1:]) elif arg.startswith('--'): try: k, v = arg[2:].split('=') long_options[k] = int(v) except Exception: helptext() else: query = arg opts.compact = opts.compact or 'c' in options opts.initialize = opts.initialize or 'i' in options opts.lines = opts.lines or 'l' in options opts.mono = opts.mono or 'm' in options opts.nulls = opts.nulls or 'n' in options opts.raw = opts.raw or 'r' in options opts.schema = opts.schema or 's' in options opts.version_info = opts.version_info or 'v' in options opts.helpme = opts.helpme or 'h' in options if opts.helpme: helptext() if opts.version_info: print( textwrap.dedent(f'''\ jello: Version: {__version__} Author: {AUTHOR} Website: {WEBSITE} Copyright: {COPYRIGHT} License: {LICENSE} ''')) sys.exit() if data is None: print_error('jello: missing piped JSON or JSON Lines data\n') # only process if there is data if data and not data.isspace(): # load the JSON or JSON Lines try: list_dict_data = load_json(data) except Exception as e: # can't parse the data. Throw an error and quit msg = f'''JSON Load Exception: {e} Cannot parse the data (Not valid JSON or JSON Lines) ''' print_error(f'''jello: {msg}''') # run the query and check for various errors try: response = pyquery(list_dict_data, query) except KeyError as e: msg = f'Key does not exist: {e}' print_error( textwrap.dedent(f'''\ jello: {msg} ''')) except IndexError as e: print_error( textwrap.dedent(f'''\ jello: {e} ''')) except SyntaxError as e: print_error( textwrap.dedent(f'''\ jello: {e} {e.text} ''')) except TypeError as e: msg = f'TypeError: {e}' print_error( textwrap.dedent(f'''\ jello: {msg} ''')) except AttributeError as e: msg = f'AttributeError: {e}' print_error( textwrap.dedent(f'''\ jello: {msg} ''')) except NameError as e: msg = f'NameError: {e}' print_error( textwrap.dedent(f'''\ jello: {msg} ''')) except Exception as e: if len(str(list_dict_data)) > 70: err_data = str(list_dict_data)[0:35] + ' ... ' + str( list_dict_data)[-35:-1] if len(str(query)) > 70: query = str(query)[0:35] + ' ... ' + str(query)[-35:-1] if len(str(response)) > 70: response = str(response)[0:35] + ' ... ' + str( response)[-35:-1] msg = textwrap.dedent(f'''Query Exception: {e} query: {query} data: {err_data} output: {response}''') print_error( textwrap.dedent(f'''\ jello: {msg} ''')) # if DotMap returns a bound function then we know it was a reserved attribute name if hasattr(response, '__self__'): print_error( textwrap.dedent(f'''\ jello: A reserved key name with dotted notation was used in the query. Please use python bracket dict notation to access this key. query: {query} ''')) set_env_colors() # create JelloStyle class with user values from set_env_colors() or default values # need to do this here (not at global level), otherwise default values will not be updated class JelloStyle(Style): styles = { Name.Tag: f'bold {JelloTheme.colors["key_name"][0]}', # key names Keyword: f'{JelloTheme.colors["keyword"][0]}', # true, false, null Number: f'{JelloTheme.colors["number"][0]}', # int, float String: f'{JelloTheme.colors["string"][0]}' # string } # output as a schema if the user desires, otherwise generate JSON or Lines try: if opts.schema: if not sys.stdout.isatty(): opts.mono = True create_schema(response) print('\n'.join(schema_list)) sys.exit() else: output = create_json(response) except Exception as e: if len(str(list_dict_data)) > 70: list_dict_data = str(list_dict_data)[0:35] + ' ... ' + str( list_dict_data)[-35:-1] if len(str(response)) > 70: response = str(response)[0:35] + ' ... ' + str( response)[-35:-1] if len(str(query)) > 70: query = str(query)[0:35] + ' ... ' + str(query)[-35:-1] print_error( textwrap.dedent(f'''\ jello: Formatting Exception: {e} query: {query} data: {list_dict_data} response: {response} ''')) # Print colorized or mono JSON to STDOUT try: if not opts.mono and not opts.lines and sys.stdout.isatty(): lexer = JsonLexer() formatter = Terminal256Formatter(style=JelloStyle) highlighted_json = highlight(output, lexer, formatter) print(highlighted_json[0:-1]) else: print(output) except Exception as e: if len(str(list_dict_data)) > 70: list_dict_data = str(list_dict_data)[0:35] + ' ... ' + str( list_dict_data)[-35:-1] if len(str(response)) > 70: response = str(response)[0:35] + ' ... ' + str( response)[-35:-1] if len(str(output)) > 70: output = str(output)[0:35] + ' ... ' + str(output)[-35:-1] if len(str(query)) > 70: query = str(query)[0:35] + ' ... ' + str(query)[-35:-1] print_error( textwrap.dedent(f'''\ jello: Output Exception: {e} query: {query} data: {list_dict_data} response: {response} output: {output} '''))
async def main(): args = process_cli() print(args, file=sys.stderr) if args.subparser_name == 'check': nodes = (args.nodes + (sys.stdin.readlines() if args.read_stdin else [])) or [ 'sinfo' ] nodes = [node.strip() for node in nodes] results = await check_nodes(nodes, use_sudo=args.use_sudo, concurrency=args.concurrency) # db_storage(results, path.join(Path.home(), 'bofhbot.db')) results_json = json.dumps(results, sort_keys=True, indent=2) if sys.stdout.isatty(): return print( highlight(results_json, JsonLexer(), TerminalFormatter())) return print(results_json) if args.subparser_name == 'analyze': print(get_analysis(read_stdin())) if args.subparser_name == 'show': selected_fields = [f.upper() for f in args.fields] data = { node: { k: v for k, v in data.items() if k.upper() in selected_fields or not args.fields } for node, data in read_stdin().items() } show_table(data) if args.subparser_name == 'suggest': status = read_stdin() suggestions = get_suggestions(status, use_reason=args.use_reason) await interactive_suggest(suggestions, status) if args.subparser_name == 'list': return show_status(args.nodes) if args.subparser_name == 'filter': status = read_stdin() if args.nodes: nodes = await node_string_to_nodes(args.nodes) results = { node: data for node, data in status.items() if node in nodes or node.split('.')[1] in args.nodes } else: results = status properties = { p.split(':')[0].upper(): p.split(':')[1] for p in (args.property or []) } def matches(data): for k, v in properties.items(): if k not in data: return False if not str(data[k]).upper() == v.upper(): return False return True results = { node: data for node, data in results.items() if matches(data) } results_json = json.dumps(results, sort_keys=True, indent=2) if sys.stdout.isatty(): return print( highlight(results_json, JsonLexer(), TerminalFormatter())) return print(results_json) if args.subparser_name == 'report': return print(await show_partition_info())
if args.type == 'collect_true_data': status = collect_true_data('picopic.json.tmpl', 4, accept_ieee=ieee, verbose=args.verbose, debug=args.debug) mean_status = dumps(status[0], indent=2, sort_keys=True) std_status = dumps(status[1], indent=2, sort_keys=True) var_status = dumps(status[2], indent=2, sort_keys=True) if args.color_style: print( Fore.YELLOW + "`Mean` mean values for 4th simulation iteraction:\n" + Style.RESET_ALL, highlight(mean_status, JsonLexer(), Terminal256Formatter(style=args.color_style))) print( Fore.YELLOW + "`Standard deviation` mean values for 4th simulation iteraction:\n" + Style.RESET_ALL, highlight(std_status, JsonLexer(), Terminal256Formatter(style=args.color_style))) print( Fore.YELLOW + "`Variance` mean values for 4 simulationth iteraction:\n" + Style.RESET_ALL, highlight(var_status, JsonLexer(), Terminal256Formatter(style=args.color_style))) else: print(
def delete_snap(volid, url, head): url = url + '/' + volid + '/Snapshots/' + args.snapshot[0] req = requests.delete(url, headers=head) details = json.dumps(req.json(), indent=4) print('Deleting snapshot ' + args.snapshot[0]) print(highlight(details, JsonLexer(), TerminalFormatter()))