Пример #1
0
 def getUserHomePath(self, subpath=""):
     """Returns unicode-encoded absolute path to the location of the user's makehuman directory (i.e normally ~/makehuman)."""
     self.trace()
     if subpath == "":
         return self.getUnicodeAbsPath(getpath.getHomePath())
     else:
         return self.getUnicodeAbsPath(getpath.getPath(subpath))
Пример #2
0
    def reset(self):
        self.open()

        mhv = MHVersion()

        self.write("VERSION: %s", os.environ['MH_VERSION'])
        self.write("SHORT VERSION: %s", os.environ['MH_SHORT_VERSION'])
        self.write("LONG VERSION: %s", mhv.getFullVersionStr())
        self.write("BASEMESH VERSION: %s", os.environ['MH_MESH_VERSION'])
        self.write("IS BUILT (FROZEN): %s", os.environ['MH_FROZEN'])
        self.write("IS RELEASE VERSION: %s", os.environ['MH_RELEASE'])
        self.write("DEFAULT ENCODING: %s", sys.getdefaultencoding())
        self.write("FILESYSTEM ENCODING: %s", sys.getfilesystemencoding())
        self.write("STDOUT ENCODING: %s", sys.stdout.encoding)
        self.write("LOCALE PREFERRED ENCODING: %s",
                   locale.getpreferredencoding(False))
        self.write("WORKING DIRECTORY: %s", getpath.pathToUnicode(os.getcwd()))
        self.write("HOME LOCATION: %s",
                   getpath.pathToUnicode(getpath.getHomePath()))
        syspath = os.path.pathsep.join(
            [getpath.pathToUnicode(p) for p in sys.path])
        self.write("PYTHON PATH: %s", syspath)
        self.write("DLL PATH: %s", getpath.pathToUnicode(os.environ['PATH']))
        version = re.sub(r"[\r\n]", " ", sys.version)
        self.write("SYS.VERSION: %s", version)
        self.write("SYS.PLATFORM: %s", sys.platform)
        self.write("SYS.EXECUTABLE: %s", sys.executable)
        self.write("PLATFORM.MACHINE: %s", platform.machine())
        self.write("PLATFORM.PROCESSOR: %s", platform.processor())
        self.write("PLATFORM.UNAME.RELEASE: %s", platform.uname()[2])

        if sys.platform.startswith('linux'):
            try:
                self.write("PLATFORM.LINUX_DISTRIBUTION: %s",
                           ' '.join(platform.linux_distribution()))
            except AttributeError:
                try:
                    import distro
                    self.write("PLATFORM.LINUX_DISTRIBUTION: %s",
                               ' '.join(distro.linux_distribution()))
                except ImportError:
                    self.write("PLATFORM.LINUX_DISTRIBUTION: %s", 'Unknown')

        if sys.platform.startswith('darwin'):
            self.write("PLATFORM.MAC_VER: %s", platform.mac_ver()[0])

        if sys.platform.startswith('win'):
            self.write("PLATFORM.WIN32_VER: %s",
                       " ".join(platform.win32_ver()))

        import numpy
        self.write("NUMPY.VERSION: %s", numpy.__version__)
        numpyVer = numpy.__version__.split('.')
        if int(numpyVer[0]) <= 1 and int(numpyVer[1]) < 6:
            raise DependencyError(
                'MakeHuman requires at least numpy version 1.6')

        self.close()
