X-Git-Url: https://git.camperquake.de/gitweb.cgi?p=time-slider.git;a=blobdiff_plain;f=usr%2Fshare%2Ftime-slider%2Flib%2Ftime_slider%2Fzfs.py;h=3efa9cabcdbe15178649134119d1ade4d96f4026;hp=4db057427bed360e17adf6d289c990c1d8e69a7b;hb=a05de207f2bae9d8131568dae5a5838a885cc3c1;hpb=1d212071bcde55b65dd992195929bc957904c6dc diff --git a/usr/share/time-slider/lib/time_slider/zfs.py b/usr/share/time-slider/lib/time_slider/zfs.py index 4db0574..3efa9ca 100644 --- a/usr/share/time-slider/lib/time_slider/zfs.py +++ b/usr/share/time-slider/lib/time_slider/zfs.py @@ -229,12 +229,7 @@ class Datasets(Exception): cmd = [ZFSCMD, "list", "-H", "-t", "filesystem", \ "-o", "name,mountpoint", "-s", "name"] try: - p = subprocess.Popen(cmd, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - close_fds=True) - outdata,errdata = p.communicate() - err = p.wait() + outdata,errdata = util.run_command(cmd, True) except OSError, message: raise RuntimeError, "%s subprocess error:\n %s" % \ (cmd, str(message)) @@ -274,19 +269,11 @@ class Datasets(Exception): cmd = [ZFSCMD, "list", "-H", "-t", "volume", \ "-o", "name", "-s", "name"] try: - p = subprocess.Popen(cmd, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - close_fds=True) - outdata,errdata = p.communicate() - err = p.wait() - except OSError, message: - raise RuntimeError, "%s subprocess error:\n %s" % \ - (cmd, str(message)) - if err != 0: + outdata,errdata = util.run_command(cmd, True) + except RuntimeError, message: Datasets._volumeslock.release() - raise RuntimeError, '%s failed with exit code %d\n%s' % \ - (str(cmd), err, errdata) + raise RuntimeError, str(message) + for line in outdata.rstrip().split('\n'): Datasets.volumes.append(line.rstrip()) Datasets._volumeslock.release() @@ -319,20 +306,10 @@ class Datasets(Exception): snaps = [] cmd = [ZFSCMD, "get", "-H", "-p", "-o", "value,name", "creation"] try: - p = subprocess.Popen(cmd, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - close_fds=True) - outdata,errdata = p.communicate() - err= p.wait() - except OSError, message: + outdata,errdata = util.run_command(cmd, True) + except RuntimeError, message: Datasets.snapshotslock.release() - raise RuntimeError, "%s subprocess error:\n %s" % \ - (cmd, str(message)) - if err != 0: - Datasets.snapshotslock.release() - raise RuntimeError, '%s failed with exit code %d\n%s' % \ - (str(cmd), err, errdata) + raise RuntimeError, str(message) for dataset in outdata.rstrip().split('\n'): if re.search("@", dataset): insort(snaps, dataset.split()) @@ -626,18 +603,9 @@ class ReadableDataset: # simple zfs get command on the snapshot cmd = [ZFSCMD, "get", "-H", "-o", "name", "type", self.name] try: - p = subprocess.Popen(cmd, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - close_fds=True) - outdata,errdata = p.communicate() - err = p.wait() - except OSError, message: - raise RuntimeError, "%s subprocess error:\n %s" % \ - (command, str(message)) - if err != 0: - # Doesn't exist - return False + outdata,errdata = util.run_command(cmd) + except RuntimeError, message: + raise RuntimeError, str(message) result = outdata.rstrip() if result == self.name: