如何使用没有回溯错误的python脚本调试错误?

时间:2015-08-25 21:00:43

标签: python shell

def make_offsite_copies_primary():
    """multi-threaded function to update OFFSITE_PREFIX volumes to primary."""

    start_date = time.strftime("%m/%d/%y",
                           time.localtime(time.time() - DR_TAPE_DATE_RANGE))

    for pool in run_command([vmpool, "-listall", "-b"]).readlines():
        if pool.startswith(OFFSITE_PREFIX):
            pool = pool.split()[0]
            logentry("***\tupdating images for pool: %s" % (pool))
            command = [bpchangeprimary, "-pool", pool, "-sd", start_date]
            RunMTCommand.lck.acquire()
            # If we've reached maxthreads, then wait for one to finish
            if len(RunMTCommand.tlist) >= RunMTCommand.maxthreads:
                RunMTCommand.lck.release()
                RunMTCommand.evnt.wait()
            else:
                RunMTCommand.lck.release()
            # For some reason, we often get a "-15" RC, when updating the
            # MLC-Duplication pool.  Let's just ignore it for now.
            RunMTCommand.newthread(command, [0, 13, -15])

    for bpchange_thread in RunMTCommand.tlist:
        bpchange_thread.join()

此函数发出NetBackup命令以将备份副本提升为主副本。

运行此脚本时,它会按预期开始登录终端:

Mon Aug 24 10:04:08 2015 - 17684 - ***  updating images for pool: MLC-2week
Mon Aug 24 10:04:08 2015 - 17684 - ***  updating images for pool: MLC-1month
Mon Aug 24 10:04:08 2015 - 17684 - ***  updating images for pool: MLC-1year
Mon Aug 24 10:04:08 2015 - 17684 - ***  updating images for pool: MLC-Shadow-2week
Mon Aug 24 10:04:08 2015 - 17684 - ***  updating images for pool: MLC-2week-DR-Files
Mon Aug 24 10:04:08 2015 - 17684 - ***  updating images for pool: MLC-Offsite

etc.

但是,似乎没有在脚本中调用bpchangeprimary命令,因为备份副本不会更改。

如果您输入' bpchangeprimary -pool MLC-LTO4-Offsite -sd 08/22/2015'直接从命令行,这将对备份副本进行预期的更改。但是,这行内部函数:

command = [bpchangeprimary, "-pool", pool, "-sd", start_date]

应该完成同样的事情,但事实并非如此,所以我猜这个功能有问题。更糟糕的是,没有追溯错误。

非常感谢任何帮助或有关如何解决此问题的提示。

0 个答案:

没有答案