Example #1
0
def simplekillByName(port, name):
    pId = getPId(port)
    if (pId == None): return False
    pId = Proc.getAncestorIdByName(pId, name);
    if (pId == None): return False
    return Proc.simpleKill(pId)
        
#print(killByName(81, "httpd"))
#print(kill(81))
#print(getPId(81))
#print(isExist(81))
            
Example #2
0
def kill(port):
    pId = getPId(port)
    if (pId == None): return False
    pId = Proc.getAncestorId(pId)
    if (pId == None): return False
    
    if not Proc.kill(pId):
        k = 3
        for i in range(k):
            if Proc.kill(pId): break
            i+=1
        if i == k: return False
    
    if not isExist(port): return True
    return kill(port)
Example #3
0
def reader(queue,i):
    ## Read from the queue
    while True:
        try:
            msg = queue.get()      
            string_me = json.loads(msg)
            post = Proc.get_fields(string_me)
            post.insert_time()
        except:
            e = sys.exc_info()[0]
            logging.error(datetime.datetime.now(),'other error, ', exc_info=full_exc_info())
            pass
        print str(msg)
#  コマンドラインの解析
#
(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']
Example #5
0
def clean():
    k = maxFailTime
    while not Port.isExist(prot) and k > 0:
        time.sleep(1)
        k -= 1
    Proc.killByName(method)
Example #6
0
    def run(self,
            dirpath,
            exefile,
            args,
            logfile,
            errlogfile,
            addpath=None,
            timeout=None,
            pipeprocess=None):
        if self.verbose:
            print('run program')
            print('  dirpath: %s' % dirpath)
            print('  exefile: %s' % exefile)
            print('  args:    %s' % args)
            print('  logfile: %s' % logfile)
            print('  errlog:  %s' % errlogfile)
            print('  addpath: %s' % addpath)
            print('  timeout: %s' % timeout)
            print('  pipe:    %s' % pipeprocess)

        # go to target directory.
        if dirpath:
            dirsave = self.__chdir('run', dirpath)
        if self.verbose:
            cwd = Util.upath(os.getcwd())
            print('run: in directory "%s"' % cwd)
        if Util.is_windows():
            if exefile[-4:] != '.exe':
                exefile = '%s.exe' % exefile
        if self.verbose:
            print('  exefile: %s' % exefile)
        if not os.path.exists(exefile):
            print('run: no such file "%s"' % exefile)
            return -1

        # use following temporary log file.
        if Util.is_unix():
            config = self.config.replace('-', '')
            ccver = ''
        else:
            config = self.config
            ccver = '_%s' % self.ccver
        tmplogdir = 'log'
        tmplog = '%s/%s%s_%s_%s_run.log' % \
         (tmplogdir, self.clsname, ccver, self.platform, config)
        os.makedirs(tmplogdir, exist_ok=True)

        # prepare log file (append mode).
        logf = self.__open_log(logfile, 'a', RST.RUN)
        errlogf = self.__open_log(errlogfile, 'a', RST.RUN)

        # execute program.
        shell = True if Util.is_unix() else False
        if pipeprocess:
            # proc1: target program.
            # proc2: generate input stream to feed proc1.
            proc1 = Proc(verbose=self.verbose, dry_run=self.dry_run)
            proc2 = Proc(verbose=self.verbose, dry_run=self.dry_run)
            proc1.execute('%s %s' % (exefile, args),
                          shell=shell,
                          addpath=addpath,
                          stdin=Proc.PIPE,
                          stdout=tmplog,
                          stderr=Proc.STDOUT)
            proc2.execute(pipeprocess,
                          shell=shell,
                          addpath=addpath,
                          stdout=Proc.PIPE)
            stat = proc1.wait(timeout)
            proc2.wait()
        else:
            # proc1: target program.
            proc1 = Proc(verbose=self.verbose, dry_run=self.dry_run)
            proc1.execute('%s %s' % (exefile, args),
                          addpath=addpath,
                          shell=shell,
                          stdout=tmplog,
                          stderr=Proc.STDOUT)
            stat = proc1.wait(timeout)

        # merge log info.
        cmnd = '%s %s' % (exefile, args)
        errors = self.__select_errors(tmplog, RST.RUN)
        self.__merge_log(2, tmplog, logf, cmnd, RST.RUN)
        self.__merge_log(1, errors, errlogf, cmnd, RST.ERR)

        if dirpath:
            os.chdir(dirsave)
        return stat
bindir = 'bin'
script = 'BatchTestControl.py'

toolset = '14.0'
platform = 'x64'
config = 'Release'
targets = ['src', 'src/tests', 'src/Samples']
section = 'dailybuild'

# ----------------------------------------------------------------------
#  Globals
#
cwd = os.getcwd()
spr_topdir = spr_path.abspath()
testdir = spr_path.abspath('test')
proc = Proc(verbose=0)
err = Error(prog)

# ----------------------------------------------------------------------
#  Options
#
usage = 'Usage: python %prog [options]'
parser = OptionParser(usage=usage)
parser.add_option('-c',
                  '--control-file',
                  dest='cfname',
                  default='dailybuild.control',
                  help='control file name (default: "%default")')
parser.add_option('-d',
                  '--dry-run',
                  dest='dryrun',
Example #8
0
#  Import Springhead2 python library.
#
sys.path.append('../RunSwig')
from FindSprPath import *
spr_path = FindSprPath(prog)
libdir = spr_path.abspath('pythonlib')
sys.path.append(libdir)
from TextFio import *
from Util import *
from Proc import *

# ----------------------------------------------------------------------
#  Globals
#
util = Util()
proc = Proc(dry_run=debug)
unix = util.is_unix()

# ----------------------------------------------------------------------
#  Directories
#
sprtop = spr_path.abspath()
bindir = spr_path.abspath('bin')
incdir = spr_path.abspath('inc')
srcdir = spr_path.abspath('src')
swigdir = '%s/%s' % (bindir, 'swig')

incdir_rel = util.pathconv(os.path.relpath(incdir), 'unix')
srcdir_rel = util.pathconv(os.path.relpath(srcdir), 'unix')

# ----------------------------------------------------------------------
Example #9
0
# ----------------------------------------------------------------------
#  Scripts
#
if options.python:
    python = options.python
nkf = 'nkf'
swig = 'swig'
make = 'make' if unix else 'nmake'
runswig_foundation = '%s %s/RunSwig.py -P %s' % (python, foundation_dir,
                                                 python)
addpath = spr_path.abspath('buildtool')

# ----------------------------------------------------------------------
#  Globals (part 2)
#
proc = Proc(verbose=verbose, dry_run=dry_run)
f_op = FileOp(verbose=verbose)

# ----------------------------------------------------------------------
#  src/Foundation へ移って RunSwig を実行する.
#
cmd = '%s Framework Foundation' % runswig_foundation
proc.exec(cmd, shell=True)
status = proc.wait()
if status != 0:
    msg = '%s failed (%d)' % (runswig_foundation, status)
    error.print(msg, exitcode=0)

# ----------------------------------------------------------------------
#  swigtemp 下に SJIS world を作る.
#
Example #10
0
def changerLocalisationFenetre(nouvelleLocalisation):

    ## menu principal ##

    if Const.localisation == "menuPrincipal" :

        # Retour #

        if nouvelleLocalisation== "menuPrincipal" :

            fen.reinitialiserObjet()

            fen.ajouter("fontMenuPrincipal",fen.can.create_image(702,402,image=Const.fontMenuPrincipalI,tag="fontMenuPrincipal"))

            fen.ajouter("texteCommencer", fen.can.create_text(700,300,text="COMMENCER",font=Const.police1_20,fill="white",tag="texteCommencer"))
            fen.ajouter("texteCharger", fen.can.create_text(700,400,text="CHARGER",font=Const.police1_20,fill="white",tag="texteCharger"))
            fen.ajouter("texteQuitter", fen.can.create_text(700,500,text="QUITTER",font=Const.police1_20,fill="white",tag="texteQuitter"))

        else :

            if nouvelleLocalisation == "joueurCharge" :

                fen.detruire("retourMenuPrincipal")

            else :

                if "retourMenuPrincipal" not in fen.object.keys() :

                    fen.ajouter("retourMenuPrincipal", fen.can.create_text(700,400,text="RETOUR",font=Const.police1_20,fill="white",tag="retourMenuPrincipal"))

                    fen.can.tag_bind("retourMenuPrincipal", "<Button-1>", lambda use : changerLocalisationFenetre("menuPrincipal"))
                    fen.can.tag_bind("retourMenuPrincipal","<Enter>", lambda use : changerCouleurTexte("retourMenuPrincipal"))
                    fen.can.tag_bind("retourMenuPrincipal","<Leave>", lambda use : changerCouleurTexte("retourMenuPrincipal"))


        # commencer #

        if Const.menu == "menuPrincipal" and nouvelleLocalisation== "creerNouveauJoueurNom" :

            fen.detruire("texteCommencer")
            fen.detruire("texteCharger")

            fen.ajouter("zoneSaisieCompteNom", ZoneSaisie(fen, 400, 300, 1000, "NOM DU JOUEUR", 15))
            fen.fenetre.bind("<Return>", lambda use : creerNouveauJoueur())


        elif Const.menu == "creerNouveauJoueurNom" and nouvelleLocalisation== "creerNouveauJoueurMDP" :

            fen.object["zoneSaisieCompteNom"].destructionZoneSaisie()
            fen.fenetre.unbind_all("<Key>")
            fen.ajouter("zoneSaisieCompteMDP", ZoneSaisie(fen, 400, 300, 1000, "MDP DU JOUEUR", 15))
            fen.fenetre.bind("<Return>", lambda use : creerNouveauJoueur())


        elif Const.menu == "creerNouveauJoueurNom" and nouvelleLocalisation== "creerNouveauJoueurNom" :

            fen.object["zoneSaisieCompteNom"].destructionZoneSaisie()
            fen.fenetre.unbind_all("<Key>")
            fen.ajouter("zoneSaisieCompteNom", ZoneSaisie(fen, 400, 300, 1000, "NOM DEJA PRIS", 15))
            fen.fenetre.bind("<Return>", lambda use : creerNouveauJoueur())


        # joueur chargé #


        elif  nouvelleLocalisation== "joueurCharge" :

            if Const.menu == "creerNouveauJoueurMDP" :

                fen.object["zoneSaisieCompteMDP"].destructionZoneSaisie()
                fen.fenetre.unbind_all("<Key>")

            elif Const.menu == "chargerJoueurMDP" :

                fen.object["zoneSaisieChargerMDP"].destructionZoneSaisie()
                fen.fenetre.unbind_all("<Key>")

            nomJoueur=Const.joueur.nomJoueur

            fen.fenetre.unbind("<Return>")

            fen.ajouter("nomJoueurMenuPrincipal", fen.can.create_text(700,200,text="BIENVENUE "+nomJoueur.upper(),font=Const.police1_20,fill="white",tag="nomJoueurMenuPrincipal"))
            fen.ajouter("jouerMenuPrincipal", fen.can.create_text(700,400,text="JOUER",font=Const.police1_20,fill="white",tag="jouerMenuPrincipal"))

            fen.can.tag_bind("nomJoueurMenuPrincipal","<Enter>", lambda use : changerCouleurTexte("nomJoueurMenuPrincipal"))
            fen.can.tag_bind("nomJoueurMenuPrincipal","<Leave>", lambda use : changerCouleurTexte("nomJoueurMenuPrincipal"))

            fen.can.tag_bind("jouerMenuPrincipal", "<Button-1>", lambda use : lancementJeu())
            fen.can.tag_bind("jouerMenuPrincipal","<Enter>", lambda use : changerCouleurTexte("jouerMenuPrincipal"))
            fen.can.tag_bind("jouerMenuPrincipal","<Leave>", lambda use : changerCouleurTexte("jouerMenuPrincipal"))


        # charger joueur #

        elif Const.menu == "menuPrincipal" and nouvelleLocalisation== "chargerJoueurNom" :
            fen.detruire("texteCommencer")
            fen.detruire("texteCharger")

            fen.ajouter("zoneSaisieChargerNom", ZoneSaisie(fen, 400, 300, 1000, "NOM DU JOUEUR", 15))
            fen.fenetre.bind("<Return>", lambda use : chargerJoueur())


        elif Const.menu == "chargerJoueurNom" and nouvelleLocalisation== "chargerJoueurNom" :

            fen.object["zoneSaisieChargerNom"].destructionZoneSaisie()
            fen.fenetre.unbind_all("<Key>")
            fen.ajouter("zoneSaisieChargerNom", ZoneSaisie(fen, 400, 300, 1000, "NOM INVALIDE", 15))
            fen.fenetre.bind("<Return>", lambda use : chargerJoueur())


        elif Const.menu == "chargerJoueurNom" and nouvelleLocalisation== "chargerJoueurMDP" :

            fen.object["zoneSaisieChargerNom"].destructionZoneSaisie()
            fen.fenetre.unbind_all("<Key>")
            fen.ajouter("zoneSaisieChargerMDP", ZoneSaisie(fen, 400, 300, 1000, "MDP DU JOUEUR", 15))
            fen.fenetre.bind("<Return>", lambda use : chargerJoueur())


        elif Const.menu == "chargerJoueurMDP" and nouvelleLocalisation== "chargerJoueurMDP" :

            fen.object["zoneSaisieChargerMDP"].destructionZoneSaisie()
            fen.fenetre.unbind_all("<Key>")
            fen.ajouter("zoneSaisieChargerMDP", ZoneSaisie(fen, 400, 300, 1000, "MOT DE PASSE FAUX", 15))
            fen.fenetre.bind("<Return>", lambda use : chargerJoueur())


    elif Const.localisation=="jeu" :

        if Const.menu=="joueurCharge" :

            fen.reinitialiserObjet()

            fen.ajouter("fontJeu", fen.can.create_image(702,402,image=Const.fontsJeu[Proc.fontJeuIndex()], tag="fontJeu"))
            fen.ajouter("miseEnPlaceJeu", fen.can.create_image(702,402,image=Const.miseEnPlaceJeuI))

            miseEnPlaceMenu()
            miseEnPlaceMonstre()
            miseEnPlaceServants()
            miseEnPlaceAffichageInfos()
            process["DPS"].start()

        # changements graphiques des menus en jeu

        elif Const.menu== "jeuServants" and nouvelleLocalisation== "jeuEsprit" :

            effacerMenuServants()
            miseEnPlaceEsprit()

        elif Const.menu== "jeuEsprit" and nouvelleLocalisation== "jeuServants" :

            effacerMenuEsprit()
            miseEnPlaceServants()
            for i in range(len(Const.joueur.servants)):
                miseAJOurAffichageNiveauDegatsPrixMultiplicateurServant(i)

    Const.menu=nouvelleLocalisation
Example #11
0
                  '--as-is',
                  dest='as_is',
                  action='count',
                  default=0,
                  help='do not update nor clear test repository')

# ----------------------------------------------------------------------
#  Process for command line
#
(options, args) = parser.parse_args()
if options.version:
    print('%s: Version %s' % (prog, version))
    sys.exit(0)
if len(args) != 2:
    Error(prog).error('incorrect number of arguments\n')
    Proc().execute('python %s.py -h' % prog, shell=True).wait()
    sys.exit(-1)

# get test repository name
repository = Util.upath(args[0])
result_repository = Util.upath(args[1])
conf = options.conf
plat = options.plat
tool = options.tool if Util().is_windows() else None
update_only = options.update_only
skip_update = options.skip_update
verbose = options.verbose
dry_run = options.dry_run
as_is = options.as_is

if repository == 'Springhead':
Example #12
0
def miseAJourAffichagePVMonstre():

    fen.can.itemconfig("textePVMonstre", text="PV : "+Proc.formatEcritureNombre(Const.ennemi.PV))
Example #13
0
def miseAJourAffichageFont():

    fen.can.itemconfig("fontJeu", image=Const.fontsJeu[Proc.fontJeuIndex()])
Example #14
0
def miseAJourAffichageMonnaie():

    fen.can.itemconfig("moneyTexte", text="money :  "+Proc.formatEcritureNombre(Const.joueur.money))
Example #15
0
def installed(path, test='--help'):
    path = Util.wpath(path) if Util.is_windows() else path
    cmnd = '%s %s' % (path, test)
    rc = Proc().execute(cmnd, stdout=Proc.NULL, stderr=Proc.NULL,
                        shell=True).wait()
    return rc == 0
Example #16
0
                  '--version',
                  dest='version',
                  action='store_true',
                  default=False,
                  help='show version')

