def run(platform, ctl, addbase, verbose): exefile = ctl.get(ctl.OUTFILE) logfile = ctl.get(ctl.LOGFILES)[ctl.RUN] if platform == 'Win32': addpath = '%s/win32' % addbase else: addpath = '%s/win64' % addbase pipeprocess = ctl.get(ctl.PIPEPROCESS) timeout = ctl.get(ctl.TIMEOUT) print('PIPE: %s' % pipeprocess) print('TIME: %s' % timeout) if pipeprocess: toolpath = spr_topdir + '/bin/test' proc1 = Proc(verbose, options.dry_run) proc2 = Proc(verbose, options.dry_run) proc1.exec(exefile, addpath=addpath, stdin=Proc.PIPE, stdout=logfile) proc2.exec(pipeprocess, addpath=toolpath, stdout=Proc.PIPE) status = proc1.wait(timeout) proc2.wait() else: proc1 = Proc(verbose, options.dry_run) proc1.exec(exefile, addpath=addpath, stdout=logfile) status = proc1.wait(timeout) head(logfile, runlog_lines) augmsg = '(timeout)' if status == Proc.ETIME else '' print('run result: %d %s' % (status, augmsg))
def __exec(self, cmnd): cmnd1 = cmnd cmnd2 = 'nkf -w' if Util.is_unix() else 'nkf -s' shell = True if Util.is_unix() else False proc1 = Proc(verbose=self.verbose) # git proc2 = Proc(verbose=self.verbose) # nkf proc1.execute(cmnd1, stdout=Proc.PIPE, stderr=Proc.STDOUT, shell=shell) proc2.execute(cmnd2, stdin=proc1.proc.stdout, stdout=Proc.PIPE, stderr=Proc.STDOUT, shell=shell) status, out, err = proc2.output() return status, out, err
def __build(self): # returns: Build status. # build option build_opt = '"%s|%s"' % (self.config, self.platform) if self.verbose: print(' build option: %s' % build_opt) # delete all files in outdir before build (rebuild) if self.clean: fop = FileOp(verbose=self.verbose, dry_run=self.dry_run) status = fop.rm(self.outdir, force=True) status = fop.rm(self.logfile, force=True) if status != 0 and not self.dry_run: self.error = 'file deletion failed (%d)' % status return status # build cmnd = 'devenv %s /build %s' % (self.solution_file, build_opt) cmnd += ' /Out %s' % Util.pathconv(self.logfile) proc = Proc(verbose=self.verbose, dry_run=self.dry_run) proc.exec(cmnd, addpath=Util.pathconv(self.vs_path)) status = proc.wait() if status != 0: self.__show_error(self.logfile) if self.verbose: print(' result is %d' % status) return status
def __build_u(self, args): # arguments: # args: Parameters to compiler (list). opt_flags = { 'Debug': 'OPTS=-g', 'Release': 'OPTS=-O2', 'Trace': 'OPTS=-O2', None: '' } [slnfile, platform, opts, outfile, force] = args if opts not in opt_flags: opts = None tmplogdir = 'log' tmplog = '%s/%s_%s_%s_build.log' % \ (tmplogdir, self.clsname, self.platform, self.config) os.makedirs(tmplogdir, exist_ok=True) cmnd = 'make -f %s compile' % slnfile args = opt_flags[opts] proc = Proc(verbose=self.verbose, dry_run=self.dry_run) proc.execute('%s %s' % (cmnd, args), shell=True, stdout=tmplog, stderr=Proc.STDOUT) stat = proc.wait() cmnd = '%s %s' % (cmnd, args) loginfo = [cmnd, tmplog] return stat, loginfo
def __exec(self, url, cmnd): cmnd1 = cmnd cmnd2 = 'nkf -s' proc1 = Proc(verbose=self.verbose) # git proc2 = Proc(verbose=self.verbose) # nkf proc1.exec(cmnd1, stdout=Proc.PIPE, stderr=Proc.STDOUT) proc2.exec(cmnd2, stdin=proc1.proc.stdout, stdout=Proc.PIPE, stderr=Proc.STDOUT) status1 = 0 status2 = 0 #status2 = proc2.wait() # Why? status1 = proc1.wait() status = status1 + status2 out, err = proc2.output() return status, out, err
def config_and_generate(self): if self.verbose: print('cmake: generation start') # Create work directory if not exists. # blddir = self.ctl.get(CFK.CMAKE_BLDDIR) if self.verbose and not os.path.exists(blddir): cwd = Util.pathconv(os.getcwd(), to='unix') if self.verbose: print(' create directory %s/%s' % (cwd, blddir)) os.makedirs(blddir, exist_ok=True) # Execuete cmake. # libtype = self.ctl.get(CFK.LIB_TYPE) topdir = self.ctl.get(CFK.CMAKE_TOPDIR) blddir = self.ctl.get(CFK.CMAKE_BLDDIR) conf = self.ctl.get(CFK.CMAKE_CONF_FILE) opts = self.ctl.get(CFK.CMAKE_OPTS_FILE) cmake_options = self.ctl.get(CFK.CMAKE_OPTIONS) # cmnd = 'cmake' if self.setup_file_exists: cmnd = self.sf.getenv('cmake') if topdir: cmnd += ' -D TOPDIR=%s' % topdir if conf: cmnd += ' -D CONF=%s' % conf if opts: cmnd += ' -D OPTS=%s' % opts if cmake_options: cmnd += ' ' + cmake_options if not libtype: libtype = 'STATIC' cmnd += ' -B %s' % blddir cmnd += ' -G %s' % self.generator cmnd += ' -D LIBTYPE=%s -D SPRLIBTYPE=%s' % (libtype, libtype) # logobj = self.__open(self.logfile) proc = Proc(verbose=0) #self.verbose) status = proc.execute(cmnd, shell=True, stdout=logobj, stderr=proc.STDOUT).wait() logobj.close() if self.verbose: print(' configure/generate done with code %d' % status) if status != 0: return None # if (Util.is_unix()): return "Makefile" slnfile = self.__find_slnfile() if slnfile is None: self.error.error('found more than two solution files') if self.verbose: print(' solution file is %s' % slnfile) print('cmake: generation end') return slnfile
def execute(cmnd, timeout=None, stdout=Proc.PIPE, stderr=Proc.NULL): # execute command proc = Proc().execute(cmnd, stdout=stdout, stderr=stderr, shell=True) # get output if stdout == Proc.PIPE: status, out, err = proc.output(timeout) else: status = proc.wait(timeout=timeout) out = '' return status, out
def BuildProc(self, proc): if proc.__class__ == Proc.Proc: return proc elif type(proc) == type(""): # build Proc object raise RuntimeError("Please pass proc object not string") return Proc.Proc(proc, datasets, datasets[0].colour, proc ) else: pdb.set_trace() raise RuntimeError("Can't understand proc type: "+str(type(proc)))
def create(fname, proj, dept): if os.path.exists(fname): #Error(prog).warn('file "%s" already exists.' % fname) return # Generate makefile body. flag = ' -v' if verbose else '' cmnd = '%s%s' % (createmkf, flag) args = '%s %s %s' % (fname, proj, dept) #print('%s %s' % (cmnd, args)) stat = Proc().execute('%s %s' % (cmnd, args), shell=True).wait()
def __build_u(self, logf): # arguments: # logf: Log file object. # self.args: Other parameters. [slnfile, opts, outfile, force] = self.args cmnd = 'make -f %s' % slnfile args = '%s -o %s' % (opts, outfile) proc = Proc(self.verbose, self.dry_run) proc.exec('%s %s' % (cmnd, args), stdout=Proc.PIPE, stderr=Proc.STDOUT) stat = proc.wait() out, err = proc.output() if logf: logf.witelines(out) return stat
def revision(self): url = self.url cmnd = 'svn info' proc = Proc(verbose=self.verbose) proc.exec(cmnd, stdout=Proc.PIPE, stderr=Proc.STDOUT) status = proc.wait() out, err = proc.output() # revision = "can't get current revision" if status == 0: lines = out.split('\n') pattern = 'Last Changed Rev:\s+(\d+).*' for s in lines: m = re.match(pattern, s) if m: revision = m.group(1) return status, revision, err
def __get_vs_path(self, version): # arguments: # version: Visual Studio version. Must have the format # that self.__get_vsinfo() returns. # returns: Path of devenv.exe. if version is None: # bad VS version return None devenv = 'devenv.exe' devenvpath = None # try 'where' command first proc = Proc(verbose=0).execute('where %s' % devenv, stdout=Proc.PIPE, shell=True) stat, out, err = proc.output() if stat == 0: out = out.split('\n')[0].strip() devenvpath = '/'.join(out.split(os.sep)[:-1]) # try default install directory elif self.vs_version <= '14.0': devenvpath = 'C:/Program Files (x86)/Microsoft Visual Studio ' devenvpath += version devenvpath += '/Common7/IDE' else: sys_base = 'C:/Program Files (x86)/Microsoft Visual Studio' devenvpath = sys_base \ + '/%s' % self.vs_name.split()[2] \ + '/Community/Common7/IDE' #if self.verbose: # print(' devenv path: %s' % devenvpath) if devenvpath is None \ or not os.path.exists(Util.pathconv('%s/%s' % (devenvpath, devenv))): self.errmsg = 'devenv not found' return None # print('devenvpath: %s' % devenvpath) sys.stdout.flush() if devenvpath is not None: devenv_found = True return devenvpath
def __exec(self, cmnd, path1, path2=None): if self.dry_run: msg = ' %s %s' % (cmnd, Util.pathconv(path1)) if path2: msg += ' ' + Util.pathconv(path2) print(msg) return 0 if self.info: if cmnd[0:2] == 'rm' or cmnd[0:3] == 'del': msg = "removed `%s'" % path1 else: msg = "`%s' -> `%s'" % (path1, path2) print(Util.upath(msg)) args = [cmnd] args.append(Util.pathconv(path1)) if path2: args.append(Util.pathconv(path2)) # null = Proc.NULL proc = Proc(self.verbose) proc.exec(args, stdout=null, stderr=null, shell=True) return proc.wait()
def Ls(path): lslist = Fop.ls(path) if not lslist: Print('no such file: "%s"' % path) return if isinstance(lslist, str): Print(lslist) return for item in lslist: Print(item) # ---------------------------------------------------------------------- P = Proc(verbose=1, dry_run=False) Ps = Proc(verbose=0, dry_run=False) Pd = Proc(verbose=1, dry_run=True) print('Test program for class: %s, Ver %s\n' % (P.clsname, P.version)) commands = {} if Util.is_unix(): commands = {'cat': 'cat', 'path': 'echo $PATH'} else: commands = {'cat': 'type', 'path': 'path'} # exec # print('-- exec --') fname = 'test/ProcTest'
# コマンドラインの解析 # (options, args) = parser.parse_args() if options.version: print('%s: Version %s' % (prog, str(version))) sys.exit(0) dry_run = options.dry_run verbose = options.verbose # ---------------------------------------------------------------------- # make はインストールされているか # cmnd = '%s -help' % make if Util.is_unix() else '%s /?' % make rc_make = Proc(dry_run=dry_run).execute(cmnd, stdout=Proc.NULL, stderr=Proc.NULL, shell=True).wait() if rc_make != 0: Error(prog).abort('can\'t find "%s"' % make) # ---------------------------------------------------------------------- # 処理するモジュールの一覧を作成 # fname = '%s/%s' % (etcdir, projfile) fio = TextFio(fname, 'r') if fio.open() != 0: Error(prog).abort('open error: "%s"' % fname) lines = fio.read() fio.close() projs = ['Base']
clean = options.clean verbose = options.verbose # ---------------------------------------------------------------------- # Scripts # if options.python: python = options.python make = 'make' if unix else 'nmake /NOLOGO' opts = '-P %s' % python makemanager = '%s "%s/make_manager.py" %s' % (python, runswigdir, opts) # ---------------------------------------------------------------------- # Globals (part 2) # proc = Proc(verbose=verbose, dry_run=debug) f_op = FileOp(verbose=verbose) # ---------------------------------------------------------------------- # プロジェクト依存定義ファイルを読み込む. # fio = TextFio('%s/%s' % (etcdir, projfile)) if fio.open() < 0: Error(prog).error(fio.error()) lines = fio.read() fio.close() # ---------------------------------------------------------------------- # 各プロジェクト毎に処理を行なう. # for line in lines:
# ---------------------------------------------------------------------- # Import Springhead python library. # from FindSprPath import * spr_path = FindSprPath(prog) libdir = spr_path.abspath('pythonlib') sys.path.append(libdir) from TextFio import * from Proc import * from FileOp import * # ---------------------------------------------------------------------- # Globals # proc = Proc() f_op = FileOp() # ---------------------------------------------------------------------- # Directories # sprtop = spr_path.abspath() bindir = spr_path.abspath('bin') srcdir = spr_path.abspath('src') etcdir = '%s/%s' % (srcdir, 'RunSwig') runswigdir = '%s/%s' % (srcdir, 'RunSwig') # ---------------------------------------------------------------------- # Files # makefile = 'makefile.swig' # name of target makefile
verbose = options.verbose # ---------------------------------------------------------------------- # Scripts # if options.python: python = options.python make = 'make' if unix else 'nmake /NOLOGO' #make = 'gmake' if unix else 'nmake /NOLOGO' opts = '-P %s' % python makemanager = '%s "%s/make_manager.py" %s' % (python, runswigdir, opts) # ---------------------------------------------------------------------- # Globals (part 2) # proc = Proc(verbose=verbose, dry_run=dry_run) f_op = FileOp(verbose=verbose) # ---------------------------------------------------------------------- # プロジェクト依存定義ファイルを読み込む. # fio = TextFio('%s/%s' % (etcdir, projfile)) if fio.open() < 0: Error(prog).error(fio.error()) lines = fio.read() fio.close() # ---------------------------------------------------------------------- # 各プロジェクト毎に処理を行なう. # for line in lines:
verbose = options.verbose dry_run = options.dry_run # ---------------------------------------------------------------------- # Scripts # if options.python: python = options.python #make = 'gmake' if unix else 'nmake' make = 'make' if unix else 'nmake' swig = 'swig' # ---------------------------------------------------------------------- # Globals (part 2) # proc = Proc(dry_run=dry_run) # ---------------------------------------------------------------------- # Files # interfacefile = '%s.i' % module makefile = '%sStub.mak.txt' % module stubfile = '%sStub.cpp' % module # ---------------------------------------------------------------------- # ヘッダファイル情報を収集する. # incf_names = ['Springhead.h', 'Base/Env.h', 'Base/BaseDebug.h'] srcf_names = [] # ['Foundation/UTTypeDesc.h'] auxdep_inc = list(map(lambda x: '%s/%s' % (incdir_rel, x), incf_names)) auxdep_src = list(map(lambda x: '%s/%s' % (srcdir_rel, x), srcf_names))
os.makedirs(repository, exist_ok=True) start_dir = os.getcwd() os.chdir(repository) if not os.path.exists('core/test/bin'): msg = 'test repository "%s/core" may be empty' % repository Error(prog).abort(msg) # ---------------------------------------------------------------------- # Create closed-source-control file (UseClosedSrcOrNot.h). # Following script must be done at RunSwig directory! # runswigdir = '%s/RunSwig' % SrcDir os.chdir(runswigdir) cmnd = '%s CheckClosedSrc.py' % python rc = Proc().execute(cmnd, shell=shell).wait() os.chdir(repository) # ---------------------------------------------------------------------- # Remove log files. # Print('clearing log files') os.chdir('%s/log' % TestDir) fop = FileOp(info=1, dry_run=dry_run, verbose=verbose) fop.rm('*') os.chdir(repository) # ---------------------------------------------------------------------- # Test Go! # if check_exec('DAILYBUILD_EXECUTE_TESTALL'):
def __exec(self, cmnd): shell = True if Util.is_unix() else False proc = Proc(verbose=self.verbose) # git proc.execute(cmnd, stdout=Proc.PIPE, stderr=Proc.STDOUT, shell=shell) status, out, err = proc.output() return status, out, err
#!/usr/local/bin/python # -*- coding: utf-8 -*- # ============================================================================= import sys import os import glob sys.path.append('../RunSwig') from FindSprPath import * spr_path = FindSprPath('SpringheadTest') libdir = spr_path.abspath('pythonlib') sys.path.append(libdir) from Proc import * outdir = './html' logfile = 'doxygen.log' os.makedirs(outdir, exist_ok=True) Proc().execute('doxygen SprCSharp.doxy', stdout=logfile).wait() sys.exit(0) # end MakeDoc.py
def traverse(self, top): #### special trap for manual test #### skips = os.getenv('SPR_SKIP') if self.trap_enabled and top.split('/')[-1] in skips: print('skip: %s' % top) return 0 #### end trap #### if not os.path.isdir(top): msg = 'not a directory: %s' % top Error(self.clsname).error(msg) return 0 # go to test directory dirsave = self.__chdir(top) cwd = Util.upath(os.getcwd()) # read control file ctl = ControlParams(self.control, self.section, verbose=self.verbose) if ctl.error(): Error(self.clsname).error(ctl.error()) return -1 if self.once: self.__init_log(ctl.get(CFK.BUILD_LOG), RST.BLD) self.__init_log(ctl.get(CFK.BUILD_ERR_LOG), RST.BLD, RST.ERR) self.__init_log(ctl.get(CFK.RUN_LOG), RST.RUN) self.__init_log(ctl.get(CFK.RUN_ERR_LOG), RST.RUN, RST.ERR) self.once = False use_cmake = True if ctl.get(CFK.USE_CMAKE) else False if ctl.get(CFK.USE_CMAKE): cmnd = 'cmake --version' proc = Proc().execute(cmnd, stdout=Proc.PIPE, shell=True) status, out, err = proc.output() if status != 0: exit(-1) print('using %s' % out.split('\n')[0]) else: print('do not use cmake') libtype = ctl.get(CFK.LIB_TYPE) if not libtype: libtype = 'STATIC' print('creating %s library' % libtype) # check test condition is_cand = self.__is_candidate_dir(cwd, ctl) exclude = ctl.get(CFK.EXCLUDE, False) has_sln = self.__has_solution_file(ctl, cwd, self.toolset) descend = ctl.get(CFK.DESCEND) and is_cand and not exclude do_this = is_cand and not exclude and has_sln # interrupted = False stat = 0 if do_this: if self.audit: print('ENTER: %s' % cwd) if self.verbose: ctl.info() stat = self.process(cwd, ctl) if stat == Proc.ECANCELED: interrupted = True elif self.audit: if not is_cand: msg = 'not a candidate dir' if exclude: msg = 'exclude condition' if not has_sln: msg = 'has no solution file' print('skip: -%s (%s)' % (cwd, msg)) # process for all subdirectories if descend and not interrupted: for item in sorted(os.listdir(cwd)): if not os.path.isdir(item): continue if not self.__is_candidate_dir(item, ctl): continue subdir = '%s/%s' % (cwd, item) stat = self.traverse(subdir) if stat == Proc.ECANCELED: break # all done for this directory and decsendants. if self.audit and do_this: print('LEAVE: %s' % cwd) if dirsave: os.chdir(dirsave) return stat
# ---------------------------------------------------------------------- # Process for command line # (options, args) = parser.parse_args() if options.version: print('%s: Version %s' % (prog, str(version))) sys.exit(0) if len(args) != 0: parser.error("incorrect number of arguments") # get options verbose = options.verbose dry_run = options.dry_run # ---------------------------------------------------------------------- # Process start. # outdir = '../../../generated/doc/CMakeGitbook/' cmnd = '%s\\gitbook.cmd build ./ %s' % (gitbookpath, outdir) #print('cmnd: %s' % cmnd) proc = Proc(dry_run=dry_run, verbose=verbose) stat = proc.execute(cmnd).wait() if stat == 0: print('%s: CMakeGitbook document generated.' % prog) sys.exit(0) # end: MakeDoc.py
def print_usage(): print() cmnd = 'python %s.py --help' % prog shell = False if Util.is_unix() else True Proc().execute(cmnd, shell=shell).wait() sys.exit(1)
def process(self, cwd, ctl): if not os.path.isdir(cwd): msg = 'not a directory: %s' % cwd Error(self.clsname).error(msg) # slnfile = self.__solution_file_name(ctl, cwd, self.toolset) if self.verbose > 1: print('solution file: %s' % slnfile) # closed source control if self.csusage == CSU.AUTO: tmp_u = ctl.get(CFK.USE_CLOSED_SRC) usage = CSU.USE if tmp_u else CSU.UNUSE else: usage = self.csusage self.csc.set_usage(usage) # process this directory name = self.__report_1('\t', True, False) bar = BuildAndRun(ctl, self.toolset, self.verbose, self.dry_run) if bar.error(): self.__report_1(bar.error(), False, True) self.result.set_info(name, TST.ERR, bar.error()) return -1 # self.result.set_info(name, RST.EXP, ctl.get(CFK.EXPECTED)) stat = 0 for platform in self.platforms: # need build? if not ctl.get(CFK.BUILD): continue # if platform != self.platforms[0]: self.__report(' ', None, False) self.__report(' %s:' % platform, None, False) self.platform = platform stat = 0 for config in self.configs: # # If use CMake, configure/generate solution file here # if ctl.get(CFK.USE_CMAKE): self.__report('%s' % config, '.cmake', False) logfile = ctl.get(CFK.BUILD_LOG) cmake = CMake(ctl, self.toolset, platform, None, logfile, self.verbose) status = cmake.preparation() if status != 0: print('CMake prep error (%d)' % stat) break slnfile = cmake.config_and_generate() if slnfile is None: print('CMake config/gen error') break # # Build (compile and link) # self.__report('%s' % config, '.build', False) self.config = config outpath = self.__make_outpath(ctl, slnfile) stat = bar.build(None, slnfile, platform, config, outpath, ctl.get(CFK.BUILD_LOG), ctl.get(CFK.BUILD_ERR_LOG), self.rebuild) if KEYINTR.is_interrupted(): KEYINTR.set_interrupted(False) stat = Proc.ECANCELED self.result.set_result(name, RST.BLD, platform, config, stat) # self.__report(None, '.', False, False) if self.verbose: print(self.__status_str(RST.BLD, stat)) if stat != 0: self.__report(None, None, False, True) if stat == Proc.ECANCELED: print('interrupted') break if self.verbose: print('build error (%d)' % stat) continue # # Run # if not ctl.get(CFK.RUN): self.__report(',', '(skip). ', False) continue if ctl.get(CFK.INTERVENTION): self.__report(',', 'intervention. ', False) continue self.__report(None, 'run', False) # addpath = self.__runtime_addpath(ctl, platform) stat = bar.run( None, outpath, '', # no args ctl.get(CFK.RUN_LOG), ctl.get(CFK.RUN_ERR_LOG), addpath, ctl.get(CFK.TIMEOUT, default=0), ctl.get(CFK.PIPE_PROCESS)) kill_proc = ctl.get(CFK.KILL_PROCESS) if kill_proc: Proc().kill(image=kill_proc) if KEYINTR.is_interrupted(): KEYINTR.set_interrupted(False) stat = Proc.ECANCELED self.result.set_result(name, RST.RUN, platform, config, stat) if stat == Proc.ECANCELED: self.__report(None, None, False, True) if self.verbose: print('interrupted') break # if self.verbose: print(self.__status_str(RST.RUN, stat)) if stat == Proc.ETIME: self.__report('', '(timedout)', False, False) self.__report(',', ' (rc %s).' % stat, False, False) # end config if stat == Proc.ECANCELED: break # end platform self.__report_1(None, False, True) return stat
'--version', dest='version', action='store_true', default=False, help='show version') # ---------------------------------------------------------------------- # コマンドラインの解析 # (options, args) = parser.parse_args() if options.version: print('%s: Version %s' % (prog, version)) sys.exit(0) if len(args) != 0: Error(prog).error('incorrect number of arguments') Proc().execute('python %s.py -h' % prog).wait() sys.exit(0) verbose = options.verbose # ---------------------------------------------------------------------- # 処理開始 # cwd = os.getcwd() os.chdir(incdir) if verbose: print('%s: cwd: %s' % (prog, os.getcwd().replace(os.sep, '/'))) # ---------------------------------------------------------------------- # ファイル "SprUseClosedSrcOrNot.h" が存在したら何もしない #
chm_file = '%s.chm' % target_name chm_log_file = '%s.log' % target_name if paths != []: hhcpath = os.sep.join(paths[0].split(os.sep)[:-1]) if verbose: print('"%s" found at "%s"' % (srchexe, hhcpath)) overrides = list(map(lambda x: 'echo %s' % x, [ 'HHC_LOCATION=%s' % hhcpath, 'GENERATE_HTMLHELP=YES', 'GENERATE_TREEVIEW=NO', 'CHM_FILE=%s' % chm_file ])) cmnd1 = 'cmd /c type %s &%s' % (doxy_file, '&'.join(overrides)) cmnd2 = 'doxygen -' # proc1 = Proc(dry_run=dry_run, verbose=verbose) proc2 = Proc(dry_run=dry_run, verbose=verbose) proc1.execute(cmnd1, addpath=addpath, stdout=Proc.PIPE) proc2.execute(cmnd2, addpath=addpath, stdin=proc1.proc.stdout, stderr=chm_log_file) stat1 = proc1.wait() stat2 = proc2.wait() if stat2 == 0: src = '%s/%s' % (wrkdir, chm_file) dst = '%s/%s' % (target_dir, chm_file) fop.mv(src, dst) if os.path.exists(wrkdir): fop.rm(wrkdir, recurse=True) else: msg = 'making chm file failed.' Error(prog).print(msg, alive=True)
from FindSprPath import * spr_path = FindSprPath(prog) libdir = spr_path.abspath('pythonlib') sys.path.append(libdir) from Proc import * from Util import * from Error import * # ---------------------------------------------------------------------- # Globals # spr_topdir = spr_path.abspath() start_dir = spr_path.abspath('test') prep_dir = os.path.abspath('%s/..' % spr_topdir) proc = Proc(verbose=0) err = Error(prog) # ---------------------------------------------------------------------- # Options # usage = 'Usage: python %prog [options] test-repository' parser = OptionParser(usage=usage) parser.add_option('-C', '--configuration', dest='conf', default='Release', help='configuration {Debug | <Release>}') parser.add_option('-P', '--platform', dest='plat',
parser.add_option('-v', '--verbose', dest='verbose', action='count', default=0, help='set verbose mode') parser.add_option('-V', '--version', dest='version', action='store_true', default=False, help='show version') # ---------------------------------------------------------------------- # Process for command line # (options, args) = parser.parse_args() if options.version: print('%s: Version %s' % (prog, version)) sys.exit(0) if len(args) != 0: proc = Proc().exec('python %s.py -h' % prog) proc.wait() parser.error("incorrect number of arguments") sys.exit(0) # get options srctop = options.srctop inifile = options.inifile outfile = options.outfile test_only = options.test_only verbose = options.verbose if verbose: print('argument used:') print(' srctop: %s' % srctop) print(' inifile: %s' % inifile)