CIME.utils
Common functions used by cime python scripts Warning: you cannot use CIME Classes in this module as it causes circular dependencies
Functions
Given a flag and value for a shell command, return a string |
|
Capture and report warning count, capture and report errors and undefined references. |
|
check for unallowed characters in name, this routine only checks the final name and does not check if path exists or is writable |
|
Given a map: jobname -> (procs, est-time), return a total time estimate for a given processor pool size |
|
Convert time value to seconds to HH:MM:SS |
|
Convert time value in [[HH:]MM:]SS to seconds |
|
Convert value back to string. |
|
Convert value from string to another type. |
|
Convert value to it's real type by probing conversions. |
|
Takes a list of globs and copies all files to output_directory. |
|
Copy any local macros files to the path given by 'destination'. |
|
Copy a file over a file that already exists |
|
if dest does not exist or is older than src copy src to dest |
|
Does the text string appear in the filepath file |
|
Similar to assert except doesn't generate an ugly stacktrace. |
|
Checks whether the given file contains a top-level definition of the function 'funcname' |
|
Sometimes unicode chars can cause problems |
|
recursively find all files matching a pattern |
|
Children implies recursive. |
|
Find and import the test matching testname Look through the paths set in config_files.xml variable SYSTEM_TESTS_DIR for components used in this case to find a test matching testname. |
|
Converts the string input_time from input_format to time_format Valid format specifiers are "%H", "%M", and "%S" % signs must be followed by an H, M, or S and then a separator Separators can be any string without digits or a % sign Each specifier can occur more than once in the input_format, but only the first occurence will be used. |
|
Hierarchy for choosing CHARGE_ACCOUNT: 1. |
|
Return the absolute path to the root of CIME that contains this script |
|
Return the name of the current branch for a repository |
|
Return the sha1 of the current HEAD commit |
|
Return the sha1s of the current currently checked out commit for each submodule, along with the submodule path and the output of git describe for the SHA-1. |
|
Given a partial CIME test name, return in form TESTCASE.GRID.COMPSET.MACHINE_COMPILER[.TESTMODS] Use the additional args to fill out the name if needed |
|
Get location for test HTML output |
|
Use to pass same logging options as was used for current executable to subprocesses. |
|
Get the currently configured model value The CIME_MODEL env variable may or may not be set |
|
Get absolute path to model config area" |
|
Hierarchy for choosing PROJECT: 0. |
|
From within CIME, return subdirectory of python libraries |
|
Get absolute path to scripts |
|
Return the absolute path to the root of SRCROOT. |
|
Convert a time from 'unit' to seconds |
|
Get a string representing the current UTC time in format: YYYYMMDD_HHMMSS |
|
Get URL to htmlroot |
|
Gzips an existing file, removes the unzipped version, returns path to zip file. |
|
Indents the given string by a given number of spaces |
|
Test if the case is a single component standalone such as FKESSLER |
|
Search the filepath in reverse order looking for expect_text before finding fail_text. |
|
return list of path sorted by timestamp oldest first |
|
Return true if item matches any regex in re_counts' keys. |
|
Given a case_id, return it in form TESTCASE.GRID.COMPSET.PLATFORM |
|
Guide to logging in CIME. |
|
Given a CIME test name TESTCASE[_CASEOPTS].GRID.COMPSET[.MACHINE_COMPILER[.TESTMODS]], return each component of the testname with machine and compiler split. |
|
Useful to keep unit tests from interfering with each other |
|
Wrapper around subprocess to make it much more convenient to run shell commands |
|
Wrapper around subprocess to make it much more convenient to run shell commands. |
|
This code will try to import and run each cmd as a subroutine if that fails it will run it as a program in a seperate shell |
|
A flexbile and safe copy routine. |
|
Copies a set of files from one dir to another. |
|
Set the model to be used in this session |
|
All stdout, stderr will be buffered after this is called. |
|
All stdout, stderr will not be buffered after this is called. |
|
Case insensitive search for string in list returns the matching list value >>> string_in_list("Brack",["bar", "bracK", "foo"]) 'bracK' >>> string_in_list("foo", ["FFO", "FOO", "foo2", "foo3"]) 'FOO' >>> string_in_list("foo", ["FFO", "foo2", "foo3"]) |
|
Makes a symlink from link_name to target. |
|
Do the variable substitution for any variables that need transforms recursively. |
|
Classes
Context manager for environment variables Usage: os.environ['MYVAR'] = 'oldvalue' with EnvironmentContex(MYVAR='myvalue', MYVAR2='myvalue2'): print os.getenv('MYVAR') # Should print myvalue. print os.getenv('MYVAR2') # Should print myvalue2. print os.getenv('MYVAR') # Should print oldvalue. print os.getenv('MYVAR2') # Should print None. |
|
Enable 0002 umask within this manager |
|
A context manager that implements a timeout. |
Exceptions