Beispiel #1
0
    def updateAppExtensions(cls, descriptorPath, extensionIDs):
        s = []
        offset = '\n        '
        for eid in extensionIDs:
            s.append('<extensionID>%s</extensionID>' % eid)
        print 'EXTENSIONS:', s
        data = FileUtils.getContents(descriptorPath)
        data = cls.APP_EXTENSION_PATTERN.sub(
            '\g<prefix>' + offset + offset.join(s) + '\n    \g<suffix>', data)

        return FileUtils.putContents(data, descriptorPath)
Beispiel #2
0
    def updateAppIconList(cls, descriptorPath, iconDefs):
        s = []
        offset = '\n        '
        for icon in iconDefs:
            size = icon['size']
            name = icon['name']
            s.append('<image%sx%s>icons/%s</image%sx%s>' % (size, size, name, size, size))

        data = FileUtils.getContents(descriptorPath)
        data = cls.APP_ICON_PATTERN.sub(
            '\g<prefix>' + offset + offset.join(s) + '\n    \g<suffix>', data)

        return FileUtils.putContents(data, descriptorPath)
Beispiel #3
0
    def _deployWalker(self, args, path, names):
        """Doc..."""

        # Skip CDN file uploads when not walking the CDN root path explicitly
        if not args['cdn'] and path.find(StaticFlowEnvironment.CDN_ROOT_PREFIX) != -1:
            return

        for name in names:
            namePath = FileUtils.createPath(path, name)
            if os.path.isdir(namePath) or StringUtils.ends(name, self._SKIP_EXTENSIONS):
                continue

            headersPath = namePath + '.headers'
            if os.path.exists(headersPath):
                headers = JSON.fromFile(headersPath)
            else:
                headers = dict()

            if self._forceAll:
                lastModified = None
            elif self._forceHtml and StringUtils.ends(name, self._FORCE_HTML_EXTENSIONS):
                lastModified = None
            else:
                lastModified = ArgsUtils.extract('_LAST_MODIFIED', None, headers)
                if lastModified:
                    lastModified = TimeUtils.webTimestampToDateTime(lastModified)

            kwargs = dict(
                key=u'/' + namePath[len(self._localRootPath):].replace(u'\\', u'/').strip(u'/'),
                maxAge=headers.get('max-age', -1),
                eTag=headers.get('eTag', None),
                expires=headers.get('Expires'),
                newerThanDate=lastModified,
                policy=S3Bucket.PUBLIC_READ)

            if StringUtils.ends(name, self._STRING_EXTENSIONS):
                result = self._bucket.put(
                    contents=FileUtils.getContents(namePath),
                    zipContents=True,
                    **kwargs)
            else:
                result = self._bucket.putFile(filename=namePath, **kwargs)

            if result:
                self._logger.write(u'DEPLOYED: ' + unicode(namePath) + u'->' + unicode(kwargs['key']))
Beispiel #4
0
    def compileCss(cls, site, path):
        outPath = FileUtils.changePathRoot(
            path, site.sourceWebRootPath, site.targetWebRootPath)
        FileUtils.getDirectoryOf(outPath, createIfMissing=True)

        if site.isLocal:
            shutil.copy(path, outPath)
            site.writeLogSuccess(u'COPIED', unicode(path))
        else:
            cmd = cls.modifyNodeCommand([
                FileUtils.createPath(
                    StaticFlowEnvironment.nodePackageManagerPath, 'minify', isFile=True),
                '"%s"' % path,
                '"%s"' % outPath])

            iniDirectory = os.curdir
            os.chdir(os.path.dirname(path))
            result = SystemUtils.executeCommand(cmd)
            if result['code']:
                site.logger.write(unicode(result['error']))
                site.writeLogError(u'CSS compilation failure:', extras={
                    'PATH':path,
                    'ERROR':result['error']})
                os.chdir(iniDirectory)
                return False

            site.writeLogSuccess(u'COMPRESSED', unicode(path))
            os.chdir(iniDirectory)

        source = FileUtils.getContents(outPath)
        if not source:
            return False
        FileUtils.putContents(
            cls._CSS_CDN_IMAGE_RE.sub('url(\g<quote>' + site.cdnRootUrl + '/', source),
            outPath)

        lastModified = FileUtils.getUTCModifiedDatetime(path)
        SiteProcessUtils.createHeaderFile(outPath, lastModified)
        cls.copyToCdnFolder(outPath, site, lastModified)
        return True
Beispiel #5
0
 def updateAppFilename(cls, descriptorPath, filename, contentFilename):
     data = FileUtils.getContents(descriptorPath)
     data = cls.FILENAME_PATTERN.sub('\g<prefix>' + filename + '\g<suffix>', data)
     data = cls.CONTENT_FILENAME_PATTERN.sub('\g<prefix>' + contentFilename + '.swf\g<suffix>', data)
     return FileUtils.putContents(data, descriptorPath)
Beispiel #6
0
 def updateAppId(cls, descriptorPath, appId):
     data = FileUtils.getContents(descriptorPath)
     data = cls.APP_ID_PATTERN.sub('\g<prefix>' + appId + '\g<suffix>', data)
     return FileUtils.putContents(data, descriptorPath)
Beispiel #7
0
 def updateDescriptorNamespace(cls, descriptorPath, airVersion):
     data = FileUtils.getContents(descriptorPath)
     data = cls.DESCRIPTOR_VERSION_PATTERN.sub('\g<prefix>' + airVersion + '\g<suffix>', data)
     return FileUtils.putContents(data, descriptorPath)