Update of /cvsroot/pywin32/pywin32/com/win32comext/bits/test
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv20331/com/win32comext/bits/test
Modified Files:
Tag: py3k
show_all_jobs.py test_bits.py
Log Message:
many more upgrades to py3k syntax
Index: show_all_jobs.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/test/show_all_jobs.py,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -d -r1.2 -r1.2.2.1
*** show_all_jobs.py 12 Feb 2008 00:10:57 -0000 1.2
--- show_all_jobs.py 26 Nov 2008 09:03:30 -0000 1.2.2.1
***************
*** 19,42 ****
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_xf, bytes_tot)
! print "Files: %d complete of %d total" % (files_xf, files_tot)
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
--- 19,42 ----
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_xf, bytes_tot))
! print("Files: %d complete of %d total" % (files_xf, files_tot))
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()
Index: test_bits.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/test/test_bits.py,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -d -r1.2 -r1.2.2.1
*** test_bits.py 12 Feb 2008 00:10:57 -0000 1.2
--- test_bits.py 26 Nov 2008 09:03:30 -0000 1.2.2.1
***************
*** 23,42 ****
def JobTransferred(self, job):
! print 'Job Transferred', job
job.Complete()
win32event.SetEvent(StopEvent) # exit msg pump
def JobError(self, job, error):
! print 'Job Error', job, error
f = error.GetFile()
! print 'While downloading', f.GetRemoteName()
! print 'To', f.GetLocalName()
! print 'The following error happened:'
self._print_error(error)
if f.GetRemoteName().endswith('missing-favicon.ico'):
! print 'Changing to point to correct file'
f2 = f.QueryInterface(bits.IID_IBackgroundCopyFile2)
favicon = 'http://www.python.org/favicon.ico'
! print 'Changing RemoteName from', f2.GetRemoteName(), 'to', favicon
f2.SetRemoteName(favicon)
job.Resume()
--- 23,42 ----
def JobTransferred(self, job):
! print('Job Transferred', job)
job.Complete()
win32event.SetEvent(StopEvent) # exit msg pump
def JobError(self, job, error):
! print('Job Error', job, error)
f = error.GetFile()
! print('While downloading', f.GetRemoteName())
! print('To', f.GetLocalName())
! print('The following error happened:')
self._print_error(error)
if f.GetRemoteName().endswith('missing-favicon.ico'):
! print('Changing to point to correct file')
f2 = f.QueryInterface(bits.IID_IBackgroundCopyFile2)
favicon = 'http://www.python.org/favicon.ico'
! print('Changing RemoteName from', f2.GetRemoteName(), 'to', favicon)
f2.SetRemoteName(favicon)
job.Resume()
***************
*** 50,63 ****
except win32api.error:
hresult_msg = ""
! print "Context=0x%x, hresult=0x%x (%s)" % (ctx, hresult, hresult_msg)
! print err.GetErrorDescription()
def JobModification(self, job, reserved):
state = job.GetState()
! print 'Job Modification', job.GetDisplayName(), states.get(state)
# Need to catch TRANSIENT_ERROR here, as JobError doesn't get
# called (apparently) when the error is transient.
if state == bits.BG_JOB_STATE_TRANSIENT_ERROR:
! print "Error details:"
err = job.GetError()
self._print_error(err)
--- 50,63 ----
except win32api.error:
hresult_msg = ""
! print("Context=0x%x, hresult=0x%x (%s)" % (ctx, hresult, hresult_msg))
! print(err.GetErrorDescription())
def JobModification(self, job, reserved):
state = job.GetState()
! print('Job Modification', job.GetDisplayName(), states.get(state))
# Need to catch TRANSIENT_ERROR here, as JobError doesn't get
# called (apparently) when the error is transient.
if state == bits.BG_JOB_STATE_TRANSIENT_ERROR:
! print("Error details:")
err = job.GetError()
self._print_error(err)
***************
*** 86,91 ****
for f in job.EnumFiles():
! print 'Downloading', f.GetRemoteName()
! print 'To', f.GetLocalName()
job.Resume()
--- 86,91 ----
for f in job.EnumFiles():
! print('Downloading', f.GetRemoteName())
! print('To', f.GetLocalName())
job.Resume()
|