Esempio n. 1
0
    def __init__(self, remote_user_name=None, **kw):

        # trac project creator
        argspec = traclegos_factory(kw.get('conf', ()),
                                    kw,
                                    kw.get('variables', {}))
        self.legos = TracLegos(**argspec)
        self.legos.interactive = False
        self.directory = self.legos.directory # XXX needed?
        self.available_templates = kw.get('available_templates') or project_dict().keys()
        assert self.available_templates
            
        # genshi template loader
        self.loader = TemplateLoader(template_directory, auto_reload=True)

        # storage of intermittent projects
        self.projects = {} 

        # URL to redirect to after project creation
        self.done = '/%(project)s'

        # steps of project creation
        self.steps = [ 'create-project', 'project-details', 'project-variables' ]
        self.steps = [ (step.name, step(self)) for step in [ CreateProject, ProjectDetails, ProjectVariables ] ]

        # available SCM repository types
        self.repositories = available_repositories()
        self.available_repositories = kw.get('available_repositories')
        if self.available_repositories is None:
            self.available_repositories = ['NoRepository'] + [ name for name in self.repositories.keys() if name is not 'NoRepository' ]
            
        else:
            for name in self.repositories.keys():
                if name not in self.available_repositories:
                    del self.repositories[name]
        if 'variables' in kw:
            # set repository options defaults from input variables
            for repository in self.repositories.values():            
                for option in repository.options:
                    option.default = kw['variables'].get(option.name, option.default)

        # available database types
        self.databases = available_databases()
        self.available_databases = kw.get('available_databases')
        if self.available_databases is None:
            self.available_databases = [ 'SQLite' ] + [ name for name in self.databases.keys() if name is not 'SQLite' ]
        else:
            for name in self.databases.keys():
                if name not in self.available_databases:
                    del self.databases[name]

        # enforce authentication
        self.auth = 'auth' in kw

        # index page for projects list
        self.index = kw.get('index', os.path.join(template_directory, 'index.html'))

        self.remote_user_name = remote_user_name
Esempio n. 2
0
def parse(parser, args=None):
    """return (legos, projects) or None"""

    options, args = parser.parse_args(args)

    # parse command line variables and determine list of projects
    projects = [] # projects to create
    vars = {} # defined variables
    for arg in args:
        if '=' in arg:
            variable, value = arg.split('=', 1)
            vars[variable] = value
        else:
            projects.append(arg)

    # list the packaged pastescript TracProject templates
    if options.listprojects:
        print 'Available project types:'
        for name, template in project_dict().items():
            print '%s: %s' % (name, template.summary)
        return

    # get the repository
    repository = None
    if options.repository: 
        repository = available_repositories().get(options.repository)
        if not repository:
            print 'Error: repository type "%s" not available\n' % options.repository
            options.listrepositories = True
    
    # list the available SCM repository setup agents
    if options.listrepositories:
        print 'Available repositories:'
        for name, repository in available_repositories().items():
            if name is not 'NoRepository': # no need to print this one
                print '%s: %s' % (name, repository.description)
        return

    # get the database
    if options.database:
        database = available_databases().get(options.database)
        if not database:
            print 'Error: database type "%s" not available\n' % options.database
            options.listdatabases = True
    else:
        database = None

    # list the available database setup agents
    if options.listdatabases:
        print 'Available databases:'
        for name, database in available_databases().items():
            print '%s: %s' % (name, database.description)
        return        

    # print help if no projects given
    if not projects and not options.printmissing: 
        parser.print_help()
        return

    # parse and apply site-configuration (including variables)
    argspec = traclegos_factory(options.conf, options.__dict__, vars)
    # project creator
    legos = TracLegos(**argspec)

    return legos, projects, { 'templates': options.templates, 
                              'repository': repository,
                              'database': database,
                              'return_missing': options.printmissing}
Esempio n. 3
0
def parse(parser, args=None):
    """return (legos, projects) or None"""

    options, args = parser.parse_args(args)

    # parse command line variables and determine list of projects
    projects = []  # projects to create
    vars = {}  # defined variables
    for arg in args:
        if '=' in arg:
            variable, value = arg.split('=', 1)
            vars[variable] = value
        else:
            projects.append(arg)

    # list the packaged pastescript TracProject templates
    if options.listprojects:
        print 'Available project types:'
        for name, template in project_dict().items():
            print '%s: %s' % (name, template.summary)
        return

    # get the repository
    repository = None
    if options.repository:
        repository = available_repositories().get(options.repository)
        if not repository:
            print 'Error: repository type "%s" not available\n' % options.repository
            options.listrepositories = True

    # list the available SCM repository setup agents
    if options.listrepositories:
        print 'Available repositories:'
        for name, repository in available_repositories().items():
            if name is not 'NoRepository':  # no need to print this one
                print '%s: %s' % (name, repository.description)
        return

    # get the database
    if options.database:
        database = available_databases().get(options.database)
        if not database:
            print 'Error: database type "%s" not available\n' % options.database
            options.listdatabases = True
    else:
        database = None

    # list the available database setup agents
    if options.listdatabases:
        print 'Available databases:'
        for name, database in available_databases().items():
            print '%s: %s' % (name, database.description)
        return

    # print help if no projects given
    if not projects and not options.printmissing:
        parser.print_help()
        return

    # parse and apply site-configuration (including variables)
    argspec = traclegos_factory(options.conf, options.__dict__, vars)
    # project creator
    legos = TracLegos(**argspec)

    return legos, projects, {
        'templates': options.templates,
        'repository': repository,
        'database': database,
        'return_missing': options.printmissing
    }
Esempio n. 4
0
    def __init__(self, remote_user_name=None, **kw):

        # trac project creator
        argspec = traclegos_factory(kw.get('conf', ()), kw,
                                    kw.get('variables', {}))
        self.legos = TracLegos(**argspec)
        self.legos.interactive = False
        self.directory = self.legos.directory  # XXX needed?
        self.available_templates = kw.get(
            'available_templates') or project_dict().keys()
        assert self.available_templates

        # genshi template loader
        self.loader = TemplateLoader(template_directory, auto_reload=True)

        # storage of intermittent projects
        self.projects = {}

        # URL to redirect to after project creation
        self.done = '/%(project)s'

        # steps of project creation
        self.steps = ['create-project', 'project-details', 'project-variables']
        self.steps = [
            (step.name, step(self))
            for step in [CreateProject, ProjectDetails, ProjectVariables]
        ]

        # available SCM repository types
        self.repositories = available_repositories()
        self.available_repositories = kw.get('available_repositories')
        if self.available_repositories is None:
            self.available_repositories = ['NoRepository'] + [
                name for name in self.repositories.keys()
                if name is not 'NoRepository'
            ]

        else:
            for name in self.repositories.keys():
                if name not in self.available_repositories:
                    del self.repositories[name]
        if 'variables' in kw:
            # set repository options defaults from input variables
            for repository in self.repositories.values():
                for option in repository.options:
                    option.default = kw['variables'].get(
                        option.name, option.default)

        # available database types
        self.databases = available_databases()
        self.available_databases = kw.get('available_databases')
        if self.available_databases is None:
            self.available_databases = ['SQLite'] + [
                name for name in self.databases.keys() if name is not 'SQLite'
            ]
        else:
            for name in self.databases.keys():
                if name not in self.available_databases:
                    del self.databases[name]

        # enforce authentication
        self.auth = 'auth' in kw

        # index page for projects list
        self.index = kw.get('index',
                            os.path.join(template_directory, 'index.html'))

        self.remote_user_name = remote_user_name