def downloadProjectFromDvid(cls, dvid_key_url): # By convention, command-line users specify the location of the project # keyvalue data using the same format that the DVID API itself uses. url_format = "^protocol://hostname/api/node/uuid/kv_instance_name(\\?/key/keyname)?" for field in ['protocol', 'hostname', 'uuid', 'kv_instance_name', 'keyname']: url_format = url_format.replace( field, '(?P<' + field + '>[^?]+)' ) match = re.match( url_format, dvid_key_url ) if not match: # DVID is the only url-based format we support right now. # So if it looks like the user gave a URL that isn't a valid DVID node, then error. raise RuntimeError("Invalid URL format for DVID key-value data: {}".format(projectFilePath)) fields = match.groupdict() projectFilePath = ProjectManager.downloadProjectFromDvid( fields['hostname'], fields['uuid'], fields['kv_instance_name'], fields['keyname'] ) return projectFilePath
def downloadProjectFromDvid(cls, dvid_key_url): dvid_key_url = str(dvid_key_url) # By convention, command-line users specify the location of the project # keyvalue data using the same format that the DVID API itself uses. url_format = "^protocol://hostname/api/node/uuid/kv_instance_name(/key/keyname)?" for field in ["protocol", "hostname", "uuid", "kv_instance_name", "keyname"]: url_format = url_format.replace(field, "(?P<" + field + ">[^?/]+)") match = re.match(url_format, dvid_key_url) if not match: # DVID is the only url-based format we support right now. # So if it looks like the user gave a URL that isn't a valid DVID node, then error. raise RuntimeError("Invalid URL format for DVID key-value data: {}".format(projectFilePath)) fields = match.groupdict() projectFilePath = ProjectManager.downloadProjectFromDvid( fields["hostname"], fields["uuid"], fields["kv_instance_name"], fields["keyname"] ) return projectFilePath