def __run_command(self, command, send_yes=False, cwd=None, retry=False): if cwd is None: cwd = self.install_dir if retry: max_attempts = 5 else: max_attempts = 1 attempt = 1 delay = 0 if send_yes: command = "yes yes | " + command rel_cwd = setup_util.path_relative_to_root(cwd) print("INSTALL: %s (cwd=$FWROOT/%s)" % (command, rel_cwd)) while attempt <= max_attempts: error_message = "" try: # Execute command. subprocess.check_call(command, shell=True, cwd=cwd, executable='/bin/bash') break # Exit loop if successful. except: exceptionType, exceptionValue, exceptionTraceBack = sys.exc_info( ) error_message = "".join( traceback.format_exception_only(exceptionType, exceptionValue)) # Exit if there are no more attempts left. attempt += 1 if attempt > max_attempts: break # Delay before next attempt. if delay == 0: delay = 5 else: delay = delay * 2 print("Attempt %s/%s starting in %s seconds." % (attempt, max_attempts, delay)) time.sleep(delay) if error_message: self.__install_error(error_message)
def __run_command(self, command, send_yes=False, cwd=None): if cwd is None: cwd = self.install_dir if send_yes: command = "yes yes | " + command rel_cwd = setup_util.path_relative_to_root(cwd) print("INSTALL: %s (cwd=$FWROOT/%s)" % (command, rel_cwd)) try: subprocess.check_call(command, shell=True, cwd=cwd, executable='/bin/bash') except: exceptionType, exceptionValue, exceptionTraceBack = sys.exc_info() error_message = "".join(traceback.format_exception_only(exceptionType, exceptionValue)) self.__install_error(error_message)
def __run_command(self, command, send_yes=False, cwd=None, retry=False): if cwd is None: cwd = self.install_dir if retry: max_attempts = 5 else: max_attempts = 1 attempt = 1 delay = 0 if send_yes: command = "yes yes | " + command rel_cwd = setup_util.path_relative_to_root(cwd) print("INSTALL: %s (cwd=$FWROOT/%s)" % (command, rel_cwd)) while attempt <= max_attempts: error_message = "" try: # Execute command. subprocess.check_call(command, shell=True, cwd=cwd, executable='/bin/bash') break # Exit loop if successful. except: exceptionType, exceptionValue, exceptionTraceBack = sys.exc_info() error_message = "".join(traceback.format_exception_only(exceptionType, exceptionValue)) # Exit if there are no more attempts left. attempt += 1 if attempt > max_attempts: break # Delay before next attempt. if delay == 0: delay = 5 else: delay = delay * 2 print("Attempt %s/%s starting in %s seconds." % (attempt, max_attempts, delay)) time.sleep(delay) if error_message: self.__install_error(error_message)
def __run_command(self, command, send_yes=False, cwd=None): if cwd is None: cwd = self.install_dir if send_yes: command = "yes yes | " + command rel_cwd = setup_util.path_relative_to_root(cwd) print("INSTALL: %s (cwd=$FWROOT/%s)" % (command, rel_cwd)) try: subprocess.check_call(command, shell=True, cwd=cwd, executable='/bin/bash') except: exceptionType, exceptionValue, exceptionTraceBack = sys.exc_info() error_message = "".join( traceback.format_exception_only(exceptionType, exceptionValue)) self.__install_error(error_message)
def __install_server_software(self): print("\nINSTALL: Installing server software (strategy=%s)\n"%self.strategy) # Install global prerequisites bash_functions_path='$FWROOT/toolset/setup/linux/bash_functions.sh' prereq_path='$FWROOT/toolset/setup/linux/prerequisites.sh' self.__run_command(". %s && . %s" % (bash_functions_path, prereq_path)) # Pull in benchmarker include and exclude list exclude = self.benchmarker.exclude include = self.benchmarker.test if exclude == None: exclude = [] # Locate all known tests install_files = glob.glob("%s/*/install.sh" % self.fwroot) # Run install for selected tests for test_install_file in install_files: test_dir = os.path.dirname(test_install_file) test_name = os.path.basename(test_dir) test_rel_dir = setup_util.path_relative_to_root(test_dir) if test_name in exclude: logging.debug("%s has been excluded", test_name) continue elif include is not None and test_name not in include: logging.debug("%s not in include list", test_name) continue else: logging.info("Running installation for %s"%test_name) # Find installation directory # e.g. FWROOT/installs or FWROOT/installs/pertest/<test-name> test_install_dir="%s/%s" % (self.fwroot, self.install_dir) if self.strategy is 'pertest': test_install_dir="%s/pertest/%s" % (test_install_dir, test_name) test_rel_install_dir=setup_util.path_relative_to_root(test_install_dir) if not os.path.exists(test_install_dir): os.makedirs(test_install_dir) # Load profile for this installation profile="%s/bash_profile.sh" % test_dir if not os.path.exists(profile): logging.warning("Framework %s does not have a bash_profile"%test_name) profile="$FWROOT/config/benchmark_profile" setup_util.replace_environ(config=profile) # Find relative installation file test_rel_install_file = "$FWROOT%s" % setup_util.path_relative_to_root(test_install_file) # Then run test installer file # Give all installers a number of variables # FWROOT - Path of the FwBm root # IROOT - Path of this test's install directory # TROOT - Path to this test's directory self.__run_command(''' export TROOT=$FWROOT%s && export IROOT=$FWROOT%s && . %s && . %s''' % (test_rel_dir, test_rel_install_dir, bash_functions_path, test_rel_install_file), cwd=test_install_dir) self.__run_command("sudo apt-get -y autoremove"); print("\nINSTALL: Finished installing server software\n")
def __install_server_software(self): print("\nINSTALL: Installing server software (strategy=%s)\n"%self.strategy) # Install global prerequisites bash_functions_path='$FWROOT/toolset/setup/linux/bash_functions.sh' prereq_path='$FWROOT/toolset/setup/linux/prerequisites.sh' self.__run_command(". %s && . %s" % (bash_functions_path, prereq_path)) tests = gather_tests(include=self.benchmarker.test, exclude=self.benchmarker.exclude, benchmarker=self.benchmarker) dirs = [t.directory for t in tests] # Locate all installation files install_files = glob.glob("%s/*/install.sh" % self.fwroot) # Run install for selected tests for test_install_file in install_files: test_dir = os.path.basename(os.path.dirname(test_install_file)) test_rel_dir = os.path.relpath(os.path.dirname(test_install_file), self.fwroot) if test_dir not in dirs: continue logging.info("Running installation for directory %s", test_dir) # Find installation directory # e.g. FWROOT/installs or FWROOT/installs/pertest/<test-name> test_install_dir="%s/%s" % (self.fwroot, self.install_dir) if self.strategy is 'pertest': test_install_dir="%s/pertest/%s" % (test_install_dir, test_dir) test_rel_install_dir=os.path.relpath(test_install_dir, self.fwroot) if not os.path.exists(test_install_dir): os.makedirs(test_install_dir) # Load profile for this installation profile="%s/bash_profile.sh" % test_dir if not os.path.exists(profile): logging.warning("Directory %s does not have a bash_profile"%test_dir) profile="$FWROOT/config/benchmark_profile" else: logging.info("Loading environment from %s", profile) setup_util.replace_environ(config=profile, command='export TROOT=$FWROOT%s && export IROOT=$FWROOT%s' % (test_rel_dir, test_rel_install_dir)) # Find relative installation file test_rel_install_file = "$FWROOT%s" % setup_util.path_relative_to_root(test_install_file) # Then run test installer file # Give all installers a number of variables # FWROOT - Path of the FwBm root # IROOT - Path of this test's install directory # TROOT - Path to this test's directory self.__run_command(''' export TROOT=$FWROOT/%s && export IROOT=$FWROOT/%s && . %s && . %s''' % (test_rel_dir, test_rel_install_dir, bash_functions_path, test_rel_install_file), cwd=test_install_dir) self.__run_command("sudo apt-get -y autoremove"); print("\nINSTALL: Finished installing server software\n")