# ----------------------------------------------------------------------
#  コマンドラインの解析
#
(options, args) = parser.parse_args()
if options.version:
    print('%s: Version %s' % (prog, str(version)))
    sys.exit(0)
if len(args) != 1:
    Error(prog).error('incorrect number of arguments\n')
    Proc().execute('python %s.py -h' % prog, shell=True).wait()
    sys.exit(-1)

module = args[0]
dry_run = options.dry_run
verbose = options.verbose

# ----------------------------------------------------------------------
#  生成するファイル
#
cpp = 'EP%s.cpp' % module
hpp = 'EP%s.h' % module
sprh = 'SprEP%s.h' % module

# ----------------------------------------------------------------------
#  swigの実行
Example #17
0
def logmsg(msg, file):
    cmnd = 'echo %s' % msg
    proc = Proc(verbose=0)
    proc.exec(cmnd, stdout=file, append=True, shell=True)
    proc.wait()
Example #18
0
def miseEnPlaceServants():

    xImage,yImage=55,150

    xNomLvl,yNomLvl=255,130

    xLvlUp,yLvlUp=470,150

    xDegats,yDegats=230,160

    xPrix,yPrix=190,190

    xMultiplicateur,yMultiplicateur=360,190

    for i in range(len(Const.joueur.servants)) :

        nom=Const.joueur.servants[i].nom

        niveau=Const.joueur.servants[i].niveau

        status=Const.joueur.servants[i].status

        degats=Const.joueur.servants[i].degats

        prix=Const.joueur.servants[i].prix

        multiplicateur=Const.joueur.servants[i].multiplicateur

        imgServant=Const.servantsI[nom+".png"]

        tagImg="servant_"+str(nom)+"I"

        tagNom="servant_"+str(nom)+"nom"

        tagLvlUp="servant_"+str(nom)+"lvlUp"

        tagDegats="servant_"+str(nom)+"degats"

        tagPrix="servant_"+str(nom)+"prix"

        tagMultiplicateur="servant_"+str(nom)+"multiplicateur"

        fen.ajouter(tagImg, fen.can.create_image( xImage, yImage, image=imgServant, tag=tagImg))

        fen.ajouter(tagNom, fen.can.create_text( xNomLvl, yNomLvl, text=nom.upper()+"  LVL : "+str(niveau),  font=Const.police2_20, fill="black", tag=tagNom))

        fen.ajouter(tagLvlUp, fen.can.create_image( xLvlUp, yLvlUp, image=Const.fenetreDivers["lvlUp"], tag=tagLvlUp))

        fen.ajouter(tagDegats, fen.can.create_text( xDegats, yDegats, text=str(status)+" : "+Proc.formatEcritureNombre(degats),  font=Const.police2_20, fill="black", tag=tagDegats))

        fen.ajouter(tagPrix, fen.can.create_text( xPrix, yPrix, text="Prix : "+Proc.formatEcritureNombre(prix), font=Const.police2_20, fill="black", tag=tagPrix))

        fen.ajouter(tagMultiplicateur, fen.can.create_text(xMultiplicateur, yMultiplicateur, text="PowUp : x"+str(multiplicateur),  font=Const.police2_20, fill="black", tag=tagMultiplicateur))


        binderBouttonLevelUpServant(tagLvlUp,i,Const.joueur.modeLvlUp)

        yImage+=120

        yNomLvl+=120

        yLvlUp+=120

        yDegats+=120

        yPrix+=120

        yMultiplicateur+=120
