Backed out changeset 2bc8e60fb356 (bug 1425399)for failing browser chrome tests r=backout on a CLOSED TREE

This commit is contained in:
Tiberius Oros 2017-12-21 19:59:37 +02:00
Родитель d0d070b48c
Коммит e38e4387e3
6 изменённых файлов: 35 добавлений и 34 удалений

Просмотреть файл

@ -9,12 +9,12 @@ import os
import sys
import shutil
import tempfile
import urllib2
import zipfile
import hashlib
from xml.dom import minidom
from six import reraise
from six.moves.urllib import request
import mozfile
from mozlog.unstructured import getLogger
@ -113,7 +113,7 @@ class AddonManager(object):
:param target_folder: Folder to store the XPI file in
"""
response = request.urlopen(url)
response = urllib2.urlopen(url)
fd, path = tempfile.mkstemp(suffix='.xpi')
os.write(fd, response.read())
os.close(fd)
@ -177,14 +177,14 @@ class AddonManager(object):
# install addon paths
if addons:
if isinstance(addons, str):
if isinstance(addons, basestring):
addons = [addons]
for addon in set(addons):
self.install_from_path(addon)
# install addon manifests
if manifests:
if isinstance(manifests, str):
if isinstance(manifests, basestring):
manifests = [manifests]
for manifest in manifests:
self.install_from_manifest(manifest)
@ -235,7 +235,7 @@ class AddonManager(object):
.. _query-documentation: https://developer.mozilla.org/en/addons.mozilla.org_%28AMO%29_API_Developers%27_Guide/The_generic_AMO_API # noqa
"""
response = request.urlopen(query)
response = urllib2.urlopen(query)
dom = minidom.parseString(response.read())
for node in dom.getElementsByTagName('install')[0].childNodes:
if node.nodeType == node.TEXT_NODE:
@ -353,7 +353,7 @@ class AddonManager(object):
reraise(AddonFormatError(str(e)), None, sys.exc_info()[2])
# turn unpack into a true/false value
if isinstance(details['unpack'], str):
if isinstance(details['unpack'], basestring):
details['unpack'] = details['unpack'].lower() == 'true'
# If no ID is set, the add-on is invalid

Просмотреть файл

