def exec_doxygen(cmd): # remove target dir if os.path.exists(target_dir + "/html/index.html"): return if os.path.exists(target_dir): shutil.rmtree(target_dir) #cmdline = string.join(cmd) cmdline = " ".join(cmd) if os_is() == "win32": os.system(cmdline) return log.info(cmdline) if sys.version_info[0] == 2: status, output = commands.getstatusoutput(cmdline) log.info(output) else: try: proc = subprocess.run(cmdline, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) status = 0 log.info(proc.stdout.decode("UTF-8")) except: status = 1 if status != 0: raise errors.DistutilsExecError("Return status of %s is %d" % (cmd, status)) return
def run(self): env = os.environ.copy() syspath = [os.path.abspath(x) for x in sys.path] if self.build_dir: syspath.insert( 0, os.path.abspath(os.path.join(self.build_dir, '..', 'lib'))) syspath = ':'.join(syspath) cmd = [ 'make', 'PYTHON=%s' % sys.executable, 'PYTHONPATH=%s' % syspath, 'SPHINXBUILD=%s %s' % (sys.executable, self.find_sphinx_build()), str(self.builder) ] opts = [] if self.version: opts.append('-D version=%s' % self.version) if self.build_dir: cmd.append('BUILDDIR=%s' % (self.build_dir, )) if opts: cmd.append('SPHINXOPTS=%s' % (' '.join(opts), )) cwd = self.source_dir if not cwd: cwd = os.getcwd() if subprocess.call(cmd, cwd=cwd, env=env): raise errors.DistutilsExecError("doc generation failed")
def exec_idl_compile(cmd_str): #cmdline = string.join(cmd_str) cmdline = " ".join(cmd_str) if os_is() == "win32": os.system(cmdline) return log.info(cmdline) if sys.version_info[0] == 2: status, output = commands.getstatusoutput(cmdline) log.info(output) else: try: proc = subprocess.run(cmdline, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) status = 0 log.info(proc.stdout.decode("UTF-8")) except: status = 1 if status != 0: raise errors.DistutilsExecError("Return status of %s is %d" % (cmd, status)) return
def compile_idl(self, cmd, params, files): log.info('{0} {1} {2}'.format(cmd, ' '.join(params), ' '.join(files))) process = subprocess.Popen([cmd] + params + files, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=self.idl_dir) stdout, stderr = process.communicate() log.info(stdout) if process.returncode != 0: raise errors.DistutilsExecError('Error compiling IDL \ ({0})'.format(process.returncode))
def exec_idl_compile(cmd_str): cmdline = string.join(cmd_str) if os_is() == "win32": os.system(cmdline) return log.info(cmdline) status, output = commands.getstatusoutput(cmdline) log.info(output) if status != 0: raise errors.DistutilsExecError("Return status of %s is %d" % (cmd, status)) return
def compile_one_idl(self, idl_f): outdir_param = '-C' + self.stubs_dir pkg_param = '-Wbpackage=rtctree.rtc' idl_path_param = '-Iidl' p = subprocess.Popen([self.omniidl, '-bpython', idl_path_param, outdir_param, pkg_param, idl_f], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() if p.returncode != 0: raise errors.DistutilsExecError( 'Failed to compile IDL file {}\nStdout:\n{}\n---\nStderr:\n' '{}'.format(idl_f, stdout, stderr))
def make_release_tree(self, base_dir, files): """Create and populate the directory tree that is put in source tars. This copies or hardlinks "normal" source files that should go into the release and adds generated files that should not exist in a working tree. """ if self.build_docs: # this is icky, but covers up cwd changing issues. cwd = os.getcwd() if subprocess.call([sys.executable, 'setup.py', 'build_docs', '--builder=man'], cwd=cwd): raise errors.DistutilsExecError("build_docs failed") import shutil shutil.copytree(os.path.join(cwd, "build/sphinx/man"), os.path.join(base_dir, "man")) snk_distutils.sdist.make_release_tree(self, base_dir, files) self.cleanup_post_release_tree(base_dir)
def exec_doxygen(cmd): # remove target dir if os.path.exists(target_dir + "/html/index.html"): return if os.path.exists(target_dir): shutil.rmtree(target_dir) cmdline = string.join(cmd) if os_is() == "win32": os.system(cmdline) return log.info(cmdline) status, output = commands.getstatusoutput(cmdline) log.info(output) if status != 0: raise errors.DistutilsExecError("Return status of %s is %d" % (cmd, status)) return
def run(self, firstrun=True): self.source_path = self.find_content() if self.source_path is None: if not firstrun: raise errors.DistutilsExecError( "no pregenerated sphinx content, and sphinx isn't available " "to generate it; bailing") self.run_command(self.build_command) return self.run(False) content = self.scan_content() content = self.content directories = set(map(os.path.dirname, content.values())) directories.discard('') for x in sorted(directories): self.mkpath(os.path.join(self.path, x)) for src, dst in sorted(content.items()): self.copy_file(os.path.join(self.source_path, src), os.path.join(self.path, dst))
def run(self): build_ext = self.reinitialize_command('build_ext') build_py = self.reinitialize_command('build_py') build_ext.inplace = build_py.inplace = self.inplace build_ext.force = build_py.force = self.force if self.include_dirs: build_ext.include_dirs = self.include_dirs if not self.pure_python: self.run_command('build_ext') if not self.inplace: self.run_command('build_py') syspath = sys.path[:] mods_to_wipe = () if not self.inplace: cwd = os.getcwd() syspath = [x for x in sys.path if x != cwd] test_path = os.path.abspath(build_py.build_lib) syspath.insert(0, test_path) mods = build_py.find_all_modules() mods_to_wipe = set(x[0] for x in mods) mods_to_wipe.update('.'.join(x[:2]) for x in mods) namespaces = self.namespaces if not self.namespaces: namespaces = [self.default_test_namespace] retval = unittest_extensions.run_tests(namespaces, disable_fork=self.disable_fork, blacklist=self.blacklist, pythonpath=syspath, modules_to_wipe=mods_to_wipe) if retval: raise errors.DistutilsExecError("tests failed; return %i" % (retval, ))
def initialize_options(self): raise errors.DistutilsExecError("sphinx is not available")
def run(self): try: apply_format(self.root) except FormatViolation as e: raise errors.DistutilsExecError("[Error at Formatter]", e)
def write_manifest(self): # TODO Seems not to be working the first time for pyramid manifest_template = self.manifest_filename + '.in' if not os.path.exists(manifest_template): self.logger.warn( 'No Web Deploy manifest template found at {0}'.format( manifest_template)) # No manifest template, don't update real manifest return # Substitute environment variables so that hashes can be dynamice manifest_str = os.path.expandvars(open(manifest_template).read()) manifest = minidom.parseString(manifest_str) for runcommand in manifest.getElementsByTagName('runCommand'): # Collect the attributes that need to be passed as settings path = None settings_attrs = {} for name, value in runcommand.attributes.items(): if name == 'path': # provider value/key attribute path = value continue elif name.startswith('MSDeploy.'): # Leave these alone continue settings_attrs[name] = value # Remove them from the output XML runcommand.removeAttribute(name) if path is None: raise errors.DistutilsFileError( 'No `path` attribute in a <runCommand> element in {0}' .format(manifest_template)) # Assemble the msdeploy.exe source command line settings = ','.join('{0}={1}'.format(*item) for item in settings_attrs.items()) if settings: settings = ',' + settings source = '-source:runCommand="{0}"{1}'.format(path, settings) tmp = tempfile.mkdtemp() package = os.path.join(tmp, 'runCommand.zip') try: cmd = ( '"{msdeploy}" -verb:sync {source} -dest:package={package}' .format(msdeploy=self.msdeploy_exe, source=source, package=package)) self.logger.info( 'Generating runCommand manifest:\n{0}'.format(cmd)) if self.msdeploy_exe and os.path.exists(self.msdeploy_exe): subprocess.check_call(cmd, shell=True) else: self.logger.error( 'msdeploy.exe does not exist: {0}'.format( self.msdeploy_exe)) continue tmp_manifest = minidom.parseString( zipfile.ZipFile(package).read('archive.xml')) finally: shutil.rmtree(tmp) new_runcommands = tmp_manifest.getElementsByTagName('runCommand') if not new_runcommands: raise errors.DistutilsExecError( 'No <runCommand> elements found in {0}:archive.xml' .format(package)) elif len(new_runcommands) > 1: raise errors.DistutilsExecError( 'Multiple <runCommand> elements found in {0}:archive.xml' .format(package)) options = new_runcommands[0].getAttribute( 'MSDeploy.MSDeployProviderOptions') runcommand.setAttribute( 'MSDeploy.MSDeployProviderOptions', options) self.logger.info('Writing Web Deploy manifest to {0}'.format( self.manifest_filename)) manifest.writexml(open(self.manifest_filename, 'w'))
for par in pars: if par.strip()[:2] == '-C': #param `-C' (Change directory do dir) was used, so test #and if need create directory build/lib if not os.path.exists(par.strip()[2:]): try: os.makedirs(par.strip()[2:]) print "Create directory", par.strip()[2:] except OSError, e: print e cmdline = cmd + ' ' + string.join(pars) + ' ' + string.join(files) log.info(cmdline) status, output = commands.getstatusoutput(cmdline) log.info(output) if status != 0: raise errors.DistutilsExecError("Return status of %s is %d" % (cmd, status)) def gen_idl_name(dir, name): """ Generate name of idl file from directory prefix and IDL module name. """ return os.path.join(dir, name + ".idl") class Install(install.install, object): user_options = [] user_options.extend(install.install.user_options) user_options.append( ('modules=', None, 'which pyfred modules will be loaded' ' [genzone mailer filemanager techcheck]'))