Example #19
0
	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))
Example #20
0
def quitterJeu():

    Proc.sauvegarderPartie()

    fen.destruction()
Example #21
0
                  '--version',
                  dest='version',
                  action='store_true',
                  default=False,
                  help='show version')

# ----------------------------------------------------------------------
#  Process for command line
#
##  Command line options and arguments.
(options, args) = parser.parse_args()
if options.version:
    print('%s: Version %s' % (prog, version))
    sys.exit(0)
if len(args) != 0:
    proc = Proc(verbose=options.verbose)
    proc.exec('%s %s.py -h' % (python, prog)).wait()
    parser.error("incorrect number of arguments")
    sys.exit(0)

# Options.
srctop = options.srctop  # top directory of source tree
inifile = options.inifile  # initial file name
outfile = options.outfile  # outout file name
test_only = options.test_only  # do not make output file (for debug)
verbose = options.verbose  # verbose mode

if verbose:
    print('argument used:')
    print('  srctop:    %s' % srctop)
    print('  inifile:   %s' % inifile)
Example #22
0
unuse_tmpl = '%s/UnuseClosedSrc.h.template' % tmpl_dir

if scratch:
    print('scratch result file')
res = TestResult(res_file, scratch, verbose=1)
csc = ClosedSrcControl(csc_head, use_tmpl, unuse_tmpl, dry_run, verbose)