@ -12,8 +12,7 @@ from __future__ import absolute_import
import codecs
import os
import sqlite3
from six.moves.urllib import parse
import urlparse
__all__ = ['MissingPrimaryLocationError', 'MultiplePrimaryLocationsError',
'DEFAULT_PORTS', 'DuplicateLocationError', 'BadPortLocationError',
@ -140,7 +139,7 @@ class ServerLocations(object):
self.add_callback([location])
def add_host(self, host, port='80', scheme='http', options='privileged'):
if isinstance(options, str):
if isinstance(options, basestring):
options = options.split(',')
self.add(Location(scheme, host, port, options))
@ -183,7 +182,7 @@ class ServerLocations(object):
# parse the server url
if '://' not in server:
server = 'http://' + server
scheme, netloc, path, query, fragment = parse.urlsplit(server)
scheme, netloc, path, query, fragment = urlparse.urlsplit(server)
# get the host and port
try:
host, port = netloc.rsplit(':', 1)

Просмотреть файл

@ -11,9 +11,8 @@ import json
import mozfile
import os
import tokenize
from six.moves.configparser import SafeConfigParser as ConfigParser
from six import StringIO
from ConfigParser import SafeConfigParser as ConfigParser
from StringIO import StringIO
__all__ = ('PreferencesReadError', 'Preferences')
@ -65,7 +64,7 @@ class Preferences(object):
with the ''s removed from both sides
"""
if not isinstance(value, str):
if not isinstance(value, basestring):
return value # no op
quote = "'"
if value == 'true':
@ -147,7 +146,7 @@ class Preferences(object):
values = prefs.values()
else:
raise PreferencesReadError("Malformed preferences: %s" % path)
types = (bool, str, int)
types = (bool, basestring, int)
if [i for i in values if not [isinstance(i, j) for j in types]]:
raise PreferencesReadError("Only bool, string, and int values allowed")
return prefs
@ -187,7 +186,7 @@ class Preferences(object):
retval = []
def pref(a, b):
if interpolation and isinstance(b, str):
if interpolation and isinstance(b, basestring):
b = b.format(**interpolation)
retval.append((a, b))
lines = [i.strip().rstrip(';') for i in string.split('\n') if i.strip()]
@ -203,7 +202,7 @@ class Preferences(object):
# de-magic the marker
for index, (key, value) in enumerate(retval):
if isinstance(value, str) and marker in value:
if isinstance(value, basestring) and marker in value:
retval[index] = (key, value.replace(marker, '//'))
return retval
@ -212,7 +211,7 @@ class Preferences(object):
def write(cls, _file, prefs, pref_string='user_pref(%s, %s);'):
"""write preferences to a file"""
if isinstance(_file, str):
if isinstance(_file, basestring):
f = file(_file, 'a')
else:
f = _file
@ -230,5 +229,5 @@ class Preferences(object):
print(pref_string % _pref, file=f)
# close the file if opened internally
if isinstance(_file, str):
if isinstance(_file, basestring):
f.close()

Просмотреть файл

@ -4,11 +4,15 @@
from __future__ import absolute_import
import sys
from setuptools import setup
PACKAGE_NAME = 'mozprofile'
PACKAGE_VERSION = '0.29'
# we only support python 2 right now
assert sys.version_info[0] == 2
deps = ['mozfile >= 1.0',
'mozlog >= 3.0',
'six >= 1.10.0'
@ -23,8 +27,7 @@ setup(name=PACKAGE_NAME,
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules',
],
keywords='mozilla',

Просмотреть файл

@ -65,21 +65,21 @@ http://example.org:80 privileged
# ensure that they're what we expect
self.assertEqual(len(locations), 6)
i = iter(locations)
self.compare_location(next(i), 'http', 'mochi.test', '8888',
self.compare_location(i.next(), 'http', 'mochi.test', '8888',
['primary', 'privileged'])
self.compare_location(next(i), 'http', '127.0.0.1', '80',
self.compare_location(i.next(), 'http', '127.0.0.1', '80',
['privileged'])
self.compare_location(next(i), 'http', '127.0.0.1', '8888',
self.compare_location(i.next(), 'http', '127.0.0.1', '8888',
['privileged'])
self.compare_location(next(i), 'https', 'test', '80', ['privileged'])
self.compare_location(next(i), 'http', 'example.org', '80',
self.compare_location(i.next(), 'https', 'test', '80', ['privileged'])
self.compare_location(i.next(), 'http', 'example.org', '80',
['privileged'])
self.compare_location(next(i), 'http', 'test1.example.org', '8888',
self.compare_location(i.next(), 'http', 'test1.example.org', '8888',
['privileged'])
locations.add_host('mozilla.org')
self.assertEqual(len(locations), 7)
self.compare_location(next(i), 'http', 'mozilla.org', '80',
self.compare_location(i.next(), 'http', 'mozilla.org', '80',
['privileged'])
# test some errors

Просмотреть файл

@ -10,6 +10,7 @@ import os
import shutil
import tempfile
import unittest
import urllib2
import zipfile
import mozunit
@ -21,7 +22,6 @@ import mozlog.unstructured as mozlog
import mozprofile
from addon_stubs import generate_addon, generate_manifest
from six.moves.urllib import error
here = os.path.dirname(os.path.abspath(__file__))
@ -104,7 +104,7 @@ class TestAddonsManager(unittest.TestCase):
# Download from an invalid URL
addon = server.get_url() + 'not_existent.xpi'
self.assertRaises(error.HTTPError,
self.assertRaises(urllib2.HTTPError,
self.am.download, addon, self.tmpdir)
self.assertEqual(os.listdir(self.tmpdir), [])
@ -166,7 +166,7 @@ class TestAddonsManager(unittest.TestCase):
self.am.install_from_path(temp_addon)
# Generate a list of addons installed in the profile
addons_installed = [str(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
addons_installed = [unicode(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
self.profile.profile, 'extensions', 'staged'))]
self.assertEqual(addons_to_install.sort(), addons_installed.sort())
@ -331,7 +331,7 @@ class TestAddonsManager(unittest.TestCase):
self.am.install_from_manifest(temp_manifest)
# Generate a list of addons installed in the profile
addons_installed = [str(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
addons_installed = [unicode(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
self.profile.profile, 'extensions', 'staged'))]
self.assertEqual(addons_installed.sort(), addons_to_install.sort())
@ -371,7 +371,7 @@ class TestAddonsManager(unittest.TestCase):
addon_two = generate_addon('test-addon-2@mozilla.org')
self.am.install_addons(addon_one)
installed_addons = [str(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
installed_addons = [unicode(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
self.profile.profile, 'extensions', 'staged'))]
# Create a new profile based on an existing profile
@ -381,7 +381,7 @@ class TestAddonsManager(unittest.TestCase):
addons=addon_two)
duplicate_profile.addon_manager.clean()
addons_after_cleanup = [str(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
addons_after_cleanup = [unicode(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
duplicate_profile.profile, 'extensions', 'staged'))]
# New addons installed should be removed by clean_addons()
self.assertEqual(installed_addons, addons_after_cleanup)