|
@@ -398,18 +398,21 @@ def list_available_modules(url, mlist=None):
|
|
|
"""List modules available in the repository
|
|
|
|
|
|
Tries to use XML metadata file first. Fallbacks to HTML page with a list.
|
|
|
+
|
|
|
+ :param url: URL of the directory (file name will be attached)
|
|
|
+ :param mlist: list only modules in this list
|
|
|
"""
|
|
|
- url = url + "modules.xml"
|
|
|
- grass.debug("url=%s" % url, 1)
|
|
|
+ file_url = url + "modules.xml"
|
|
|
+ grass.debug("url=%s" % file_url, 1)
|
|
|
try:
|
|
|
- tree = etree_fromurl(url, proxies=PROXIES)
|
|
|
+ tree = etree_fromurl(file_url, proxies=PROXIES)
|
|
|
except ETREE_EXCEPTIONS:
|
|
|
grass.warning(_("Unable to parse '%s'. Trying to scan"
|
|
|
- " SVN repository (may take some time)...") % url)
|
|
|
- list_available_extensions_svn()
|
|
|
+ " SVN repository (may take some time)...") % file_url)
|
|
|
+ list_available_extensions_svn(url)
|
|
|
return
|
|
|
except (HTTPError, URLError, IOError, OSError):
|
|
|
- list_available_extensions_svn()
|
|
|
+ list_available_extensions_svn(url)
|
|
|
return
|
|
|
|
|
|
for mnode in tree.findall('task'):
|
|
@@ -430,14 +433,22 @@ def list_available_modules(url, mlist=None):
|
|
|
else:
|
|
|
print(name)
|
|
|
|
|
|
-# list extensions (scan SVN repo)
|
|
|
-
|
|
|
|
|
|
-def list_available_extensions_svn():
|
|
|
+# TODO: this is now broken/dead code, SVN is basically not used
|
|
|
+# 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
|
|
|
+def list_available_extensions_svn(url):
|
|
|
"""List available extensions from HTML given by URL
|
|
|
|
|
|
+ Filename is generated based on the module class/family.
|
|
|
+
|
|
|
``<li><a href=...`` is parsed to find module names.
|
|
|
+ This works well for HTML page generated by Subversion.
|
|
|
+
|
|
|
+ :param url: a directory URL (filename will be attached)
|
|
|
"""
|
|
|
+ gscript.debug("list_available_extensions_svn(url=%s)" % url, 2)
|
|
|
grass.message(_('Fetching list of extensions from'
|
|
|
' GRASS-Addons SVN repository (be patient)...'))
|
|
|
pattern = re.compile(r'(<li><a href=".+">)(.+)(</a></li>)', re.IGNORECASE)
|
|
@@ -455,7 +466,8 @@ def list_available_extensions_svn():
|
|
|
modclass = expand_module_class_name(prefix)
|
|
|
grass.verbose(_("Checking for '%s' modules...") % modclass)
|
|
|
|
|
|
- url = '%s/%s' % (options['svnurl'], modclass)
|
|
|
+ # construct a full URL of a file
|
|
|
+ url = '%s/%s' % (url, modclass)
|
|
|
grass.debug("url = %s" % url, debug=2)
|
|
|
try:
|
|
|
file_ = urlopen(url, proxies=PROXIES)
|
|
@@ -472,18 +484,23 @@ def list_available_extensions_svn():
|
|
|
if name.split('.', 1)[0] == prefix:
|
|
|
print(name)
|
|
|
|
|
|
- # get_wxgui_extensions()
|
|
|
+ # get_wxgui_extensions(url)
|
|
|
+
|
|
|
|
|
|
+# TODO: this is a dead code, not clear why not used, but seems not needed
|
|
|
+def get_wxgui_extensions(url):
|
|
|
+ """Return list of extensions/addons in wxGUI directory at given URL
|
|
|
|
|
|
-def get_wxgui_extensions():
|
|
|
- """Return list of extensions/addons in wxGUI directory at given URL"""
|
|
|
+ :param url: a directory URL (filename will be attached)
|
|
|
+ """
|
|
|
mlist = list()
|
|
|
grass.debug('Fetching list of wxGUI extensions from '
|
|
|
'GRASS-Addons SVN repository (be patient)...')
|
|
|
pattern = re.compile(r'(<li><a href=".+">)(.+)(</a></li>)', re.IGNORECASE)
|
|
|
grass.verbose(_("Checking for '%s' modules...") % 'gui/wxpython')
|
|
|
|
|
|
- url = '%s/%s' % (options['svnurl'], 'gui/wxpython')
|
|
|
+ # construct a full URL of a file
|
|
|
+ url = '%s/%s' % (url, 'gui/wxpython')
|
|
|
grass.debug("url = %s" % url, debug=2)
|
|
|
file_ = urlopen(url, proxies=PROXIES)
|
|
|
if not file_:
|
|
@@ -1584,6 +1601,8 @@ def main():
|
|
|
if sys.platform != "win32":
|
|
|
check_progs()
|
|
|
|
|
|
+ original_url = options['svnurl']
|
|
|
+
|
|
|
# manage proxies
|
|
|
global PROXIES
|
|
|
if options['proxy']:
|
|
@@ -1600,9 +1619,9 @@ def main():
|
|
|
# using dummy module, we don't need any module URL now,
|
|
|
# but will work only as long as the function does not check
|
|
|
# if the URL is actually valid or something
|
|
|
- source, url = resolve_source_code(name='r.dummy',
|
|
|
- url=options['svnurl'])
|
|
|
- xmlurl = resolve_xmlurl_prefix(options['svnurl'], source=source)
|
|
|
+ source, url = resolve_source_code(name='dummy',
|
|
|
+ url=original_url)
|
|
|
+ xmlurl = resolve_xmlurl_prefix(original_url, source=source)
|
|
|
list_available_extensions(xmlurl)
|
|
|
return 0
|
|
|
elif flags['a']:
|
|
@@ -1620,8 +1639,8 @@ def main():
|
|
|
if options['operation'] == 'add':
|
|
|
check_dirs()
|
|
|
source, url = resolve_source_code(name=options['extension'],
|
|
|
- url=options['svnurl'])
|
|
|
- xmlurl = resolve_xmlurl_prefix(options['svnurl'], source=source)
|
|
|
+ url=original_url)
|
|
|
+ xmlurl = resolve_xmlurl_prefix(original_url, source=source)
|
|
|
install_extension(source=source, url=url, xmlurl=xmlurl)
|
|
|
else: # remove
|
|
|
remove_extension(force=flags['f'])
|