# traverse start
trv = Traverse(testid, res, csc, ctl_file, section, toolset, platforms,
               configs, csusage, rebuild, timeout, report, audit, dry_run,
               verbose)
signal.signal(signal.SIGINT, KEYINTR.handler)
stat = trv.traverse(top)
res.finish()
csc.revive()

# back to start directory and make "result.log".
os.chdir(cwd)
cmnd = 'python GenResultLog.py'
outf = '-o ../log/result.log'
args = 'r %s %s %s' % (res_file, platforms[0], configs[0])
print(' '.join([cmnd, outf, args]))
proc = Proc(dry_run=options.dry_run, verbose=options.verbose)
proc.execute([cmnd, outf, args], shell=True).wait()

# done
print('test ended at: %s' % Util.now(format=date_format))
sys.exit(0)

# end: SpringheadTest.py
Example #23
0
# Scene name
scene = args[0]
if scene[-6:] != '.unity':
    scene += '.unity'

if options.verbose:
    print('  inifile:\t%s' % (options.inifile))
    print('  scene:\t%s' % (scene))

# ----------------------------------------------------------------------
#  Globals
#
error = Error(prog)
util = Util()
proc = Proc(verbose=options.exec_trace)
f_op = FileOp(verbose=options.verbose)

# ----------------------------------------------------------------------
#  Read init file
#
mandatory_keys = ['Unity', 'Springhead', 'UnityProject', 'DllPath']

