コード例 #1
0
ファイル: validation_generate.py プロジェクト: sernst/Cadence
def initialize():
    path = FileUtils.makeFolderPath(MY_DIR, 'data')
    SystemUtils.remove(path)
    os.makedirs(path)

    tracks = DataLoadUtils.getTrackWithAnalysis()
    return tracks[['uid', 'site', 'width', 'sizeClass']]
コード例 #2
0
ファイル: PyGlassApplication.py プロジェクト: sernst/PyGlass
    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
コード例 #3
0
ファイル: AirUtils.py プロジェクト: sernst/CompilerDeck
    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
コード例 #4
0
ファイル: AnalysisStage.py プロジェクト: sernst/Cadence
 def initializeFolder(self, *args):
     """ Initializes a folder within the root analysis path by removing any existing contents
         and then creating a new folder if it does not already exist. """
     path = self.getPath(*args, isDir=True)
     if os.path.exists(path):
         SystemUtils.remove(path)
     os.makedirs(path)
     return path
コード例 #5
0
ファイル: __init__.py プロジェクト: sernst/Cadence
def initialize(my_path):
    if os.path.isfile(my_path):
        my_path = FileUtils.getDirectoryOf(my_path)

    path = FileUtils.makeFolderPath(my_path, 'data')
    SystemUtils.remove(path)
    os.makedirs(path)

    return path
コード例 #6
0
ファイル: AnalyzerBase.py プロジェクト: sernst/Cadence
    def run(self):
        """ Executes the analysis process, iterating through each of the analysis stages before
            cleaning up and exiting. """

        print('[OUTPUT PATH]: %s' % self.analysisRootPath)
        print(analysisStamp)
        print(tracksStamp)

        self._startTime = TimeUtils.getNowDatetime()

        myRootPath = self.getPath(isDir=True)
        if os.path.exists(myRootPath):
            FileUtils.emptyFolder(myRootPath)
        if not os.path.exists(myRootPath):
            os.makedirs(myRootPath)

        tempPath = self.tempPath
        if os.path.exists(tempPath):
            SystemUtils.remove(tempPath)
        os.makedirs(tempPath)

        if not self.logger.loggingPath:
            self.logger.loggingPath = myRootPath

        try:
            session = self.getAnalysisSession()
            self._preAnalyze()
            for stage in self._stages:
                self._currentStage = stage
                stage.analyze()
            self._currentStage = None
            self._postAnalyze()

            session.commit()
            session.close()
            self._success = True
        except Exception as err:
            session = self.getAnalysisSession()
            session.close()
            msg = [
                '[ERROR]: Failed to execute analysis',
                'STAGE: %s' % self._currentStage]
            self._errorMessage = Logger.createErrorMessage(msg, err)
            self.logger.writeError(msg, err)

        session = self.getTracksSession()
        session.close()

        self._cleanup()
        SystemUtils.remove(tempPath)

        self.logger.write('\n\n[%s]: %s (%s)' % (
            'SUCCESS' if self._success else 'FAILED',
            self.__class__.__name__,
            TimeUtils.toPrettyElapsedTime(self.elapsedTime)
        ), indent=False)
コード例 #7
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
コード例 #8
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
コード例 #9
0
ファイル: Site.py プロジェクト: sernst/StaticFlow
 def run(self):
     """ Executes the site generation process """
     try:
         if os.path.exists(self.targetWebRootPath):
             if not SystemUtils.remove(self.targetWebRootPath):
                 # In unsuccessful wait a brief period and try again in case the OS delayed
                 # the allowance for the removal because of an application conflict
                 time.sleep(5)
                 SystemUtils.remove(self.targetWebRootPath, throwError=True)
         os.makedirs(self.targetWebRootPath)
     except Exception, err:
         self.writeLogError(
             u'Unable to Remove Existing Deployment',
             error=err,
             throw=False)
         return False
