Package schrodinger :: Package application :: Package matsci :: Module jobutils
[hide private]
[frames] | no frames]

Module jobutils

Classes [hide private]
  StringCleaner
Manages the cleaning of strings.
Functions [hide private]
 
add_keyword_parser_argument(parser, arghelp=None)
Add a keyword argument to the parser
 
parse_keyword_list(options, exit_on_error=True)
Adds keystring and keydict properties to the argparse options object that are the list of keyword arguments turned into, respectively, a string or a dictionary.
bool
check_license(panel=None, token=94, name='')
Check if a valid token exists
str or None
create_run_dir(panel, jobname)
Create a subdirectory to run a job in, asking the user and removing existing directories if needed.
 
working_directory(*args, **kwds)
A context manager which changes the working directory to the given path, and then changes it back to its previous value on exit.
Variables [hide private]
  __package__ = 'schrodinger.application.matsci'
Function Details [hide private]

add_keyword_parser_argument(parser, arghelp=None)

 

Add a keyword argument to the parser

Parameters:
  • parser (argparse.ArgumentParser) - The parser to add this argument to

parse_keyword_list(options, exit_on_error=True)

 

Adds keystring and keydict properties to the argparse options object that are the list of keyword arguments turned into, respectively, a string or a dictionary. Valid keyword syntax is checked for.

Typical usage:

jobutils.add_keyword_parser_argument(parser) options = parser.parse_args(args) jobutils.parse_keyword_list(options) print options.keystring, options.keydict

Parameters:
  • options (argparse.Namespace) - The parser Namespace object with a keywords attribute
  • exit_on_error (bool) - True if the ValueError for keyword syntax should result in a message being printed and sys.exit() being called, False if the error should just be raised.
Raises:
  • ValueError - If an invalid keyword pair syntax is detected and handle_error is False

check_license(panel=None, token=94, name='')

 

Check if a valid token exists

Parameters:
  • panel (schrodinger.ui.qt.appframework.AppFramework) - panel to use to put up an error dialog if no license
  • token (schrodinger.utils.license constant) - A token type from the schrodinger.utils.license module, such as MATERIALSCIENCE_MAIN or MATERIALSCIENCE_GA
  • name (str) - The user-identifiable name for the token - used for error messages. If not provided, the string used in the license module for this token (if one exists) will be used.
Returns: bool
True if valid license exists, False if not

create_run_dir(panel, jobname)

 

Create a subdirectory to run a job in, asking the user and removing existing directories if needed.

Parameters:
  • panel (schrodinger.ui.qt.appframework.AppFramework) - panel to use to put up an error dialog if no license
  • jobname (str) - The name of the job. The directory will be jobname + _dir
Returns: str or None
The path to the directory or None if an existing directory was found and the user elected not to remove it

working_directory(*args, **kwds)

 

A context manager which changes the working directory to the given path, and then changes it back to its previous value on exit.

Decorators:
  • @contextlib.contextmanager