Пример #1
0
 def make_description(self, tasks=None):
     """
     Returns the description of this project, in the context of the
     settings given.
     """
     self.setup_config()
     if tasks is None:
         tasks = self.bind_tasks()
     out = StringIO()
     title = self.title or self.name
     title = '%s (%s)' % (title, self.project_name)
     print >> out, underline(title)
     doc = self.__doc__
     if doc == Project.__doc__:
         doc = '[No project description set]'
     print >> out, dedent(doc)
     print >> out
     print >> out, indent(underline('Settings', '='), '  ')
     ns = self.create_namespace()
     if not self.settings:
         print >> out, indent('No settings', '    ')
     else:
         for setting in self.settings:
             try:
                 setting_value = getattr(ns['config'], setting.name)
             except Exception, e:
                 setting_value = 'Cannot calculate value: %s %s' % (
                     e.__class__.__name__, e)
             print >> out, indent(setting.description(value=setting_value),
                                  '    ')
Пример #2
0
 def make_description(self, tasks=None):
     """
     Returns the description of this project, in the context of the
     settings given.
     """
     self.setup_config()
     if tasks is None:
         tasks = self.bind_tasks()
     out = StringIO()
     title = self.title or self.name
     title = '%s (%s)' % (title, self.project_name)
     print >> out, underline(title)
     doc = self.__doc__
     if doc == Project.__doc__:
         doc = '[No project description set]'
     print >> out, dedent(doc)
     print >> out
     print >> out, indent(underline('Settings', '='), '  ')
     ns = self.create_namespace()
     if not self.settings:
         print >> out, indent('No settings', '    ')
     else:
         for setting in self.settings:
             try:
                 setting_value = getattr(ns['config'], setting.name)
             except Exception, e:
                 setting_value = 'Cannot calculate value: %s %s' % (e.__class__.__name__, e)
             print >> out, indent(setting.description(value=setting_value), '    ')
Пример #3
0
 def description(self, value=None):
     msg = '%s:' % self.name
     msg += '\n  Default: %s' % self.description_repr(self.default)
     if value != self.default:
         msg += '\n  Value:   %s' % self.description_repr(value)
     if self.help:
         msg += '\n' + indent(self.help, '    ')
     return msg
Пример #4
0
 def description(self, value=None):
     msg = '%s:' % self.name
     msg += '\n  Default: %s' % self.description_repr(self.default)
     if value != self.default:
         msg += '\n  Value:   %s' % self.description_repr(value)
     if self.help:
         msg += '\n'+indent(self.help, '    ')
     return msg
Пример #5
0
def list_projects(options):
    """
    Implements --list-projects
    """
    import traceback
    from cStringIO import StringIO
    entry_points = [(ep_to_name(ep), ep) for ep in
                    pkg_resources.iter_entry_points('fassembler.project')]
    for name, ep in sorted(entry_points):
        print '%s (from %s:%s)' % (name, ep.module_name, '.'.join(ep.attrs))
        try:
            obj = ep.load()
        except:
            out = StringIO()
            out.write('Exception loading entry point:\n')
            traceback.print_exc(file=out)
            desc = out.getvalue()
        else:
            desc = obj.__doc__
        desc = indent(desc, '  ') or '(undocumented)'
        print desc
        print
Пример #6
0
 def run(self):
     """
     Actually run the project.  Subclasses seldom override this;
     this runs all the tasks given in ``self.actions``
     """
     if self.actions is None:
         raise NotImplementedError(
             "The actions attribute has not been overridden in %r" % self)
     self.setup_config()
     tasks = self.bind_tasks()
     for task in tasks:
         self.logger.set_section(self.name + '.' + task.name)
         self.logger.notify('== %s ==' % task.name, color='bold green')
         self.logger.indent += 2
         while 1:
             try:
                 try:
                     self.logger.debug('Task Plan:')
                     self.logger.debug(indent(str(task), '  '))
                     task.run()
                 finally:
                     self.logger.indent -= 2
             except (KeyboardInterrupt, CommandError):
                 raise
             except:
                 should_continue = self.maker.handle_exception(
                     sys.exc_info(), can_continue=True, can_retry=True)
                 if should_continue == 'retry':
                     self.logger.notify('Retrying task %s' % task.name)
                     continue
                 if not should_continue:
                     self.logger.fatal('Project %s aborted.' % self.title,
                                       color='red')
                     raise CommandError('Aborted', show_usage=False)
             break
     self.environ.add_built_project(self.project_name)