kvf = KvFile(options.inifile)
if (kvf.read() < 0):
    error.print(kvf.error())
if kvf.check(mandatory_keys) != 0:
    error.print(kvf.error())

# set defaults
defaults = {}
Example #24
0
    if unix:
        make = sf.getenv('gmake')
    else:
        make = '%s /NOLOGO' % sf.getenv('nmake')
    swig = sf.getenv('swig')
else:
    if options.python:
        python = options.python
    make = 'gmake' if unix else 'nmake /NOLOGO'
    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))
Example #25
0
                      '--dry-run',
                      dest='dry_run',
                      action='store_true',
                      default=False,
                      help='set dry-run mode')
    parser.add_option('-v',
                      '--verbose',
                      dest='verbose',
                      action='count',
                      default=0,
                      help='set verbose mode')
    (options, args) = parser.parse_args()

    if len(args) != 1:
        prog = sys.argv[0].split(os.sep)[-1].split('.')[0]
        Proc().execute('python %s.py -h' % prog).wait()
        sys.exit(-1)
    if not options.toolset:
        prog = sys.argv[0].split(os.sep)[-1].split('.')[0]
        Proc().execute('python %s.py -h' % prog).wait()
        sys.exit(-1)
    directory = args[0]
    toolset = options.toolset
    config = options.config
    platform = options.platform
    solution = options.solution
    force = options.force
    clean = options.clean
    timeout = options.timeout
    dry_run = options.dry_run
    verbose = options.verbose
