def mainNewBroker(gl):

    NTRC.ntrace(3, "proc params ncases|%s| nparallel|%s| "
                    "nwaitmsec|%s| nwaitmany|%s|" 
                % (gl.nCases, gl.nParallel, gl.nWaitMsec, gl.nWaitHowMany))
    
    # Main loop
    
    # Create list of instructions.  Each instruction is a list of 
    #  command strings.
    lLinesTemp = [sLine.lstrip() 
                for sLine in sTempListOfCommands.split('\n')
                ]
    llsInstructionsTemp =  [lLinesTemp] * gl.nCases

    # Subprocess to start all case jobs.
    qOut = multiprocessing.Queue()
    qWaited = multiprocessing.Queue()
    jRunJobs = multiprocessing.Process(target=fnRunEverything, name="RunJobs"
                , args=(gl, llsInstructionsTemp
                        , gl.nWaitMsec, gl.nWaitHowMany
                        , qOut, qWaited))
    jRunJobs.start()    # Start subproc that does the work
    jRunJobs.join()     #  and wait for it to finish.
    llOut = qOut.get()  # Get massive output list.
    qOut.close()
    tTmp = qWaited.get()
    (gl.nWaitedForSlot, gl.nWaitedForDone) = (tTmp.slot, tTmp.done)
    qWaited.close()
    return llOut
def main(gl):
    """ Temp hack to make instructions for debugging.
    """
    NTRC.ntrace(0, "Starting...")
    tStart = datetime.datetime.now()
    llFullOutput = mainNewBroker(gl)

    if gl.bDebugPrint:
        # Print all the crap that comes back.  
        print("---------begin cases----------")
        for lCase in llFullOutput:
            sCaseOut = ""
            NTRC.ntrace(3, "proc fromq lCase|%s|" % (lCase))
            sCaseOut = '\n'.join(lCase)
            print(sCaseOut)
            print("--------------")
        print("---------end cases----------")
    NTRC.ntrace(0, "Finished nWaitedForSlot|%s| nWaitedForDone|%s|" 
                % (gl.nWaitedForSlot, gl.nWaitedForDone))
    tEnd = datetime.datetime.now()
    tDif = tEnd - tStart
    tDifMuSec = float((tDif.seconds * 1E6) + tDif.microseconds)
    NTRC.ntrace(0, "Time total|%.3f|sec cases|%s| parallel|%s| "
                "per case|%.0f|msec" 
                % (tDifMuSec/1E6, gl.nCases, gl.nParallel,
                tDifMuSec/gl.nCases/1E3))
    def mainNewBroker(gl):

        NTRC.ntrace(3, "proc params ncases|%s| nparallel|%s| "
                        "nwaitmsec|%s| nwaitmany|%s|" 
                    % (gl.nCases, gl.nParallel, gl.nWaitMsec, gl.nWaitHowMany))
        
        # Main loop
        
        # Create list of instructions.  Each instruction is a list of 
        #  command strings.
        lLinesTemp = [sLine.lstrip() 
                    for sLine in sTempListOfCommands.split('\n')
                    ]
        # And make a list of instructions for each case.
        llsInstructionsTemp =  [lLinesTemp] * gl.nCases

        tTmp = fnRunEverything(gl, iter(llsInstructionsTemp)
                            , gl.nWaitMsec, gl.nWaitHowMany)
        (gl.nWaitedForSlot, gl.nWaitedForDone) = (tTmp.slot, tTmp.done)
        return []   # used to be llOut in early proto
Ejemplo n.º 4
0
# example1.py
# program to display student's marks from record

from NewTrace import NTRC
import random

marks = {'James': 90, 'Jules': 55, 'Arthur': 77}
student_list = list(marks.keys())
# Include a ringer, a name that is not in the dictionary, to test for failure.
student_list.append('Soyuj')

# Pick a student at random from the list.
student_name = student_list[random.randrange(len(student_list))]
print("Looking for grades of student " + student_name)

# Look through the list one by one, the hard way.
# (The easy way would be getattr() or try-except.)
for student in marks.keys():
    NTRC.ntrace(3, f'found {student}, looking for {student_name}')
    if student == student_name:
        print(f"Marks for student {student_name} = {marks[student]}")
        break
else:
    print(f'No entry found for the name: {student_name}.')

Ejemplo n.º 5
0
def testFacils():
    print("========== testFacils ============")
    NTRC.ntrace(0, "test level 0")
    NTRC.ntrace(1, "test level 1")
    NTRC.ntracef(1, "AAA", "facil AAA at test level 1")
    NTRC.ntracef(1, "BBB", "facil AAA at test level 1")
Ejemplo n.º 6
0
def testAllLevels():
    print("\n========== testAllLevels ============\n")
    NTRC.ntrace(0, "test level 0")
    NTRC.ntrace(1, "test level 1")
    NTRC.ntrace(2, "test level 2")
    NTRC.ntrace(3, "test level 3")
    NTRC.ntrace(4, "test level 4")
    NTRC.ntrace(5, "test level 5")
Ejemplo n.º 7
0
    testDecoFancy1()
    testDecoFancy2()


#  E N T R Y   P O I N T
if 1:
    print("============= Begin =============")
    setNewDefaults(NTRC,
                   mylevel=0,
                   mytarget=0,
                   myfile="",
                   myfacility="",
                   mytime="YES",
                   myhtml="",
                   myproduction=0)
    NTRC.ntrace(0, "BEGIN")

    setNewDefaults(NTRC,
                   mylevel=6,
                   mytarget=0,
                   myfile="",
                   myfacility="all-aaa",
                   mytime="",
                   myhtml="",
                   myproduction=0)
    testAllLevels()

    testVariousLevels()

    testAllFacils()
Ejemplo n.º 8
0
def greet2(*names):
    NTRC.ntrace(3, f"proc namelist={names!r}")
    print('Hello', end='')
    for name in names:
        print(', ' + name, end='')
    print(':')