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


Python FileUtils.makeFilePath方法代码示例

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


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

示例1: _deployResources

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
    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,代码行数:29,代码来源:PyGlassApplication.py

示例2: run

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
    def run(self):
        """Doc..."""
        resources = self._compiler.resources

        #-------------------------------------------------------------------------------------------
        # RESOURCES
        #       If no resource folders were specified copy the entire contents of the resources
        #       folder. Make sure to skip the local resources path in the process.
        if not resources:
            for item in os.listdir(PyGlassEnvironment.getRootResourcePath(isDir=True)):
                itemPath = PyGlassEnvironment.getRootResourcePath(item)
                if os.path.isdir(itemPath) and not item in ['local', 'apps']:
                    resources.append(item)

        for container in resources:
            parts = container.replace('\\', '/').split('/')
            self._copyResourceFolder(
                PyGlassEnvironment.getRootResourcePath(*parts, isDir=True), parts)

        #-------------------------------------------------------------------------------------------
        # APP RESOURCES
        appResources = self._compiler.resourceAppIds
        if not appResources:
            appResources = []
        for appResource in appResources:
            itemPath = PyGlassEnvironment.getRootResourcePath('apps', appResource, isDir=True)
            if not os.path.exists(itemPath):
                self._log.write('[WARNING]: No such app resource path found: %s' % appResource)
                continue
            self._copyResourceFolder(itemPath, ['apps', appResource])

        #-------------------------------------------------------------------------------------------
        # PYGLASS RESOURCES
        #       Copy the resources from the PyGlass
        resources = []
        for item in os.listdir(PyGlassEnvironment.getPyGlassResourcePath('..', isDir=True)):
            itemPath = PyGlassEnvironment.getPyGlassResourcePath('..', item)
            if os.path.isdir(itemPath):
                resources.append(item)

        for container in resources:
            self._copyResourceFolder(
                PyGlassEnvironment.getPyGlassResourcePath('..', container), [container])

        # Create a stamp file in resources for comparing on future installations
        creationStampFile = FileUtils.makeFilePath(self._targetPath, 'install.stamp')
        JSON.toFile(creationStampFile, {'CTS':TimeUtils.toZuluPreciseTimestamp()})

        #-------------------------------------------------------------------------------------------
        # CLEANUP
        if self._verbose:
            self._log.write('CLEANUP: Removing unwanted destination files.')
        self._cleanupFiles(self._targetPath)

        self._copyPythonStaticResources()

        if self._verbose:
            self._log.write('COMPLETE: Resource Collection')

        return True
开发者ID:sernst,项目名称:PyGlass,代码行数:62,代码来源:ResourceCollector.py

示例3: getTempFilePath

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
    def getTempFilePath(self, name =None, extension =None, *args):
        """ Used to create a temporary file path within this instance's temporary folder.
            Any file on this path will be automatically removed at the end of the analysis
            process.

            [name] :: String :: None
                The desired file name for the desired file within the temporary directory. If no
                name is specified, a name will be created automatically using the current time
                (microsecond) and a 16 digit random code for a very low probability of collisions.

            [extension] :: String :: None
                Specifies the extension to add to this file. The file name is not altered if no
                extension is specified.

            [*args] :: [String] :: []
                A list of relative folder prefixes in which the file should reside. For example,
                if you wish to have a file 'bar' in a folder 'foo' then you would specify 'foo' as
                the single arg to get a file located at 'foo/bar' within the temporary file. No
                directory prefixes will be created within this method. """

        if not name:
            name = TimeUtils.getUidTimecode(suffix=StringUtils.getRandomString(16))
        if extension:
            extension = '.' + extension.strip('.')
            if not name.endswith(extension):
                name += extension

        args = list(args) + [name]
        return FileUtils.makeFilePath(self.tempPath, *args)
开发者ID:sernst,项目名称:Cadence,代码行数:31,代码来源:AnalyzerBase.py

示例4: run

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
    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
开发者ID:sernst,项目名称:PyGlass,代码行数:58,代码来源:PyGlassApplicationCompiler.py

