source: src/python/bin/gnuboat-splashscreen@ 79a1004

0.5 debian/bullseye debian/jessie
Last change on this file since 79a1004 was 6f09609, checked in by Joachim Langenbach <joachim.langenbach@…>, 9 years ago

Make Python files pep8 compliant

  • Property mode set to 100755
File size: 2.2 KB
RevLine 
[10edeb0]1#!/usr/bin/python
2'''
3 Copyright (C) 2016 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17'''
18
19import sys
20import os
21import getopt
[cfdd201]22try:
[6f09609]23 from PIL import Image
24 from PIL import ImageOps
25 from EPD import EPD
26 epdEnabled = True
[cfdd201]27except:
[6f09609]28 epdEnabled = False
29
[10edeb0]30
31def displayImage(epd, imageFilePath):
[6f09609]32 image = Image.open(imageFilePath)
33 image = ImageOps.grayscale(image)
34 imageResized = image.resize((epd.width, epd.height))
35 imageBlackWhite = imageResized.convert("1", dither=Image.FLOYDSTEINBERG)
36 epd.display(imageBlackWhite)
37 epd.update()
38
[0272b16]39
40def usage():
[6f09609]41 print "Usage of gnuboat-splashscreen:"
42 print " gnuboat-splashscreen [-h] -i PATH_TO_IMAGE_TO_DISPLAY"
43 print ""
44 print " -h --help Print this help"
45 print " -i --image Path to the image, which should be displayed"
46 sys.exit()
[10edeb0]47
48
[6f09609]49def main(argv):
50 image = ""
51 try:
52 opts, args = getopt.getopt(argv, "hi:", ["help", "image="])
53 except getopt.GetoptError:
54 usage()
55 sys.exit(2)
[0272b16]56
[6f09609]57 for option, argument in opts:
58 if option == ("-h", "--help"):
59 usage()
60 sys.exit()
61 elif option in ("-i", "--image"):
62 image = argument
63 else:
64 assert False, "unhandled option"
65
66 if not os.path.exists(image):
67 print "Image %s not found" % image
68 print ""
69 usage()
70 sys.exit(2)
[10edeb0]71
[6f09609]72 if not epdEnabled:
73 print "Could not initialize EPD or PIL python packages"
74 sys.exit(2)
[cfdd201]75
[6f09609]76 epd = EPD()
77 epd.clear()
78 displayImage(epd, image)
[10edeb0]79
80if __name__ == "__main__":
[6f09609]81 main(sys.argv[1:])
Note: See TracBrowser for help on using the repository browser.