コード例 #10
0
    def _createEngineCss(self):
        resourcePath = StaticFlowEnvironment.rootResourcePath
        sourceFolder = FileUtils.createPath(resourcePath, '..', 'css', isDir=True)
        targetFolder = FileUtils.createPath(resourcePath, 'web', 'css', isDir=True)

        tempPath = FileUtils.createPath(targetFolder, 'engine.temp.css', isFile=True)
        SystemUtils.remove(tempPath)
        destF = open(tempPath, 'a')

        for item in FileUtils.getFilesOnPath(sourceFolder):
            try:
                f = open(item, 'r')
                destF.write('\n' + f.read())
                f.close()
            except Exception , err:
                print 'ERROR: Failed to read CSS file:', item
コード例 #11
0
ファイル: SystemCommandIssuer.py プロジェクト: hannahp/PyAid
    def _remove(self, path):
        if not os.path.exists(path):
            print 'NOTHING TO REMOVE: ' + path
            return False

        result = SystemUtils.remove(path)
        if not result:
            print 'FAILED TO REMOVE: ' + path
            return False

        print 'REMOVED PATH: ' + path
        return True
コード例 #12
0
    def emptyFolder(cls, folderPath):
        """ Recursively empties all elements within a folder, and returns a
            boolean specifying whether the operation succeeded.
        """
        folderPath = cls.cleanupPath(folderPath, isDir=True)
        if not os.path.exists(folderPath):
            return False

        result = True
        for path in os.listdir(folderPath[:-1]):
            result = SystemUtils.remove(folderPath + path) and result
        return result
コード例 #13
0
ファイル: FileUtils.py プロジェクト: sernst/PyAid
    def emptyFolder(cls, folderPath):
        """ Recursively empties all elements within a folder, and returns a
            boolean specifying whether the operation succeeded.
        """
        folderPath = cls.cleanupPath(folderPath, isDir=True)
        if not os.path.exists(folderPath):
            return False

        result = True
        for path in os.listdir(folderPath[:-1]):
            result = SystemUtils.remove(folderPath + path) and result
        return result
コード例 #14
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
コード例 #15
0
    def _handleReplaceDatabase(self):

        self.mainWindow.showLoading(
            self,
            u'Browsing for Database File',
            u'Choose a valid database (*.vcd) file')

        defaultPath = self.appConfig.get(UserConfigEnum.DATABASE_IMPORT_PATH)
        if not defaultPath:
            defaultPath = self.appConfig.get(UserConfigEnum.LAST_BROWSE_PATH)

        path = PyGlassBasicDialogManager.browseForFileOpen(
            parent=self,
            caption=u'Select Database File',
            defaultPath=defaultPath)
        self.mainWindow.hideLoading(self)

        if not path:
            self.mainWindow.toggleInteractivity(True)
            return

        # Store directory for later use
        self.appConfig.set(
            UserConfigEnum.DATABASE_IMPORT_PATH,
            FileUtils.getDirectoryOf(path) )

        self.mainWindow.showStatus(
            self,
            u'Replacing Database File',
            u'Removing existing database file and replacing it with selection')

        sourcePath = getattr(Tracks_Track, 'URL')[len(u'sqlite:'):].lstrip(u'/')
        if not OsUtils.isWindows():
            sourcePath = u'/' + sourcePath

        savePath = '%s.store' % sourcePath
        try:
            if os.path.exists(savePath):
                SystemUtils.remove(savePath, throwError=True)
        except Exception as err:
            self.mainWindow.appendStatus(
                self, u'<span style="color:#CC3333">ERROR: Unable to access database save location.</span>')
            self.mainWindow.showStatusDone(self)
            return

        try:
            SystemUtils.move(sourcePath, savePath)
        except Exception as err:
            self.mainWindow.appendStatus(
                self, u'<span style="color:#CC3333;">ERROR: Unable to modify existing database file.</span>')
            self.mainWindow.showStatusDone(self)
            return

        try:
            SystemUtils.copy(path, sourcePath)
        except Exception as err:
            SystemUtils.move(savePath, sourcePath)
            self.mainWindow.appendStatus(
                self, u'<span style="color:#CC3333;">ERROR: Unable to copy new database file.</span>')
            self.mainWindow.showStatusDone(self)
            return

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

        self.mainWindow.appendStatus(self, u'<span style="color:#33CC33;">Database Replaced</span>')
        self.mainWindow.showStatusDone(self)
