Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for python3 #172

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

robgil
Copy link

@robgil robgil commented Dec 26, 2017

Not backwards compatible, but possibly could be should someone want to
take that on.

Modules changed to python3 specific.

Ref #171

Not backwards compatible, but possibly could be should someone want to
take that on.

Modules changed to python3 specific.
@@ -1,4 +1,4 @@
import ConfigParser
import configparser as ConfigParser
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be switched to a try/except to be backwards compatible

@@ -11,7 +11,7 @@
import unicodecsv
import threading
from logger import get_logger
from Queue import Queue
import queue as Queue
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module changed here, but just aliased. Again, try/except if you want backwards compatible.

@@ -21,8 +21,8 @@
import os
import sys
import time
import urllib2
from cStringIO import StringIO
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now a builtin with io

@@ -70,25 +70,25 @@ def _query(self, path):
url = '%s/lookup/%s' % (self.server, path)
if self.limit:
url += '?limit=%d' % self.limit
req = urllib2.Request(url)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to urllib3.

@@ -23,14 +23,14 @@ def reap(file_name):
outbound_url_file = config.get('Reaper', 'outbound_urls')

try:
with open(inbound_url_file, 'rb') as f:
with open(inbound_url_file, 'r') as f:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're reading string, we need to turn off binary for python3.

@@ -9,5 +9,6 @@ netaddr>=0.7.12,<0.8.0
pygeoip>=0.3.1,<0.4.0
requests>=2.10.0,<3.0.0
sortedcontainers>=0.9.4,<1.6.0
wsgiref==0.1.2
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused anywhere and everything works without it.

unicodecsv>=0.9.4,<0.15.0
urllib3
configparser
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python3 version

unicodecsv>=0.9.4,<0.15.0
urllib3
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python3 version

@@ -102,7 +100,7 @@ def process_packetmail(response, source, direction):
data = []
filter_comments = lambda x: not x[0].startswith('#')
try:
for line in ifilter(filter_comments,
for line in filter(filter_comments,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filter is now a builtin and replaces itertools.ifilter. Not sure how we'd make this backward compatible.

@ptester87
Copy link

Hi, do you have the modified script for py3? or any place where thr is documentation on how to install it correctly.

@robgil
Copy link
Author

robgil commented Dec 13, 2018

@ptester87 its in my fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants