Exemplo n.º 1
0
    def _executeBuildScript(self, scriptName):
        pd = self._flexData

        scriptsPath = FileUtils.createPath(pd.projectPath, 'compiler', 'scripts', isDir=True)
        if not os.path.exists(scriptsPath):
            return False

        typePath = FileUtils.createPath(scriptsPath, self._flexData.buildTypeFolderName, isDir=True)
        if not os.path.exists(typePath):
            return False

        platformPath = FileUtils.createPath(typePath, pd.currentPlatformID.lower(), isDir=True)
        if not os.path.exists(platformPath):
            return False

        targetPath = FileUtils.createPath(platformPath, scriptName, isFile=True)
        if not os.path.exists(targetPath):
            targetPath += '.py'
            if not os.path.exists(targetPath):
                return False

        self._log.write('Running post build script: ' + scriptName)
        f = open(targetPath, 'r')
        script = f.read()
        f.close()

        module = imp.new_module('postBuildScriptModule')
        setattr(module, '__file__', targetPath)
        setattr(module, 'logger', self._log)
        setattr(module, 'flexProjectData', self._flexData)
        exec script in module.__dict__
        self._log.write('Post build script execution complete')
Exemplo n.º 2
0
    def _getJDKPath(cls, *args, **kwargs):
        if cls._JDK_PATH is None:
            jdkPath   = None
            lastParts = [0, 0, 0, 0]
            for root in [cls._PROG_64_PATH, cls._PROG_PATH]:
                for p in os.listdir(FileUtils.createPath(root, 'java')):
                    if not p.lower().startswith('jdk'):
                        continue

                    parts = cls._NUM_FINDER.findall(p)
                    skip  = False
                    index = 0
                    while index < len(lastParts) and index < len(parts):
                        if parts[index] < lastParts[index]:
                            skip = True
                            break
                        index += 1

                    if not skip:
                        lastParts = parts
                        jdkPath   = FileUtils.createPath(cls._PROG_64_PATH, 'java', p)
            cls._JDK_PATH = jdkPath

        if cls._JDK_PATH is None:
            raise Exception, 'Unable to locate a Java Development Kit installation.'

        return FileUtils.createPath(cls._JDK_PATH, *args, **kwargs)
Exemplo n.º 3
0
    def locateMayaEnvFiles(cls):
        """ Finds the location of all Maya.env files located in the default location on the host
            and return them as a list. If no such env files exist, the method returns an empty
            list. """

        home = FileUtils.cleanupPath(OsUtils.getHomePath(), isDir=True)
        if not os.path.exists(home):
            return []

        if OsUtils.isWindows():
            root = FileUtils.createPath(OsUtils.getDocumentsPath(),
                                        'maya',
                                        isDir=True)
            if not os.path.exists(root):
                return []
        elif OsUtils.isMac():
            root = FileUtils.createPath(home,
                                        'Library',
                                        'Preferences',
                                        'Autodesk',
                                        'maya',
                                        isDir=True)
            if not os.path.exists(root):
                return []
        else:
            return []

        out = []
        FileUtils.walkPath(root, cls._handleFindEnvFiles, out)
        return out
Exemplo n.º 4
0
    def appleProvisioningProfile(self):
        if self._currentPlatformID != self.IOS_PLATFORM:
            return None

        certPaths = [
            FileUtils.createPath(
                self.platformProjectPath, 'cert', self.buildTypeFolderName, isDir=True),
            FileUtils.createPath(self.platformProjectPath, 'cert', isDir=True) ]

        if self.iosAdHoc:
            certPaths.insert(0, FileUtils.createPath(
                self.platformProjectPath, 'cert', 'adhoc', isDir=True))

        for certPath in certPaths:
            if not os.path.exists(certPath):
                continue

            filename = self.getSetting('PROVISIONING_PROFILE', None)
            if filename is None:
                for path in FileUtils.getFilesOnPath(certPath):
                    if path.endswith('.mobileprovision'):
                        return path
                continue

            filename = filename.replace('\\', '/').strip('/').split('/')
            path     = FileUtils.createPath(certPath, filename, isFile=True)
            if not os.path.exists(path) and os.path.exists(path + '.mobileprovision'):
                path += '.mobileprovision'

            if os.path.exists(path):
                return path

        return None
