Navigation Menu

Skip to content

Commit

Permalink
Move generate_tox_bootstrap.py to python3
Browse files Browse the repository at this point in the history
Signed-off-by: Andrzej Godziuk <andrzej@godziuk.pl>
  • Loading branch information
ag-gh committed Aug 14, 2020
1 parent b626f19 commit 3cd3c88
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -9,6 +9,7 @@ DSO_LDFLAGS=-g -pthread -lm -lrt
DSO_LDFLAGS += $(shell pkg-config --libs $(DEPS))
OBJECTS=$(SOURCES:.c=.o)
INCLUDES = $(wildcard *.h)
PYTHON = /usr/bin/env python3


# Targets
Expand All @@ -20,7 +21,7 @@ gitversion.h: FORCE
FORCE:

tox_bootstrap.h:
python generate_tox_bootstrap.py
$(PYTHON) generate_tox_bootstrap.py

%.o: %.c $(INCLUDES) gitversion.h tox_bootstrap.h
@echo " CC $@"
Expand Down
16 changes: 8 additions & 8 deletions generate_tox_bootstrap.py
@@ -1,5 +1,5 @@
#!/usr/bin/python
# pip install jinja2 requests
#!/usr/bin/python3
# pip3 install jinja2 requests

import datetime
import jinja2
Expand Down Expand Up @@ -52,7 +52,7 @@ def get_16_bytes(value):
Generate 1 line of C code - 16 bytes
@param value a hex string of length 32 (32 hex chars)
"""
if len(value) <> 32:
if len(value) != 32:
raise ValueError('%r is not a 32-char string')

rv = ""
Expand Down Expand Up @@ -86,11 +86,11 @@ def get_source(self, environment, template):
for elem in data['nodes']:
node = {}
if 'ipv4' not in elem or 'port' not in elem or 'public_key' not in elem:
print "SKIPPING", elem
print("SKIPPING", elem)
continue

if len(elem['public_key']) <> 64:
print "Bad public key %s, skipping!" % elem['public_key']
if len(elem['public_key']) != 64:
print("Bad public key %s, skipping!" % elem['public_key'])
continue

node['port'] = int(elem['port'])
Expand All @@ -102,10 +102,10 @@ def get_source(self, environment, template):
except socket.error:
# IPv4 is not numeric, let's try resolving
try:
print "RESOLVING", elem['ipv4']
print("RESOLVING", elem['ipv4'])
node['ipv4'] = socket.gethostbyname(elem['ipv4'])
except socket.error:
print "Could not resolve ipv4: %s, skipping!" % elem['ipv4']
print("Could not resolve ipv4: %s, skipping!" % elem['ipv4'])
continue

if 'status_udp' in elem and elem['status_udp']:
Expand Down

0 comments on commit 3cd3c88

Please sign in to comment.