コード例 #16
0
ファイル: Site.py プロジェクト: sernst/StaticFlow
    def _runImpl(self):
        if not os.path.exists(self.targetWebRootPath):
            os.makedirs(self.targetWebRootPath)

        for staticPath in self.get('STATIC_PATHS', []):
            self._staticPaths.append(FileUtils.createPath(
                self.sourceWebRootPath,
                *staticPath.strip(u'/').split(u'/')))

        #-------------------------------------------------------------------------------------------
        # COPY FILES
        #       Copies files from the source folders to the target root folder, maintaining folder
        #       structure in the process
        FileUtils.walkPath(self.sourceWebRootPath, self._copyWalker)

        #--- COMMON FILES ---#
        copies = [
            (u'StaticFlow Javascript', 'web/js', 'js/sflow'),
            (u'StaticFlow CSS', 'web/css', 'css/sflow') ]

        for item in copies:
            source = FileUtils.createPath(
                StaticFlowEnvironment.rootResourcePath, *item[1].split('/'), isDir=True)
            target = FileUtils.createPath(
                self.targetWebRootPath, *item[2].split('/'), isDir=True)

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

            targetFolder = FileUtils.createPath(target, '..', isDir=True)
            if not os.path.exists(targetFolder):
                os.makedirs(targetFolder)

            fileList = FileUtils.mergeCopy(source, target)
            for path, data in fileList.files.iteritems():
                SiteProcessUtils.copyToCdnFolder(
                    path, self, FileUtils.getUTCModifiedDatetime(source))

            self.writeLogSuccess(u'COPIED', u'%s | %s -&gt; %s' % (
                item[0], source.rstrip(os.sep), target.rstrip(os.sep) ))

        #-------------------------------------------------------------------------------------------
        # COMPILE
        #       Compiles source files to the target root folder
        currentPath = os.curdir
        os.path.walk(self.sourceWebRootPath, self._compileWalker, None)
        os.chdir(currentPath)

        #-------------------------------------------------------------------------------------------
        # CREATE PAGE DEFS
        #       Creates the page data files that define the pages to be generated
        os.path.walk(self.sourceWebRootPath, self._htmlDefinitionWalker, None)
        self._pages.process()

        self._sitemap.write()
        self._robots.write()

        for rssGenerator in self._rssGenerators:
            rssGenerator.write()

        self._writeGoogleFiles()

        #-------------------------------------------------------------------------------------------
        # CLEANUP
        #       Removes temporary and excluded file types from the target root folder
        os.path.walk(self.targetWebRootPath, self._cleanupWalker, dict())

        return True
コード例 #17
0
ファイル: initializeStatsEnv.py プロジェクト: sernst/Cadence
import sys
import os

from pyaid.file.FileUtils import FileUtils
from pyaid.string.StringUtils import StringUtils
from pyaid.system.SystemUtils import SystemUtils

rootPath = FileUtils.getDirectoryOf(__file__)

#---------------------------------------------------------------------------------------------------
# INPUTS

inputPath = FileUtils.createPath('input', isDir=True)
if os.path.exists(inputPath):
    SystemUtils.remove(inputPath)
os.makedirs(inputPath)

localDatabasePath = FileUtils.createPath(
    rootPath, '..', 'resources', 'local', 'apps', 'Cadence', 'data', isDir=True)

if not os.path.exists(localDatabasePath):
    print('[ERROR]: No local database resource folder exists')
    sys.exit(1)

for filename in os.listdir(localDatabasePath):
    if StringUtils.begins(filename, '.'):
        # Skip '.' hidden files
        continue

    source = FileUtils.createPath(localDatabasePath, filename)
コード例 #18
0
ファイル: deployResults.py プロジェクト: sernst/Cadence
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')

