[GRASS-SVN] r65869 - in grass/trunk: gui/wxpython/modules lib/gis scripts/g.extension scripts/g.extension/testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Aug 9 04:08:12 PDT 2015


Author: wenzeslaus
Date: 2015-08-09 04:08:12 -0700 (Sun, 09 Aug 2015)
New Revision: 65869

Modified:
   grass/trunk/gui/wxpython/modules/extensions.py
   grass/trunk/lib/gis/renamed_options
   grass/trunk/scripts/g.extension/g.extension.py
   grass/trunk/scripts/g.extension/testsuite/test_addons_modules.py
   grass/trunk/scripts/g.extension/testsuite/test_addons_toolboxes.py
Log:
g.extension: rename option svnurl to url

The name url is not 100% friendly for all when used for local files but source
(with unclear meaning) and input (usually an actual file to process) don't
seem better.

Also clean up in the GUI wrapper, document tests and fix bug in listing from HTML
(introduced in r65868).


Modified: grass/trunk/gui/wxpython/modules/extensions.py
===================================================================
--- grass/trunk/gui/wxpython/modules/extensions.py	2015-08-09 02:45:22 UTC (rev 65868)
+++ grass/trunk/gui/wxpython/modules/extensions.py	2015-08-09 11:08:12 UTC (rev 65869)
@@ -48,7 +48,7 @@
         self.panel = wx.Panel(parent = self, id = wx.ID_ANY)
 
         self.repoBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
-                                    label = " %s " % _("Repository"))
+                                    label = " %s " % _("Repository (leave empty to use the official one)"))
         self.treeBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
                                     label = " %s " % _("List of extensions - double-click to install"))
         
@@ -86,9 +86,9 @@
                 continue
             self.options[name] = wx.CheckBox(parent = self.panel, id = wx.ID_ANY,
                                              label = desc)
-        defaultUrl = 'http://svn.osgeo.org/grass/grass-addons/grass7'
-        self.repo.SetValue(task.get_param(value = 'svnurl').get('default', defaultUrl))
-        
+        defaultUrl = ''  # default/official one will be used when option empty
+        self.repo.SetValue(task.get_param(value='url').get('default', defaultUrl))
+
         self.statusbar = self.CreateStatusBar(number = 1)
         
         self.btnFetch = wx.Button(parent = self.panel, id = wx.ID_ANY,
@@ -179,7 +179,7 @@
                     flags.append('--%s' % key)
         
         return ['g.extension'] + flags + ['extension=' + name,
-                                          'svnurl=' + self.repo.GetValue().strip()]
+                                          'url=' + self.repo.GetValue().strip()]
 
     def OnFetch(self, event):
         """Fetch list of available extensions"""
@@ -310,7 +310,7 @@
         else:
             flags = 'l'
         retcode, ret, msg = RunCommand('g.extension', read = True, getErrorMsg = True,
-                                       svnurl = url,
+                                       url=url,
                                        flags = flags, quiet = True)
         if retcode != 0:
             raise GException(_("Unable to load extensions. %s") % msg)

Modified: grass/trunk/lib/gis/renamed_options
===================================================================
--- grass/trunk/lib/gis/renamed_options	2015-08-09 02:45:22 UTC (rev 65868)
+++ grass/trunk/lib/gis/renamed_options	2015-08-09 11:08:12 UTC (rev 65869)
@@ -87,6 +87,8 @@
 #########################################
 ### General map management module changes
 #########################################
+# g.extension
+g.extension|svnurl:url
 # g.mapset
 g.mapset|gisdbase:dbase
 # g.mapsets

Modified: grass/trunk/scripts/g.extension/g.extension.py
===================================================================
--- grass/trunk/scripts/g.extension/g.extension.py	2015-08-09 02:45:22 UTC (rev 65868)
+++ grass/trunk/scripts/g.extension/g.extension.py	2015-08-09 11:08:12 UTC (rev 65869)
@@ -4,9 +4,10 @@
 #
 # MODULE:       g.extension
 # AUTHOR(S):    Markus Neteler
-#               Pythonized & upgraded for GRASS 7 by Martin Landa <landa.martin gmail.com>
-# PURPOSE:      Tool to download and install extensions from GRASS Addons SVN into
-#               local GRASS installation
+#               Martin Landa <landa.martin gmail com> (Pythonized & upgraded for GRASS 7)
+#               Vaclav Petras <wenzeslaus gmail com> (support for general sources)
+# PURPOSE:      Tool to download and install extensions into local installation
+#               
 # COPYRIGHT:    (C) 2009-2014 by Markus Neteler, and the GRASS Development Team
 #
 #               This program is free software under the GNU General
@@ -19,10 +20,12 @@
 
 #%module
 #% label: Maintains GRASS Addons extensions in local GRASS installation.
-#% description: Downloads, installs extensions from GRASS Addons SVN repository into local GRASS installation or removes installed extensions.
+#% description: Downloads and installs extensions from GRASS Addons repository or other source into the local GRASS installation or removes installed extensions.
 #% keyword: general
 #% keyword: installation
 #% keyword: extensions
+#% keyword: addons
+#% keyword: download
 #%end
 
 #%option
@@ -42,10 +45,11 @@
 #% answer: add
 #%end
 #%option
-#% key: svnurl
+#% key: url
 #% type: string
 #% key_desc: url
-#% description: SVN Addons repository URL
+#% label: URL or directory to get the extension from
+#% description: The official repository is used by default. User can specify a ZIP file, directory or a repository on common hosting services. If not identified, Subversion repository is assumed. See manual for all options.
 #%end
 #%option
 #% key: prefix
