X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fbacula%2Ffiles%2Fvolume-purge-action;h=53888293be54022956373f36af020cf942d549f5;hb=d65d563ddf3dbd57e4c80905a442279d11e7dd1a;hp=fc6eef7d0d6f22c16449a64ecadc2436f2d354fe;hpb=3f3b92742679c0dfdf75794f45ef526a133fdc90;p=mirror%2Fdsa-puppet.git diff --git a/modules/bacula/files/volume-purge-action b/modules/bacula/files/volume-purge-action index fc6eef7d0..53888293b 100755 --- a/modules/bacula/files/volume-purge-action +++ b/modules/bacula/files/volume-purge-action @@ -60,27 +60,28 @@ storages = set(r['mediatype'] for r in cursor.fetchall()) cmd = [] for s in storages: - c = 'truncate allpools storage=%s'%(s,) - cmd.append(c) + c = 'truncate allpools storage=%s'%(s,) + cmd.append(c) if args.nodo: print("\n".join(cmd)) sys.exit(0) -if args.verbose: - for c in cmd: - print("Will run: %s"%(c,)) -p = subprocess.Popen(['bconsole'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) -(out, err) = p.communicate("\n".join(cmd).encode()) -if p.returncode != 0: +for c in cmd: + if args.verbose: + print("Will run: %s"%(c,)) + + p = subprocess.Popen(['/usr/sbin/bconsole'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (out, err) = p.communicate(c.encode()) + if p.returncode != 0: raise Exception("bconsole failed. stdout:\n%s\nstderr:%s\n"%(out, err)) -if args.verbose: + if args.verbose: print("stdout:\n") sys.stdout.buffer.write(out) print("\n") -if err != b"": - print("bconsole said on stderr:\n", file=sys.stderr) - sys.stderr.buffer.write(out) - print("", file=sys.stderr) - sys.exit(1) + if err != b"": + print("bconsole said on stderr:\n", file=sys.stderr) + sys.stderr.buffer.write(out) + print("", file=sys.stderr) + sys.exit(1)