Skip to content

Commit 6063576

Browse files
committed
Update docker base image to ubuntu-20.04
Update docker files to use ubuntu-20.04. Update ditaa and conf.py hieroglyph checks to python3 since python2 is no longer supported. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro>
1 parent 724b37a commit 6063576

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
build_job:
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-20.04
1212
name: Build documentation
1313
steps:
1414
- name: Checkout

Documentation/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@
127127
extensions.append("sphinx.ext.pngmath")
128128

129129
try:
130-
hglyph_ver = subprocess.check_output(["hieroglyph", "--version"])
130+
hglyph_ver = subprocess.check_output(["hieroglyph", "--version"]).decode('utf-8')
131131
if LooseVersion(hglyph_ver) > LooseVersion("1.0.0"):
132-
extensions.append('hieroglyph')
132+
extensions.append("hieroglyph")
133133
except:
134134
None
135135

Documentation/sphinx/ditaa.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
:copyright: Copyright 2017 by Yongping Guo
88
:license: BSD, see LICENSE for details.
99
"""
10+
from __future__ import print_function
1011

1112
import re, os
1213
import codecs
@@ -76,7 +77,7 @@ class Ditaa(directives.images.Image):
7677

7778
def run(self):
7879
if self.arguments:
79-
print self.arguments
80+
print(self.arguments)
8081
document = self.state.document
8182
if self.content:
8283
return [document.reporter.warning(
@@ -119,11 +120,13 @@ def run(self):
119120

120121
def render_ditaa(app, code, options, format, prefix='ditaa'):
121122
"""Render ditaa code into a PNG output file."""
122-
hashkey = code.encode('utf-8') + str(options) + \
123+
# ditaa expects UTF-8 by default
124+
code = code.encode('utf-8')
125+
hashkey = str(code) + str(options) + \
123126
str(app.builder.config.ditaa) + \
124127
str(app.builder.config.ditaa_args)
125-
infname = '%s-%s.%s' % (prefix, sha(hashkey).hexdigest(), "ditaa")
126-
outfname = '%s-%s.%s' % (prefix, sha(hashkey).hexdigest(), "png")
128+
infname = '%s-%s.%s' % (prefix, sha(hashkey.encode('utf-8')).hexdigest(), "ditaa")
129+
outfname = '%s-%s.%s' % (prefix, sha(hashkey.encode('utf-8')).hexdigest(), "png")
127130

128131
rel_imgpath = (format == "html") and relative_uri(app.builder.env.docname, app.builder.imagedir) or ''
129132
infullfn = path.join(app.builder.outdir, app.builder.imagedir, infname)
@@ -135,25 +138,23 @@ def render_ditaa(app, code, options, format, prefix='ditaa'):
135138
return outrelfn, outfullfn
136139

137140
ensuredir(path.dirname(outfullfn))
138-
# ditaa expects UTF-8 by default
139-
if isinstance(code, unicode): code = code.encode('utf-8')
140141

141142
ditaa_args = [app.builder.config.ditaa]
142143
ditaa_args.extend(app.builder.config.ditaa_args)
143144
ditaa_args.extend(options)
144145
ditaa_args.extend( [infname, outfname] ) # use relative path
145-
f = open(infullfn, 'w')
146-
f.write(code.encode('utf-8'))
147-
f.close()
146+
f = open(infullfn, 'wb')
147+
f.write(code)
148+
f.close()
148149
currpath = os.getcwd()
149150
os.chdir(path.join(app.builder.outdir, app.builder.imagedir))
150151

151152
try:
152153
if app.builder.config.ditaa_log_enable:
153-
print "rending %s" %(outfullfn)
154+
print("rending %s" %(outfullfn))
154155
#app.builder.warn(ditaa_args)
155156
p = Popen(ditaa_args, stdout=PIPE, stdin=PIPE, stderr=PIPE)
156-
except OSError, err:
157+
except OSError as err:
157158
if err.errno != ENOENT: # No such file or directory
158159
raise
159160
app.builder.warn('ditaa command %r cannot be run (needed for ditaa '
@@ -169,11 +170,11 @@ def render_ditaa(app, code, options, format, prefix='ditaa'):
169170
# Ditaa may close standard input when an error occurs,
170171
# resulting in a broken pipe on communicate()
171172
stdout, stderr = p.communicate(code)
172-
except OSError, err:
173+
except OSError as err:
173174
if err.errno != EPIPE:
174175
raise
175176
wentWrong = True
176-
except IOError, err:
177+
except IOError as err:
177178
if err.errno != EINVAL:
178179
raise
179180
wentWrong = True

tools/labs/docker/docs/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:18.04
1+
FROM ubuntu:20.04
22

33
ENV DEBIAN_FRONTEND noninteractive
44
RUN apt-get update
@@ -7,8 +7,10 @@ RUN apt-get install -y software-properties-common
77
RUN apt-get install -y sudo
88
RUN apt-get install -y make
99
RUN apt-get install -y git
10-
RUN apt-get install -y python
11-
RUN apt-get install -y python-pip
10+
RUN apt-get install -y python3
11+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
12+
RUN apt-get install -y python3-pip
13+
RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
1214
RUN apt-get install -y ditaa
1315
RUN apt-get install -y graphviz
1416
RUN apt-get install -y imagemagick

0 commit comments

Comments
 (0)