@@ -438,10 +442,12 @@
 # fallback for Trac should parse Trac HTML page
 # this might be useful for potential SVN repos or anything
 # which would list the extensions/addons as list
+# TODO: fail when nothing is accessible
 def list_available_extensions_svn(url):
     """List available extensions from HTML given by URL
 
     Filename is generated based on the module class/family.
+    This works well for the structure which is in grass-addons repository.
 
     ``<li><a href=...`` is parsed to find module names.
     This works well for HTML page generated by Subversion.
@@ -467,12 +473,12 @@
         grass.verbose(_("Checking for '%s' modules...") % modclass)
 
         # construct a full URL of a file
-        url = '%s/%s' % (url, modclass)
-        grass.debug("url = %s" % url, debug=2)
+        file_url = '%s/%s' % (url, modclass)
+        grass.debug("url = %s" % file_url, debug=2)
         try:
-            file_ = urlopen(url, proxies=PROXIES)
+            file_ = urlopen(file_url, proxies=PROXIES)
         except (HTTPError, IOError, OSError):
-            grass.debug(_("Unable to fetch '%s'") % url, debug=1)
+            grass.debug(_("Unable to fetch '%s'") % file_url, debug=1)
             continue
 
         for line in file_.readlines():
@@ -1498,6 +1504,7 @@
         return None, None
 
 
+# TODO: add also option to enforce the source type
 def resolve_source_code(url=None, name=None):
     """Return type and URL or path of the source code
 
@@ -1601,7 +1608,7 @@
     if sys.platform != "win32":
         check_progs()
 
-    original_url = options['svnurl']
+    original_url = options['url']
 
     # manage proxies
     global PROXIES

Modified: grass/trunk/scripts/g.extension/testsuite/test_addons_modules.py
===================================================================
--- grass/trunk/scripts/g.extension/testsuite/test_addons_modules.py	2015-08-09 02:45:22 UTC (rev 65868)
+++ grass/trunk/scripts/g.extension/testsuite/test_addons_modules.py	2015-08-09 11:08:12 UTC (rev 65869)
@@ -51,8 +51,8 @@
     url = 'file://' + os.path.abspath('data')
 
     def test_listing(self):
-        """Test if results is in expected limits"""
-        module = SimpleModule('g.extension', flags='l', svnurl=self.url)
+        """List individual extensions/modules/addons"""
+        module = SimpleModule('g.extension', flags='l', url=self.url)
         self.assertModule(module)
         stdout = module.outputs.stdout
         self.assertMultiLineEqual(stdout, MODULES_OUTPUT)
@@ -87,35 +87,35 @@
         silent_rmtree(self.install_prefix)
 
     def test_directory_install(self):
-        """Test if results is in expected limits"""
+        """Test installing extension from directory"""
         self.assertModule('g.extension', extension='r.plus.example',
-                          svnurl=os.path.join(self.path, 'r.plus.example'),
+                          url=os.path.join(self.path, 'r.plus.example'),
                           prefix=self.install_prefix)
         # TODO: this is wrong for MS Win
         for file in self.files:
             self.assertFileExists(file)
 
     def test_targz_install(self):
-        """Test if results is in expected limits"""
+        """Test installing extension from local .tar.gz"""
         self.assertModule('g.extension', extension='r.plus.example',
-                          svnurl=os.path.join(self.path,
+                          url=os.path.join(self.path,
                                               'r.plus.example.tar.gz'),
                           prefix=self.install_prefix)
         for file in self.files:
             self.assertFileExists(file)
 
     def test_remote_targz_without_dir_install(self):
-        """Test if results is in expected limits"""
+        """Test installing extension from (remote) .tar.gz without main dir"""
         self.assertModule('g.extension', extension='r.plus.example',
-                          svnurl=self.url + '/' + 'r.plus.example_sep.tar.gz',
+                          url=self.url + '/' + 'r.plus.example_sep.tar.gz',
                           prefix=self.install_prefix, verbose=True)
         for file in self.files:
             self.assertFileExists(file)
 
     def test_remote_zip_install(self):
-        """Test if results is in expected limits"""
+        """Test installing extension from .zip specified by URL (local)"""
         self.assertModule('g.extension', extension='r.plus.example',
-                          svnurl=self.url + '/' + 'r.plus.example.zip',
+                          url=self.url + '/' + 'r.plus.example.zip',
                           prefix=self.install_prefix)
         for file in self.files:
             self.assertFileExists(os.path.join(file))

Modified: grass/trunk/scripts/g.extension/testsuite/test_addons_toolboxes.py
===================================================================
--- grass/trunk/scripts/g.extension/testsuite/test_addons_toolboxes.py	2015-08-09 02:45:22 UTC (rev 65868)
+++ grass/trunk/scripts/g.extension/testsuite/test_addons_toolboxes.py	2015-08-09 11:08:12 UTC (rev 65869)
@@ -41,8 +41,8 @@
     url = 'file://' + os.path.abspath('data')
 
     def test_listing(self):
-        """Test if results is in expected limits"""
-        module = SimpleModule('g.extension', flags='lt', svnurl=self.url)
+        """List toolboxes and their content"""
+        module = SimpleModule('g.extension', flags='lt', url=self.url)
         self.assertModule(module)
         stdout = module.outputs.stdout
         self.assertLooksLike(stdout, FULL_TOOLBOXES_OUTPUT)



More information about the grass-commit mailing list