Example #26
0
    def run(self,
            dirpath,
            exefile,
            args,
            logfile,
            addpath=None,
            timeout=None,
            pipeprocess=None):
        if self.verbose:
            print('run program')
            print('  dirpath: %s' % dirpath)
            print('  exefile: %s' % exefile)
            print('  args:    %s' % args)
            print('  logfile: %s' % logfile)
            print('  addpath: %s' % addpath)
            print('  timeout: %s' % timeout)
            print('  pipe:    %s' % pipeprocess)

        # go to target directory.
        dirsave = self.__chdir('run', dirpath)
        if self.verbose:
            cwd = Util.upath(os.getcwd())
            print('run: in directory "%s"' % cwd)

        if Util.is_windows():
            arch = 'x64' if self.arch == 'x64' else 'Win32'
            bindir = '%s/%s/%s' % (self.ccver, arch, self.config)
            exefile = '%s/%s' % (bindir, exefile)
        if self.verbose:
            print('  exefile: %s' % exefile)
        if not os.path.exists(exefile):
            print('fun: no such file "%s"' % exefile)
            return -1

        # use following temporary log file.
        tmpdir = self.__dirpart(logfile)
        if Util.is_unix():
            config = config.replace('-', '')
        tmplog = 'log/%s_%s_%s_%s_run.log' % \
          (self.clsname, self.ccver, self.arch, self.config)

        # prepare log file (append mode).
        logf = self.__open_log(logfile, 'a', 'go')

        # execute program.
        if pipeprocess:
            proc1 = Proc(self.verbose, self.dry_run)
            proc2 = Proc(self.verbose, self.dry_run)
            proc1.exec('%s %s' % (exefile, args),
                       addpath=addpath,
                       stdin=Proc.PIPE,
                       stdout=tmplog,
                       stderr=Proc.STDOUT)
            proc2.exec(pipeprocess, addpath=addpath, stdout=Proc.PIPE)
            proc2.wait()
            stat = proc1.wait(timeout)
        else:
            proc1 = Proc(self.verbose, self.dry_run)
            proc1.exec('%s %s' % (exefile, args),
                       stdout=tmplog,
                       stderr=Proc.STDOUT)
            stat = proc1.wait(timeout)

        # merge log info.
        if logf:
            tmpf = TextFio(tmplog)
            if tmpf.open() < 0:
                msg = '__run: open error: "%s"' % tmplog
                self.E.print(msg, alive=True)
            else:
                lines = tmpf.read()
                logf.writelines(lines)
                tmpf.close()
            logf.close()

        os.chdir(dirsave)
        return stat
