Skip to content

Commit 7031462

Browse files
committed
added test script to display output instead of printing it (apt-get install qiv)
1 parent f14f604 commit 7031462

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.pyc
2+
*~
3+
badge/completed/*.png

badge/print_badge

+6-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# - Give helpful error messages when the configuration file is missing parts that we expect.
3333
# - Add fancypants python documentation
3434
# - 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
3636
#
3737

3838
import gd, os, sys, subprocess, getopt, unicodedata, time, simplejson as json
@@ -50,9 +50,11 @@ def print_image(file):
5050
print_file = 'lp -d DYMO_LabelWriter_400_USB_1 -o landscape -o fitplot'.split() + [file]
5151
# print_file = 'lp -H test -d DYMO_LabelWriter_400_USB_1 -o landscape -o fitplot'.split() + [file]
5252

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"
5454
if opts and '-n' in opts[0]:
5555
print "Not executing command:",print_file
56+
elif opts and '-q' in opts[0]:
57+
subprocess.call(['qiv',file])
5658
else:
5759
subprocess.call(print_file)
5860

@@ -72,7 +74,7 @@ def place(image,(x,y),item):
7274
im = gd.image((input["width"],input["height"]))
7375

7476
x,y = 0,0 # since we are making a temporary image, set these to origin
75-
77+
7678
# one pass calculation for ideal string size!
7779
size = 100
7880
p = im.get_bounding_rect(item["font"],size,0,(x,y),item["string"])
@@ -106,7 +108,7 @@ def main():
106108
except NameError: conf["badge"]["remove_accents"] = None
107109

108110
os.environ["GDFONTPATH"] = conf["badge"]["font_path"]
109-
111+
110112
im = gd.image((conf["badge"]["width"],conf["badge"]["height"]))
111113
white = im.colorAllocate(conf["badge"]["color"])
112114

badge/test

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
./print_badge -q <<END
4+
{
5+
"first_name": "J Random",
6+
"last_name": "Hacker",
7+
"tags": "Python, Haskell, QR Codes in devhouse badge code, nerd-girl flirting",
8+
"shdh_number": "42",
9+
10+
"badge_icons": null,
11+
"attended_shdh_42": 1229171859,
12+
"event_key": "shdh_42"
13+
}
14+
END

0 commit comments

Comments
 (0)