|
@@ -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 @@ def list_available_modules(url, mlist=None):
|
|
|
# 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 @@ def list_available_extensions_svn(url):
|
|
|
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 @@ def resolve_known_host_service(url):
|
|
|
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 @@ def main():
|
|
|
if sys.platform != "win32":
|
|
|
check_progs()
|
|
|
|
|
|
- original_url = options['svnurl']
|
|
|
+ original_url = options['url']
|
|
|
|
|
|
# manage proxies
|
|
|
global PROXIES
|