[pywin32-checkins] pywin32/com/win32comext/bits/test show_all_jobs.py, NONE, 1.1.2.1
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2008-02-08 05:43:55
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/bits/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27087 Added Files: Tag: sidnei-bits show_all_jobs.py Log Message: utility for dumping all bits jobs --- NEW FILE: show_all_jobs.py --- # Dump lots of info about BITS jobs. from win32com.bits import bits import pythoncom states = dict([(val, (name[13:])) for name, val in vars(bits).items() if name.startswith('BG_JOB_STATE_')]) job_types = dict([(val, (name[12:])) for name, val in vars(bits).items() if name.startswith('BG_JOB_TYPE_')]) bcm = pythoncom.CoCreateInstance(bits.CLSID_BackgroundCopyManager, None, pythoncom.CLSCTX_LOCAL_SERVER, bits.IID_IBackgroundCopyManager) try: enum = bcm.EnumJobs(bits.BG_JOB_ENUM_ALL_USERS) except pythoncom.error: print "Failed to get jobs for all users - trying for current user" enum = bcm.EnumJobs(0) for job in enum: print "Job:", job.GetDisplayName() print "Description:", job.GetDescription() print "Id:", job.GetId() print "State:", states.get(job.GetState()) print "Type:", job_types.get(job.GetType()) print "Owner:", job.GetOwner() print "Errors:", job.GetErrorCount() print "Created/Modified/Finished times:", [str(t) for t in job.GetTimes()] bytes_tot, bytes_xf, files_tot, files_xf = job.GetProgress() print "Bytes: %d complete of %d total" % (bytes_tot, bytes_xf) print "Files: %d complete of %d total" % (files_tot, files_xf) for f in job.EnumFiles(): bytes, total, done = f.GetProgress() print " Remote:", f.GetRemoteName() print " Local:", f.GetLocalName() print " Progress: %d of %d bytes - completed=%s)" % (bytes, total, done) print print |