From b6ff8746bc5b1087cc91bd814aac1d7632c53d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sun, 3 May 2015 02:47:47 +0200 Subject: [PATCH] Make the code python3 friendly --- examples/copy_list.py | 14 +++++++------- examples/get_network_activity.py | 12 ++++++------ pymisp/__init__.py | 2 +- pymisp/api.py | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/copy_list.py b/examples/copy_list.py index 074403a..b7a1a55 100644 --- a/examples/copy_list.py +++ b/examples/copy_list.py @@ -18,7 +18,7 @@ destination = None def init(cert_to_priv=True): global source global destination - print cert_to_priv + print(cert_to_priv) if cert_to_priv: source = PyMISP(url_cert, cert, cert_cert, 'xml') destination = PyMISP(url_priv, priv, cert_priv, 'xml') @@ -63,22 +63,22 @@ def loop_copy(): def copy(eventid): eventid = eventid.strip() if len(eventid) == 0 or not eventid.isdigit(): - print 'empty line or NaN.' + print('empty line or NaN.') return eventid = int(eventid) - print eventid, 'copying...' + print(eventid, 'copying...') r = copy_event(eventid) if r.status_code >= 400: loc = r.headers['location'] if loc is not None: event_to_update = loc.split('/')[-1] - print'updating', event_to_update + print('updating', event_to_update) r = update_event(eventid, event_to_update) if r.status_code >= 400: - print r.status_code, r.headers + print(r.status_code, r.headers) else: - print r.status_code, r.headers - print eventid, 'done.' + print(r.status_code, r.headers) + print(eventid, 'done.') def export_our_org(): diff --git a/examples/get_network_activity.py b/examples/get_network_activity.py index 5199db4..0b0fe16 100755 --- a/examples/get_network_activity.py +++ b/examples/get_network_activity.py @@ -74,7 +74,7 @@ def get_event(event_id): else: continue else: - print "Not a valid ID" + print("Not a valid ID") return @@ -109,16 +109,16 @@ def print_events(): if app_ip_src == True: for ip in network_ip_src: - print ip[0] + print(ip[0]) if app_ip_dst == True: for ip in network_ip_dst: - print ip[0] + print(ip[0]) if app_domain == True: for ip in network_domain: - print ip[0] + print(ip[0]) if app_hostname == True: for ip in network_hostname: - print ip[0] + print(ip[0]) if __name__ == '__main__': @@ -164,5 +164,5 @@ if __name__ == '__main__': get_event( event_id.strip() ) print_events() else: - print "No filename given, stopping." + print("No filename given, stopping.") diff --git a/pymisp/__init__.py b/pymisp/__init__.py index 1c09d31..e4c98cb 100644 --- a/pymisp/__init__.py +++ b/pymisp/__init__.py @@ -1 +1 @@ -from api import PyMISP +from .api import PyMISP diff --git a/pymisp/api.py b/pymisp/api.py index b7bf979..79df3c8 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -53,7 +53,7 @@ class PyMISP(object): return query url = self.rest.format(path) query = {'request': query} - print json.dumps(query) + print(json.dumps(query)) r = session.post(url, data=json.dumps(query)) return r.json()