Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python调用Apple Reporter JAR文件回答运行时问题以检索令牌_Python - Fatal编程技术网

Python调用Apple Reporter JAR文件回答运行时问题以检索令牌

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

苹果的Reporter API要求从2017年8月10日起获得代币。我试图通过调用Python中的JAR文件来实现自动化,其中包含参数,因此我使用子流程,并且我需要在运行时处理stdout。下面正在进行的工作使我在使用时出现属性退出错误。我对其他方法持开放态度,因为到目前为止我无法回答运行时问题,所以我不会得到返回的令牌

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)现在返回代码为零,但仍然不起作用。您解决了这个问题吗?