if not SystemUtils.copy(outputPath, targetPath, echo=True):
    print('[FAILED]: Deployment')
    sys.exit(1)

print('Deployment Complete')
コード例 #19
0
    def _compileImpl(self):
        sets = self._settings
        os.chdir(sets.projectPath)

        adtPath     = self.getAirPath('bin', 'adt', isFile=True)
        swcRootPath = FileUtils.createPath(sets.projectPath, 'swc', isDir=True)

        buildPath = FileUtils.createPath(sets.projectPath, 'build', isDir=True)
        SystemUtils.remove(buildPath)
        os.makedirs(buildPath)

        sets.setPlatform(FlexProjectData.DEFAULT_PLATFORM)

        swcPath = FileUtils.createPath(
            swcRootPath,
            sets.getSetting('FOLDER'),
            sets.getSetting('FILENAME') + '.swc',
            isFile=True)

        cmd = [adtPath,
            '-package',
            '-target', 'ane', sets.getSetting('FILENAME') + '.ane', 'extension.xml',
            '-swc', swcPath]

        platforms = [
            (FlexProjectData.DEFAULT_PLATFORM, 'default', None),
            (FlexProjectData.ANDROID_PLATFORM, 'Android-ARM', 'jar'),
            (FlexProjectData.IOS_PLATFORM, 'iPhone-ARM', 'a'),
            (FlexProjectData.WINDOWS_PLATFORM, 'Windows-x86', None),
            (FlexProjectData.MAC_PLATFORM, 'MacOS-x86', None)]

        platformsData = []
        for platformDef in platforms:
            if not sets.setPlatform(platformDef[0]):
                continue

            platformFolder = sets.getSetting('FOLDER')

            platformBuildPath = FileUtils.createPath(buildPath, platformFolder, isDir=True, noTail=True)
            os.makedirs(platformBuildPath)

            # LIBRARY.SWF
            SystemUtils.copy(
                FileUtils.createPath(
                    sets.projectPath, 'swc', platformFolder, 'extracted', 'library.swf', isFile=True),
                FileUtils.createPath(platformBuildPath, 'library.swf', isFile=True) )

            # NATIVE LIBRARY
            nativeLibrary = sets.getSetting('NATIVE_LIBRARY')
            if nativeLibrary:
                SystemUtils.copy(
                    FileUtils.createPath(sets.projectPath, platformFolder, nativeLibrary, isFile=True),
                    FileUtils.createPath(buildPath, platformFolder, nativeLibrary, isFile=True))

            # Android RES folder
            if platformDef[0] == FlexProjectData.ANDROID_PLATFORM:
                FileUtils.mergeCopy(
                    FileUtils.createPath(sets.projectPath, platformFolder, 'res', isDir=True),
                    FileUtils.createPath(buildPath, platformFolder, 'res', isDir=True))

            cmd.extend(['-platform', platformDef[1]])

            optionsPath = FileUtils.createPath(
                sets.projectPath, platformFolder, 'platform.xml', isFile=True, noTail=True)
            if os.path.exists(optionsPath):
                cmd.extend(['-platformoptions', '"%s"' % optionsPath])

            cmd.extend(['-C', platformBuildPath, '.'])

            data = dict(
                nativeLibrary=nativeLibrary,
                definition=platformDef,
                folder=platformFolder,
                initializer=sets.getSetting('INITIALIZER'),
                finalizer=sets.getSetting('FINALIZER'))
            platformsData.append(data)

        self._createExtensionDescriptor(platformsData)
        result = self.executeCommand(cmd, 'PACKAGING ANE')

        # Cleanup deployed library.swf files
        SystemUtils.remove(buildPath)

        if result:
            self._log.write('PACKAGING FAILED')
            return False

        self._log.write('PACKAGED SUCCEEDED')
        return True
コード例 #20
0
ファイル: CsvWriter.py プロジェクト: sernst/Cadence
 def remove(self):
     """remove doc..."""
     return SystemUtils.remove(self.path)
