def createMoFile(self): try: mkpath(self.LOCALEDIR) copy_file(self.POFILEPATH, self.LOCALEDIR) cwd = os.getcwd() os.chdir(self.LOCALEDIR) if self.USE_MSGFMT_BINARY: # The msgfmt binary that ships as part of GNU gettext tools # is more robust then the Python version and includes # error checking capabilities. moFile = self.POFILE[:-2] + "mo" exp = ["msgfmt", "-c", "--check-accelerators", "-o%s" % moFile, self.POFILE] else: # The msgfmt gettext binary is not installed by default on # Windows and OS X. The Python version of msgfmt is included # however with Chandler. msgfmt = os.path.join(self.CHANDLERHOME, "tools", "msgfmt.py") exp = [self.PYTHON, msgfmt, self.POFILE] result = build_lib.runCommand(exp, timeout=TIMEOUT, logger=ignore, ignorepreexec=True) os.chdir(cwd) if result != 0: raise Exception(' '.join(exp) + ' failed with error code %d' % result) except Exception, e: self.raiseError("Unable to create mo file from %s': %s." % (self.POFILEPATH, e))
def buildDEB(mode, options): os.chdir(options.buildDir) debPath = os.path.join(options.buildDir, 'internal', 'installers', 'deb') debScript = os.path.join(debPath, 'makeinstaller.sh') version = options.version_info['version'].replace('-', '~') libicu = 'libicu38' if options.platformSubID == 'gutsy': libicu = 'libicu36' cmd = [debScript, debPath, options.buildDir, options.distribName, version, mode, libicu] r = runCommand(cmd) log('DEB created (%d)' % r) if r: raise DistributionError(str(r)) if mode == 'release': m = '_' else: m = '_debug_' return 'Chandler_linux%(mode)s%(version)s-1_i386.deb' % {'mode': m, 'version': version}
def putEggInDevelopMode(self): exp = [ self.PYTHON, "setup.py", "develop", "-x", "--install-dir=%s" % self.CHANDLERHOME ] result = build_lib.runCommand(exp, timeout=TIMEOUT, logger=ignore, ignorepreexec=True) if result != 0: self.raiseError(' '.join(exp) + ' failed with error code %d' % result)
def createEggInfoDir(self): exp = [self.PYTHON, 'setup.py', 'egg_info'] result = build_lib.runCommand(exp, timeout=TIMEOUT, logger=ignore, ignorepreexec=True) if result != 0: self.raiseError(' '.join(exp) + ' failed with error code %d' % result) for item in os.listdir(os.getcwd()): if item.endswith(".egg-info"): self.EGGINFODIR = item break if not self.EGGINFODIR: self.raiseError("An Error occurred while building %s project. Please try again." \ % (self.PLUGINNAME))
def buildDMG(mode, options): os.chdir(options.buildDir) distribFile = '%s.dmg' % options.distribName if os.path.isfile(distribFile): os.remove(distribFile) cmd = [ os.path.join(options.toolsDir, 'makediskimage.sh'), options.distribDir ] r = runCommand(cmd) log('OS X disk image file created (%d)' % r) if r: raise DistributionError(str(r)) return distribFile
def buildRPM(mode, options): os.chdir(options.buildDir) rpmPath = os.path.join(options.buildDir, 'internal', 'installers', 'rpm') rpmScript = os.path.join(rpmPath, 'makeinstaller.sh') specFile = os.path.join(rpmPath, 'chandler.spec') version = '%s.%s' % (options.version_info['major'], options.version_info['minor']) release = options.version_info['release'].replace('-', '_') # RPM doesn't like '-' cmd = [ rpmScript, rpmPath, specFile, options.buildDir, options.distribName, version, release ] r = runCommand(cmd) log('RPM created (%d)' % r) if r: raise DistributionError(str(r)) return '%s.i386.rpm' % options.distribName
def packageEggForDistribution(self): exp = [self.PYTHON, "setup.py", "bdist_egg"] result = build_lib.runCommand(exp, timeout=TIMEOUT, logger=ignore, ignorepreexec=True) if result != 0: self.raiseError(' '.join(exp) + ' failed with error code %d' % result) distDir = os.path.join(os.getcwd(), "dist") for item in os.listdir(distDir): if item.endswith(".egg"): self.DISTNAME = item break if not self.DISTNAME: self.raiseError("An Error occurred while building %s project.\n" \ "Unable to build distribution egg." % (self.PLUGINNAME)) copy_file(os.path.join(distDir, self.DISTNAME), \ self.OUTPUTDIR and self.OUTPUTDIR or self.CWD)
def build(commands, config): status = 'success' cwd = os.getcwd() timeout = int(config.get('timeout') or 180) bl.initLog('tbox.log', echo=debug_script) starttime = int(time.time()) for command in commands: cmd = config.get(command) if not cmd: cmd = DEFAULT_COMMANDS[command] if not cmd: continue else: cmd = cmd.split() bl.log('*** %s, timeout=%ds' % (' '.join(cmd), timeout)) exit_code = bl.runCommand(cmd, timeout=timeout) if exit_code: bl.log('*** error exit code = %d' % exit_code) if command == 'test': status = 'test_failed' if os.name != 'nt': try: # If tests were killed due to timeout, we may have left # openssl processes running, so try killing zap_servers() except Exception, e: bl.log('*** error: tried to zap_servers: ' + str(e)) else: status = 'build_failed' break if command == 'svn': os.chdir('m2crypto')
def buildEXE(mode, options): os.chdir(options.buildDir) result = None nsisBinary = findInPath(os.environ['PATH'], 'makensis.exe') if nsisBinary is None: log('Unable to locate makensis.exe in PATH', error=True) else: nsisPath = os.path.join(options.buildDir, 'internal', 'installers', 'win') nsisScript = os.path.join(nsisPath, 'makeinstaller.sh') scriptFile = getCommand(['cygpath', '-aw', os.path.join(nsisPath, 'chandler.nsi')]) cmd = [ nsisBinary, '/DSNAP_%s' % mode.upper(), '/DDISTRIB_DIR=%s' % options.distribName, '/DDISTRIB_VERSION=%s' % options.version_info['version'], scriptFile ] r = runCommand(cmd) distribFile = '%s.exe' % options.distribName targetFile = os.path.join(options.buildDir, distribFile) sourceFile = os.path.join(nsisPath, 'Setup.exe') if os.path.exists(targetFile): os.remove(targetFile) if os.path.exists(sourceFile): os.rename(sourceFile, targetFile) result = distribFile if r: raise DistributionError(str(r)) return result
def buildTarball(mode, options): os.chdir(options.buildDir) if options.platformID == 'win': distribFile = '%s.zip' % options.distribName cmd = [ findInPath(os.environ['PATH'], 'zip'), '-r', distribFile, options.distribName ] else: distribFile = '%s.tar.gz' % options.distribName cmd = [ 'tar', 'czf', distribFile, options.distribName ] if os.path.isfile(distribFile): os.remove(distribFile) r = runCommand(cmd) log('Compressed distribution file created (%d)' % r) if r: raise DistributionError(str(r)) return distribFile
def createMoFile(self): try: mkpath(self.LOCALEDIR) copy_file(self.POFILEPATH, self.LOCALEDIR) cwd = os.getcwd() os.chdir(self.LOCALEDIR) if self.USE_MSGFMT_BINARY: # The msgfmt binary that ships as part of GNU gettext tools # is more robust then the Python version and includes # error checking capabilities. moFile = self.POFILE[:-2] + "mo" exp = [ "msgfmt", "-c", "--check-accelerators", "-o%s" % moFile, self.POFILE ] else: # The msgfmt gettext binary is not installed by default on # Windows and OS X. The Python version of msgfmt is included # however with Chandler. msgfmt = os.path.join(self.CHANDLERHOME, "tools", "msgfmt.py") exp = [self.PYTHON, msgfmt, self.POFILE] result = build_lib.runCommand(exp, timeout=TIMEOUT, logger=ignore, ignorepreexec=True) os.chdir(cwd) if result != 0: raise Exception(' '.join(exp) + ' failed with error code %d' % result) except Exception, e: self.raiseError("Unable to create mo file from %s': %s." % (self.POFILEPATH, e))
def __init__(self): super(TranslationTool, self).__init__() self.GETTEXT = "xgettext" try: build_lib.runCommand("xgettext", timeout=5, logger=ignore) except: self.raiseError( "The xgettext utility is required to run createPot.py") self.getOpts() self.setLibraryPath() self.setWXRC() try: self.OUTPUTFILE_EXISTS = os.access(self.OUTPUTFILE, os.F_OK) self.CWD = os.getcwd() os.chdir(self.ROOTDIR) self.XRC_PYTHON = "XRC_STRINGS_FOR_%s.py" % self.OUTPUTFILE[: -4].upper( ) self.extractXRCStrings() res = self.getText() if os.access(self.XRC_PYTHON, os.F_OK): # Remove the temp XRC Python file os.remove(self.XRC_PYTHON) if res != 0: # No .pot file is generated at this point since # an error was raised parsing the Python and XRC for # localizable stings. sys.exit(-1) os.chdir(self.CWD) # checks that there are no %s, %i , %d type # values in the msgid strings. These values # are not localizable since the ordering can # not be changed. error = self.checkPOFile(self.OUTPUTFILE) if (self.OPTIONS.ValidateOnly or error is not None) and \ not self.OUTPUTFILE_EXISTS and \ os.access(self.OUTPUTFILE, os.F_OK): # If the optional ValidateOnly command is passed # then remove the generated .pot file. os.remove(self.OUTPUTFILE) if error is not None: self.raiseError(error) if os.access(self.OUTPUTFILE, os.F_OK): # Add the Chandler license banner # and glossary overview self.addHeader() if self.OPTIONS.Debug: self.debug() except Exception, e: self.raiseError(str(e))
def putEggInDevelopMode(self): exp = [self.PYTHON, "setup.py", "develop", "-x", "--install-dir=%s" % self.CHANDLERHOME] result = build_lib.runCommand(exp, timeout=TIMEOUT, logger=ignore, ignorepreexec=True) if result != 0: self.raiseError(' '.join(exp) + ' failed with error code %d' % result)
if build == 'tarball': options.distribFiles[mode].append(buildTarball(mode, options)) if build == 'dmg': options.distribFiles[mode].append(buildDMG(mode, options)) if build == 'exe': options.distribFiles[mode].append(buildEXE(mode, options)) if build == 'rpm': options.distribFiles[mode].append(buildRPM(mode, options)) if build == 'deb': options.distribFiles[mode].append(buildDEB(mode, options)) if options.outputDir <> options.buildDir: generateTinderboxOutput(mode, options.distribFiles[mode]) if os.access(options.distribDir, os.F_OK): rmdirs(options.distribDir) if _debug: log(options.distribFiles[mode]) else: log('Skipping %s because the directory is not present' % mode, error=True) except DistributionError: success = False # revert the contents of version.py to clear any previously generated values runCommand([ findInPath(os.environ['PATH'], 'svn'), 'revert', os.path.join(options.sourceDir, 'version.py') ]) if not success: sys.exit('Failed to create distributions')
if sys.platform == 'darwin': # This might be specific to Intel Mac "Leopard", but playing safe # See bug 11645. TIMEOUT = -1 else: TIMEOUT = 60 def ignore(output): pass try: build_lib.runCommand("msgfmt", timeout=5, logger=ignore, ignorepreexec=True) MSGFMT_INSTALLED = True except: MSGFMT_INSTALLED = False class TranslationEggTool(LocalizationBase): PROJECTNAME = None PROJECTNAMES = None LOCALE = None OUTPUTDIR = None PLUGINDIR = None PLUGINDIR_EXISTS = False PLUGINNAME = None EGGINFODIR = None
PYICU_INSTALLED = True except: PYICU_INSTALLED = False if sys.platform == 'darwin': # This might be specific to Intel Mac "Leopard", but playing safe # See bug 11645. TIMEOUT = -1 else: TIMEOUT = 60 def ignore(output): pass try: build_lib.runCommand("msgfmt", timeout=5, logger=ignore, ignorepreexec=True) MSGFMT_INSTALLED = True except: MSGFMT_INSTALLED = False class TranslationEggTool(LocalizationBase): PROJECTNAME = None PROJECTNAMES = None LOCALE = None OUTPUTDIR = None PLUGINDIR = None PLUGINDIR_EXISTS = False PLUGINNAME = None EGGINFODIR = None
def __init__(self): super(TranslationTool, self).__init__() self.GETTEXT = "xgettext" try: build_lib.runCommand("xgettext", timeout=5, logger=ignore) except: self.raiseError("The xgettext utility is required to run createPot.py") self.getOpts() self.setLibraryPath() self.setWXRC() try: self.OUTPUTFILE_EXISTS = os.access(self.OUTPUTFILE, os.F_OK) self.CWD = os.getcwd() os.chdir(self.ROOTDIR) self.XRC_PYTHON = "XRC_STRINGS_FOR_%s.py" % self.OUTPUTFILE[:-4].upper() self.extractXRCStrings() res = self.getText() if os.access(self.XRC_PYTHON, os.F_OK): # Remove the temp XRC Python file os.remove(self.XRC_PYTHON) if res != 0: # No .pot file is generated at this point since # an error was raised parsing the Python and XRC for # localizable stings. sys.exit(-1) os.chdir(self.CWD) # checks that there are no %s, %i , %d type # values in the msgid strings. These values # are not localizable since the ordering can # not be changed. error = self.checkPOFile(self.OUTPUTFILE) if (self.OPTIONS.ValidateOnly or error is not None) and \ not self.OUTPUTFILE_EXISTS and \ os.access(self.OUTPUTFILE, os.F_OK): # If the optional ValidateOnly command is passed # then remove the generated .pot file. os.remove(self.OUTPUTFILE) if error is not None: self.raiseError(error) if os.access(self.OUTPUTFILE, os.F_OK): # Add the Chandler license banner # and glossary overview self.addHeader() if self.OPTIONS.Debug: self.debug() except Exception, e: self.raiseError(str(e))