示例5: _analyzeTrackway

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
    def _analyzeTrackway(self, trackway, sitemap):
        """

        @param trackway:
        @param sitemap:
        @return:
        """

        self.entries = dict(lp=[], rp=[], lm=[], rm=[])

        super(SimulationCsvExporterStage, self)._analyzeTrackway(
            trackway=trackway,
            sitemap=sitemap
        )

        csv = CsvWriter(
            autoIndexFieldName='Index',
            fields=[
                'lp_name', 'lp_uid', 'lp_x', 'lp_dx', 'lp_y', 'lp_dy',
                'rp_name', 'rp_uid', 'rp_x', 'rp_dx', 'rp_y', 'rp_dy',
                'lm_name', 'lm_uid', 'lm_x', 'lm_dx', 'lm_y', 'lm_dy',
                'rm_name', 'rm_uid', 'rm_x', 'rm_dx', 'rm_y', 'rm_dy'
            ]
        )

        length = max(
            len(self.entries['lp']),
            len(self.entries['rp']),
            len(self.entries['lm']),
            len(self.entries['rm']),
        )

        for index in range(length):
            items = []
            for limb_id, entries in self.entries.items():
                if index < len(entries):
                    items += entries[index].items()
                else:
                    items += self._create_entry(limb_id).items()
            csv.addRow(dict(items))

        path = self.owner.settings.fetch('EXPORT_DATA_PATH')
        if path is None:
            path = self.owner.getLocalPath('Simulation', 'data', isFile=True)
        path = FileUtils.makeFilePath(path, trackway.name, 'source.csv')

        directory = os.path.dirname(path)
        if not os.path.exists(directory):
            os.makedirs(directory)

        if csv.save(path):
            print('[SAVED]:', path)
        else:
            print('[ERROR]: Unable to save CSV at "{}"'.format(path))
开发者ID:sernst,项目名称:Cadence,代码行数:56,代码来源:SimulationCsvExporterStage.py

示例6: getAnalysisSettings

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
def getAnalysisSettings():
    """ Retrieves the analysis configuration settings file as a SettingsConfig
        instance that can be modified and saved as needed.
        @return: SettingsConfig """
    if not __LOCALS__.SETTINGS_CONFIG:
        __LOCALS__.SETTINGS_CONFIG = SettingsConfig(
            FileUtils.makeFilePath(
                PyGlassEnvironment.getRootLocalResourcePath(
                    'analysis', isDir=True),
                'analysis.json'), pretty=True)
    return __LOCALS__.SETTINGS_CONFIG
开发者ID:sernst,项目名称:Cadence,代码行数:13,代码来源:DataLoadUtils.py

示例7: redirectLogOutputs

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
    def redirectLogOutputs(self, prefix =None, logFolderPath =None):
        """ Sets a temporary standard out and error for deployed applications in a write allowed
            location to prevent failed write results. """

        if not PyGlassEnvironment.isDeployed:
            return

        if not prefix:
            prefix = self.appID

        if not prefix.endswith('_'):
            prefix += '_'

        if logFolderPath:
            logPath = logFolderPath
        elif PyGlassEnvironment.isInitialized:
            logPath = PyGlassEnvironment.getRootLocalResourcePath('logs', isDir=True)
        else:
            prefix += 'init_'
            if appdirs:
                logPath = appdirs.user_data_dir(self.appID, self.appGroupID)
            else:
                logPath = FileUtils.createPath(
                    os.path.expanduser('~'), '.pyglass', self.appGroupID, self.appID, isDir=True)

        FileUtils.getDirectoryOf(logPath, createIfMissing=True)
        try:
            sys.stdout.flush()
            sys.stdout.close()
        except Exception as err:
            pass
        sys.stdout = open(FileUtils.makeFilePath(logPath, prefix + 'out.log'), 'w+')

        try:
            sys.stderr.flush()
            sys.stderr.close()
        except Exception as err:
            pass
        sys.stderr = open(FileUtils.makeFilePath(logPath, prefix + 'error.log'), 'w+')

        return True
开发者ID:sernst,项目名称:PyGlass,代码行数:43,代码来源:PyGlassApplication.py