Example #27
0
	stat = proc.wait()
	Print('-> returned status: %d' % stat)

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'
Example #28
0
 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:
Example #29
0
                  '--version',
                  dest='version',
                  action='store_true',
                  default=False,
                  help='show version')

# ----------------------------------------------------------------------
#  Process for command line
#
##  Command line options and arguments.
(options, args) = parser.parse_args()
if options.version:
    print('%s: Version %s' % (prog, version))
    sys.exit(0)
if len(args) != 0:
    proc = Proc(verbose=options.verbose)
    proc.exec('python %s.py -h' % prog).wait()
    parser.error("incorrect number of arguments")
    sys.exit(0)

# Options.
##  Top diredctory of src tree.
srctop = options.srctop
##  Initial file name.
inifile = options.inifile
##  Output file name.
outfile = options.outfile
##  Do not make outfile (for debug).
test_only = options.test_only
##  Verbose level (0: silent).
verbose = options.verbose
Example #30
0
# ----------------------------------------------------------------------
#  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 *
from Error import *

# ----------------------------------------------------------------------
#  Globals
#
proc = Proc()
f_op = FileOp()

# ----------------------------------------------------------------------
#  Files
#
makefile = 'makefile.swig'  # name of target makefile
tempfile = makefile + '.tmp'  # temporary file name
projfile = 'do_swigall.projs'  # project dependency definition
one_file = 'do_swigone.projs'

