Package mrv :: Package cmd :: Module base
[hide private]
[frames] | no frames]

Module base

source code

Contains routines required to initialize mrv
Classes [hide private]
    Classes
  SpawnedHelpFormatter
Formatter assuring our help looks good
  SpawnedOptionParser
Customized version to ease use of SpawnedCommand
  SpawnedCommand
Implements a command which can be started easily by specifying a class path such as package.cmd.module.CommandClass whose instance should be started in a standalone process.
Functions [hide private]
    Maya-Intiialization
 
is_supported_maya_version(version)
Returns: True if version is a supported maya version
source code
 
uses_mayapy()
Returns: True if the executable is mayapy
source code
 
mayapy_maya_version()
mayapy interpreter.
source code
 
parse_maya_version(arg, default)
be parsed and was valid, and a float representing the parsed or default version.
source code
 
python_version_of(maya_version)
Returns: python version matching the given maya version
source code
 
update_env_path(environment, env_var, value, append=False)
Set the given env_var to the given value, but append the existing value to it using the system path separator
source code
 
available_maya_versions()
they can be used in methods that require the maya_version to be given.
source code
 
maya_location(maya_version)
given maya version :raise EnvironmentError: if it was not found
source code
 
update_maya_environment(maya_version)
Configure os.environ to allow Maya to run in standalone mode :param maya_version: The maya version to prepare to run, either 8.5 or 2008 to 20XX.
source code
 
mangle_args(args)
Enclose arguments in quotes if they contain spaces ...
source code
 
mangle_executable(executable)
Returns: possibly adjusted path to executable in order to allow its execution This currently only kicks in on windows as we can't handle spaces properly.
source code
 
init_environment(args)
Intialize MRV up to the point where we can replace this process with the one we prepared
source code
 
_execute(executable, args)
Perform the actual execution of the executable with the given args.
source code
 
python_executable(py_version=None)
linux and windows specials
source code
 
find_mrv_script(name)
Find an mrv script of the given name.
source code
 
exec_python_interpreter(args, maya_version, mayapy_only=False)
Replace this process with a python process as determined by the given options.
source code
 
exec_maya_binary(args, maya_version)
Replace this process with the maya executable as specified by maya_version.
source code
    Decorators
 
log_exception(func)
Assures that exceptions result in a logging message.
source code
Variables [hide private]
  log = logging.getLogger("mrv.cmd.base")
  __package__ = 'mrv.cmd'
    Globals
  maya_to_py_version_map = {8.5: 2.4, 2008: 2.5, 2009: 2.5, 2010...
Function Details [hide private]

is_supported_maya_version(version)

source code 
Parameters:
  • version - float which is either 8.5 or 2008 to 20XX
Returns:
True if version is a supported maya version

uses_mayapy()

source code 
Returns:
True if the executable is mayapy

mayapy_maya_version()

source code 
mayapy interpreter. :raise EnvironmentError: If called from a 'normal' python interpreter
Returns:
float representing the maya version of the currently running

parse_maya_version(arg, default)

source code 
be parsed and was valid, and a float representing the parsed or default version. :param default: The desired default maya version
Returns:
tuple(bool, version) tuple of bool indicating whether the version could

python_version_of(maya_version)

source code 
Returns:
python version matching the given maya version
Raises:
  • EnvironmentError - If there is no known matching python version

update_env_path(environment, env_var, value, append=False)

source code 
Set the given env_var to the given value, but append the existing value to it using the system path separator
Parameters:
  • append - if True, value will be appended to existing values, otherwise it will be prepended

available_maya_versions()

source code 
they can be used in methods that require the maya_version to be given. Versions are ordered such that the latest version is given last.
Returns:
list of installed maya versions which are locally available -

maya_location(maya_version)

source code 
given maya version :raise EnvironmentError: if it was not found
Returns:
string path to the existing maya installation directory for the

update_maya_environment(maya_version)

source code 
Configure os.environ to allow Maya to run in standalone mode :param maya_version: The maya version to prepare to run, either 8.5 or 2008 to 20XX. This requires the respective maya version to be installed in a default location. :raise EnvironmentError: If the platform is unsupported or if the maya installation could not be found

mangle_args(args)

source code 
Enclose arguments in quotes if they contain spaces ... on windows only :return: tuple of possibly modified arguments

To Do: remove this function, its unused

mangle_executable(executable)

source code 
Returns:
possibly adjusted path to executable in order to allow its execution This currently only kicks in on windows as we can't handle spaces properly.

Note: Will change working dir

To Do: remove this function, its unused

init_environment(args)

source code 
Intialize MRV up to the point where we can replace this process with the one we prepared
Parameters:
  • args - commandline arguments excluding the executable ( usually first arg )
Returns:
tuple(use_this_interpreter, maya_version, args) tuple of Bool, maya_version, and the remaining args The boolean indicates whether we have to reuse this interpreter, as it is mayapy

_execute(executable, args)

source code 
Perform the actual execution of the executable with the given args. This method does whatever is required to get it right on windows, which is the only reason this method exists !
Parameters:
  • args - arguments, without the executable as first argument

Note: does not return

python_executable(py_version=None)

source code 
linux and windows specials
Returns:
name or path to python executable in this system, deals with

find_mrv_script(name)

source code 

Find an mrv script of the given name. This method should be used if you want to figure out where the mrv executable with the given name is located. The returned path is either relative or absolute.

which use mrv as a subproject

Returns:
Path to script
Raises:
  • EnvironmentError - if the executable could not be found

Note: Currently it only looks for executables, but handles projects

exec_python_interpreter(args, maya_version, mayapy_only=False)

source code 

Replace this process with a python process as determined by the given options. This will either be the respective python interpreter, or mayapy. If it works, the function does not return

Use this option in case the python interpreter crashes for some reason. :raise EnvironmentError: If no suitable executable could be started

Parameters:
  • args - remaining arguments which should be passed to the process
  • maya_version - float indicating the maya version to use
  • mayapy_only - If True, only mayapy will be considered for startup.

exec_maya_binary(args, maya_version)

source code 
Replace this process with the maya executable as specified by maya_version.
Parameters:
  • args - The arguments to be provided to maya
  • maya_version - Float identifying the maya version to be launched

log_exception(func)

source code 
Assures that exceptions result in a logging message. Currently only works with a SpawnedCommand as we need a log instance. On error, the server exits with status 64

Variables Details [hide private]

maya_to_py_version_map

Value:
{8.5: 2.4, 2008: 2.5, 2009: 2.5, 2010: 2.6, 2011: 2.6, 2012: 2.6}