当前位置: 首页>>代码示例>>Python>>正文


Python FileUtils.FileUtils类代码示例

本文整理汇总了Python中pyaid.file.FileUtils.FileUtils的典型用法代码示例。如果您正苦于以下问题:Python FileUtils类的具体用法?Python FileUtils怎么用?Python FileUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FileUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save

    def save(self, toPDF=True):
        """ Writes the current _drawing in SVG format to the file specified at initialization. If
            one wishes to have create a PDF file (same file name as used for the .SVG, but with
            suffix .PDF), then call with toPDF True). """

        if not self.siteMapReady:
            return

        # Make sure the directory where the file will be saved exists before saving
        FileUtils.getDirectoryOf(self._drawing.filename, createIfMissing=True)

        self._drawing.save()

        #  we're done if no PDF version is also required
        if not toPDF:
            return

        # strip any extension off of the file name
        basicName = self.fileName.split(".")[0]

        # load up the command
        cmd = ["/Applications/Inkscape.app/Contents/Resources/bin/inkscape", "-f", None, "-A", None]
        cmd[2] = basicName + ".svg"
        cmd[4] = basicName + ".pdf"

        # and execute it
        response = SystemUtils.executeCommand(cmd)
        if response["error"]:
            print("response[error]=%s" % response["error"])
开发者ID:sernst,项目名称:Cadence,代码行数:29,代码来源:CadenceDrawing.py

示例2: deployDebugNativeExtensions

    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
开发者ID:sernst,项目名称:CompilerDeck,代码行数:29,代码来源:AirUtils.py

示例3: appleProvisioningProfile

    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
开发者ID:sernst,项目名称:CompilerDeck,代码行数:33,代码来源:FlexProjectData.py

示例4: _createMacDmg

    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
开发者ID:hannahp,项目名称:PyGlass,代码行数:32,代码来源:PyGlassApplicationCompiler.py

示例5: _copyV4SupportLib

 def _copyV4SupportLib(self):
     v4Path = self._owner.mainWindow.getAndroidSDKPath(*AndroidCompiler._V4_SUPPORT_LIB, isDir=True)
     for item in os.listdir(v4Path):
         itemPath = FileUtils.createPath(v4Path, item, isDir=True)
         self._copyMerges.append(
             FileUtils.mergeCopy(itemPath, self.getTargetPath('android', 'src'), False)
         )
开发者ID:sernst,项目名称:CompilerDeck,代码行数:7,代码来源:AndroidCompiler.py

示例6: certificate

    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
开发者ID:sernst,项目名称:CompilerDeck,代码行数:28,代码来源:FlexProjectData.py

示例7: _executeBuildScript

    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')
开发者ID:sernst,项目名称:CompilerDeck,代码行数:32,代码来源:ANECompileThread.py

示例8: path

 def path(self):
     if not self._path:
         return None
     if not StringUtils.ends(self._path, '.csv'):
         if not FileUtils.getFileExtension(self._path):
             self._path += '.csv'
     return FileUtils.cleanupPath(self._path, isFile=True)
开发者ID:sernst,项目名称:Cadence,代码行数:7,代码来源:CsvWriter.py

示例9: __init__

    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
开发者ID:sernst,项目名称:StaticFlow,代码行数:35,代码来源:Site.py

示例10: _deployResources

    def _deployResources(cls):
        """ On windows the resource folder data is stored within the application install directory.
            However, due to permissions issues, certain file types cannot be accessed from that
            directory without causing the program to crash. Therefore, the stored resources must
            be expanded into the user's AppData/Local folder. The method checks the currently
            deployed resources folder and deploys the stored resources if the existing resources
            either don't exist or don't match the currently installed version of the program. """

        if not OsUtils.isWindows() or not PyGlassEnvironment.isDeployed:
            return False

        storagePath       = PyGlassEnvironment.getInstallationPath('resource_storage', isDir=True)
        storageStampPath  = FileUtils.makeFilePath(storagePath, 'install.stamp')
        resourcePath      = PyGlassEnvironment.getRootResourcePath(isDir=True)
        resourceStampPath = FileUtils.makeFilePath(resourcePath, 'install.stamp')

        try:
            resousrceData = JSON.fromFile(resourceStampPath)
            storageData   = JSON.fromFile(storageStampPath)
            if resousrceData['CTS'] == storageData['CTS']:
                return False
        except Exception as err:
            pass

        SystemUtils.remove(resourcePath)
        FileUtils.mergeCopy(storagePath, resourcePath)
        return True
开发者ID:sernst,项目名称:PyGlass,代码行数:27,代码来源:PyGlassApplication.py

示例11: compileAllOnPath

    def compileAllOnPath(path, rootPath=None, recursive=False, debug=False, trace=False, force=False, compress=False):

        CoffeescriptBuilder._results = ""
        CoffeescriptBuilder._missing = {}
        if recursive:
            print("RECURSIVE COMPILE AT: " + path)

            def walker(paths, dirName, names):
                out = CoffeescriptBuilder._compileAllInDirectory(
                    os.path.join(paths[0], dirName), paths[1], debug=debug, trace=trace, force=force, compress=compress
                )
                CoffeescriptBuilder._results += out["res"]
                for n, v in DictUtils.iter(out["missing"]):
                    if n in CoffeescriptBuilder._missing:
                        continue
                    CoffeescriptBuilder._missing[n] = v

            FileUtils.walkPath(path, walker, [path, rootPath])
            print("\n\nCOMPILATION RESULTS:" + CoffeescriptBuilder._results)

            if CoffeescriptBuilder._missing:
                print("\n\nMISSING IMPORTS:" + "\n\n")
                for n, v in DictUtils.iter(CoffeescriptBuilder._missing):
                    print(v["class"] + " [LINE: #" + str(v["line"]) + " | " + v["package"] + "]")
        else:
            print("COMPILING DIRECTORY: " + path)
            CoffeescriptBuilder._compileAllInDirectory(
                path, rootPath, debug=debug, trace=trace, force=force, compress=compress
            )
开发者ID:sernst,项目名称:PyAid,代码行数:29,代码来源:CoffeescriptBuilder.py

示例12: compileCoffeescriptFile

    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
开发者ID:sernst,项目名称:StaticFlow,代码行数:30,代码来源:SiteProcessUtils.py

示例13: _copyResourceFolder

    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)
开发者ID:sernst,项目名称:PyGlass,代码行数:7,代码来源:ResourceCollector.py

示例14: _getJDKPath

    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)
开发者ID:sernst,项目名称:CompilerDeck,代码行数:27,代码来源:CompilerDeckMainWindow.py

示例15: initializeEnvironment

    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)
开发者ID:sernst,项目名称:NGinxWinManager,代码行数:30,代码来源:NGinxRunOps.py


注:本文中的pyaid.file.FileUtils.FileUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。