Skip to content

Instantly share code, notes, and snippets.

Created August 12, 2013 21:14
Show Gist options
  • Save anonymous/6215335 to your computer and use it in GitHub Desktop.
Save anonymous/6215335 to your computer and use it in GitHub Desktop.
# Function to print the last order row of new Order
def printOrder(d):
key = d.keys()[-1]
lpr = subprocess.Popen("/usr/bin/lpr", stdin=subprocess.PIPE)
lpr.stdin.write("OrderNo"+ str(key)+"\n")
lpr.stdin.write("Name :"+ d[key]['name'] + "\n")
lpr.stdin.write("tel :"+ str(d[key]['telephone'])+"\n")
for y in d[key]['items']:
lpr.stdin.write(y['name'] + " " + y['size'] +" " + str(y['quantity']) + " " +str(y['price']) + "\n")
lpr.stdin.write("$ "+ str(d[key]['total']) + " discount" +" "+ str(d[key]['discount']) )
lpr.stdin.write(d[key]['instruct']+"\n")
lpr.stdin.close()
lpr.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment