update trigger scripts to Python 3

This commit is contained in:
Davide Alberani 2017-04-15 17:54:07 +02:00
parent dc19cabf25
commit 5119d1ff64
2 changed files with 11 additions and 11 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""echo.py - Simply echo the environment and the stdin."""
import os
@ -7,14 +7,14 @@ import json
def main():
# NOTE: even if not used, ALWAYS consume sys.stdin to close the pipe.
print 'STDIN JSON:', repr(json.loads(sys.stdin.read()))
print ''
print 'ENV:', repr(os.environ)
print('STDIN JSON: %s' % repr(json.loads(sys.stdin.read())))
print('')
print('ENV: %s' % repr(os.environ))
if __name__ == '__main__':
try:
main()
except Exception, e:
print 'echo.py error: %s' % e
except Exception as e:
print('echo.py error: %s' % e)

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""print_label.py - print a label with the name, the company and SEQ_HEX (in a barcode) of an attendee
Copyright 2015-2016 Emiliano Mattioli <oloturia AT gmail.com>
Copyright 2015-2013 Emiliano Mattioli <oloturia AT gmail.com>
Davide Alberani <da@erlug.linux.it>
RaspiBO <info@raspibo.org>
@ -33,8 +33,8 @@ def _get_resource(filename):
def build_label(w, h, barcode_text, line1, line2, font_text=FONT_TEXT, font_barcode=FONT_BARCODE):
barcode_text = "*" + barcode_text + "*"
line1 = unicode(line1, 'utf-8').encode(FONT_TEXT_ENCODING, 'ignore')
line2 = unicode(line2, 'utf-8').encode(FONT_TEXT_ENCODING, 'ignore')
line1 = str(line1, 'utf-8').encode(FONT_TEXT_ENCODING, 'ignore')
line2 = str(line2, 'utf-8').encode(FONT_TEXT_ENCODING, 'ignore')
fontbar = ImageFont.truetype(_get_resource(font_barcode), 2000)
fontname = ImageFont.truetype(_get_resource(font_text), 1100)
fontjob = ImageFont.truetype(_get_resource(font_text), 780)
@ -75,6 +75,6 @@ def run():
if __name__ == '__main__':
try:
run()
except Exception, e:
except Exception as e:
sys.stderr.write('print_label. Exception raised: %s\n' % e)