Make the code python3 friendly

pull/2/merge
Raphaël Vinot 2015-05-03 02:47:47 +02:00
parent 59254c8246
commit b6ff8746bc
4 changed files with 15 additions and 15 deletions

View File

@ -18,7 +18,7 @@ destination = None
def init(cert_to_priv=True): def init(cert_to_priv=True):
global source global source
global destination global destination
print cert_to_priv print(cert_to_priv)
if cert_to_priv: if cert_to_priv:
source = PyMISP(url_cert, cert, cert_cert, 'xml') source = PyMISP(url_cert, cert, cert_cert, 'xml')
destination = PyMISP(url_priv, priv, cert_priv, 'xml') destination = PyMISP(url_priv, priv, cert_priv, 'xml')
@ -63,22 +63,22 @@ def loop_copy():
def copy(eventid): def copy(eventid):
eventid = eventid.strip() eventid = eventid.strip()
if len(eventid) == 0 or not eventid.isdigit(): if len(eventid) == 0 or not eventid.isdigit():
print 'empty line or NaN.' print('empty line or NaN.')
return return
eventid = int(eventid) eventid = int(eventid)
print eventid, 'copying...' print(eventid, 'copying...')
r = copy_event(eventid) r = copy_event(eventid)
if r.status_code >= 400: if r.status_code >= 400:
loc = r.headers['location'] loc = r.headers['location']
if loc is not None: if loc is not None:
event_to_update = loc.split('/')[-1] event_to_update = loc.split('/')[-1]
print'updating', event_to_update print('updating', event_to_update)
r = update_event(eventid, event_to_update) r = update_event(eventid, event_to_update)
if r.status_code >= 400: if r.status_code >= 400:
print r.status_code, r.headers print(r.status_code, r.headers)
else: else:
print r.status_code, r.headers print(r.status_code, r.headers)
print eventid, 'done.' print(eventid, 'done.')
def export_our_org(): def export_our_org():

View File

@ -74,7 +74,7 @@ def get_event(event_id):
else: else:
continue continue
else: else:
print "Not a valid ID" print("Not a valid ID")
return return
@ -109,16 +109,16 @@ def print_events():
if app_ip_src == True: if app_ip_src == True:
for ip in network_ip_src: for ip in network_ip_src:
print ip[0] print(ip[0])
if app_ip_dst == True: if app_ip_dst == True:
for ip in network_ip_dst: for ip in network_ip_dst:
print ip[0] print(ip[0])
if app_domain == True: if app_domain == True:
for ip in network_domain: for ip in network_domain:
print ip[0] print(ip[0])
if app_hostname == True: if app_hostname == True:
for ip in network_hostname: for ip in network_hostname:
print ip[0] print(ip[0])
if __name__ == '__main__': if __name__ == '__main__':
@ -164,5 +164,5 @@ if __name__ == '__main__':
get_event( event_id.strip() ) get_event( event_id.strip() )
print_events() print_events()
else: else:
print "No filename given, stopping." print("No filename given, stopping.")

View File

@ -1 +1 @@
from api import PyMISP from .api import PyMISP

View File

@ -53,7 +53,7 @@ class PyMISP(object):
return query return query
url = self.rest.format(path) url = self.rest.format(path)
query = {'request': query} query = {'request': query}
print json.dumps(query) print(json.dumps(query))
r = session.post(url, data=json.dumps(query)) r = session.post(url, data=json.dumps(query))
return r.json() return r.json()