Exemplo n.º 5
0
    def _createMacDmg(self, binPath):
        print 'CREATING Mac DMG'
        target   = FileUtils.createPath(binPath, self.application.appID + '.dmg', isFile=True)
        tempTarget = FileUtils.createPath(binPath, 'pack.tmp.dmg', isFile=True)
        distPath = FileUtils.createPath(binPath, 'dist', isDir=True, noTail=True)

        if os.path.exists(tempTarget):
            SystemUtils.remove(tempTarget)

        cmd = ['hdiutil', 'create', '-size', '500m', '"%s"' % tempTarget, '-ov', '-volname',
            '"%s"' % self.appDisplayName, '-fs', 'HFS+', '-srcfolder', '"%s"' % distPath]

        result = SystemUtils.executeCommand(cmd, wait=True)
        if result['code']:
            print 'Failed Command Execution:'
            print result
            return False

        cmd = ['hdiutil', 'convert', "%s" % tempTarget, '-format', 'UDZO', '-imagekey',
               'zlib-level=9', '-o', "%s" % target]

        if os.path.exists(target):
            SystemUtils.remove(target)

        result = SystemUtils.executeCommand(cmd)
        if result['code']:
            print 'Failed Command Execution:'
            print result
            return False

        SystemUtils.remove(tempTarget)
        return True
Exemplo n.º 6
0
    def initializeEnvironment(cls, path):
        """ CREATE MISSING FILES AND FOLDERS
            Due to the limited file creation privileges while running NGinx as a normal user,
            certain files and folders must exist prior to starting the server.
        """

        for folderParts in cls._NGINX_FOLDERS:
            p = FileUtils.createPath(path, *folderParts, isDir=True)
            if not os.path.exists(p):
                os.makedirs(p)

        for fileParts in cls._NGINX_FILES:
            p = FileUtils.createPath(path, *fileParts, isFile=True)
            if not os.path.exists(p):
                f = open(p, 'w+')
                f.close()

        #-------------------------------------------------------------------------------------------
        # COPY CONF FILES
        #       NGinx requires a number of conf files to be present and comes with a default set of
        #       files, which must be cloned to the target location if they do not already exist.
        nginxExeConfFolder = FileUtils.createPath(NGinxSetupOps.getExePath(), 'conf', isDir=True)
        for item in os.listdir(nginxExeConfFolder):
            itemPath = FileUtils.createPath(nginxExeConfFolder, item)
            if not os.path.isfile(itemPath):
                continue
            targetPath = FileUtils.createPath(path, 'conf', item, isFile=True)
            if os.path.exists(targetPath):
                continue
            shutil.copy(itemPath, targetPath)
Exemplo n.º 7
0
    def certificate(self):
        """Returns the absolute path to the certificate file needed for packaging."""
        certPaths = [
            FileUtils.createPath(
                self.platformProjectPath, 'cert', self.buildTypeFolderName, isDir=True),
            FileUtils.createPath(self.platformProjectPath, 'cert', isDir=True) ]

        for certPath in certPaths:
            if not os.path.exists(certPath):
                continue

            certFileName = self.getSetting('CERTIFICATE')
            if certFileName is None:
                for path in FileUtils.getFilesOnPath(certPath):
                    if path.endswith('.p12'):
                        return path
                continue

            certFileName = certFileName.replace('\\', '/').strip('/').split('/')
            certPath     = FileUtils.createPath(certPath, certFileName, isFile=True)

            if not os.path.exists(certPath) and os.path.exists(certPath + '.p12'):
                certPath += '.p12'

            if os.path.exists(certPath):
                return certPath

        return None
Exemplo n.º 8
0
    def __init__(self):
        """Creates a new instance of PyGlassApplication."""
        QtCore.QObject.__init__(self)
        self._qApplication = None
        self._window       = None
        self._splashScreen = None

        # Sets a temporary standard out and error for deployed applications in a write allowed
        # location to prevent failed write results.
        if PyGlassEnvironment.isDeployed:
            if appdirs:
                userDir = appdirs.user_data_dir(self.appID, self.appGroupID)
            else:
                userDir = FileUtils.createPath(
                    os.path.expanduser('~'), '.pyglass', self.appGroupID, self.appID, isDir=True)

            path = FileUtils.createPath(
                userDir,
                self.appID + '_out.log', isFile=True)
            folder = FileUtils.getDirectoryOf(path, createIfMissing=True)
            sys.stdout = open(path, 'w+')

            FileUtils.createPath(
                appdirs.user_data_dir(self.appID, self.appGroupID),
                self.appID + '_error.log',
                isFile=True)
            folder = FileUtils.getDirectoryOf(path, createIfMissing=True)
            sys.stderr = open(path, 'w+')

        PyGlassEnvironment.initializeAppSettings(self)
