def setUpClass(cls): import uuid from PySide2 import QtCore, QtWidgets import bookmarks.common as common import bookmarks.settings as settings import bookmarks.standalone as standalone common.PRODUCT = u'bookmarks_unittest' settings.local_settings.deleteLater() settings.local_settings = settings.LocalSettings() settings.local_settings.setValue(u'servers', None) # Add mock server dir tempdir = QtCore.QStandardPaths.writableLocation( QtCore.QStandardPaths.TempLocation) cls.server = tempdir # Mock job dir _id = uuid.uuid4() cls.job = u'testroot_{id}'.format(id=_id) cls.root_dir = u'{tempdir}/testroot_{id}'.format( tempdir=tempdir, id=_id) _dir = QtCore.QDir(cls.root_dir) _dir.mkpath(u'.') for bookmark in cls.bookmarks: _dir.mkpath(u'./{}'.format(bookmark)) if not QtWidgets.QApplication.instance(): cls.app = standalone.StandaloneApp([]) else: cls.app = QtWidgets.QApplication.instance()
def setUpClass(cls): """Modifiying the environment to add Bookmark's dependencies. This is a must, as otherwise the dependent DLLs would fail to load. """ import os import sys p = os.path.dirname(__file__) + os.path.sep + '..' + os.path.sep p = os.path.normpath(p) sys.path.insert(0, p) k = 'BOOKMARKS_ROOT' if k not in os.environ: raise EnvironmentError( 'Is Bookmarks installed? Could not find BOOKMARKS_ROOT environment variable' ) shared = os.environ[k] + os.path.sep + 'shared' sys.path.insert(1, shared) paths = os.environ['PATH'].split(';') _bin = os.environ[k] + os.path.sep + 'bin' paths.insert(1, _bin) os.environ['PATH'] = ';'.join(paths) try: from PySide2 import QtWidgets import maya.standalone as maya_standalone import maya.mel as mel import maya.cmds as cmds except ImportError as e: raise try: import bookmarks.maya.widget as mayawidget import bookmarks.common as common import bookmarks.standalone as standalone import bookmarks.maya as maya except ImportError as e: raise app = standalone.StandaloneApp([]) maya_standalone.initialize(name='python') mel.eval('') # Let's initialize the plugin dependencies cmds.loadPlugin("AbcExport.mll", quiet=True) cmds.loadPlugin("AbcImport.mll", quiet=True)
def exec_(): """Start Bookmarks as a standalone PySide2 application. .. code-block:: python import bookmarks bookmarks.exec_() """ # Some basic debugging information for info in get_info(): sys.stdout.write(u'{}\n'.format(info)) from PySide2 import QtWidgets import bookmarks.settings as settings import bookmarks.common as common if not settings.local_settings: settings.local_settings = settings.LocalSettings() ui_scale = settings.local_settings.value(u'preferences/ui_scale') ui_scale = ui_scale if ui_scale else common.UI_SCALE common.UI_SCALE = float(ui_scale) common.STANDALONE = True import bookmarks.standalone as standalone if QtWidgets.QApplication.instance(): app = QtWidgets.QApplication.instance() else: app = standalone.StandaloneApp([]) import bookmarks.mainwidget as mainwidget standalone.StandaloneMainWidget() mainwidget.show_window() app.exec_()
from PySide2 import QtWidgets import maya.standalone as maya_standalone import maya.mel as mel import maya.cmds as cmds except ImportError as e: raise try: from bookmarks.maya.widget import MayaBrowserButton import bookmarks.common as common import bookmarks.standalone as standalone import bookmarks.maya as maya except ImportError as e: raise app = standalone.StandaloneApp([]) maya_standalone.initialize(name='python') mel.eval('') # Let's initialize the plugin dependencies cmds.loadPlugin("AbcExport.mll", quiet=True) cmds.loadPlugin("AbcImport.mll", quiet=True) meshes = [] for n in xrange(10): s = cmds.polyCube(name=u'testMesh#') meshes.append(s[0]) cmds.sets(meshes, name=u'testMesh_geo_set') cmds.sets([], name=u'emptyTestMesh_geo_set') w = MayaBrowserButton()