Skip to content

Commit a524c61

Browse files
author
Bradley A. Thornton
committed
Update to py3
1 parent 2eff5d4 commit a524c61

File tree

12 files changed

+51
-48
lines changed

12 files changed

+51
-48
lines changed

Dockerfile renamed to Containerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:2.7.14-alpine3.6
1+
FROM python:3.8.5-alpine3.12
22

33
# Update the packages
44
RUN apk update
@@ -8,7 +8,7 @@ RUN apk add gcc libffi-dev musl-dev openssl-dev sshpass make
88
# RUN apk add py-crypto python-dev
99

1010
# Install td4a
11-
RUN pip install td4a==1.7
11+
RUN pip install td4a==2.0.3
1212

1313
# Clear out extras
1414
RUN rm -rf /var/cache/apk/*

README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ https://td4a.codethenetwork.com
99

1010
TD4A is a visual design aid for building and testing jinja2 templates. It will combine data in yaml format with a jinja2 template and render the output.
1111

12-
All jinja2 filters are supported along with the filter plugins from Ansible version 2.4.1.0.
12+
All jinja2 filters are supported along with the filter plugins from Ansible version 2.9.12
1313

1414
### Installation:
1515

16-
#### using docker:
17-
16+
##### using podman (or docker):
1817
```
19-
docker pull cidrblock/td4a
18+
podman pull cidrblock/td4a
2019
```
2120

22-
The docker hub page can be found here:
21+
The container registry page can be found here:
2322

2423
https://hub.docker.com/r/cidrblock/td4a/
2524

@@ -39,9 +38,9 @@ https://pypi.python.org/pypi/td4a
3938

4039
#### Simple
4140

42-
##### using docker:
41+
##### using podman (or docker):
4342
```
44-
docker run -p 5000:5000 cidrblock/td4a
43+
podman run -p 5000:5000 cidrblock/td4a
4544
```
4645

4746
##### using the cli:
@@ -61,10 +60,9 @@ TD4A support two different modes of operation.
6160

6261
#### Enabling a mode
6362

64-
##### using docker:
65-
63+
##### using podman (or docker):
6664
```
67-
docker run -p 5000:5000 \
65+
podman run -p 5000:5000 \
6866
-it \
6967
cidrblock/td4a \
7068
td4a-server -m mode
@@ -81,13 +79,14 @@ where `mode` is either jinja2 (default) or schema
8179

8280
#### Loading custom filter plugins (jinja2 mode only)
8381

84-
##### using docker:
8582

8683
TD4A supports custom filter plugins within the container. Pass your custom filter_plugins directory as a volume and use the -f option to specify to custom filter plugin directory.
84+
85+
##### using podman (or docker):
8786
```
88-
docker run -p 5000:5000 \
87+
podman run -p 5000:5000 \
8988
-it \
90-
-v `pwd`/my_filter_plugins:/filter_plugins
89+
-v `pwd`/my_filter_plugins:/filter_plugins \
9190
cidrblock/td4a \
9291
td4a-server -f /filter_plugins
9392
```
@@ -101,11 +100,13 @@ td4a-server -f ./my_filter_plugins
101100

102101
#### Loading an ansible inventory (jinja2 and schema mode)
103102

104-
##### using docker:
105-
106103
Mount the inventory as `/inventory` in the container, and run TD4A with the `-i` option.
104+
105+
106+
##### using podman (or docker):
107+
107108
```
108-
docker run -p 5000:5000 \
109+
podman run -p 5000:5000 \
109110
-it \
110111
-v '/Users/me/github/ansible_network_inventory:/inventory' \
111112
cidrblock/td4a \
@@ -114,7 +115,7 @@ docker run -p 5000:5000 \
114115

115116
If environment variables are needed for a dynamic inventory, they can be passed to the docker container.
116117
```
117-
docker run -p 5000:5000 \
118+
podman run -p 5000:5000 \
118119
-it \
119120
-v `pwd`/my_filter_plugins:/filter_plugins \
120121
-v '/Users/me/github/ansible_network_inventory:/inventory' \
@@ -142,10 +143,10 @@ The CouchDB needs to previously created.
142143

143144
To enable link support, and add the link button to the UI, set the following environ variables:
144145

145-
##### using docker:
146+
##### using podman (or docker):
146147

147148
```
148-
docker run -p 5000:5000 \
149+
podman run -p 5000:5000 \
149150
-v `pwd`/my_filter_plugins:/filter_plugins \
150151
-e "COUCH_USERNAME=admin" \
151152
-e "COUCH_PASSWORD=password" \
@@ -182,7 +183,7 @@ The UI is broken into three sections:
182183

183184
### Python version
184185

185-
To date, this has only been tested with python 2.7.
186+
To date, this has only been tested with python 3.8.5.
186187

187188
### Development
188189

gcp/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM cidrblock/td4a:2.0.3
2+
EXPOSE 5000

now/Dockerfile

Lines changed: 0 additions & 2 deletions
This file was deleted.

requirements.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
ansible==2.4.1.0
2-
Flask==0.12.2
3-
netaddr==0.7.19
4-
Twisted==17.9.0
5-
requests==2.18.4
6-
ruamel.yaml==0.15.35
7-
genson==0.2.3
8-
jsonschema==2.6.0
1+
ansible==2.9.12
2+
Flask==1.1.2
3+
netaddr==0.8.0
4+
Twisted==20.3.0
5+
requests==2.24.0
6+
ruamel.yaml==0.16.10
7+
genson==1.2.1
8+
jsonschema==3.2.0

setup.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup
22

33
setup(name='td4a',
4-
version='1.7',
4+
version='2.0.3',
55
description='A browser based jinja template renderer',
66
url='http://github.com/cidrblock/td4a',
77
author='Bradley A. Thornton',
@@ -13,11 +13,13 @@
1313
],
1414
scripts=['td4a-server'],
1515
install_requires=[
16-
'ansible==2.4.1.0',
17-
'Flask==0.12.2',
18-
'netaddr==0.7.19',
19-
'Twisted==17.9.0',
20-
'requests==2.18.4',
21-
'ruamel.yaml==0.15.35'
16+
'ansible==2.9.12',
17+
'Flask==1.1.2',
18+
'netaddr==0.8.0',
19+
'Twisted==20.3.0',
20+
'requests==2.24.0',
21+
'ruamel.yaml==0.16.10',
22+
'genson==1.2.1',
23+
'jsonschema==3.2.0'
2224
],
2325
zip_safe=False)

td4a-server

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def parse_args():
3434
return args
3535

3636
def main():
37-
print "Loading..."
37+
print("Loading...")
3838
app.args = parse_args()
3939
app.filters = filters_load(app.args.custom_filters)
4040
if app.args.inventory_source:
@@ -51,7 +51,7 @@ def main():
5151
reactor_args['installSignalHandlers'] = 0
5252
import werkzeug.serving
5353
wsgi = werkzeug.serving.run_with_reloader(wsgi)
54-
print "Ready."
54+
print("Ready.")
5555
wsgi()
5656

5757
if __name__ == '__main__':

td4a/controllers/render.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ def rest_render():
9696
""" render path
9797
"""
9898
try:
99-
print "Checking and parsing data..."
99+
print("Checking and parsing data...")
100100
response = render(payload=request.json, filters=app.filters, typ="page")
101-
print "Done."
101+
print("Done.")
102102
return jsonify(response)
103103
except HandledException as error:
104104
return jsonify(error.json())

td4a/controllers/validate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def validation(payload):
3434
if errors:
3535
return {"p3": yaml.dump({"messages":errors})}
3636
return {"p3": yaml.dump({"messages":["validation passed"]})}
37-
except UnknownType, error:
37+
except UnknownType as error:
3838
error_message = str(error)
3939
lines = error_message.splitlines()
4040
message = [x for x in lines if x.startswith('Unknown type')]

td4a/models/exception_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self, function):
3131
def __call__(self, *args, **kwargs):
3232
try:
3333
return self.function(*args, **kwargs)
34-
except Exception, error:
34+
except Exception as error:
3535
self.error = error
3636
self.exc_type, self.exc_value, self.exc_traceback = sys.exc_info()
3737
self.tback = traceback.extract_tb(self.exc_traceback)
@@ -115,7 +115,7 @@ def type_error(self):
115115
line_number=line_number)
116116

117117
def unhandled(self):
118-
print self.exc_type, self.exc_value, self.exc_traceback, self.tback, self.error
118+
print(self.exc_type, self.exc_value, self.exc_traceback, self.tback, self.error)
119119
line_numbers = [x for x in self.tback if re.search('^<.*>$', x[0])]
120120
if line_numbers:
121121
line_number = line_numbers[0][1]

0 commit comments

Comments
 (0)