Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import win32print
- import win32api
- from os.path import isfile, join
- import glob
- import os
- import time
- source_path = "c:\\temp\\source\\"
- def main():
- printer_name = win32print.GetDefaultPrinter()
- while True:
- file_queue = [f for f in glob.glob("%s\\*.txt" % source_path) if isfile(f)]
- if len(file_queue) > 0:
- for i in file_queue:
- hinstance = print_file(i, printer_name)
- print hinstance
- raw_input("press enter")
- if hinstance > 32:
- delete_file(i)
- print "Filename: %r has printed" % i
- print
- time.sleep(.25)
- print
- else:
- print "No files to print. Will retry in 15 seconds"
- time.sleep(15)
- def print_file(pfile, printer):
- hinstance = win32api.ShellExecute(
- 0,
- "print",
- '%s' % pfile,
- '/d:"%s"' % printer,
- ".",
- 0
- )
- time.sleep(.25)
- return hinstance
- def delete_file(f):
- os.remove(f)
- print f, "was deleted!"
- def alert(email):
- pass
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement