incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [37/50] git commit: [#6480] Importer bug fixes
Date Mon, 12 Aug 2013 16:41:22 GMT
[#6480] Importer bug fixes

- Normalize trac urls
- Flush new app configs and related objects before importing artifacts
- Add options needed for WikiExporter

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/75539774
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/75539774
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/75539774

Branch: refs/heads/cj/6422
Commit: 755397743b8956fe2342eede82d4163b6fd92a3d
Parents: 35cc655
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Tue Aug 6 18:57:37 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Aug 7 16:47:24 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/base.py                    |  4 +++-
 ForgeImporters/forgeimporters/google/code.py             |  1 +
 ForgeImporters/forgeimporters/trac/tickets.py            |  9 +++++++--
 ForgeImporters/forgeimporters/trac/wiki.py               | 10 +++++++++-
 ForgeWiki/forgewiki/scripts/wiki_from_trac/extractors.py |  4 ++++
 5 files changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/75539774/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index 5652474..7ad720c 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -52,7 +52,9 @@ class ProjectImportForm(schema.Schema):
 @task
 def import_tool(importer_name, project_name, mount_point=None, mount_label=None, **kw):
     importer = ToolImporter.by_name(importer_name)
-    importer.import_tool(c.project, mount_point, mount_label, **kw)
+    importer.import_tool(project=c.project, user=c.user,
+            mount_point=mount_point,
+            mount_label=mount_label, **kw)
 
 
 class ProjectImporter(BaseController):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/75539774/ForgeImporters/forgeimporters/google/code.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/code.py b/ForgeImporters/forgeimporters/google/code.py
index ef7f800..4457b55 100644
--- a/ForgeImporters/forgeimporters/google/code.py
+++ b/ForgeImporters/forgeimporters/google/code.py
@@ -101,6 +101,7 @@ class GoogleRepoImporter(ToolImporter):
     tool_description = 'Import your SVN, Git, or Hg repo from Google Code'
 
     def import_tool(self, project, project_name, mount_point=None, mount_label=None):
+    def import_tool(self, project, project_name, mount_point=None, mount_label=None, **kw):
         """ Import a Google Code repo into a new SVN, Git, or Hg Allura tool.
 
         """

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/75539774/ForgeImporters/forgeimporters/trac/tickets.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/tickets.py b/ForgeImporters/forgeimporters/trac/tickets.py
index 969dfd2..0f13649 100644
--- a/ForgeImporters/forgeimporters/trac/tickets.py
+++ b/ForgeImporters/forgeimporters/trac/tickets.py
@@ -24,6 +24,7 @@ import json
 import formencode as fe
 from formencode import validators as fev
 
+from ming.orm import session
 from pylons import tmpl_context as c
 from pylons import app_globals as g
 from tg import (
@@ -84,21 +85,25 @@ class TracTicketImporter(ToolImporter):
     tool_description = 'Import your tickets from Trac'
 
     def import_tool(self, project=None, mount_point=None, mount_label=None,
-            trac_url=None, user=None):
+            trac_url=None, user=None, **kw):
         """ Import Trac tickets into a new Allura Tracker tool.
 
         """
+        trac_url = trac_url.rstrip('/') + '/'
         mount_point = mount_point or 'tickets'
         app = project.install_app(
                 'Tickets',
                 mount_point=mount_point,
                 mount_label=mount_label or 'Tickets',
                 )
-        export = TracExport(trac_url)
+        session(app.config).flush(app.config)
+        session(app.globals).flush(app.globals)
+        export = [ticket for ticket in TracExport(trac_url)]
         export_string = json.dumps(export, cls=DateJSONEncoder)
         api_ticket = ApiTicket(user_id=user._id,
                 capabilities={"import": ["Projects", project.shortname]},
                 expires=datetime.utcnow() + timedelta(minutes=60))
+        session(api_ticket).flush(api_ticket)
         cli = AlluraImportApiClient(config['base_url'], api_ticket.api_key,
                 api_ticket.secret_key, False)
         import_tracker(cli, project.shortname, mount_point, {},

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/75539774/ForgeImporters/forgeimporters/trac/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/wiki.py b/ForgeImporters/forgeimporters/trac/wiki.py
index 2417863..e7ead86 100644
--- a/ForgeImporters/forgeimporters/trac/wiki.py
+++ b/ForgeImporters/forgeimporters/trac/wiki.py
@@ -25,6 +25,7 @@ import tempfile
 import formencode as fe
 from formencode import validators as fev
 
+from ming.orm import session
 from pylons import tmpl_context as c
 from pylons import app_globals as g
 from tg import (
@@ -83,25 +84,32 @@ class TracWikiImporter(ToolImporter):
     tool_description = 'Import your wiki from Trac'
 
     def import_tool(self, project=None, mount_point=None, mount_label=None,
-            trac_url=None, user=None):
+            trac_url=None, user=None, **kw):
         """ Import Trac wiki into a new Allura Wiki tool.
 
         """
+        trac_url = trac_url.rstrip('/') + '/'
         mount_point = mount_point or 'wiki'
         app = project.install_app(
                 'Wiki',
                 mount_point=mount_point,
                 mount_label=mount_label or 'Wiki',
                 )
+        session(app.config).flush(app.config)
         api_ticket = ApiTicket(user_id=user._id,
                 capabilities={"import": ["Projects", project.shortname]},
                 expires=datetime.utcnow() + timedelta(minutes=60))
+        session(api_ticket).flush(api_ticket)
         options = argparse.Namespace()
         options.api_key = api_ticket.api_key
         options.secret_key = api_ticket.secret_key
         options.project = project.shortname
         options.wiki = mount_point
         options.base_url = config['base_url']
+        options.verbose = False
+        options.converter = 'html2text'
+        options.import_opts = []
+        options.user_map_file = None
         with tempfile.NamedTemporaryFile() as f:
             WikiExporter(trac_url, options).export(f)
             f.flush()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/75539774/ForgeWiki/forgewiki/scripts/wiki_from_trac/extractors.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/scripts/wiki_from_trac/extractors.py b/ForgeWiki/forgewiki/scripts/wiki_from_trac/extractors.py
index 0038dd9..7f111d7 100644
--- a/ForgeWiki/forgewiki/scripts/wiki_from_trac/extractors.py
+++ b/ForgeWiki/forgewiki/scripts/wiki_from_trac/extractors.py
@@ -15,6 +15,7 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
+import logging
 import re
 import sys
 import json
@@ -36,6 +37,8 @@ except:
 
 from BeautifulSoup import BeautifulSoup
 
+log = logging.getLogger(__name__)
+
 
 class WikiExporter(object):
 
@@ -114,6 +117,7 @@ class WikiExporter(object):
         out.write('\n')
 
     def log(self, msg):
+        log.info(msg)
         if self.options.verbose:
             print >>sys.stderr, msg
 


Mime
View raw message