allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [1/2] git commit: [#6843] Fixed error handling for project metadata import
Date Tue, 05 Nov 2013 17:08:43 GMT
Updated Branches:
  refs/heads/cj/6843 [created] 49f2e8d7c


[#6843] Fixed error handling for project metadata import

Signed-off-by: Cory Johns <cjohns@slashdotmedia.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/0944d135
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0944d135
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0944d135

Branch: refs/heads/cj/6843
Commit: 0944d135cf45c2ef151f49045d6bb579c0395d3e
Parents: 586c77e
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Tue Nov 5 16:28:24 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Tue Nov 5 17:07:42 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/base.py         |  4 +++-
 ForgeImporters/forgeimporters/github/tasks.py | 16 ++++++++++------
 ForgeImporters/forgeimporters/google/tasks.py | 18 +++++++++++-------
 3 files changed, 24 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0944d135/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index 49d49a1..97f7c92 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -85,7 +85,8 @@ class ImportErrorHandler(object):
         return self
 
     def __exit__(self, exc_type, exc_val, exc_tb):
-        self.importer.clear_pending(self.project)
+        if hasattr(self.importer, 'clear_pending'):
+            self.importer.clear_pending(self.project)
         if exc_type:
             g.post_event('import_tool_task_failed',
                 error=str(exc_val),
@@ -209,6 +210,7 @@ class ProjectImporter(BaseController):
 
     """
     source = None
+    tool_label = 'Project Info'
     process_validator = None
     index_template = None
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0944d135/ForgeImporters/forgeimporters/github/tasks.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tasks.py b/ForgeImporters/forgeimporters/github/tasks.py
index 588c5a6..9abdb3d 100644
--- a/ForgeImporters/forgeimporters/github/tasks.py
+++ b/ForgeImporters/forgeimporters/github/tasks.py
@@ -22,13 +22,17 @@ from ming.orm import ThreadLocalORMSession
 
 from allura.lib.decorators import task
 
-from . import GitHubProjectExtractor
+from forgeimporters.base import ImportErrorHandler
+from forgeimporters.github import GitHubProjectExtractor
 
 
 @task
 def import_project_info(project_name):
-    extractor = GitHubProjectExtractor(project_name)
-    c.project.summary = extractor.get_summary()
-    c.project.external_homepage = extractor.get_homepage()
-    ThreadLocalORMSession.flush_all()
-    g.post_event('project_updated')
+    from forgeimporters.github.project import GitHubProjectImporter
+    importer = GitHubProjectImporter(None)
+    with ImportErrorHandler(importer, project_name, c.project) as handler:
+        extractor = GitHubProjectExtractor(project_name)
+        c.project.summary = extractor.get_summary()
+        c.project.external_homepage = extractor.get_homepage()
+        ThreadLocalORMSession.flush_all()
+        g.post_event('project_updated')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0944d135/ForgeImporters/forgeimporters/google/tasks.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/tasks.py b/ForgeImporters/forgeimporters/google/tasks.py
index 69e7556..b0cb76f 100644
--- a/ForgeImporters/forgeimporters/google/tasks.py
+++ b/ForgeImporters/forgeimporters/google/tasks.py
@@ -22,14 +22,18 @@ from ming.orm import ThreadLocalORMSession
 
 from allura.lib.decorators import task
 
-from . import GoogleCodeProjectExtractor
+from forgeimporters.base import ImportErrorHandler
+from forgeimporters.google import GoogleCodeProjectExtractor
 
 
 @task
 def import_project_info(project_name):
-    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')
+    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')


Mime
View raw message