X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=source%2Futils.py;h=e0f3c72d00d686d5a68dd741849f009318b7f96d;hb=64ddfcb8ba5498bd25f469d5daabdbcafbc41821;hp=5ad3ec7b61ade5e97773edef0c30505836a4a8dd;hpb=752736d288e356875e5a3198bf1ef1dd43ac9f34;p=bootmanager.git diff --git a/source/utils.py b/source/utils.py index 5ad3ec7..e0f3c72 100644 --- a/source/utils.py +++ b/source/utils.py @@ -7,6 +7,8 @@ # All rights reserved. # expected /proc/partitions format +from __future__ import print_function + import os, sys, shutil import subprocess import shlex @@ -41,7 +43,7 @@ VERBOSE_MODE = True # in seconds : if no input, proceed PROMPT_TIMEOUT = 5 -def prompt_for_breakpoint_mode (): +def prompt_for_breakpoint_mode(): global BREAKPOINT_MODE if PROMPT_MODE: @@ -75,9 +77,12 @@ def breakpoint (message, cmd = None): cmd = "/bin/sh" message = message + " -- Entering bash - type ^D to proceed" - print message + print(message) os.system(cmd) + else: + print("Ignoring breakpoint (BREAKPOINT_MODE=False) : {}".format(message)) + ######################################## def makedirs(path): @@ -142,13 +147,13 @@ def sysexec(cmd, log=None, fsck=False, shell=False): if log is not None: log.write("sysexec (shell mode) >>> {}".format(cmd)) if VERBOSE_MODE: - print "sysexec (shell mode) >>> {}".format(cmd) + print("sysexec (shell mode) >>> {}".format(cmd)) else: prog = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE) if log is not None: log.write("sysexec >>> {}\n".format(cmd)) if VERBOSE_MODE: - print "sysexec >>> {}".format(cmd) + print("sysexec >>> {}".format(cmd)) except OSError: raise BootManagerException( "Unable to create instance of subprocess.Popen " @@ -220,8 +225,8 @@ def sysexec_noerr(cmd, log=None, shell=False): same as sysexec, but capture boot manager exceptions """ try: - rc= 0 - rc= sysexec(cmd, log, shell=shell) + rc = 0 + rc = sysexec(cmd, log, shell=shell) except BootManagerException as e: pass