示例8: loadWidgetFile

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
    def loadWidgetFile(cls, widget, names =None, loadAsWidget =True, target =None):
        """ Loads the UI file for the widget from its resource path. """

        widgetName = widget.__class__.__name__
        lookups = ListUtils.asList(names, allowTuples=False) + [widgetName, 'widget', 'main', 'gui']

        if not target:
            target = widget

        try:
            path = widget.getResourcePath(isDir=True, inApp=True)
        except Exception:
            raise IOError('[ERROR]: No widget resource path found for "%s" widget' % (widgetName))

        if not os.path.exists(path):
            try:
                path = widget.getResourcePath(isDir=True)
            except Exception:
                raise IOError(
                    '[ERROR]: No widget resource path found for "%s" widget' % (widgetName))

            if not os.path.exists(path):
                raise IOError(
                    '[ERROR]: Missing widget resource path [%s]: %s' % (widgetName, path))

        result = None
        for item in lookups:
            result = cls.loadUiFile(
                target=target,
                pathNoExtension=FileUtils.makeFilePath(path, item, isFile=True),
                loadAsWidget=loadAsWidget)
            if result:
                break

        if not result:
            raise Exception('[ERROR]: No UI file found at: ' + path)

        if result is not target:
            layout = QtGui.QVBoxLayout()
            layout.addWidget(result)
            target.setLayout(layout)

            elements = []
            for item in dir(result):
                item = getattr(result, item)
                if isinstance(item, QtGui.QWidget):
                    elements.append(item)
        else:
            layout   = target.layout()
            elements = None

        return {'widget':result, 'layout':layout, 'elements':elements}
开发者ID:sernst,项目名称:PyGlass,代码行数:54,代码来源:UiFileLoader.py

示例9: getPathFromDatabaseUrl

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
    def getPathFromDatabaseUrl(cls, databaseUrl, localResourcesPath=None):
        urlParts = databaseUrl.split("://")

        # Determine the sqlite database path
        if urlParts[0].lower() == "shared":
            path = ["shared", "data"]
        else:
            path = ["apps", urlParts[0], "data"]

        path += urlParts[1].strip("/").split("/")
        if not path[-1].endswith(".vdb"):
            path[-1] += ".vdb"

        if localResourcesPath:
            return FileUtils.makeFilePath(localResourcesPath, *path)

        return PyGlassEnvironment.getRootLocalResourcePath(*path, isFile=True)
开发者ID:sernst,项目名称:PyGlass,代码行数:19,代码来源:PyGlassModelUtils.py

示例10: hasMigrationEnvironment

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
    def hasMigrationEnvironment(cls, databaseUrl, resourcesPath =None):
        """ Determines whether or not the specified application database currently has a migration
            environment setup
            :param databaseUrl:
            :param resourcesPath:
            :return: True or false depending on the presence of a migration environment """

        if not resourcesPath:
            resourcesPath = PyGlassEnvironment.getRootResourcePath(isDir=True)

        migrationPath = PyGlassModelUtils.getMigrationPathFromDatabaseUrl(
            databaseUrl=databaseUrl, resourcesPath=resourcesPath)

        if not os.path.exists(migrationPath):
            return False
        if not os.path.exists(FileUtils.makeFilePath(migrationPath, 'alembic.ini')):
            return False
        if not os.path.exists(FileUtils.makeFolderPath(migrationPath, 'versions')):
            return False
        return True
开发者ID:sernst,项目名称:PyGlass,代码行数:22,代码来源:AlembicUtils.py

示例11: generateData

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
def generateData(tracks):
    trackway_number = tracks.iloc[0]["trackwayNumber"]
    metadata = {"key": "/trackway/tw_{}".format(trackway_number), "count": len(tracks)}

    df = tracks.sort_values(["number", "pes", "left"], ascending=[1, 0, 0])
    df = df.copy()
    df["number"] = df["number"].str.lstrip("0")

    fields = []
    for entry in CONVERSIONS:
        fields.append((get_key(entry.src), entry.label))

    csv = CsvWriter(path=FileUtils.makeFilePath(DATA_DIR, "BEB-500 S-{}.csv".format(trackway_number)), fields=fields)

    for index, track in df.iterrows():
        csv.addRow(create_export_entry(index, track, tracks))

    csv.save()
    df.to_hdf(OUT_PATH, key=metadata["key"], mode="a")

    return metadata
开发者ID:sernst,项目名称:Cadence,代码行数:23,代码来源:beb500_generate.py