# ----------------------------------------------------------------------
#  Helper methods.
#

Example #31
0
    parser.error("incorrect number of arguments")

# get options
verbose = options.verbose
dry_run = options.dry_run

# ----------------------------------------------------------------------
#  Process start.
#
#  (1) create pdf version.
curr_date = Util.date(format='%Y-%m%d')
curr_time = Util.time(format='%H%M')
opts = 'DATE=%s TIME=%s' % (curr_date, curr_time)
cmnd = '%s %s' % (make_pdf, opts)

proc = Proc(dry_run=dry_run, verbose=verbose)
stat = proc.execute(cmnd, addpath=addpath).wait()
if stat == 0:
    print('%s:HowToUseCMake.pdf generated.' % prog)

# (2) create html version.
#opts = '-v -E -K -R -c'
opts = '-E -H -K -R -c -v -v'
cmnd = '%s %s %s main_html.tex' % (python, make_html, opts)

proc = Proc(dry_run=dry_run, verbose=verbose)
stat = proc.execute(cmnd, addpath=addpath).wait()
if stat == 0:
    print('%s: HowToUseCMake.html generated.' % prog)

# ----------------------------------------------------------------------
Example #32
0
cmd = "D:/memcached.exe"
if Port.isExist(prot): 
    Port.kill(prot);
    time.sleep(3)
proc = subprocess.Popen(cmd, shell=True)
print("memcached ok !")

print("start resin ...")
prot = 8082
# cmd = "D:/resin-3.1.9/httpd -Xmn256m -Xms512m -Xmx1024m -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8001 -conf conf/resin-product-svn.conf"
cmd = "D:/resin-3.1.9/httpd -Xmn256m -Xms512m -Xmx1024m -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8001 -conf conf/resin-product-svn.conf"
method = "httpd"
maxFailTime = 3*60
killFormTime = 100


def clean():
    k = maxFailTime
    while not Port.isExist(prot) and k > 0:
        time.sleep(1)
        k -= 1
    Proc.killByName(method)


Proc.killByName(method)
if Port.isExist(prot): Port.kill(prot)
    
threading.Thread(target=clean).start()
proc = subprocess.Popen(cmd, shell=True)
print("resin ok !")
Example #33
0
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:
Example #34
0
def action(jrec):
    post = Proc.get_fields(jrec)
    post.insert_time()
    print str(jrec)
Example #35
0
    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
Example #36
0
			default=False, help='test only on x64 platform')
	parser.add_option('-8', '--x86',
			dest='x86', action='store_true',
			default=False, help='test only on x86 platform')
	parser.add_option('-D', '--dry-run',
			dest='dry_run', action='store_true',
			default=False, help='set dry-run mode')
	parser.add_option('-v', '--verbose',
			dest='verbose', action='count',
			default=0, help='set verbose mode')
	parser.add_option('-w', '--vs-verbose',
			dest='vs_verbose', action='count',
			default=0, help='set VisualStudio verbose mode')
	(options, args) = parser.parse_args()
	if len(args) != 1:
		Proc().exec('python ControlParams.py -h').wait()
		sys.exit(-1)
	if options.cs_control not in ['use', 'unuse', 'auto']:
		print("Error: -c: must be one of 'use', 'unuse' or 'auto'")
		sys.exit(-1)
	if not options.x86 and not options.x64:
		options.x86 = True
		options.x64 = True
	testdir = args[0]

	putlog = [True, 64]		# [build, run]
	runlog_lines = 10

	def build(platform, config, execute):
		if execute == False:
			return 1