Browse files

added test script to display output instead of printing it (apt-get i…

…nstall qiv)
  • Loading branch information...
1 parent f14f604 commit 70314627561fa8d2479e814fa55f91eb82eedaa9 @stighackvan stighackvan committed Feb 19, 2011
Showing with 23 additions and 4 deletions.
  1. +3 −0 .gitignore
  2. +6 −4 badge/print_badge
  3. +14 −0 badge/test
View
3 .gitignore
@@ -0,0 +1,3 @@
+*.pyc
+*~
+badge/completed/*.png
View
10 badge/print_badge
@@ -32,7 +32,7 @@
# - Give helpful error messages when the configuration file is missing parts that we expect.
# - Add fancypants python documentation
# - Add a library or wrapper for CUPS, send the PNG directly to CUPS
-# - Get the job ID from CUPS, wait for the CUPS job to complete before exiting, fail if the CUPS job fails
+# - Get the job ID from CUPS, wait for the CUPS job to complete before exiting, fail if the CUPS job fails
#
import gd, os, sys, subprocess, getopt, unicodedata, time, simplejson as json
@@ -50,9 +50,11 @@ def print_image(file):
print_file = 'lp -d DYMO_LabelWriter_400_USB_1 -o landscape -o fitplot'.split() + [file]
# print_file = 'lp -H test -d DYMO_LabelWriter_400_USB_1 -o landscape -o fitplot'.split() + [file]
- opts, args = getopt.getopt(sys.argv[1:], "n") # "no print"
+ opts, args = getopt.getopt(sys.argv[1:], "nq") # n:"no print", q:"quick view"
if opts and '-n' in opts[0]:
print "Not executing command:",print_file
+ elif opts and '-q' in opts[0]:
+ subprocess.call(['qiv',file])
else:
subprocess.call(print_file)
@@ -72,7 +74,7 @@ def place(image,(x,y),item):
im = gd.image((input["width"],input["height"]))
x,y = 0,0 # since we are making a temporary image, set these to origin
-
+
# one pass calculation for ideal string size!
size = 100
p = im.get_bounding_rect(item["font"],size,0,(x,y),item["string"])
@@ -106,7 +108,7 @@ def main():
except NameError: conf["badge"]["remove_accents"] = None
os.environ["GDFONTPATH"] = conf["badge"]["font_path"]
-
+
im = gd.image((conf["badge"]["width"],conf["badge"]["height"]))
white = im.colorAllocate(conf["badge"]["color"])
View
14 badge/test
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+./print_badge -q <<END
+{
+ "first_name": "J Random",
+ "last_name": "Hacker",
+ "tags": "Python, Haskell, QR Codes in devhouse badge code, nerd-girl flirting",
+ "shdh_number": "42",
+ "key": "jrandom@gmail.com",
+ "badge_icons": null,
+ "attended_shdh_42": 1229171859,
+ "event_key": "shdh_42"
+}
+END

0 comments on commit 7031462

Please sign in to comment.