stage('python') {
sh script: '''
#!/bin/bash
set -ex
python2.7 -u run_test.py <--- this script had a import error but stage passed
'''.stripIndent()
}
在日志中,
[2021-01-09T05:35:25.812Z] + python2.7 -u run_test.py
[2021-01-09T05:
我想从嵌入的python代码中退出shell脚本。下面的os.system()不起作用,其余的shell脚本代码仍在执行。
echo "this is shell code"
a=10
python << END
import os
print "this is python code"
if True:
print "yes"
print $a
os.system("exit 1")
END
echo "I am out of python code"
我需要计算python脚本中shell命令输出的行数。
此函数在有输出的情况下工作得很好,但在输出为空的情况下,它会给出一个错误,如错误输出中所述。
我尽量避免使用if语句,以防命令的输出是None,但这没有帮助。
#!/usr/bin/python
import subprocess
lines_counter=0
func="nova list | grep Shutdown "
data=subprocess.check_output(func, shell=True)
if data is True:
for line in data.splitline
试图在python提示符中运行简单的python文件,但给出了一个错误:
test.py含量
print("Trying to print this using .py file on anaconda prompt")
从python提示符运行文件
(base) C:\Users\acharbha>python
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyr
我正在尝试执行一个数据流python文件,该文件使用DataFlowPythonOperator从GCS桶中读取文本文件。我能够独立地执行python文件,但是当我通过气流执行它时,它失败了。我使用一个服务帐户来验证我的默认gcp连接。执行作业时遇到的错误是:
{gcp_dataflow_hook.py:108} INFO - Start waiting for DataFlow process to complete.
{models.py:1417} ERROR - DataFlow failed with return code 2
Traceback (most recent call
我试图使用"check_output“方法在python程序中获得命令的输出。但我发现了一个错误:
out = check_output(command5 , shell=True)
文件“/usr/ line 64/python3.6/subprocess.py”,第336行,在check_output **kwargs).stdout File“/usr/ line 64/python3.6/subprocess.py”中,第418行,在run output=stdout,stderr=stderr) subprocess.CalledProcessError中:命令'