예제 #1
0
def dump_to_file(runner, path_in, path_out):
    writer = utility.File(path_out, 'w')
    writer.open()
    try:
        for line in iter_catalog_dump(runner, path_in, True):
            writer.write('%s\n' % line)
    finally:
        writer.close()
예제 #2
0
def log4j(runner):
    log4j_file = utility.File(runner.opts.log4j_xml_path)
    try:
        log4j_file.open()
        xml_text = log4j_file.read()
        response = runner.call_proc('@UpdateLogging',
                                    [VOLT.FastSerializer.VOLTTYPE_STRING],
                                    [xml_text])
        print(response)
    finally:
        log4j_file.close()
예제 #3
0
 def package(self, output_dir_in, force, *args):
     """
     Create python-runnable package/zip file.
     """
     if output_dir_in is None:
         output_dir = ''
     else:
         output_dir = output_dir_in
         if not os.path.exists(output_dir):
             os.makedirs(output_dir)
     if args:
         # Package other verbspaces.
         for name in args:
             if name not in self.internal_verbspaces:
                 utility.abort(
                     'Unknown base command "%s" specified for packaging.' %
                     name)
             verbspace = self.internal_verbspaces[name]
             self._create_package(output_dir, verbspace.name,
                                  verbspace.version, verbspace.description,
                                  force)
     else:
         # Package the active verbspace.
         self._create_package(output_dir, self.verbspace.name,
                              self.verbspace.version,
                              self.verbspace.description, force)
     # Warn for Python version < 2.6.
     compat_msg = compatibility_warning % dict(name=self.verbspace.name)
     if sys.version_info[0] == 2 and sys.version_info[1] < 6:
         utility.warning(compat_msg)
     # Generate README.<tool> file.
     readme_path = os.path.join(output_dir,
                                'README.%s' % self.verbspace.name)
     readme_file = utility.File(readme_path, mode='w')
     readme_file.open()
     try:
         readme_file.write(readme_template % dict(name=self.verbspace.name,
                                                  usage=self.get_usage(),
                                                  warning=compat_msg))
     finally:
         readme_file.close()
예제 #4
0
    def package(self, output_dir_in, force, *args):
        """
        Create python-runnable package/zip file.
        """
        if output_dir_in is None:
            output_dir = ''
        else:
            output_dir = output_dir_in
            if not os.path.exists(output_dir):
                os.makedirs(output_dir)
        if args:
            # Package other verbspaces.
            for name in args:
                if name not in self.internal_verbspaces:
                    utility.abort('Unknown base command "%s" specified for packaging.' % name)
                verbspace = self.internal_verbspaces[name]
                self._create_package(output_dir, verbspace.name, verbspace.version,
                                     verbspace.description, force)
        else:
            # Package the active verbspace.
            self._create_package(output_dir, self.verbspace.name, self.verbspace.version,
                                 self.verbspace.description, force)
        # Warn for Python version < 2.6.
        compat_msg = ('''\
The program package requires Python version 2.6 or greater.  It will
crash with older Python versions that can't detect and run zip
packages. If a newer Python is not the default you can run by passing
the package file to an explicit python version, e.g.

    python2.6 %s''' % self.verbspace.name)
        if sys.version_info[0] == 2 and sys.version_info[1] < 6:
            utility.warning(compat_msg)
        # Generate README.<tool> file.
        readme_path = os.path.join(output_dir, 'README.%s' % self.verbspace.name)
        readme_file = utility.File(readme_path, mode = 'w')
        readme_file.open()
        try:
            readme_file.write('%s\n\nWARNING: %s\n' % (self.get_usage(), compat_msg))
        finally:
            readme_file.close()