Fix crash on lsof on python3

This commit is contained in:
Florian Mounier
2017-05-15 11:30:59 +02:00
parent 0625e05cbb
commit 269dd2b618
4 changed files with 7 additions and 6 deletions

2
.gitignore vendored
View File

@@ -9,4 +9,4 @@ sass/scss
*.egg-info/ *.egg-info/
build/ build/
.cache/ .cache/
.env/ .env*

View File

@@ -4,9 +4,9 @@ include Makefile.config
all: install lint check-outdated run-debug all: install lint check-outdated run-debug
install: install:
test -d $(VENV) || virtualenv $(VENV) test -d $(VENV) || virtualenv $(VENV) -p $(PYTHON_VERSION)
$(PIP) install --upgrade --no-cache pip setuptools -e .[lint] devcore # $(PIP) install --upgrade --no-cache pip setuptools -e .[lint] devcore
$(NPM) install # $(NPM) install
clean: clean:
rm -fr $(NODE_MODULES) rm -fr $(NODE_MODULES)

View File

@@ -1,7 +1,8 @@
PROJECT_NAME = butterfly PROJECT_NAME = butterfly
# Python env # Python env
VENV = $(PWD)/.env PYTHON_VERSION ?= python
VENV = $(PWD)/.env$(if $(filter $(PYTHON_VERSION),python),,-$(PYTHON_VERSION))
PIP = $(VENV)/bin/pip PIP = $(VENV)/bin/pip
PYTHON = $(VENV)/bin/python PYTHON = $(VENV)/bin/python
PYTEST = $(VENV)/bin/py.test PYTEST = $(VENV)/bin/py.test

View File

@@ -168,7 +168,7 @@ def get_lsof_socket_line(addr, port):
# May want to make this into a dictionary in the future... # May want to make this into a dictionary in the future...
regex = "\w+\s+(?P<pid>\d+)\s+(?P<user>\w+).*\s" \ regex = "\w+\s+(?P<pid>\d+)\s+(?P<user>\w+).*\s" \
"(?P<laddr>.*?):(?P<lport>\d+)->(?P<raddr>.*?):(?P<rport>\d+)" "(?P<laddr>.*?):(?P<lport>\d+)->(?P<raddr>.*?):(?P<rport>\d+)"
output = subprocess.check_output(['lsof', '-Pni']) output = subprocess.check_output(['lsof', '-Pni']).decode('utf-8')
lines = output.split('\n') lines = output.split('\n')
for line in lines: for line in lines:
# Look for local address with peer port # Look for local address with peer port