自动删除linux中的目录(CentOS)

时间:2012-10-03 05:56:28

标签: python linux centos

我正在编写一个代码来生成coredumps的网络摘要文件。 代码:

cmd = "/usr/bin/python2.6 %s %s %s %s %s" % (NET_PATH, build, vsicache, vsicache_5_seconds_later, netdvs)
    full_dir_path = os.path.dirname(vsicache)
    storefile = "%s/netsummary.html" % full_dir_path
    try:
        with open(storefile, "w") as buff:
            buff.write("<html>\n<body>\n<h1>Network Summary</h1>\n<a name=1></a><textarea rows=100 cols=150>\n")
            buff.flush()
            c = subprocess.Popen(args = cmd, shell = True, stdout = buff, stderr = subprocess.PIPE, universal_newlines = True)
            (out, err) = c.communicate()
            if c.returncode is not 0:
                print "There was a problem in execution of command: %s %s" % (err,traceback.format_exc()
                try:
                    os.remove(storefile)
                except:
                    print "Error in deletion of vestigial network-summary file. TraceBack: %s" % traceback.format_exc()

'full_dir_path'有效并包含生成网络摘要所需的3个文件,并且在'subprocess.Popen'开始之前已经在该目录中。但是在执行'subprocess.Popen'的过程中,整个目录('869652')被神秘地删除了所有内容,因此给了我错误:

There was a problem in execution of command:  None
ERROR 2012-10-02 22:12:10,786 netAnalyzer.py:getNetInfo:148 18556:Thread-1 Error in  deletion of vestigial network-summary file. TraceBack: Traceback (most recent call last):
File "/var/www/html/coredump/analyzer/utils/netAnalyzer.py", line 146, in getNetInfo
os.remove(storefile)
OSError: [Errno 2] No such file or directory: '/var/anirudhp/prstore/prs/869652/esx-XSVH-01.gastrostar.gastrostar.ch-2012-08-09--07.17/commands/netsummary.html'

自动删除目录'869652'的原因可能是什么?

0 个答案:

没有答案