Source code for schrodinger.maestro.commands
from contextlib import contextmanager
from schrodinger import get_maestro
maestro = get_maestro()
[docs]@contextmanager
def temporary_preference(command, preference, value):
    """
    Set a maestro command preference to a temporary value, then after executing
    other code, restore the original value for the command preference.
    :param command: Command used to set temporary value
    :type  command: str
    :param preference: Preference to temporarily set
    :type  preference: str
    :param value: Temporary value
    :type  value: str
    """
    old_value = maestro.get_command_option(command, preference)
    maestro.command('%s %s="%s"' % (command, preference, value))
    try:
        yield
    finally:
        maestro.command('%s %s="%s"' % (command, preference, old_value))