python跳过错误_为什么我的python函数被跳过?

我有一个小脚本试图执行一个外部命令。但是由于某些原因,我用来执行命令的函数被完全跳过了!似乎没有出现错误,只是无法执行。我在里面有一些调试print语句来验证函数是否被输入,但是它们从不打印。我在它外面有一个print语句来验证脚本没有死。那么什么给予?在from xml.etree import ElementTree as et

import subprocess

pomFileLocation = "pom.xml"

uiAutomationCommand = "mvn clean install"

revertPomFileCommand = "git checkout pom.xml"

profileToSetToDefault = "smoketest"

def modifyxml( datafile, value ):

print( "modifying " + datafile )

tree = et.parse( datafile )

rootNodes = tree.getroot()

for node in rootNodes:

if "profiles" in node.tag:

for profile in node.iter():

foundIt = False

for param in profile.iter():

if "id" in param.tag and profileToSetToDefault in param.text:

foundIt = True

break

if foundIt == True:

for param in profile.iter():

if "activation" in param.tag:

for child in param.iter():

if "activeByDefault" in child.tag:

child.text = value

tree.write( datafile )

return

def runExternalCommand( comm ):

print( "running command " + comm )

p = subprocess.Popen( comm, bufsize=-1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ).communicate()[0]

print( str(p) )

while( True ):

print( "still running" )

retcode = p.poll()

line = p.stdout.readline()

yield line

if( retcode is not None ):

print("Exiting")

break

return

if __name__ == '__main__':

modifyxml( pomFileLocation, "true" )

#runExternalCommand( uiAutomationCommand )

runExternalCommand( revertPomFileCommand )

print( "finished" )

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值