I have successfully managed to trigger a callback when a print job is initially requested on the local machine during spooling. However is there anyway with win32print
or something similar that may allow me to handle the event in which a print job is transferred to a print server or USB printer?
################################################################################
# Imports ######################################################################
################################################################################
from os.path import *
from printer import *
from watcher import *
from statvar import *
################################################################################
# Event Callback ###############################################################
################################################################################
def callback(code, event):
num = splitext(event)[0]
ext = splitext(event)[1]
if code == 1 and ext == '.SPL':
main(num.lstrip('0'))
################################################################################
# wx Event Handler #############################################################
################################################################################
def handling(*args):
wx.CallAfter(callback, *args)
################################################################################
# Create Listener ##############################################################
################################################################################
# listens to the spool directory for files
watch = Watcher(SPOOL_DIRECTORY, handling)
# set the appropriate flags for a listener
watch.flags = FILE_NOTIFY_CHANGE_FILE_NAME
################################################################################
# Start Listener ###############################################################
################################################################################
watch.start()
################################################################################
# Start wx App #################################################################
################################################################################
app = wx.App()
wx.Frame(None)
app.MainLoop()
################################################################################
################################################################################
################################################################################