def run_tests_from_commandline():
"""Runs the tests in Maya standalone mode.
This is called when running cmt/bin/runmayatests.py from the commandline.
"""
import maya.standalone
maya.standalone.initialize()
# Make sure all paths in PYTHONPATH are also in sys.path
# When a maya module is loaded, the scripts folder is added to PYTHONPATH, but it doesn't seem
# to be added to sys.path. So we are unable to import any of the python files that are in the
# module/scripts folder. To workaround this, we simply add the paths to sys ourselves.
realsyspath = [os.path.realpath(p) for p in sys.path]
pythonpath = os.environ.get('PYTHONPATH', '')
for p in pythonpath.split(os.pathsep):
p = os.path.realpath(p) # Make sure symbolic links are resolved
if p not in realsyspath:
sys.path.insert(0, p)
run_tests()
# Starting Maya 2016, we have to call uninitialize
if float(cmds.about(v=True)) >= 2016.0:
maya.standalone.uninitialize()
python类about()的实例源码
def ImportFileSelectDialog():
importFrom = None
if cmds.about(version=True)[:4] == "2012": # Support for newer versions
importFrom = cmds.fileDialog2(fileMode=1, fileFilter="SEAnim Files (*.seanim)", caption="Import SEAnim")
else:
importFrom = cmds.fileDialog2(fileMode=1, dialogStyle=2, fileFilter="SEAnim Files (*.seanim)", caption="Import SEAnim")
if importFrom == None or len(importFrom) == 0 or importFrom[0].strip() == "":
return None
path = importFrom[0].strip()
pathSplit = os.path.splitext(path) # Fix bug with Maya 2013
if pathSplit[1] == ".*":
path = pathSplit
return path
# Attempt to resolve the animType for a bone based on a given list of modifier bones, returns None if no override is needed
def enableaPlugin(filename):
extDict = {'win64':'mll','mac':'bundle','linux':'so','linux64':'so'}
os = cmds.about(os=True)
ext = extDict[os]
version = cmds.about(v=True)[:4]
pluginName = 'deltaMushToSkinCluster_%s' % version
fileFullName = '%s.%s' % (pluginName,ext)
rootPath = getParentPath(currentFileDirectory())
pluginsPath = rootPath+'/plug-ins/'
pluginFilePath = pluginsPath+fileFullName
pluginStr = mel.eval('getenv "MAYA_PLUG_IN_PATH";')+';'+pluginsPath
mel.eval('putenv "MAYA_PLUG_IN_PATH" "%s";' % pluginStr)
with open(filename,'a+') as f:
state = True
for line in f.readlines():
if re.findall(fileFullName,line):
state = False
if state:
f.write(r'evalDeferred("autoLoadPlugin(\"\", \"%s\", \"%s\")");' % (fileFullName,pluginName))
if not cmds.pluginInfo( pluginFilePath, query=True, autoload=True):
cmds.pluginInfo( pluginFilePath, edit=True, autoload=True)
if not cmds.pluginInfo(pluginFilePath,query=True,loaded=True):
cmds.loadPlugin(pluginFilePath)
def maya_api_version():
return int(cmds.about(api=True))
def maya_api_version():
return int(cmds.about(api=True))
def maya_version():
return cmds.about(version=True)
def maya_api_version():
return int(cmds.about(api=True))
def _on_maya_initialized(*args):
api.emit("init", args)
if cmds.about(batch=True):
logger.warning("Running batch mode ...")
return
# Keep reference to the main Window, once a main window exists.
self._parent = {
widget.objectName(): widget
for widget in QtWidgets.QApplication.topLevelWidgets()
}["MayaWindow"]
def install():
"""Run all compatibility functions"""
if cmds.about(version=True) == "2018":
remove_googleapiclient()