Exemplo n.º 9
0
    def __init__(self, containerPath, isRemoteDeploy =False, sourceRootFolder ='src', **kwargs):
        """Creates a new instance of Site."""
        super(Site, self).__init__()

        self.errorCount     = 0
        self.warningCount   = 0
        self._staticPaths   = []

        self._logger = ArgsUtils.getLogger(self, kwargs)
        self._sourceRootFolderName = sourceRootFolder

        # NGinx root path in which all files reside
        self._containerPath = FileUtils.cleanupPath(containerPath, isDir=True)

        # Location of the source files used to create the website
        self._sourceWebRootPath = FileUtils.createPath(containerPath, sourceRootFolder, isDir=True)

        # Locations where files should be deployed. If the target root path is None, which is the
        # default value, the local web root path is used in its place.

        if isRemoteDeploy:
            self._targetWebRootPath = FileUtils.cleanupPath(
                tempfile.mkdtemp(prefix='staticFlow_'), isDir=True)
        else:
            self._targetWebRootPath = None

        self._localWebRootPath  = FileUtils.createPath(
            containerPath, ArgsUtils.get('localRootFolder', 'root', kwargs), isDir=True)

        path = FileUtils.createPath(self.sourceWebRootPath, '__site__.def', isFile=True)
        try:
            self._data.data = JSON.fromFile(path, throwError=True)
        except Exception, err:
            self.writeLogError(u'Unable to load site definition file: "%s"' % path, error=err)
            pass
Exemplo n.º 10
0
    def initializeEnvironment(cls, path):
        """ CREATE MISSING FILES AND FOLDERS
            Due to the limited file creation privileges while running NGinx as a normal user,
            certain files and folders must exist prior to starting the server.
        """

        for folderParts in cls._NGINX_FOLDERS:
            p = FileUtils.createPath(path, *folderParts, isDir=True)
            if not os.path.exists(p):
                os.makedirs(p)

        for fileParts in cls._NGINX_FILES:
            p = FileUtils.createPath(path, *fileParts, isFile=True)
            if not os.path.exists(p):
                f = open(p, 'w+')
                f.close()

        #-------------------------------------------------------------------------------------------
        # COPY CONF FILES
        #       NGinx requires a number of conf files to be present and comes with a default set of
        #       files, which must be cloned to the target location if they do not already exist.
        nginxExeConfFolder = FileUtils.createPath(NGinxSetupOps.getExePath(),
                                                  'conf',
                                                  isDir=True)
        for item in os.listdir(nginxExeConfFolder):
            itemPath = FileUtils.createPath(nginxExeConfFolder, item)
            if not os.path.isfile(itemPath):
                continue
            targetPath = FileUtils.createPath(path, 'conf', item, isFile=True)
            if os.path.exists(targetPath):
                continue
            shutil.copy(itemPath, targetPath)
Exemplo n.º 11
0
    def deployDebugNativeExtensions(cls, cmd, settings):
        from CompilerDeck.adobe.flex.FlexProjectData import FlexProjectData

        sets = settings
        if not sets.aneIncludes:
            return None

        debugPath = FileUtils.createPath(
            sets.projectPath, 'NativeExtensions', '__debug__', isDir=True, noTail=True)

        if os.path.exists(debugPath):
            SystemUtils.remove(debugPath)
        os.makedirs(debugPath)

        extensionIDs = []
        for ane in sets.aneIncludes:
            anePath = FileUtils.createPath(sets.projectPath, 'NativeExtensions', ane, isDir=True)
            aneSets = FlexProjectData(anePath)
            extensionIDs.append(aneSets.getSetting('ID'))
            aneFilename = aneSets.getSetting('FILENAME')

            aneFile = FileUtils.createPath(anePath, aneFilename + '.ane', isFile=True)
            z = zipfile.ZipFile(aneFile)
            z.extractall(FileUtils.createPath(debugPath, aneFilename + '.ane', isDir=True, noTail=True))

        AirUtils.updateAppExtensions(sets.appDescriptorPath, extensionIDs)

        cmd.extend(['-extdir', '"%s"' % debugPath])
        return debugPath
Exemplo n.º 12
0
 def platformProjectPath(self):
     """The root project path for the currently active platform."""
     pid = self._currentPlatformID
     if pid == self.ANDROID_PLATFORM:
         return FileUtils.createPath(self.projectPath, 'android', isDir=True)
     elif pid == self.IOS_PLATFORM:
         return FileUtils.createPath(self.projectPath, 'ios', isDir=True)
     return self.projectPath
