mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 15:00:30 +03:00
Replace many subprocess.Popen with FDroidPopen
This commit is contained in:
parent
caa3d4eace
commit
7967cfa6a6
1 changed files with 14 additions and 24 deletions
|
|
@ -71,12 +71,8 @@ def vagrant(params, cwd=None, printout=False):
|
||||||
:returns: (ret, out) where ret is the return code, and out
|
:returns: (ret, out) where ret is the return code, and out
|
||||||
is the stdout (and stderr) from vagrant
|
is the stdout (and stderr) from vagrant
|
||||||
"""
|
"""
|
||||||
p = subprocess.Popen(['vagrant'] + params, cwd=cwd,
|
p = FDroidPopen(['vagrant'] + params, cwd=cwd)
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
return (p.returncode, p.stdout)
|
||||||
out = p.communicate()[0]
|
|
||||||
if options.verbose:
|
|
||||||
print out
|
|
||||||
return (p.returncode, out)
|
|
||||||
|
|
||||||
|
|
||||||
# Note that 'force' here also implies test mode.
|
# Note that 'force' here also implies test mode.
|
||||||
|
|
@ -91,10 +87,8 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
|
||||||
print "Checking for valid existing build server"
|
print "Checking for valid existing build server"
|
||||||
if got_valid_builder_vm():
|
if got_valid_builder_vm():
|
||||||
print "...VM is present"
|
print "...VM is present"
|
||||||
p = subprocess.Popen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'list', '--details'],
|
p = FDroidPopen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'list', '--details'], cwd='builder')
|
||||||
cwd='builder', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
if 'fdroidclean' in p.stdout:
|
||||||
output = p.communicate()[0]
|
|
||||||
if 'fdroidclean' in output:
|
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print "...snapshot exists - resetting build server to clean state"
|
print "...snapshot exists - resetting build server to clean state"
|
||||||
retcode, output = vagrant(['status'], cwd='builder')
|
retcode, output = vagrant(['status'], cwd='builder')
|
||||||
|
|
@ -104,9 +98,8 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
|
||||||
vagrant(['suspend'], cwd='builder')
|
vagrant(['suspend'], cwd='builder')
|
||||||
print "...waiting a sec..."
|
print "...waiting a sec..."
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
p = subprocess.Popen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'restore', 'fdroidclean'],
|
p = FDroidPopen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'restore', 'fdroidclean'],
|
||||||
cwd='builder', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
cwd='builder')
|
||||||
output = p.communicate()[0]
|
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print output
|
print output
|
||||||
if p.returncode == 0:
|
if p.returncode == 0:
|
||||||
|
|
@ -131,9 +124,8 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
|
||||||
shutil.rmtree('builder')
|
shutil.rmtree('builder')
|
||||||
os.mkdir('builder')
|
os.mkdir('builder')
|
||||||
|
|
||||||
p = subprocess.Popen('vagrant --version', shell=True, stdout=subprocess.PIPE)
|
p = FDroidPopen('vagrant --version', shell=True, stdout=subprocess.PIPE)
|
||||||
vver = p.communicate()[0]
|
if p.stdout.startswith('Vagrant version 1.2'):
|
||||||
if vver.startswith('Vagrant version 1.2'):
|
|
||||||
with open('builder/Vagrantfile', 'w') as vf:
|
with open('builder/Vagrantfile', 'w') as vf:
|
||||||
vf.write('Vagrant.configure("2") do |config|\n')
|
vf.write('Vagrant.configure("2") do |config|\n')
|
||||||
vf.write('config.vm.box = "buildserver"\n')
|
vf.write('config.vm.box = "buildserver"\n')
|
||||||
|
|
@ -176,11 +168,10 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
|
||||||
raise BuildException("Failed to suspend build server")
|
raise BuildException("Failed to suspend build server")
|
||||||
print "...waiting a sec..."
|
print "...waiting a sec..."
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
p = subprocess.Popen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'take', 'fdroidclean'],
|
p = FDroidPopen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'take', 'fdroidclean'],
|
||||||
cwd='builder', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
cwd='builder')
|
||||||
output = p.communicate()[0]
|
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
print output
|
print p.stdout
|
||||||
raise BuildException("Failed to take snapshot")
|
raise BuildException("Failed to take snapshot")
|
||||||
print "...waiting a sec..."
|
print "...waiting a sec..."
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
@ -191,10 +182,9 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
|
||||||
print "...waiting a sec..."
|
print "...waiting a sec..."
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
# Make sure it worked...
|
# Make sure it worked...
|
||||||
p = subprocess.Popen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'list', '--details'],
|
p = FDroidPopen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'list', '--details'],
|
||||||
cwd='builder', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
cwd='builder')
|
||||||
output = p.communicate()[0]
|
if 'fdroidclean' not in p.stdout:
|
||||||
if 'fdroidclean' not in output:
|
|
||||||
raise BuildException("Failed to take snapshot.")
|
raise BuildException("Failed to take snapshot.")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue