def _writeGoogleFiles(self): vid = self.get(('GOOGLE', 'SITE_VERIFY_ID')) if not vid: return False if not vid.endswith('.html'): vid += '.html' path = FileUtils.createPath(self.targetWebRootPath, vid, isFile=True) FileUtils.putContents(u'google-site-verification: ' + vid, path) SiteProcessUtils.createHeaderFile(path, None) return True
def _handleCompilationComplete(self, event): snap = self._buildSnapshot if self._package and event.target.success: # If this was an appended package then prior to storing the snapshot the combined # platforms should be stored as the result instead of the platforms stored in this # particular case if 'combinedPlatforms' in snap: platforms = snap['combinedPlatforms'] snap['platforms'] = platforms del snap['combinedPlatforms'] else: platforms = snap['platforms'] # Any package uploads conducted as part of the compilation process should be included # in the build snapshot for reference to prevent uploading them again in the future output = event.target.output if 'urls' in output: snap['platformUploads'] = DictUtils.merge( snap['platformUploads'], output['urls']) self._storeBuildSnapshot() FileUtils.putContents('\t'.join([ TimeUtils.getNowDatetime().strftime('[%a %m-%d %H:%M]'), 'DSK' if platforms.get(FlexProjectData.AIR_PLATFORM, False) else '---', 'AND' if platforms.get(FlexProjectData.ANDROID_PLATFORM, False) else '---', 'IOS' if platforms.get(FlexProjectData.IOS_PLATFORM, False) else '---', 'WIN' if platforms.get(FlexProjectData.WINDOWS_PLATFORM, False) else '---', 'MAC' if platforms.get(FlexProjectData.MAC_PLATFORM, False) else '---', '<<' + snap['versionInfo']['number'] + '>>', '<<' + snap['versionInfo']['label'] + '>>' ]) + '\n', self._settingsEditor.buildLogFilePath, True ) self._settingsEditor.reset() self._settingsEditor.populate() self._updateSettings() self._handleRemoteThreadComplete(event) self._package = False
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)
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
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)
def _createReleaseNotes(self): notes = ReleaseNotesGenerator( owner=self.parent(), label=self._flexData.getSetting('LABEL', u'Application'), versionInfo=self._flexData.versionInfo, **self._releaseNotes) path = FileUtils.createPath( self._flexData.projectPath, 'compiler', 'releaseNotes', isDir=True) if not os.path.exists(path): os.makedirs(path) filename = self._flexData.contentTargetFilename + \ self._flexData.versionInfoNumber.replace(u'.', u'-') + u'.txt' path = FileUtils.createPath(path, filename, isFile=True) FileUtils.putContents(notes.generate(), path) uploader = BuildPackageUploader(self._flexData, self._bucket) url = uploader.uploadFile(path, filename) self._log.write('Uploaded release notes to: <a href="%s">%s</a>' % (url, url)) return notes.text
def write(self): """ Generates the rss.xml file and saves it to the target location. """ mr = MakoRenderer(self._TEMPLATE, StaticFlowEnvironment.rootTemplatePath, {'rss':self}) result = mr.render() if not mr.success: self.page.site.writeErrorLog(mr.errorMessage) return False result = FileUtils.putContents(result, self.targetPath) if result: self.page.site.writeLogSuccess(u'CREATED', u'RSS File: "%s"' % self.targetPath) else: self.page.site.writeErrorLog(u'Unable to write RSS file "%s"' % self.targetPath) return result
def write(self): """ Generates the sitemap and writes the result to the targetPath """ mr = MakoRenderer(self._TEMPLATE, StaticFlowEnvironment.rootTemplatePath, {'sitemap':self}) result = mr.render() if not mr.success: self.site.writeLogError(unicode(mr.errorMessage)) return False if not FileUtils.putContents(result, self.targetPath): self.site.writeLogError(u'Unable to save sitemap file at: "%s"' % self.targetPath) return False self.site.writeLogSuccess(u'SITEMAP', u'Created sitemap at: "%s"' % self.targetPath) return True
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)
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)
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)
def write(self): """Doc...""" FileUtils.putContents(self._convertDataToText(), self.targetPath)