Getting an error in Python when trying to use stdin: io.UnsupportedOperation: fileno -


i trying std in xml file. read xml file subversion, updated line in file , trying create jenkins job using subporcess.popen , stdin

test = subprocess.popen('svn cat http://localhost/svn/wernertest/jenkinsjobtemplates/trunk/smarttemplate.xml --username admin --password admin', stdout=subprocess.pipe, universal_newlines=true) job = test.stdout.read().replace("@url@", "http://localhost/svn/wernertest/tms/branches/test1") output = io.stringio() output.write(job) subprocess.popen('java -jar d:\\applications\\jenkins\\war\\web-inf\\jenkins-cli.jar\\jenkins-cli.jar -s http://localhost:8080/ create-job test7', stdin=output) 

and getting following error:

traceback (most recent call last):  file "d:\scripts\jenkinsgetjobs.py", line 20, in <module> subprocess.popen('java -jar d:\\applications\\jenkins\\war\\web-inf\\jenkins-cli.jar\\jenkins-cli.jar -s http://localhost:8080/ create-job test7', stdin=output) file "d:\applications\python 3.5\lib\subprocess.py", line 914,  in __init__errread, errwrite) = self._get_handles(stdin, stdout, stderr) file "d:\applications\python 3.5\lib\subprocess.py", line 1127, in _get_handles p2cread = msvcrt.get_osfhandle(stdin.fileno()) io.unsupportedoperation: fileno 

so how pass in updated file next subprocess?

use pipe , write data directly pipe:

test = subprocess.popen(     'svn cat http://localhost/svn/wernertest/jenkinsjobtemplates/trunk/smarttemplate.xml --username admin --password admin',     stdout=subprocess.pipe, universal_newlines=true) job = test.stdout.read().replace("@url@", "http://localhost/svn/wernertest/tms/branches/test1")  jenkins = subprocess.popen(     'java -jar d:\\applications\\jenkins\\war\\web-inf\\jenkins-cli.jar\\jenkins-cli.jar -s http://localhost:8080/ create-job test7',     stdin=subprocess.pipe, universal_newlines=true) jenkins.communicate(job) 

the popen.communicate() method takes first argument , sends stdin subprocess.

note set universal_newlines argument true jenkins well; alternative explicitly encode job string suitable codec jenkins accept.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -