我正试图通过Python脚本中的直线连接并运行hql脚本。我无法使用subprocess.run或subprocess.popen运行。我可以直接在命令提示符上运行它
beeline_connect=str('"jdbc:hive2://192.168.0.100:10000/serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2;transportMode=http;httpPath=cliservice;principal=hive/system1.example.co.in@EXAMPLE.CO.IN"')
#passing params as a list
param_list= ['beeline -u' + beeline_connection,'-hivevar', 'VAR1=val1', '-hivevar', 'VAR2=val2', '-hivevar', 'VAR3=val3', '-hivevar', 'VAR4=val4', '-hivevar', 'VAR5=val5', '-f', '/my/path/filename.hql']
command = subprocess.run(param_list, check=True, stdout=subprocess.PIPE)
output = command.stdout
status = str(output.decode('utf-8'))
print(
'****Its failed****, return code {1} with return count {2} :'.format(command.returncode, status))
if command.returncode > 0:
print('Job failed. Raising exception')
raise Exception('Job ' + job_name + ' failed')
else:
## do something else###
#####我还尝试过同时使用shell=True和False,并删除stdout
它永远被卡住了,我联系直线指挥部的方式有什么问题吗?我试过很多下面串联的组合,但没有成功。任何帮助都是可观的。感谢
param_list =['beeline', '-u' + beeline_connection...]
param_list =['beeline', '-u', beeline_connection....]
按以下方式更改代码行对我有效
param_list= ['beeline', '-u',beeline_connection,'-hivevar', 'VAR1=val1', '-hivevar', 'VAR2=val2', '-hivevar', 'VAR3=val3', '-hivevar', 'VAR4=val4', '-hivevar', 'VAR5=val5', '-f', '/my/path/filename.hql']