32
32
# - Give helpful error messages when the configuration file is missing parts that we expect.
33
33
# - Add fancypants python documentation
34
34
# - Add a library or wrapper for CUPS, send the PNG directly to CUPS
35
- # - Get the job ID from CUPS, wait for the CUPS job to complete before exiting, fail if the CUPS job fails
35
+ # - Get the job ID from CUPS, wait for the CUPS job to complete before exiting, fail if the CUPS job fails
36
36
#
37
37
38
38
import gd , os , sys , subprocess , getopt , unicodedata , time , simplejson as json
@@ -50,9 +50,11 @@ def print_image(file):
50
50
print_file = 'lp -d DYMO_LabelWriter_400_USB_1 -o landscape -o fitplot' .split () + [file ]
51
51
# print_file = 'lp -H test -d DYMO_LabelWriter_400_USB_1 -o landscape -o fitplot'.split() + [file]
52
52
53
- opts , args = getopt .getopt (sys .argv [1 :], "n " ) # "no print"
53
+ opts , args = getopt .getopt (sys .argv [1 :], "nq " ) # n: "no print", q:"quick view "
54
54
if opts and '-n' in opts [0 ]:
55
55
print "Not executing command:" ,print_file
56
+ elif opts and '-q' in opts [0 ]:
57
+ subprocess .call (['qiv' ,file ])
56
58
else :
57
59
subprocess .call (print_file )
58
60
@@ -72,7 +74,7 @@ def place(image,(x,y),item):
72
74
im = gd .image ((input ["width" ],input ["height" ]))
73
75
74
76
x ,y = 0 ,0 # since we are making a temporary image, set these to origin
75
-
77
+
76
78
# one pass calculation for ideal string size!
77
79
size = 100
78
80
p = im .get_bounding_rect (item ["font" ],size ,0 ,(x ,y ),item ["string" ])
@@ -106,7 +108,7 @@ def main():
106
108
except NameError : conf ["badge" ]["remove_accents" ] = None
107
109
108
110
os .environ ["GDFONTPATH" ] = conf ["badge" ]["font_path" ]
109
-
111
+
110
112
im = gd .image ((conf ["badge" ]["width" ],conf ["badge" ]["height" ]))
111
113
white = im .colorAllocate (conf ["badge" ]["color" ])
112
114
0 commit comments