summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>2013-10-21 11:08:31 +0200
committerHauke Mehrtens <hauke@hauke-m.de>2013-10-21 21:50:38 +0200
commit57554a365682979473778ffca9a9c5c82ab4dee6 (patch)
tree892af382c73530305804e2535cbb790825d4bced /lib
parentdcd5524fc04730b0af05b28388d246cad97a91c2 (diff)
lib/bpkup.py: add or own kernel uploader helper lib
kup is written in perl, add some basic python interfaces for it to allow us to upload to kernel.org backport releases. Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/bpkup.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/bpkup.py b/lib/bpkup.py
new file mode 100644
index 00000000..03504bb3
--- /dev/null
+++ b/lib/bpkup.py
@@ -0,0 +1,44 @@
+import subprocess, os
+
+class KupError(Exception):
+ pass
+class ExecutionError(KupError):
+ def __init__(self, errcode):
+ self.error_code = errcode
+
+def _check(process):
+ if process.returncode != 0:
+ raise ExecutionError(process.returncode)
+
+def mkdir(path):
+ cmd = ['kup', 'mkdir', path]
+ process = subprocess.Popen(cmd,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ close_fds=True, universal_newlines=True)
+ stdout = process.communicate()[0]
+ process.wait()
+ _check(process)
+
+ return stdout
+
+def ls(path=None):
+ cmd = ['kup', 'ls', path]
+ process = subprocess.Popen(cmd,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ close_fds=True, universal_newlines=True)
+ stdout = process.communicate()[0]
+ process.wait()
+ _check(process)
+
+ return stdout
+
+def put(tar_bz2, signed_tar, path):
+ cmd = ['kup', 'put', tar_bz2, signed_tar, path]
+ process = subprocess.Popen(cmd,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ close_fds=True, universal_newlines=True)
+ stdout = process.communicate()[0]
+ process.wait()
+ _check(process)
+
+ return stdout