diff options
author | Andrzej Godziuk <andrzej@godziuk.pl> | 2020-08-14 12:29:41 +0200 |
---|---|---|
committer | Andrzej Godziuk <andrzej@godziuk.pl> | 2020-08-14 12:29:41 +0200 |
commit | 3cd3c88bde3029230f1d436486c57a587f177c13 (patch) | |
tree | a2dc0717c4fe64cf985235efd6effb0088332d75 | |
parent | b626f19f69846a0eac8941c7173237fc4037a221 (diff) |
Move generate_tox_bootstrap.py to python3
Signed-off-by: Andrzej Godziuk <andrzej@godziuk.pl>
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | generate_tox_bootstrap.py | 16 |
2 files changed, 10 insertions, 9 deletions
@@ -9,6 +9,7 @@ DSO_LDFLAGS=-g -pthread -lm -lrt | |||
9 | DSO_LDFLAGS += $(shell pkg-config --libs $(DEPS)) | 9 | DSO_LDFLAGS += $(shell pkg-config --libs $(DEPS)) |
10 | OBJECTS=$(SOURCES:.c=.o) | 10 | OBJECTS=$(SOURCES:.c=.o) |
11 | INCLUDES = $(wildcard *.h) | 11 | INCLUDES = $(wildcard *.h) |
12 | PYTHON = /usr/bin/env python3 | ||
12 | 13 | ||
13 | 14 | ||
14 | # Targets | 15 | # Targets |
@@ -20,7 +21,7 @@ gitversion.h: FORCE | |||
20 | FORCE: | 21 | FORCE: |
21 | 22 | ||
22 | tox_bootstrap.h: | 23 | tox_bootstrap.h: |
23 | python generate_tox_bootstrap.py | 24 | $(PYTHON) generate_tox_bootstrap.py |
24 | 25 | ||
25 | %.o: %.c $(INCLUDES) gitversion.h tox_bootstrap.h | 26 | %.o: %.c $(INCLUDES) gitversion.h tox_bootstrap.h |
26 | @echo " CC $@" | 27 | @echo " CC $@" |
diff --git a/generate_tox_bootstrap.py b/generate_tox_bootstrap.py index 0cde94a..3198cd4 100644 --- a/generate_tox_bootstrap.py +++ b/generate_tox_bootstrap.py | |||
@@ -1,5 +1,5 @@ | |||
1 | #!/usr/bin/python | 1 | #!/usr/bin/python3 |
2 | # pip install jinja2 requests | 2 | # pip3 install jinja2 requests |
3 | 3 | ||
4 | import datetime | 4 | import datetime |
5 | import jinja2 | 5 | import jinja2 |
@@ -52,7 +52,7 @@ def toxtoc(value): | |||
52 | Generate 1 line of C code - 16 bytes | 52 | Generate 1 line of C code - 16 bytes |
53 | @param value a hex string of length 32 (32 hex chars) | 53 | @param value a hex string of length 32 (32 hex chars) |
54 | """ | 54 | """ |
55 | if len(value) <> 32: | 55 | if len(value) != 32: |
56 | raise ValueError('%r is not a 32-char string') | 56 | raise ValueError('%r is not a 32-char string') |
57 | 57 | ||
58 | rv = "" | 58 | rv = "" |
@@ -86,11 +86,11 @@ if __name__ == "__main__": | |||
86 | for elem in data['nodes']: | 86 | for elem in data['nodes']: |
87 | node = {} | 87 | node = {} |
88 | if 'ipv4' not in elem or 'port' not in elem or 'public_key' not in elem: | 88 | if 'ipv4' not in elem or 'port' not in elem or 'public_key' not in elem: |
89 | print "SKIPPING", elem | 89 | print("SKIPPING", elem) |
90 | continue | 90 | continue |
91 | 91 | ||
92 | if len(elem['public_key']) <> 64: | 92 | if len(elem['public_key']) != 64: |
93 | print "Bad public key %s, skipping!" % elem['public_key'] | 93 | print("Bad public key %s, skipping!" % elem['public_key']) |
94 | continue | 94 | continue |
95 | 95 | ||
96 | node['port'] = int(elem['port']) | 96 | node['port'] = int(elem['port']) |
@@ -102,10 +102,10 @@ if __name__ == "__main__": | |||
102 | except socket.error: | 102 | except socket.error: |
103 | # IPv4 is not numeric, let's try resolving | 103 | # IPv4 is not numeric, let's try resolving |
104 | try: | 104 | try: |
105 | print "RESOLVING", elem['ipv4'] | 105 | print("RESOLVING", elem['ipv4']) |
106 | node['ipv4'] = socket.gethostbyname(elem['ipv4']) | 106 | node['ipv4'] = socket.gethostbyname(elem['ipv4']) |
107 | except socket.error: | 107 | except socket.error: |
108 | print "Could not resolve ipv4: %s, skipping!" % elem['ipv4'] | 108 | print("Could not resolve ipv4: %s, skipping!" % elem['ipv4']) |
109 | continue | 109 | continue |
110 | 110 | ||
111 | if 'status_udp' in elem and elem['status_udp']: | 111 | if 'status_udp' in elem and elem['status_udp']: |