Exemplo n.º 13
0
    def _compileUiFile(self, path, filename):
        """Doc..."""

        source = FileUtils.createPath(path, filename, isFile=True)
        if self._verbose:
            self._log.write('COMPILING: ' + source)

        if PyGlassEnvironment.isWindows:
            uicCommand = FileUtils.createPath(self._pythonPath, 'Scripts', 'pyside-uic.exe')
        else:
            uicCommand = 'pyside-uic'

        cmd = '%s %s' % (uicCommand, source)
        pipe = subprocess.Popen(
            cmd,
            shell=True,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        out, error = pipe.communicate()

        if pipe.returncode or error:
            self._log.write('ERROR: Failed to compile %s widget: %s' % (str(source), str(error)))
            return False

        res = WidgetUiCompiler._CLASS_NAME_RE.search(out)
        if not res:
            self._log.write('ERROR: Failed to find widget class name for ' + str(source))
            return False
        out = WidgetUiCompiler._CLASS_NAME_RE.sub('PySideUiFileSetup', out, 1)

        res = WidgetUiCompiler._SETUP_UI_RE.search(out)
        if not res:
            self._log.write('ERROR: Failed to find widget setupUi method for ' + str(source))
            return False
        targetName = res.groupdict().get('parentName')
        out = WidgetUiCompiler._SETUP_UI_RE.sub('\g<parentName>', out, 1)

        res = WidgetUiCompiler._RETRANSLATE_RE.search(out)
        if not res:
            self._log.write('ERROR: Failed to find widget retranslateUi method for ' + str(source))
            return False
        out = WidgetUiCompiler._RETRANSLATE_RE.sub('\g<parentName>', out, 1)

        if isinstance(out, unicode):
            out = out.encode('utf8', 'ignore')

        out = WidgetUiCompiler._SELF_RE.sub(targetName + '.', out)

        dest = FileUtils.createPath(path, filename[:-3] + '.py', isFile=True)
        if os.path.exists(dest):
            os.remove(dest)
        f = open(dest, 'w+')
        f.write(out)
        f.close()

        py_compile.compile(dest)
        return True
Exemplo n.º 14
0
    def _createIcon(self, binPath):
        iconPath = self._getIconPath()
        if not iconPath:
            return iconPath

        if os.path.isfile(iconPath):
            return iconPath

        #-------------------------------------------------------------------------------------------
        # MAC ICON CREATION
        #       On OSX use Apple's iconutil (XCode developer tools must be installed) to create an
        #       icns file from the icons.iconset folder at the specified location.
        if OsUtils.isMac():
            targetPath = FileUtils.createPath(binPath, self.appDisplayName + '.icns', isFile=True)
            result = SystemUtils.executeCommand([
                'iconutil', '-c', 'icns', '-o', '"' + targetPath + '"', '"' + iconPath + '"'])
            if result['code']:
                return ''
            return targetPath

        #-------------------------------------------------------------------------------------------
        # WINDOWS ICON CREATION
        #       On Windows use convert (ImageMagick must be installed and on the PATH) to create an
        #       ico file from the icons folder of png files.
        result = SystemUtils.executeCommand('where convert')
        if result['code']:
            return ''
        items = result['out'].replace('\r', '').strip().split('\n')
        convertCommand = None
        for item in items:
            if item.find('System32') == -1:
                convertCommand = item
                break
        if not convertCommand:
            return ''

        images = os.listdir(iconPath)
        cmd = ['"' + convertCommand + '"']
        for image in images:
            if not StringUtils.ends(image, ('.png', '.jpg')):
                continue
            imagePath = FileUtils.createPath(iconPath, image, isFile=True)
            cmd.append('"' + imagePath + '"')
        if len(cmd) < 2:
            return ''

        targetPath = FileUtils.createPath(binPath, self.appDisplayName + '.ico', isFile=True)
        cmd.append('"' + targetPath + '"')

        result = SystemUtils.executeCommand(cmd)
        if result['code'] or not os.path.exists(targetPath):
            print 'FAILED:'
            print result['command']
            print result['error']
            return ''

        return targetPath
Exemplo n.º 15
0
    def path(self):
        if self._common:
            return FileUtils.createPath(
                self._gui.appResourcePath,
                ApplicationConfig._APP_COMMON_CONFIG_FILENAME)

        return FileUtils.createPath(
            self._gui.localAppResourcePath,
            ApplicationConfig._APP_CONFIG_FILENAME)
Exemplo n.º 16
0
    def faviconUrl(self):
        path = FileUtils.createPath(self.sourceWebRootPath, 'favicon.png', isFile=True)
        if os.path.exists(path):
            return self.getSiteUrl('/favicon.png')

        path = FileUtils.createPath(self.sourceWebRootPath, 'favicon.ico', isFile=True)
        if os.path.exists(path):
            return self.getSiteUrl('/favicon.ico')
        return None
Exemplo n.º 17
0
    def run(self):
        """Doc..."""

        # Create the bin directory where the output will be stored if it does not already exist
        binPath = self.getBinPath(isDir=True)
        if not os.path.exists(binPath):
            os.makedirs(binPath)

        # Remove any folders created by previous build attempts
        for d in self._CLEANUP_FOLDERS:
            path = os.path.join(binPath, d)
            if os.path.exists(path):
                shutil.rmtree(path)

        os.chdir(binPath)

        ResourceCollector(self, verbose=True).run()

        cmd = [
            FileUtils.makeFilePath(sys.prefix, 'bin', 'python'),
            '"%s"' % self._createSetupFile(binPath),
            OsUtils.getPerOsValue('py2exe', 'py2app'), '>',
            '"%s"' % self.getBinPath('setup.log', isFile=True)]

        print('[COMPILING]: Executing %s' % OsUtils.getPerOsValue('py2exe', 'py2app'))
        print('[COMMAND]: %s' % ' '.join(cmd))
        result = SystemUtils.executeCommand(cmd, remote=False, wait=True)
        if result['code']:
            print('COMPILATION ERROR:')
            print(result['out'])
            print(result['error'])
            return False

        if self.appFilename and OsUtils.isWindows():
            name   = self.applicationClass.__name__
            source = FileUtils.createPath(binPath, 'dist', name + '.exe', isFile=True)
            dest   = FileUtils.createPath(binPath, 'dist', self.appFilename + '.exe', isFile=True)
            os.rename(source, dest)

        if OsUtils.isWindows() and not self._createWindowsInstaller(binPath):
            print('Installer Creation Failed')
            return False
        elif OsUtils.isMac() and not self._createMacDmg(binPath):
            print('DMG Creation Failed')
            return False

        # Remove the resources path once compilation is complete
        resourcePath = FileUtils.createPath(binPath, 'resources', isDir=True)
        SystemUtils.remove(resourcePath)

        buildPath = FileUtils.createPath(binPath, 'build', isDir=True)
        SystemUtils.remove(buildPath)

        FileUtils.openFolderInSystemDisplay(binPath)

        return True
Exemplo n.º 18
0
    def platformDistributionPath(self):
        ptype = self.buildTypeFolderName

        if self.isNative:
            platform = 'win' if OsUtils.isWindows() else 'mac'
            return FileUtils.createPath(
                self.platformProjectPath,
                'dist', 'native', platform, ptype, isDir=True)

        return FileUtils.createPath(self.platformProjectPath, 'dist', ptype, isDir=True)
Exemplo n.º 19
0
    def _cleanupInFolder(self, arg, dirname, names):
        for name in names:
            if StringUtils.ends(name, self._compiler.ignoreExtensions):
                os.remove(FileUtils.createPath(dirname, name, isFile=True))

                # Deletes python (.py) files associated with ui files so only .pyc files remain.
                if name.endswith('.ui'):
                    pyName     = name.rsplit('.', 1)[0] + '.py'
                    pyNamePath = FileUtils.createPath(dirname, pyName, isFile=True)
                    if os.path.exists(pyNamePath):
                        os.remove(pyNamePath)
Exemplo n.º 20
0
    def _htmlDefinitionWalker(self, args, path, names):
        # If a folder definition is found, use it to populate the directory with any missing
        # definition files before proceeding
        if '__folder__.def' in names:
            self._processFolderDefinitions(
                FileUtils.createPath(path, '__folder__.def', isFile=True))
            names = os.listdir(path)

        # For each definition file in the directory create page data for processing
        for name in names:
            if name.endswith('.def') and not name.startswith('__'):
                self._pages.create(FileUtils.createPath(path, name, isFile=True))
Exemplo n.º 21
0
    def __init__(self, parent, test =True, install =True, check =False, verbose =True, **kwargs):
        """Creates a new instance of MayaIniRemoteThread."""
        super(MayaIniRemoteThread, self).__init__(parent, **kwargs)
        self._test      = test
        self._verbose   = verbose
        self._install   = install
        self._check     = check
        self._output    = {}

        self._cadenceEntry = MayaEnvEntry.fromRootPath(FileUtils.createPath(
            FileUtils.getDirectoryOf(cadence.__file__), noTail=True))

        self._elixirEntry = MayaEnvEntry.fromRootPath(FileUtils.createPath(
            FileUtils.getDirectoryOf(elixir.__file__), noTail=True))
Exemplo n.º 22
0
    def _createLoaderJs(self):
        """Doc..."""
        result = SiteProcessUtils.compileCoffeescriptFile(
            FileUtils.createPath(
                StaticFlowEnvironment.rootResourcePath, '..', 'js', 'loader.coffee', isFile=True),
            FileUtils.createPath(
                StaticFlowEnvironment.rootResourcePath, 'web', 'js', isDir=True) )
        if result['code']:
            print 'ERROR: Failed to compile loader.coffee'
            print result
            return False

        print u'COMPILED: loader.js'
        return True
Exemplo n.º 23
0
    def run(self):
        """Doc..."""

        # Create the bin directory where the output will be stored if it does not alread exist
        binPath = self.getBinPath(isDir=True)
        if not os.path.exists(binPath):
            os.makedirs(binPath)

        # Remove any folders created by previous build attempts
        for d in self._CLEANUP_FOLDERS:
            path = os.path.join(binPath, d)
            if os.path.exists(path):
                shutil.rmtree(path)

        os.chdir(binPath)

        ResourceCollector(self, verbose=True).run()

        cmd = 'python %s %s > %s' % (
            self._createSetupFile(binPath),
            'py2exe' if OsUtils.isWindows() else 'py2app',
            self.getBinPath('setup.log', isFile=True) )

        result = SystemUtils.executeCommand(cmd, remote=False, wait=True)
        if result['code']:
            print 'COMPILATION ERROR:'
            print result['error']
            return False

        if self.appFilename and OsUtils.isWindows():
            name   = self.applicationClass.__name__
            source = FileUtils.createPath(binPath, 'dist', name + '.exe', isFile=True)
            dest   = FileUtils.createPath(binPath, 'dist', self.appFilename + '.exe', isFile=True)
            os.rename(source, dest)

        if OsUtils.isWindows() and not self._createWindowsInstaller(binPath):
            print 'Installer Creation Failed'
            return False
        elif OsUtils.isMac() and not self._createMacDmg(binPath):
            print 'DMG Creation Failed'
            return False

        # Remove the resources path once compilation is complete
        resourcePath = FileUtils.createPath(binPath, 'resources', isDir=True)
        SystemUtils.remove(resourcePath)

        buildPath = FileUtils.createPath(binPath, 'build', isDir=True)
        SystemUtils.remove(buildPath)

        return True
Exemplo n.º 24
0
 def getResourcePath(self, *args, **kwargs):
     """Doc..."""
     inApp = kwargs.get('inApp', False)
     if inApp:
         return self.getAppResourcePath('widget', self._resourceFolderParts, *args, **kwargs)
     return FileUtils.createPath(
         self.mainWindow.rootResourcePath, 'widget', self._resourceFolderParts, *args, **kwargs )
Exemplo n.º 25
0
    def addAIRNativeExtensionArguments(cls, cmd, settings):
        from CompilerDeck.adobe.flex.FlexProjectData import FlexProjectData

        sets = settings
        if not sets.aneIncludes:
            return

        extensionIDs = []
        for ane in sets.aneIncludes:
            anePath = FileUtils.createPath(sets.projectPath, 'NativeExtensions', ane, isDir=True)
            aneSets = FlexProjectData(anePath)
            cmd.extend(
                ['-extdir', '"%s"' % FileUtils.createPath(aneSets.projectPath, isDir=True, noTail=True)])
            extensionIDs.append(aneSets.getSetting('ID'))

        AirUtils.updateAppExtensions(sets.appDescriptorPath, extensionIDs)
Exemplo n.º 26
0
    def _copyResourceFolder(self, sourcePath, parts):
        targetPath = FileUtils.createPath(self._targetPath, *parts, isDir=True)
        WidgetUiCompiler(sourcePath).run()

        if self._verbose:
            self._log.write('COPYING: %s -> %s' % (sourcePath, targetPath))
        return FileUtils.mergeCopy(sourcePath, targetPath)
Exemplo n.º 27
0
    def getJavaAntPath(self, *args, **kwargs):
        """Doc..."""
        res = self.appConfig.get(self._JAVA_ANT_PATH)
        if not res:
            return ''

        return FileUtils.createPath(res, *args, **kwargs)
Exemplo n.º 28
0
    def getFlexSDKPath(self, *args, **kwargs):
        """Doc..."""
        res = self.appConfig.get(self._FLEX_SDK_PATH)
        if not res:
            return ''

        return FileUtils.createPath(res, *args, **kwargs)
Exemplo n.º 29
0
    def getRootAIRPath(self, *args, **kwargs):
        """Doc..."""
        res = self.appConfig.get(self._AIR_ROOT_PATH)
        if not res:
            return ''

        return FileUtils.createPath(res, *args, **kwargs)
Exemplo n.º 30
0
    def compileCoffeescriptFile(cls, source, destFolder, minify =True):
        iniDirectory = os.curdir
        os.chdir(os.path.dirname(source))

        cmd = cls.modifyNodeCommand([
            StaticFlowEnvironment.getNodeCommandAbsPath('coffee'),
            '--output', '"%s"' % FileUtils.stripTail(destFolder),
            '--compile', '"%s"' % source ])

        result = SystemUtils.executeCommand(cmd)
        if not minify or result['code']:
            os.chdir(iniDirectory)
            return result

        name = os.path.splitext(os.path.basename(source))[0] + '.js'
        dest = FileUtils.createPath(destFolder, name, isFile=True)

        tempOutPath = dest + '.tmp'
        shutil.move(dest, tempOutPath)

        cmd = cls.modifyNodeCommand([
            StaticFlowEnvironment.getNodeCommandAbsPath('uglifyjs'),
            '"%s"' % tempOutPath,
            '>',
            '"%s"' % dest ])

        result = SystemUtils.executeCommand(cmd)
        os.remove(tempOutPath)
        os.chdir(iniDirectory)
        return result
Exemplo n.º 31
0
 def _compileWalker(self, args, path, names):
     for name in names:
         namePath = FileUtils.createPath(path, name, isFile=True)
         if name.endswith('.coffee'):
             SiteProcessUtils.compileCoffeescript(self, namePath)
         elif name.endswith('.css'):
             SiteProcessUtils.compileCss(self, namePath)
Exemplo n.º 32
0
    def _copyWalker(self, walkData):
        staticFolder = False
        for folder in self._staticPaths:
            path = FileUtils.cleanupPath(walkData.folder, isDir=True)
            folder = FileUtils.cleanupPath(folder, isDir=True)
            if path == folder or FileUtils.isInFolder(path, folder):
                staticFolder = True
                break

        copiedNames = []
        for item in walkData.names:
            if not staticFolder and not StringUtils.ends(item, self._FILE_COPY_TYPES):
                continue

            sourcePath = FileUtils.createPath(walkData.folder, item)
            if os.path.isdir(sourcePath):
                continue

            destPath = FileUtils.changePathRoot(
                sourcePath, self.sourceWebRootPath, self.targetWebRootPath)

            try:
                FileUtils.getDirectoryOf(destPath, createIfMissing=True)
                shutil.copy(sourcePath, destPath)

                lastModified = FileUtils.getUTCModifiedDatetime(sourcePath)
                SiteProcessUtils.createHeaderFile(destPath, lastModified)
                SiteProcessUtils.copyToCdnFolder(destPath, self, lastModified)
                copiedNames.append(item)
            except Exception, err:
                self.writeLogError(u'Unable to copy file', error=err, extras={
                    'SOURCE':sourcePath,
                    'TARGET':destPath })
                return
Exemplo n.º 33
0
    def _getSourcePaths(cls, otherPaths=None):
        nimbleEntry = MayaEnvEntry.fromRootPath(
            FileUtils.createPath(FileUtils.getDirectoryOf(nimble.__file__),
                                 noTail=True))

        pyaidEntry = MayaEnvEntry.fromRootPath(
            FileUtils.createPath(FileUtils.getDirectoryOf(pyaid.__file__),
                                 noTail=True))

        pyglassEntry = MayaEnvEntry.fromRootPath(
            FileUtils.createPath(FileUtils.getDirectoryOf(pyglass.__file__),
                                 noTail=True))

        additions = [nimbleEntry, pyaidEntry, pyglassEntry]

        if not otherPaths:
            return additions

        for p in otherPaths:
            additions.append(p if isinstance(p, MayaEnvEntry) else MayaEnvEntry
                             .fromRootPath(p))

        return additions
Exemplo n.º 34
0
    def loggingPath(self, value):
        self._logPath = FileUtils.cleanupPath(value)

        logFolder = self.getLogFolder()
        if logFolder:
            name = self._name
            extension = self.logFileExtension
            if self.timestampFileSuffix:
                name += '_' + self._timeCode
            self._logFile = FileUtils.createPath(logFolder,
                                                 name + '.' + extension)
            if self.removeIfExists:
                self.resetLogFile()
        else:
            self._logFile = None
Exemplo n.º 35
0
cmds.move(offset, offset, offset, name)
cmds.rotate(50, 20, 10, name)
cmds.scale(2, 2, 2, name)

response = nimble.createRemoteResponse(globals())
response.put('name', name)
response.put('offset', offset)
"""

#---------------------------------------------------------------------------------------------------
print('RUNNING SCRIPT:')
conn = nimble.getConnection()
result = conn.runPythonScript(script, offset=20)

print('\tRESULT:', result, type(result))
print('\tPAYLOAD:', result.payload)

#---------------------------------------------------------------------------------------------------
print('RUNNING FILE:')
result = conn.runPythonScriptFile(FileUtils.createPath(os.path.abspath(
    os.path.dirname(__file__)),
                                                       'pythonTestScript.py',
                                                       isFile=True),
                                  offset=5)

print('\tRESULT:', result, type(result))
print('\tPAYLOAD:', result.payload)

print('Operation Complete')
Exemplo n.º 36
0
 def _handleFindEnvFiles(cls, walkData):
     for name in walkData.names:
         if name == 'Maya.env':
             walkData.data.append(
                 FileUtils.createPath(walkData.folder, name))
Exemplo n.º 37
0
# helloPythonImport.py
# (C)2014
# Scott Ernst
""" This example shows how to use the advanced import scripting in Nimble. """

from __future__ import print_function, absolute_import, unicode_literals, division

import sys

from pyaid.file.FileUtils import FileUtils

import nimble

# Add the src path for this example to the python system path for access to the scripts
scriptPath = FileUtils.createPath(FileUtils.getDirectoryOf(__file__),
                                  'src',
                                  isDir=True)
sys.path.append(scriptPath)

from helloPythonImportExample.scripts import CreateSpheres

# Create a Nimble connection object. This object will be used to send and receive across the
# nimble communication bridge between this script and the Nimble server running in Maya
conn = nimble.getConnection()

# Add the script src path to the Maya Python environment as well so that it can import and run
# the scripts directly
result = conn.addToMayaPythonPath(scriptPath)
if not result.success:
    print(
        'Unable to modify Maya Python path. Are you sure Maya is running a Nimble server?'
Exemplo n.º 38
0
# Check for PySide system dynamic libraries
paths = []
for p in os.listdir(u'/usr/lib'):
    if p.endswith(u'.dylib') and p.startswith(u'libpyside-'):
        paths.append(p)

printResult(u'PySide (Dynamic Libraries)', u'PASSED' if paths else u'FAILED')
for p in paths:
    print u'\t', p
result = SystemUtils.executeCommand('find /usr -name "libpyside-*.dylib"')
print result['out']

# Check for PySide site package shared libraries
foundLocation = None
for p in sys.path:
    p = FileUtils.createPath(p, u'PySide', isDir=True)
    if not os.path.exists(p):
        continue
    if os.path.exists(FileUtils.createPath(p, u'QtCore.so', isFile=True)):
        foundLocation = p
        break

printResult(u'PySide (Package Libraries)',
            u'PASSED' if foundLocation else u'FAILED')
if foundLocation:
    print u'\t', foundLocation

# Check for PySide
try:
    from PySide import QtCore
    printResult(u'PySide', u'PASSED')
Exemplo n.º 39
0
 def rootPath(self):
     return FileUtils.createPath(self.folderPath,
                                 self.rootName,
                                 noTail=True)
Exemplo n.º 40
0
    def modifyEnvFile(cls, target, install=True, test=False, otherPaths=None):
        """Doc..."""
        pathSep = OsUtils.getPerOsValue(';', ':')
        removals = []
        entries = cls._getSourcePaths(otherPaths=otherPaths)
        additions = entries + []

        with open(target, 'r') as f:
            contents = f.read().strip()

        result = cls._PYTHON_PATH_PATTERN.search(contents)
        if not result:
            if install and not test:
                with open(target, 'w') as f:
                    f.write((contents + '\n' if contents else '') +
                            'PYTHONPATH=' + cls._joinPathEntries(additions))
            return cls.MAYA_ENV_MODIFIED_RESULT_NT(
                additions if install else [], removals)

        paths = result.groupdict()['paths'].strip()
        paths = paths.split(pathSep) if paths else []
        if not paths and not install:
            return cls.MAYA_ENV_MODIFIED_RESULT_NT([], [])

        index = 0
        while index < len(paths):
            # Stop if no more additions remain
            if not additions:
                break

            p = FileUtils.cleanupPath(paths[index], noTail=True)

            # If path already exists don't add it again
            pathMatch = cls._hasPath(p, additions)
            if pathMatch:
                additions.remove(pathMatch)

                # If uninstalling add to removals
                if not install:
                    removals.append(pathMatch)
                    paths.remove(p)
                else:
                    index += 1
                continue
            elif not install:
                index += 1
                continue

            for entry in entries:
                testPath = FileUtils.createPath(p, entry.rootName, noTail=True)
                if os.path.exists(testPath):
                    paths.remove(p)

            index += 1

        for entry in additions:
            paths.append(entry.folderPath)

        insertion = ('PYTHONPATH=' + pathSep.join(paths) +
                     '\n') if paths else ''
        contents = contents[:result.start()] + insertion + contents[result.end(
        ):]

        result = cls.MAYA_ENV_MODIFIED_RESULT_NT(additions if install else [],
                                                 removals)
        if test:
            return result

        with open(target, 'w') as f:
            f.write(contents)

        return result