Пример #3
0
    def reset(self):
        self.open()

        self.write("VERSION: %s", os.environ['MH_VERSION'])
        if 'HGREVISION' in os.environ and 'HGREVISION_SOURCE' in os.environ:
            self.write("HG REVISION: r%s (%s) [%s]", os.environ['HGREVISION'],
                       os.environ['HGNODEID'], os.environ['HGREVISION_SOURCE'])
        else:
            self.write("HG REVISION: UNKNOWN")
        if 'HGBRANCH' in os.environ:
            self.write("HG BRANCH: %s", os.environ['HGBRANCH'])
        self.write("SHORT VERSION: %s", os.environ['MH_SHORT_VERSION'])
        self.write("BASEMESH VERSION: %s", os.environ['MH_MESH_VERSION'])
        self.write("IS BUILT (FROZEN): %s", os.environ['MH_FROZEN'])
        self.write("IS RELEASE VERSION: %s", os.environ['MH_RELEASE'])
        self.write("DEFAULT ENCODING: %s", sys.getdefaultencoding())
        self.write("FILESYSTEM ENCODING: %s", sys.getfilesystemencoding())
        self.write("STDOUT ENCODING: %s", sys.stdout.encoding)
        self.write("WORKING DIRECTORY: %s", getpath.pathToUnicode(os.getcwd()))
        self.write("HOME LOCATION: %s",
                   getpath.pathToUnicode(getpath.getHomePath()))
        syspath = os.path.pathsep.join(
            [getpath.pathToUnicode(p) for p in sys.path])
        self.write("PYTHON PATH: %s", syspath)
        self.write("DLL PATH: %s", getpath.pathToUnicode(os.environ['PATH']))
        version = re.sub(r"[\r\n]", " ", sys.version)
        self.write("SYS.VERSION: %s", version)
        self.write("SYS.PLATFORM: %s", sys.platform)
        self.write("SYS.EXECUTABLE: %s", sys.executable)
        self.write("PLATFORM.MACHINE: %s", platform.machine())
        self.write("PLATFORM.PROCESSOR: %s", platform.processor())
        self.write("PLATFORM.UNAME.RELEASE: %s", platform.uname()[2])

        if sys.platform.startswith('linux'):
            self.write("PLATFORM.LINUX_DISTRIBUTION: %s",
                       ' '.join(platform.linux_distribution()))

        if sys.platform.startswith('darwin'):
            self.write("PLATFORM.MAC_VER: %s", platform.mac_ver()[0])

        if sys.platform.startswith('win'):
            self.write("PLATFORM.WIN32_VER: %s",
                       " ".join(platform.win32_ver()))

        import numpy
        self.write("NUMPY.VERSION: %s", numpy.__version__)
        numpyVer = numpy.__version__.split('.')
        if int(numpyVer[0]) <= 1 and int(numpyVer[1]) < 6:
            raise DependencyError(
                'MakeHuman requires at least numpy version 1.6')

        self.close()
Пример #4
0
 def onClicked(event):
     if hasConfigFile():
         os.remove(getConfigPath('makehuman.conf'))
         self.homeButton.setLabel('Create Config File')
         gui3d.app.statusPersist('Home Folder Location: Default')
     else:
         filePath = getConfigPath('makehuman.conf')
         homePath = formatPath(getExistingDirectory(getHomePath()))
         if homePath != '.':
             if sys.platform.startswith('darwin') or sys.platform.startswith('linux') and not os.path.isdir(getConfigPath('')):
                 os.makedirs(getConfigPath(''))
             if os.path.isdir(homePath) and os.path.isdir(getConfigPath('')):
                 with io.open(filePath, 'w', encoding='utf-8') as f:
                     f.writelines(homePath + '\n')
             self.homeButton.setLabel('Delete Config File')
             gui3d.app.statusPersist('Home Folder Location: ' + homePath)
