Example #1
0
def test_cleanSingleAvaDir(tmp_path):

    # Make sure cleanSingleAvaDir catches:
    # - empty variable
    undefVar = initProj.cleanSingleAvaDir('')
    assert undefVar == 'AvaDir is empty'

    # - non string variable
    notAString = initProj.cleanSingleAvaDir(2)
    assert notAString == 'AvaDir is NOT a string'

    # create test directories and touch log files
    # then delete and check again
    avaDir = tmp_path / "avaTestDir"
    initProj.initializeFolderStruct(avaDir)

    # create and fill fake logs
    fakeLog = avaDir / "fake.log"
    keepLog = avaDir / "keep.log"
    content = 'FakelogContent'
    fakeLog.write_text(content)
    keepLog.write_text(content)

    assert fakeLog.read_text() == content
    assert keepLog.read_text() == content

    # check with keep and deleteOutput false
    initProj.cleanSingleAvaDir(str(avaDir), keep='keep', deleteOutput=False)
    # 3 items should be left (Inputs, keep.log, Outputs)
    assert len(list(avaDir.iterdir())) == 3

    # check with keep
    initProj.cleanSingleAvaDir(str(avaDir), keep='keep')
    # 2 items should be left (inputs, keep.log)
    assert len(list(avaDir.iterdir())) == 2

    # check with no optional parameter
    initProj.cleanSingleAvaDir(str(avaDir))
    # 1 items should be left (inputs)
    assert len(list(avaDir.iterdir())) == 1
Example #2
0
cfgMain = cfgUtils.getGeneralConfig()
avalancheDir = cfgMain['MAIN']['avalancheDir']

# Start logging
log = logUtils.initiateLogger(avalancheDir, logName)
log.debug('MAIN SCRIPT')
log.debug('Current avalanche: %s', avalancheDir)

# Load input parameters from configuration file
# write config to log file
cfg = cfgUtils.getModuleConfig(com1DFAOrig)

startTime = time.time()

# Clean input directory(ies) of old work and output files
initProj.cleanSingleAvaDir(avalancheDir, keep=logName)

# Run Standalone DFA
reportDictList = com1DFAOrig.com1DFAOrigMain(cfg, avalancheDir)

# Print time needed
endTime = time.time()
log.info(('Took %s seconds to calculate.' % (endTime - startTime)))

# append parameters from logFile
for reportD in reportDictList:
    simName = reportD['simName']['name']
    parameterDict, reportD = fU.extractParameterInfo(avalancheDir, simName, reportD)


# Generate plots for all peakFiles