aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlice Ferrazzi <alicef@gentoo.org>2017-07-06 22:26:35 +0900
committerAlice Ferrazzi <alicef@gentoo.org>2017-07-06 22:26:35 +0900
commit2aa75cdd5af96e97470ae496fa6d8c867b80a532 (patch)
tree831f9623ed4e6e48a1ffcb4d53aa6f5befb0d8c6
parentUnified send file function (diff)
downloadelivepatch-2aa75cdd5af96e97470ae496fa6d8c867b80a532.tar.gz
elivepatch-2aa75cdd5af96e97470ae496fa6d8c867b80a532.tar.bz2
elivepatch-2aa75cdd5af96e97470ae496fa6d8c867b80a532.zip
made function for subprocess popen
-rw-r--r--elivepatch_server/resources/livepatch.py38
1 files changed, 18 insertions, 20 deletions
diff --git a/elivepatch_server/resources/livepatch.py b/elivepatch_server/resources/livepatch.py
index c2bc5ce..bcd4e4e 100644
--- a/elivepatch_server/resources/livepatch.py
+++ b/elivepatch_server/resources/livepatch.py
@@ -88,27 +88,25 @@ class PaTch(object):
if debug:
bashCommand.extend(['--skip-cleanup'])
bashCommand.extend(['--debug'])
- print(bashCommand)
- process = subprocess.Popen(bashCommand, stdout=subprocess.PIPE)
- output, error = process.communicate()
- print(output)
+ self.command(bashCommand)
def build_kernel(self, kernel_source_dir):
- bashCommand = (['sudo','make','oldconfig'])
- print(bashCommand)
- process = subprocess.Popen(bashCommand, stdout=subprocess.PIPE, cwd=kernel_source_dir)
- output, error = process.communicate()
- print(output)
-
- bashCommand = (['sudo','make'])
- print(bashCommand)
- process = subprocess.Popen(bashCommand, stdout=subprocess.PIPE, cwd=kernel_source_dir)
- output, error = process.communicate()
- print(output)
+ self.command(['sudo','make','oldconfig'], kernel_source_dir)
+ self.command(['sudo','make'], kernel_source_dir)
+ self.command(['sudo','make', 'modules'], kernel_source_dir)
+ self.command(['sudo','make', 'modules_install'], kernel_source_dir)
def get_kernel(self, kernel_version):
- bashCommand = ['sudo','emerge','-q','"=sys-kernel/gentoo-sources-'+kernel_version+'"']
- print(bashCommand)
- process = subprocess.Popen(bashCommand, stdout=subprocess.PIPE)
- output, error = process.communicate()
- print(output)
+ self.command(['sudo','emerge','-q','"=sys-kernel/gentoo-sources-'+kernel_version+'"'])
+
+ def command(self, bashCommand, kernel_source_dir=None):
+ if kernel_source_dir:
+ print(bashCommand)
+ process = subprocess.Popen(bashCommand, stdout=subprocess.PIPE, cwd=kernel_source_dir)
+ output, error = process.communicate()
+ print(output)
+ else:
+ print(bashCommand)
+ process = subprocess.Popen(bashCommand, stdout=subprocess.PIPE)
+ output, error = process.communicate()
+ print(output)