示例12: initializeDatabase

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
    def initializeDatabase(cls, databaseUrl, resourcesPath =None, localResourcesPath =None):

        migrationRootPath = PyGlassModelUtils.getMigrationPathFromDatabaseUrl(
            databaseUrl=databaseUrl,
            root=True,
            resourcesPath=resourcesPath)

        migrationPath = PyGlassModelUtils.getMigrationPathFromDatabaseUrl(
            databaseUrl=databaseUrl,
            resourcesPath=resourcesPath)

        configPath = FileUtils.makeFilePath(migrationPath, 'alembic.ini')

        if not os.path.exists(migrationRootPath):
            os.makedirs(migrationRootPath)

        if os.path.exists(migrationPath + 'alembic.ini'):
            return False

        os.chdir(migrationRootPath)

        config = alembicConfig.Config()
        config.config_file_name = configPath

        alembicCmd.init(config=config, directory=migrationPath)

        # Refresh config with proper settings
        cp = configparser.ConfigParser()
        cp.read(configPath)
        cp.set('alembic', 'sqlalchemy.url', PyGlassModelUtils.getEngineUrl(
            databaseUrl=databaseUrl,
            localResourcesPath=localResourcesPath))

        f = open(configPath, 'w+')
        cp.write(f)
        f.close()

        return True
开发者ID:sernst,项目名称:PyGlass,代码行数:40,代码来源:AlembicUtils.py

示例13: getAnalysisData

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
def getAnalysisData(
        analyzerClass, filename, analysisRootPath =None, renames =None
):
    """ Using the analyzer class and CSV filename, return a Pandas DataFrame
        containing that data.

    @param analyzerClass: Class
    @param filename: str
    @param analysisRootPath: str
    @param renames: dict
        A dictionary containing columns to rename. The old column names are the
        keys and the new column names the values.

    @return: DataFrame
    """
    folderName = analyzerClass.__name__
    path = FileUtils.makeFilePath(analysisRootPath, folderName, filename) \
        if analysisRootPath \
        else getAnalysisPath(folderName, filename, isFile=True)

    df = pd.read_csv(path)
    pops.rename.columns(df, renames)
    return df
开发者ID:sernst,项目名称:Cadence,代码行数:25,代码来源:DataLoadUtils.py

示例14:

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
from __future__ import print_function, absolute_import, unicode_literals, division

import os
import sys

from pyaid.file.FileUtils import FileUtils
from pyaid.json.JSON import JSON
from pyaid.system.SystemUtils import SystemUtils

FOLDER_NAME = 'Statistical-Results'

#---------------------------------------------------------------------------------------------------

rootPath = FileUtils.getDirectoryOf(__file__)
localAnalysisPath = FileUtils.makeFolderPath(rootPath, '..', 'resources', 'local', 'analysis')
analysisConfigPath = FileUtils.makeFilePath(localAnalysisPath, 'analysis.json')

config = JSON.fromFile(analysisConfigPath)

if 'OUTPUT_PATH' not in config:
    rootTargetPath = localAnalysisPath
else:
    rootTargetPath = FileUtils.cleanupPath(config['OUTPUT_PATH'], isDir=True)

targetPath = FileUtils.makeFolderPath(rootTargetPath, FOLDER_NAME)

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

outputPath = FileUtils.makeFolderPath(rootPath, 'output')
开发者ID:sernst,项目名称:Cadence,代码行数:32,代码来源:deployResults.py

示例15: print

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import makeFilePath [as 别名]
from pyglass.app.PyGlassEnvironment import PyGlassEnvironment
from cadence.svg.CadenceDrawing import CadenceDrawing

PyGlassEnvironment.initializeFromInternalPath(__file__)

from cadence.models.tracks.Tracks_SiteMap import Tracks_SiteMap

#---------------------------------------------------------------------------------------------------
model = Tracks_SiteMap.MASTER
session = model.createSession()

sitemap = session.query(model).filter(model.name == 'BEB').filter(model.level == '515').first()
print('SITEMAP[%s]: %s' % (sitemap.index, sitemap.name))

output = FileUtils.makeFilePath(OsUtils.getHomePath(), 'Desktop', '%s.svg' % sitemap.name)
drawing = CadenceDrawing(output, sitemap)

trackways = sitemap.getTrackways()
print('TRACKWAY COUNT: %s' % len(trackways))

for trackway in trackways:
    print('TRACKWAY[%s]: %s' % (trackway.index, trackway.name))

    for key, series in DictUtils.iter(trackway.getTrackwaySeriesBundle()):
        for track in series.tracks:
            print('  * %s' % track.fingerprint)
            drawing.circle(
                track.positionValue.toMayaTuple(), 5,
                stroke='none', fill='#003300', fill_opacity='0.1')
开发者ID:sernst,项目名称:Cadence,代码行数:31,代码来源:box_sitemapDrawing.py


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