[core] Fix import error for Python3

Import exceptions module only for Python2.

fixes #22
This commit is contained in:
Tobi-wan Kenobi 2016-11-27 18:33:37 +01:00
parent 60d96506e8
commit 28a4f4ab9d

View file

@ -1,6 +1,10 @@
import shlex import shlex
import exceptions
import subprocess import subprocess
try:
from exceptions import RuntimeError
except ImportError:
# Python3 doesn't require this anymore
pass
def bytefmt(num): def bytefmt(num):
for unit in [ "", "Ki", "Mi", "Gi" ]: for unit in [ "", "Ki", "Mi", "Gi" ]:
@ -23,4 +27,4 @@ def execute(cmd):
out = p.communicate() out = p.communicate()
if p.returncode != 0: if p.returncode != 0:
raise exceptions.RuntimeError("{} exited with {}".format(cmd, p.returncode)) raise RuntimeError("{} exited with {}".format(cmd, p.returncode))