Пример #5
0
    def __init__(self, category):

        info_msg = "Install new plugins by either copying to the user plugins folder or using the built in installer.\n"\
                   "The installer only handles Python script files and plugin packages in plain zip file format."\
                   "\n\nTo activate a plugin it must be checked in the list. Then click the \"Activate\"-Button or " \
                   "restart MakeHuman.\nTo deactivate a plugin uncheck it in the list and restart MakeHuman."

        gui3d.TaskView.__init__(self, category, 'User Plugins')

        self.userPlugins = getUserPlugins()
        activePlugins = gui3d.app.getSetting('activeUserPlugins')

        for plugin in activePlugins:
            if plugin not in [k for k, _ in self.userPlugins]:
                activePlugins.remove(plugin)

        gui3d.app.setSetting('activeUserPlugins', activePlugins)
        gui3d.app.saveSettings()

        self.home = getpath.getHomePath()

        scroll = self.addTopWidget(gui.VScrollArea())
        self.userPluginBox = gui.GroupBox('User Plugins')
        self.userPluginBox.setSizePolicy(gui.SizePolicy.MinimumExpanding,
                                         gui.SizePolicy.Preferred)
        scroll.setWidget(self.userPluginBox)

        self.updatePluginList()

        installWidget = gui.QtWidgets.QWidget()
        installWidgetLayout = gui.QtWidgets.QVBoxLayout()
        installWidget.setLayout(installWidgetLayout)
        self.addLeftWidget(installWidget)

        installBox = gui.GroupBox('')
        self.installPyButton = gui.Button('Install Plugin File')
        installBox.addWidget(self.installPyButton)
        self.installZipButton = gui.Button('Install Zipped Plugin')
        installBox.addWidget(self.installZipButton)
        installWidgetLayout.addWidget(installBox)

        actionsBox = gui.GroupBox('')
        self.reloadButton = gui.Button('Reload Plugins Folder')
        actionsBox.addWidget(self.reloadButton)
        self.activateButton = gui.Button('Activate Plugins')
        actionsBox.addWidget(self.activateButton)
        installWidgetLayout.addWidget(actionsBox)

        infoBox = gui.GroupBox('Info')
        infoText = gui.TextView(info_msg)
        infoText.setWordWrap(True)
        infoText.setSizePolicy(gui.SizePolicy.Ignored,
                               gui.SizePolicy.MinimumExpanding)
        infoBox.addWidget(infoText)
        installWidgetLayout.addWidget(infoBox)
        installWidgetLayout.addStretch(1)

        @self.installZipButton.mhEvent
        def onClicked(event):

            filename = getpath.pathToUnicode(
                gui.QtWidgets.QFileDialog.getOpenFileName(
                    gui3d.app.mainwin,
                    directory=self.home,
                    filter='Zip files ( *.zip );; All files ( *.* )')[0])

            dest_path = getpath.getPath('plugins')
            if os.path.isfile(filename):
                result = decompress(filename, dest_path)
                if result == 0:
                    self.updatePluginList()
                    gui3d.app.prompt(
                        'Info',
                        'The plugin copied successfully. To activate, check '
                        'the plugin in the list and press the "Activate"-Button or restart MakeHuman.',
                        'OK',
                        helpId='installPluginHelp')
                elif result == 3:
                    gui3d.app.prompt(
                        'Warning',
                        'Potentially dangerous zip file, containing files with unsuitable path. '
                        'Inspect/fix the zip file before usage!', 'OK')
                elif result == 4:
                    gui3d.app.prompt(
                        'Error',
                        'Zip file {0:s} contains exiting files.'.format(
                            filename), 'OK')
                elif result == 1:
                    gui3d.app.prompt('Error',
                                     'Not a zip file {0:s}'.format(filename),
                                     'OK')
            self.home = os.path.dirname(filename)

        @self.installPyButton.mhEvent
        def onClicked(event):
            filename = getpath.pathToUnicode(
                gui.QtWidgets.QFileDialog.getOpenFileName(
                    gui3d.app.mainwin,
                    directory=self.home,
                    filter='Python files ( *.py );; All files ( *.* )')[0])
            if os.path.isfile(filename) and os.path.splitext(
                    filename)[1] == '.py':
                try:
                    shutil.copy2(filename, getpath.getPath('plugins'))
                except OSError as e:
                    gui3d.app.prompt(
                        'Error',
                        'Failed to copy {0:s} to user plugins folder'.format(
                            filename), 'OK')
                self.updatePluginList()
                gui3d.app.prompt(
                    'Info',
                    'The plugin copied successfully. To activate, check '
                    'the plugin in the list and press the "Activate"-Button or restart MakeHuman.',
                    'OK',
                    helpId='installPluginHelp')
            self.home = os.path.dirname(filename)

        @self.reloadButton.mhEvent
        def onClicked(event):
            self.updatePluginList()

        @self.activateButton.mhEvent
        def onClicked(event):
            for child in self.userPluginBox.children:
                if child.selected:
                    if not child.module in gui3d.app.modules:
                        if not gui3d.app.loadPlugin(name=child.module,
                                                    location=child.path):
                            gui3d.app.prompt(
                                'Error',
                                'Cannot load module {0:s}\nCheck the log files'
                                .format(child.module), 'OK')
                    else:
                        log.message(
                            'Module %s already exists and will not be imported a second time.',
                            child.module)
Пример #6
0
 def onShow(self, event):
     gui3d.TaskView.onShow(self, event)
     gui3d.app.statusPersist('Home Folder Location: ' + getHomePath())
Пример #7
0
 def getUserHomePath(self,subpath = ""):
     """Returns the location of the user's makehuman directory (i.e normally ~/makehuman)."""
     self.trace()
     return getpath.getHomePath(subpath)