def JobEnd(self, job):
        # If this is a verify job, bail
        if 'Verify' in job.Job: return
        if job.JobStatus in 'fAEe']: return # Don't do anything fancy with errored-out jobs

        # Let's truncate any new purged volumes in this pool.
         runcmd = 'purge volume acti allpools storage=%s\nquit\n' % job.Storage
        # We cannot use job.run() because it won't accept the action
        # keyword for purge.  Le sigh.
        try:
            so = subprocess.Popen('bconsole', shell=True,
                                  stdin=subprocess.PIPE,
                                  stdout=subprocess.PIPE).communicate(runcmd)[0]
        except Exception, e:
            job.JobReport = 'Bailing ... '
            job.JobReport = str(e)
            return
        job.JobReport = "ran volume purge command: %s" % so

        # This bit gives us a chance (5%) of running a verify job against this one.
        if choice(numarray) < 5:          # 5% chance of running a verify
            runcmd = 'run job=%s-Verify jobid=%d yes' % (job.Job, job.JobId)
            newjob = job.run(runcmd)
            job.JobReport="%s: jobid=%d\\n" % (runcmd, newjob)
        return

Add a code snippet to your website: www.paste.org