コード例 #21
0
ファイル: SWCCompiler.py プロジェクト: sernst/CompilerDeck
    def _compileImpl(self):

        sets         = self._settings
        airPath      = self._owner.mainWindow.getRootAIRPath()
        commandFile  = 'acompc.bat' if PyGlassEnvironment.isWindows else 'acompc'
        isDefault    = sets.currentPlatformID == FlexProjectData.DEFAULT_PLATFORM
        isWindows    = sets.currentPlatformID == FlexProjectData.WINDOWS_PLATFORM
        isMac        = sets.currentPlatformID == FlexProjectData.MAC_PLATFORM
        isAndroid    = sets.currentPlatformID == FlexProjectData.ANDROID_PLATFORM
        isIOS        = sets.currentPlatformID == FlexProjectData.IOS_PLATFORM
        flashVersion = sets.getFlashVersion(self._owner.mainWindow.getRootAIRPath())

        libPath = FileUtils.createPath(
            sets.projectPath, sets.getSetting('LIB_PATH', 'lib'), isDir=True)
        if not os.path.exists(libPath):
            os.makedirs(libPath)

        sourcePath = FileUtils.createPath(
                sets.projectPath, sets.getSetting('SOURCE_PATH', 'src'), isDir=True)
        if not os.path.exists(sourcePath):
            os.makedirs(sourcePath)

        cmd = [
            FileUtils.createPath(airPath, sets.airVersion, 'bin', commandFile, isFile=True),
            '-library-path+="%s"' % libPath,
            '--source-path+="%s"' % sourcePath,
            '-target-player=' + flashVersion,
            '-swf-version=' + str(FlashUtils.convertFlashToSwfVersion(flashVersion)) ]

        cmd.extend([
            self._getBooleanDefinition('DEFAULT', isDefault),
            self._getBooleanDefinition('DESKTOP', isMac or isWindows),
            self._getBooleanDefinition('WINDOWS', isWindows),
            self._getBooleanDefinition('MAC', isMac),
            self._getBooleanDefinition('IOS', isIOS),
            self._getBooleanDefinition('ANDROID', isAndroid),
            self._getStringVarDefinition('ID', sets.getSetting('ID', '')),
            self._getStringVarDefinition('VERSION_NUMBER_MAJOR', sets.versionInfo.get('major', '0')),
            self._getStringVarDefinition('VERSION_NUMBER_MINOR', sets.versionInfo.get('minor', '0')),
            self._getStringVarDefinition('VERSION_NUMBER_MICRO', sets.versionInfo.get('micro', '0')),
            self._getStringVarDefinition('VERSION_NUMBER_REVISION', sets.versionInfo.get('revision', '0')) ])

        swcFolderPath = self.getTargetPath('swc', sets.getSetting('FOLDER'), isDir=True)
        if not os.path.exists(swcFolderPath):
            os.makedirs(swcFolderPath)

        swcPath = FileUtils.createPath(swcFolderPath, sets.getSetting('FILENAME') + '.swc')
        SystemUtils.remove(swcPath)

        cmd.append('--include-classes')
        sharedClasses = sets.getSetting('SHARED_CLASSES')
        if sharedClasses:
            for c in sharedClasses:
                cmd.append(c)
        cmd.append(self._settings.targetClass)
        cmd.append('-output="%s"' % swcPath)

        header = 'COMPILING SWC: "%s" (%s)' % (
            sets.getSetting('LABEL', 'Unknown'), sets.currentPlatformID)

        if self.executeCommand(cmd, header):
            self._log.write('FAILED: SWC COMPILATION')
            return False
        self._log.write('SUCCESS: SWC COMPILATION')

        zipFolderPath = FileUtils.createPath(swcFolderPath, 'extracted', isDir=True)
        SystemUtils.remove(zipFolderPath)

        try:
            z = zipfile.ZipFile(swcPath)
            z.extractall(zipFolderPath)
        except Exception, err:
            self._log.writeError('FAILED: SWC EXTRACTION', err)
            return False
コード例 #22
0
 def remove(self):
     """remove doc..."""
     return SystemUtils.remove(self.path)