Пример #7
0
def list_projects(options):
    """
    Implements --list-projects
    """
    import traceback
    from cStringIO import StringIO
    entry_points = [
        (ep_to_name(ep), ep)
        for ep in pkg_resources.iter_entry_points('fassembler.project')
    ]
    for name, ep in sorted(entry_points):
        print '%s (from %s:%s)' % (name, ep.module_name, '.'.join(ep.attrs))
        try:
            obj = ep.load()
        except:
            out = StringIO()
            out.write('Exception loading entry point:\n')
            traceback.print_exc(file=out)
            desc = out.getvalue()
        else:
            desc = obj.__doc__
        desc = indent(desc, '  ') or '(undocumented)'
        print desc
        print
Пример #8
0
 def run(self):
     """
     Actually run the project.  Subclasses seldom override this;
     this runs all the tasks given in ``self.actions``
     """
     if self.actions is None:
         raise NotImplementedError(
             "The actions attribute has not been overridden in %r"
             % self)
     self.setup_config()
     tasks = self.bind_tasks()
     for task in tasks:
         self.logger.set_section(self.name+'.'+task.name)
         self.logger.notify('== %s ==' % task.name, color='bold green')
         self.logger.indent += 2
         while 1:
             try:
                 try:
                     self.logger.debug('Task Plan:')
                     self.logger.debug(indent(str(task), '  '))
                     task.run()
                 finally:
                     self.logger.indent -= 2
             except (KeyboardInterrupt, CommandError):
                 raise
             except:
                 should_continue = self.maker.handle_exception(sys.exc_info(), can_continue=True,
                                                               can_retry=True)
                 if should_continue == 'retry':
                     self.logger.notify('Retrying task %s' % task.name)
                     continue
                 if not should_continue:
                     self.logger.fatal('Project %s aborted.' % self.title, color='red')
                     raise CommandError('Aborted', show_usage=False)
             break
     self.environ.add_built_project(self.project_name)
Пример #9
0
        print >> out
        print >> out, indent(underline('Settings', '='), '  ')
        ns = self.create_namespace()
        if not self.settings:
            print >> out, indent('No settings', '    ')
        else:
            for setting in self.settings:
                try:
                    setting_value = getattr(ns['config'], setting.name)
                except Exception, e:
                    setting_value = 'Cannot calculate value: %s %s' % (
                        e.__class__.__name__, e)
                print >> out, indent(setting.description(value=setting_value),
                                     '    ')
        print >> out
        print >> out, indent(underline('Tasks', '='), '  ')
        for task in tasks:
            desc = str(task)
            print >> out, indent(underline(task.title, '-'), '    ')
            print >> out, indent(desc, '    ')
            print >> out
        if self.depends_on_projects:
            print >> out, indent(underline('Dependencies', '='), '  ')
            for project in self.depends_on_projects:
                print >> out, indent('* %s' % project, '  ')
        return out.getvalue()

    def interpolate(self, string, stacklevel=1, name=None):
        """
        Interpolate a string in the context of the project namespace.
        """
Пример #10
0
            doc = '[No project description set]'
        print >> out, dedent(doc)
        print >> out
        print >> out, indent(underline('Settings', '='), '  ')
        ns = self.create_namespace()
        if not self.settings:
            print >> out, indent('No settings', '    ')
        else:
            for setting in self.settings:
                try:
                    setting_value = getattr(ns['config'], setting.name)
                except Exception, e:
                    setting_value = 'Cannot calculate value: %s %s' % (e.__class__.__name__, e)
                print >> out, indent(setting.description(value=setting_value), '    ')
        print >> out
        print >> out, indent(underline('Tasks', '='), '  ')
        for task in tasks:
            desc = str(task)
            print >> out, indent(underline(task.title, '-'), '    ')
            print >> out, indent(desc, '    ')
            print >> out
        if self.depends_on_projects:
            print >> out, indent(underline('Dependencies', '='), '  ')
            for project in self.depends_on_projects:
                print >> out, indent('* %s' % project, '  ')
        return out.getvalue()

    def interpolate(self, string, stacklevel=1, name=None):
        """
        Interpolate a string in the context of the project namespace.
        """