@ -9,8 +9,8 @@
#import sys, getopt
import argparse
import copy
import yaml , os
import yaml
import os
from datetime import datetime
import basic . constants as B
import basic . message
@ -18,6 +18,7 @@ import basic.message
import basic . componentHandling
import utils . date_tool
import utils . path_tool
import utils . file_tool
jobdef = {
" unit " : {
@ -55,16 +56,23 @@ jobdef = {
" basedir " : " tcbase " ,
" dirname " : " tcdir " ,
" logdir " : " {job.par.tcdir} / {log} /log_ {tctime} .txt " } ,
" execute_testcase " : {
" pardef " : " tcdir " , # ",tdtyp,tdsrc,tdname",
" pfilesource " : " tcparfile " ,
" pfiletarget " : " tcparfile " ,
" basedir " : " tcbase " ,
" dirname " : " tcdir " ,
" logdir " : " {job.par.tcdir} / {log} /log_ {tctime} .txt " } ,
" collect_testcase " : {
" pardef " : " tcdir " , # ",tdtyp,tdsrc,tdname",
" pfilesource " : " envparfile " ,
" pfilesource " : " tc parfile" ,
" pfiletarget " : " tcparfile " ,
" basedir " : " tcbase " ,
" dirname " : " tcdir " ,
" logdir " : " {job.par.tcdir} / {log} /log_ {tctime} .txt " } ,
" compare_testcase " : {
" pardef " : " tcdir " , # ",tdtyp,tdsrc,tdname",
" pfilesource " : " env parfile" ,
" pfilesource " : " tc parfile" ,
" pfiletarget " : " tcparfile " ,
" basedir " : " tcbase " ,
" dirname " : " tcdir " ,
@ -72,22 +80,22 @@ jobdef = {
" test_system " : {
" pardef " : " tcdir,tdtyp,tdsrc,tdname " ,
" pfilesource " : " tsparfile " ,
" pfiletarget " : " tc parfile " ,
" pfiletarget " : " ts parfile " ,
" basedir " : " tcbase " ,
" dirname " : " tcdir " ,
" logdir " : " {job.par.tcdir} / {log} /log_ {tctime} .txt " } ,
" finish_testcase " : {
" pardef " : " tcdir,tdtyp,tdsrc,tdname " ,
" pfilesource " : " ts parfile " ,
" pardef " : " tcdir " ,
" pfilesource " : " tc parfile " ,
" pfiletarget " : " tcparfile " ,
" basedir " : " tcbase " ,
" dirname " : " tcdir " ,
" logdir " : " {job.par.tcdir} / {log} /log_ {tctime} .txt " } ,
" finish_testsuite " : {
" pardef " : " tcdir,tdtyp,tdsrc,tdname " ,
" pardef " : " tsdir " ,
" pfilesource " : " tsparfile " ,
" pfiletarget " : " tcp arfile " ,
" basedir " : " tc base " ,
" pfiletarget " : " tss arfile " ,
" basedir " : " ts base " ,
" dirname " : " tsdir " ,
" logdir " : " {job.par.tcdir} / {log} /log_ {tctime} .txt " }
}
@ -141,9 +149,18 @@ class Job:
def setProgram ( self , program ) :
self . program = program
self . par . program = program
self . par . setBasedir ( program )
self . m . setLogdir ( " logTime " )
basedir = jobdef [ program ] [ " basedir " ]
if ( self . par is not None ) :
setattr ( self . par , " program " , program )
setattr ( self . par , " basedir " , basedir )
parstring = getattr ( self . par , " parstring " )
parstring = parstring [ parstring . find ( " -- " ) : ]
parstring = " python " + program + " " + parstring
setattr ( self . par , " parstring " , parstring )
if not hasattr ( self . par , jobdef [ program ] [ " dirname " ] ) :
setattr ( self . par , jobdef [ program ] [ " dirname " ] ,
utils . path_tool . composePattern ( " { " + basedir + " } " , None ) )
self . par . setParameterLoaded ( )
def getInstance ( ) :
if ( Job . __instance is not None ) :
@ -178,21 +195,28 @@ class Job:
def dumpParameter ( self ) :
parpath = utils . path_tool . composePath ( jobdef [ self . program ] [ " pfiletarget " ] , None )
if not os . path . exists ( parpath ) :
return None
output = { }
output [ " comps " ] = basic . componentHandling . getComponentDict ( )
cconf = basic . componentHandling . getComponentDict ( )
output [ " par " ] = self . par . __dict__
# print(str(output))
with open ( parpath , " w " ) as file :
doc = yaml . dump ( output , file )
file . close ( )
output [ " comps " ] = { }
for c in cconf :
output [ " comps " ] [ c ] = { }
for x in [ " function " , " conn " ] :
output [ " comps " ] [ c ] [ x ] = cconf [ c ] [ x ]
if x == " conn " and " passwd " in cconf [ c ] [ x ] :
output [ " comps " ] [ c ] [ x ] [ " passwd " ] = " xxxxx "
utils . file_tool . writeFileText ( self . m , parpath , output )
def loadParameter ( self ) :
output = { }
if len ( str ( jobdef [ self . program ] [ " pfilesource " ] ) ) < 2 :
return None
parpath = utils . path_tool . composePath ( jobdef [ self . program ] [ " pfilesource " ] , None )
with open ( parpath , " r " ) as file :
doc = yaml . full_load ( file )
if not os . path . join ( parpath ) :
return None
doc = utils . file_tool . readFileDict ( parpath , self . m )
for k in doc . keys ( ) :
output [ k ] = copy . deepcopy ( doc [ k ] )
return output
@ -256,7 +280,7 @@ class Parameter:
if hasattr ( self , jobdef [ program ] [ " dirname " ] ) :
utils . path_tool . extractPath ( self . basedir , getattr ( self , jobdef [ program ] [ " dirname " ] ) )
elif program != " unit " :
dirpath = utils . path_tool . composePattt ern ( " { " + jobdef [ program ] [ " basedir " ] + " } " , None )
dirpath = utils . path_tool . composePattern ( " { " + jobdef [ program ] [ " basedir " ] + " } " , None )
setattr ( self , jobdef [ program ] [ " dirname " ] , dirpath )
else :
self . basedir = " debugs "
@ -331,6 +355,9 @@ class Parameter:
for k in vars ( args ) :
if getattr ( args , k ) is not None :
self . setJobAttr ( k , getattr ( args , k ) )
dirpath = self . getDirParameter ( )
if dirpath is not None :
utils . path_tool . extractPath ( dirpath [ 0 ] , dirpath [ 1 ] )
def setParameterLoaded ( self ) :
job = Job . getInstance ( )
@ -369,6 +396,7 @@ class Configuration:
def setConfiguration ( self , path ) :
self . confs = { }
doc = utils . file_tool . readFileLines ( path , None )
with open ( path , " r " ) as file :
doc = yaml . full_load ( file )
if " basic " in doc :
@ -377,6 +405,7 @@ class Configuration:
else :
for i , v in doc . items ( ) :
self . confs [ i ] = v
def setConfig ( self , path , val ) :
a = path . split ( " . " )
if len ( a ) == 1 :