From 40dee274e71e2d0d90977562ed255e2142fbbd37 Mon Sep 17 00:00:00 2001 From: David Cruz Date: Thu, 31 Aug 2023 09:06:15 -0700 Subject: [PATCH] Update API --- .gitignore | 1 + panw_utils/get_panw_firewalls.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f24fc58..3660b77 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vscode +.DS_Store # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/panw_utils/get_panw_firewalls.py b/panw_utils/get_panw_firewalls.py index 2ad433d..cee4c29 100755 --- a/panw_utils/get_panw_firewalls.py +++ b/panw_utils/get_panw_firewalls.py @@ -29,9 +29,11 @@ import signal import ssl import sys -import urllib.request import xml.dom.minidom as MD import xml.etree.ElementTree as ET +from urllib import parse +from urllib.request import urlopen + def sigint_handler(signum, frame): sys.exit(1) @@ -47,14 +49,14 @@ def query_api(args): cmd = '' else: cmd = '' - params = urllib.parse.urlencode({ + params = parse.urlencode({ 'type': 'op', 'cmd': cmd, 'key': args.key, }) url = f'https://{args.panorama}/api/?{params}' try: - with urllib.request.urlopen(url, context=ctx) as response: + with urlopen(url, context=ctx) as response: xml = response.read().decode('utf-8') except OSError as err: sys.stderr.write(f'{args.panorama}: Unable to connect to host ({err})\n')