def build_parts(gconfig): from part import parts root_dir = shared_root_path(gconfig) target_dir = target_path(gconfig) remove_dir(root_dir) remove_dir(target_dir) for part in parts: print "Build part '{}'".format(part.name) build_part(part) print "Prepare taregt environment" copy_targets(part, target_dir) copy("", "", part.install_path(), root_dir)
def save_current_report_to_repository(): report_dir = os.path.join( env.RESULT_PATH, "result", "%s__%s" % (datetime.datetime.strptime( env.TOTAL_START_TIME, "%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%d_%H%M%S"), datetime.datetime.strptime( env.TOTAL_STOP_TIME, "%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%d_%H%M%S"))) common.delete_then_mkdir(report_dir) common.copy(os.path.join(env.RESULT_PATH, "result", "testcase"), os.path.join(report_dir, "testcase")) common.copy(os.path.join(env.RESULT_PATH, "result", "screenshots"), os.path.join(report_dir, "screenshots")) common.copy(os.path.join(env.RESULT_PATH, "result", "index.html"), report_dir) with open(os.path.join(report_dir, "status.ini"), "w") as f: f.write("Duration=%s\n" % str( datetime.datetime.strptime( env.TOTAL_STOP_TIME, "%Y-%m-%d %H:%M:%S") - datetime.datetime. strptime(env.TOTAL_START_TIME, "%Y-%m-%d %H:%M:%S"))) f.write("TotalCases=%s\n" % str(env.TOTAL_TESTCASE_PASS + env.TOTAL_TESTCASE_FAIL)) f.write("PassedCases=%s\n" % str(env.TOTAL_TESTCASE_PASS)) f.write("FailedCases=%s\n" % str(env.TOTAL_TESTCASE_FAIL))
def save_current_report_to_repository(): report_dir = os.path.join(env.RESULT_PATH, "result", "%s__%s" % (datetime.datetime.strptime(env.TOTAL_START_TIME, "%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%d_%H%M%S"), datetime.datetime.strptime(env.TOTAL_STOP_TIME, "%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%d_%H%M%S"))) common.delete_then_mkdir(report_dir) common.copy(os.path.join(env.RESULT_PATH, "result", "testcase"), os.path.join(report_dir, "testcase")) common.copy(os.path.join(env.RESULT_PATH, "result", "screenshots"), os.path.join(report_dir, "screenshots")) common.copy(os.path.join(env.RESULT_PATH, "result", "index.html"), report_dir) with open(os.path.join(report_dir, "status.ini"), "w") as f: f.write("Duration=%s\n" % str(datetime.datetime.strptime(env.TOTAL_STOP_TIME, "%Y-%m-%d %H:%M:%S") - datetime.datetime.strptime(env.TOTAL_START_TIME, "%Y-%m-%d %H:%M:%S"))) f.write("TotalCases=%s\n" % str(env.TOTAL_TESTCASE_PASS+env.TOTAL_TESTCASE_FAIL)) f.write("PassedCases=%s\n" % str(env.TOTAL_TESTCASE_PASS)) f.write("FailedCases=%s\n" % str(env.TOTAL_TESTCASE_FAIL))
def copy_targets(part, target_dir): install_dir = part.install_path() src_tag = "$(ROOT)/" dst_tag = "$(TARGET)/" if len(part.targets) == 0: copy(src_tag, dst_tag, install_dir, target_dir) return for target in part.targets: if isinstance(target, str): copy(src_tag, dst_tag, install_dir, target_dir, target) elif isinstance(target, dict): for src, dest in target.iteritems(): if dest.find("*") >= 0 or dest.find("?") >= 0: print_error("target path cannot contain wildcards:", dest) dir, base = os.path.split(dest) if base != "": dest = os.path.join(dest, "") copy(src_tag, dst_tag, install_dir, target_dir, src, dest) else: print_error("illegal target '{}' for part '{}'".format( target, part.name))
def run(command, run_in_dir=True, dont_run=False, monitor=True, shell_output=False, name=None, use_terminal=False, disable_pulseaudio=False, cpu_limit=None): """Intelligently runs a Windows program. This function also handles start.exe arguments (like web links), .msi installers and provides the alias "cmd" for launching the wineconsole and "winetricks" for running, and optionally downloading winetricks, with arguments. Note that disable_pulseaudio only works when use_terminal is True.""" command = parse_command(command) if 'VINEYARD_NO_MONITORING' in command['env']: monitor = False if monitor and shell_output: error("monitor and shell_output can't both be True, disabling shell_output") shell_output = False # Override any WINEPREFIX defined by command command['env']['WINEPREFIX'] = common.ENV['WINEPREFIX'] # Create a new environment dict from our internal one env = common.copy(common.ENV) # Update it with the command's environment env.update(command['env']) if name is not None: command['name'] = name kwargs = { 'env': env, } if command['command'] is None: command['command'] = common.ENV['WINE'] if run_in_dir and command['path'] is not None: kwargs['cwd'] = command['path'] if cpu_limit is not None: if type(cpu_limit) is int: kwargs['cpu_limit'] = cpu_limit elif cpu_limit is True: kwargs['cpu_limit'] = 1 if monitor: kwargs['output_to_shell'] = False kwargs['use_log'] = True kwargs['name'] = command['name'] kwargs['executable'] = command['command'] if dont_run: return ('Monitor', command['arguments'], kwargs) else: if use_terminal: return util.open_terminal( cwd = kwargs.get('cwd', None), configuration_name = name, cmd = command['command'], arguments = command['arguments'], disable_pulseaudio = disable_pulseaudio, keep_open = True ) else: return sys.modules['wine.monitor'].Program( command['arguments'], **kwargs ) else: command_list = [command['command']] + command['arguments'] if shell_output: kwargs['stdout'] = sys.stdout kwargs['stderr'] = sys.stderr if dont_run: return ('Run', command_list, kwargs) else: if use_terminal: return util.open_terminal( cwd = kwargs.get('cwd', None), configuration_name = name, cmd = command['command'], arguments = command_list, disable_pulseaudio = disable_pulseaudio, keep_open = True ) else: return common.Popen( command_list, **kwargs )
strLayer = 'tmp_i095' relLayer = 'tmp_i043' with common.runtool(7) as parameters: interLayer, strengthFld, lengthFld, minStrengthStr, minRelStrengthStr, maxLengthStr, output = parameters if minStrengthStr or maxLengthStr: queries = [] if minStrengthStr: common.progress('assembling absolute strength exclusion') minStrength = common.toFloat(minStrengthStr, 'minimum absolute interaction strength') queries.append(common.query(interLayer, '[%s] >= %g', strengthFld, minStrength)) if maxLengthStr: common.progress('assembling absolute length exclusion') maxLength = common.toFloat(maxLengthStr, 'maximum absolute interaction length') queries.append(common.query(interLayer, '[%s] <= %g', lengthFld, maxLength)) common.selection(interLayer, strLayer, ' OR '.join(queries)) else: strLayer = interLayer if minRelStrengthStr: common.progress('performing relative strength exclusion') minRelStrength = common.toFloat(minRelStrengthStr, 'minimum relative interaction strength') relQuery = common.query(interLayer, '[%s] > 0 AND ([%s] / [%s] * 1000) >= %g', lengthFld, strengthFld, lengthFld, minRelStrength) common.select(strLayer, relLayer, relQuery) else: relLayer = strLayer common.progress('counting selected interactions') common.message('%i interactions selected.' % common.count(relLayer)) common.progress('writing output') common.copy(relLayer, output)
def __init__(self, arguments, name=None, env=-1, cwd=None, output_to_shell=False, use_logfiles=True): command_safe = False if type(arguments) in (list, tuple): self.command = escape_arguments_to_string(arguments) command_safe = True else: self.command = arguments[:] self.start_time = time.localtime() kwargs = {} if env == -1: kwargs['env'] = common.copy(common.ENV) else: kwargs['env'] = env if cwd is not None: kwargs['cwd'] = cwd if output_to_shell: kwargs['stdin'] = sys.stdin kwargs['stdout'] = sys.stdout kwargs['stderr'] = sys.stderr elif use_logfiles: # If we are not outputting to the shell # the output will be routed to two files in /tmp. conf_name = util.string_safe_chars( env.get('WINEPREFIXNAME', common.ENV.get('WINEPREFIXNAME', '')) ) self.log_filename_base = '%s-%s-%s' % ( conf_name, time.strftime('%Y-%m-%d-%H:%M:%S', self.start_time), util.string_random() ) self.log_filename_out = '{tmppath}/run-process-{filename}.out'.format( tmppath = common.ENV['VINEYARDTMP'], filename = self.log_filename_base) self.log_filename_err = '{tmppath}/run-process-{filename}.err'.format( tmppath = common.ENV['VINEYARDTMP'], filename = self.log_filename_base) self.log_out_last_pos = 0 self.log_err_last_pos = 0 if command_safe: self.command = "%s 2>%s 1>%s" % ( self.command, self.log_filename_err, self.log_filename_out ) else: self.command = "%s 2>%s 1>%s" % ( util.string_safe_shell(self.command), self.log_filename_err, self.log_filename_out ) # Use a new process group for this process if 'preexec_fn' not in kwargs: kwargs['preexec_fn'] = os.setpgrp if 'env' in kwargs: self.shell = common.which(['dash', 'bash', 'sh'], kwargs['env']) else: self.shell = common.which(['dash', 'bash', 'sh']) print("Going to run:", self.shell, '-c', '--', 'exec %s' % self.command) self.child = Popen([ self.shell, '-c', '--', 'exec %s' % self.command ], **kwargs) print("Running:", self.shell, '-c', '--', 'exec %s' % self.command) self._kwargs = kwargs self.pid = self.child.pid self.returncode = self.child.returncode self.send_signal = self.child.send_signal self.terminate = self.child.terminate self.kill = self.child.kill