Beispiel #1
0
    def import_tool(self, project, user, project_name=None, mount_point=None,
                    mount_label=None, **kw):
        """ Import a Google Code repo into a new SVN, Git, or Hg Allura tool.

        """
        extractor = GoogleCodeProjectExtractor(project_name, 'source_browse')
        repo_type = extractor.get_repo_type()
        repo_url = get_repo_url(project_name, repo_type)
        app = project.install_app(
            REPO_ENTRY_POINTS[repo_type],
            mount_point=mount_point or 'code',
            mount_label=mount_label or 'Code',
            init_from_url=repo_url,
            import_id={
                'source': self.source,
                'project_name': project_name,
            }
        )
        M.AuditLog.log(
            'import tool %s from %s on %s' % (
                app.config.options.mount_point,
                project_name, self.source,
            ), project=project, user=user, url=app.url)
        g.post_event('project_updated')
        return app
Beispiel #2
0
    def import_tool(self,
                    project,
                    user,
                    project_name=None,
                    mount_point=None,
                    mount_label=None,
                    **kw):
        """ Import a Google Code repo into a new SVN, Git, or Hg Allura tool.

        """
        extractor = GoogleCodeProjectExtractor(project_name, 'source_browse')
        repo_type = extractor.get_repo_type()
        repo_url = get_repo_url(project_name, repo_type)
        app = project.install_app(REPO_ENTRY_POINTS[repo_type],
                                  mount_point=mount_point or 'code',
                                  mount_label=mount_label or 'Code',
                                  init_from_url=repo_url,
                                  import_id={
                                      'source': self.source,
                                      'project_name': project_name,
                                  })
        M.AuditLog.log('import tool %s from %s on %s' % (
            app.config.options.mount_point,
            project_name,
            self.source,
        ),
                       project=project,
                       user=user,
                       url=app.url)
        g.post_event('project_updated')
        return app
 def import_tool(self,
                 project,
                 user,
                 project_name,
                 mount_point=None,
                 mount_label=None,
                 **kw):
     import_id_converter = ImportIdConverter.get()
     app = project.install_app(
         'tickets',
         mount_point,
         mount_label,
         EnableVoting=True,
         open_status_names='New Accepted Started',
         closed_status_names='Fixed Verified Invalid Duplicate WontFix Done',
         import_id={
             'source': self.source,
             'project_name': project_name,
         },
     )
     ThreadLocalORMSession.flush_all()
     try:
         M.session.artifact_orm_session._get().skip_mod_date = True
         with h.push_config(c, user=M.User.anonymous(), app=app):
             for ticket_num, issue in GoogleCodeProjectExtractor.iter_issues(
                     project_name):
                 self.max_ticket_num = max(ticket_num, self.max_ticket_num)
                 ticket = TM.Ticket(app_config_id=app.config._id,
                                    custom_fields=dict(),
                                    ticket_num=ticket_num,
                                    import_id=import_id_converter.expand(
                                        ticket_num, app))
                 self.process_fields(ticket, issue)
                 self.process_labels(ticket, issue)
                 self.process_comments(ticket, issue)
                 session(ticket).flush(ticket)
                 session(ticket).expunge(ticket)
             app.globals.custom_fields = self.postprocess_custom_fields()
             app.globals.last_ticket_num = self.max_ticket_num
             ThreadLocalORMSession.flush_all()
         M.AuditLog.log(
             'import tool %s from %s on %s' % (
                 app.config.options.mount_point,
                 project_name,
                 self.source,
             ),
             project=project,
             user=user,
             url=app.url,
         )
         g.post_event('project_updated')
         app.globals.invalidate_bin_counts()
         return app
     except Exception as e:
         h.make_app_admin_only(app)
         raise
     finally:
         M.session.artifact_orm_session._get().skip_mod_date = False
Beispiel #4
0
def import_project_info(project_name):
    from forgeimporters.google.project import GoogleCodeProjectImporter
    importer = GoogleCodeProjectImporter(None)
    with ImportErrorHandler(importer, project_name, c.project) as handler:
        extractor = GoogleCodeProjectExtractor(project_name, 'project_info')
        extractor.get_short_description(c.project)
        extractor.get_icon(c.project)
        extractor.get_license(c.project)
        ThreadLocalORMSession.flush_all()
        g.post_event('project_updated')
Beispiel #5
0
 def import_tool(self, project, user, project_name, mount_point=None,
                 mount_label=None, **kw):
     import_id_converter = ImportIdConverter.get()
     app = project.install_app('tickets', mount_point, mount_label,
                               EnableVoting=True,
                               open_status_names='New Accepted Started',
                               closed_status_names='Fixed Verified Invalid Duplicate WontFix Done',
                               import_id={
                                   'source': self.source,
                                   'project_name': project_name,
                               },
                               )
     ThreadLocalORMSession.flush_all()
     try:
         M.session.artifact_orm_session._get().skip_mod_date = True
         with h.push_config(c, user=M.User.anonymous(), app=app):
             for ticket_num, issue in GoogleCodeProjectExtractor.iter_issues(project_name):
                 self.max_ticket_num = max(ticket_num, self.max_ticket_num)
                 ticket = TM.Ticket(
                     app_config_id=app.config._id,
                     custom_fields=dict(),
                     ticket_num=ticket_num,
                     import_id=import_id_converter.expand(ticket_num, app))
                 self.process_fields(ticket, issue)
                 self.process_labels(ticket, issue)
                 self.process_comments(ticket, issue)
                 session(ticket).flush(ticket)
                 session(ticket).expunge(ticket)
             app.globals.custom_fields = self.postprocess_custom_fields()
             app.globals.last_ticket_num = self.max_ticket_num
             ThreadLocalORMSession.flush_all()
         M.AuditLog.log(
             'import tool %s from %s on %s' % (
                 app.config.options.mount_point,
                 project_name, self.source,
             ),
             project=project,
             user=user,
             url=app.url,
         )
         g.post_event('project_updated')
         app.globals.invalidate_bin_counts()
         return app
     except Exception:
         h.make_app_admin_only(app)
         raise
     finally:
         M.session.artifact_orm_session._get().skip_mod_date = False
Beispiel #6
0
    def _to_python(self, value, state):
        value = super(self.__class__, self)._to_python(value, state)

        gc_project_name = value['gc_project_name']
        mount_point = value['mount_point']
        try:
            repo_type = GoogleCodeProjectExtractor(
                gc_project_name).get_repo_type()
        except urllib2.HTTPError as e:
            if e.code == 404:
                msg = 'No such project'
            else:
                msg = str(e)
            msg = 'gc_project_name:' + msg
            raise fe.Invalid(msg, value, state)
        except Exception:
            raise
        tool_class = REPO_APPS[repo_type]
        try:
            value['mount_point'] = v.MountPointValidator(tool_class).to_python(
                mount_point)
        except fe.Invalid as e:
            raise fe.Invalid('mount_point:' + str(e), value, state)
        return value