Bug 1295948 - fixing method so it works with encoded URLs, changed return method r?aki
MozReview-Commit-ID: J9kBeUBDtOh
--- a/testing/mozharness/mozharness/mozilla/testing/testbase.py
+++ b/testing/mozharness/mozharness/mozilla/testing/testbase.py
@@ -8,17 +8,17 @@
import copy
import os
import platform
import pprint
import re
import urllib2
import json
import socket
-from urlparse import urlparse
+from urlparse import urlparse, ParseResult
from mozharness.base.errors import BaseErrorList
from mozharness.base.log import FATAL, WARNING
from mozharness.base.python import (
ResourceMonitoringMixin,
VirtualenvMixin,
virtualenv_config_options,
)
@@ -157,31 +157,26 @@ class TestingMixin(VirtualenvMixin, Buil
if self.test_packages_url:
reference_url = self.test_packages_url
elif self.installer_url:
reference_url = self.installer_url
else:
self.fatal("Can't figure out build directory urls without an installer_url "
"or test_packages_url!")
- #first we decode url
reference_url = urllib2.unquote(reference_url)
-
- #now we parse url so we can extract path
- reference_url = urlparse(reference_url)
+ parts = list(urlparse(reference_url))
- #now we should extract path to string so we can find last slash
- reference_url = reference_url.path
+ last_slash = parts[2].rfind('/')
+ parts[2] = '/'.join([parts[2][:last_slash], file_name])
- # and now this should work even with encoded urls ( which are not encoded anymore
- # when they come by the time they come here
- last_slash = reference_url.rfind('/')
- base_url = reference_url[:last_slash]
+ url = ParseResult(*parts).geturl()
- return '%s/%s' % (base_url, file_name)
+
+ return '%s' %url
def query_prefixed_build_dir_url(self, suffix):
"""Resolve a file name prefixed with platform and build details to a potential url
in the build upload directory where that file can be found.
"""
if self.test_packages_url:
reference_suffixes = ['.test_packages.json']
reference_url = self.test_packages_url