Python调用Apple Reporter JAR文件回答运行时问题以检索令牌
苹果的Reporter API要求从2017年8月10日起获得代币。我试图通过调用Python中的JAR文件来实现自动化,其中包含参数,因此我使用子流程,并且我需要在运行时处理stdout。下面正在进行的工作使我在使用时出现属性退出错误。我对其他方法持开放态度,因为到目前为止我无法回答运行时问题,所以我不会得到返回的令牌Python调用Apple Reporter JAR文件回答运行时问题以检索令牌,python,Python,苹果的Reporter API要求从2017年8月10日起获得代币。我试图通过调用Python中的JAR文件来实现自动化,其中包含参数,因此我使用子流程,并且我需要在运行时处理stdout。下面正在进行的工作使我在使用时出现属性退出错误。我对其他方法持开放态度,因为到目前为止我无法回答运行时问题,所以我不会得到返回的令牌 import subprocess from subprocess import Popen, PIPE with subprocess.call(['java -jar R
import subprocess
from subprocess import Popen, PIPE
with subprocess.call(['java -jar Reporter.jar p=Reporter.properties sales.generateToken'], shell=True, stdin=PIPE, stdout=PIPE, universal_newlines=True) as p:
for line in p.stdout:
if line.startswith("Please enter your username"):
answer = 'username'
elif line.startswith("Please enter your password"):
answer = 'password'
else:
continue # skip it
print(answer, p.stdin) # provide answer
p.stdin.flush()
我已经放弃了WITH和CALL上下文,现在使用:p=subprocess.Popen(['java-jar/etl/apple2/Reporter.jar p=Reporter.properties sales.generateToken',shell=True,stdin=PIPE,stdout=PIPE,stderr=PIPE)现在返回代码为零,但仍然不起作用。您解决了这个问题吗?