commit/galaxy-central: dan: Add a script to check toolshed dependency files for broken/invalid download URLs.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/a67b8cdce345/ Changeset: a67b8cdce345 User: dan Date: 2014-02-17 18:51:34 Summary: Add a script to check toolshed dependency files for broken/invalid download URLs. Affected #: 1 file diff -r 6353214a32ee96343f8a3e9e25e9e5b2f9517d9b -r a67b8cdce345bef55e349641445598e7db735a1a scripts/tool_shed/check_download_urls.py --- /dev/null +++ b/scripts/tool_shed/check_download_urls.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +##Dan Blankenberg +##Script that checks toolshed tags to see if URLs are accessible. +##Does not currently handle 'download_binary' + +import os +import sys +from optparse import OptionParser +import xml.etree.ElementTree as ET +import urllib2 + +FILENAMES = [ 'tool_dependencies.xml' ] +ACTION_TYPES = [ 'download_by_url', 'download_file' ] + +def main(): + parser = OptionParser() + parser.add_option( '-d', '--directory', dest='directory', action='store', type="string", default='.', help='Root directory' ) + + ( options, args ) = parser.parse_args() + + for (dirpath, dirnames, filenames) in os.walk( options.directory ): + for filename in filenames: + if filename in FILENAMES: + path = os.path.join( dirpath, filename ) + try: + tree = ET.parse( path ) + root = tree.getroot() + for action_type in ACTION_TYPES: + for element in root.findall( ".//action[@type='%s']" % action_type ): + url = element.text.strip() + try: + urllib2.urlopen( urllib2.Request( url ) ) + except Exception, e: + print "Bad URL '%s' in file '%s': %s" % ( url, path, e ) + except Exception, e: + print "Unable to check XML file '%s': %s" % ( path, e ) + +if __name__ == "__main__": + main() Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org