我有一段Python,我的头撞在墙上。我不是python开发人员/程序员。然而,我的任务是在这个应用程序中重做一些功能,我不能弄清楚这是什么寻找。我有一个聚会计划,支持.sh,也就是说。它做的和旧的一样,但是我删除了500行无用的代码。它收集一堆日志和其他信息,然后我重新同步一些目录,并通过它们进入/tmp/“$bundleName”,然后创建一个zip。你知道吗
为了开始这个过程,有一个python脚本被调用,它调用了我的bash脚本。这里是检查我的bash的片段,但是我不知道它在寻找什么来表示我的bash程序的完成。一旦我知道它想要什么来表示我的bash已经完成,我将把它添加到我的程序的末尾来表示它已经完成了。你知道吗
下面是查找我的bash状态的python:
def checkSupportBundleGenerationStatus(bundle):
try:
f=open(SUPPORT_BUNDLE_DIR + bundle + '/' + SUPPORT_BUNDLE_LOG,'r')
blog=f.read()
f.close()
except:
sendError("Invalid bundle")
log.message(cgiutil.LOG_INFO, "Log bundle generation output so far %r bytes." % len(blog))
filename=None
lines = blog.splitlines()
for l in lines:
pair = l.split(':', 1)
if len(pair) == 2 and pair[0] == 'File':
filename=pair[1].strip()
break
blog=re.sub(r'\rPreparing Files: [-\\|/]','',blog)
if filename:
dlPath=filename.replace(SUPPORT_BUNDLE_DIR,'',1)
try:
fileSize=os.stat(filename).st_size
except:
sendError('Error accesing bundle zip')
lastSlash=filename.rfind("/")
if lastSlash != -1 :
filename=filename[lastSlash+1:]
dlMessage='''<form action="%s" method="post">
<input type="hidden" name="HTTP_AUTHORIZATION" value="%s"/>
%s (%s) is ready for download. <input type="submit" value="Download">
</form>''' % (
buildGetQuery(downloadbundle=dlPath),
os.environ['HTTP_AUTHORIZATION'],
filename,
convertBytes(fileSize)
)
sendBundlePage(dlMessage,blog)
else:
sendBundlePage(WAIT_MSG,blog,buildGetQuery(checkbundle=bundle), os.environ['HTTP_AUTHORIZATION'])
谢谢!你知道吗
循环:
查找以
File:
开头的第一行。它将filename
设置为前缀后面的文件名。如果找到此行,它将在以下时间后执行代码块:如果找不到,将转到:
相关问题 更多 >
编程相关推荐