Bug 1176642 - Defer import of urllib2; r=chmanchester

This prevents 8 module imports from occurring at mach startup time.

As part of this, I discovered a redundant import of "sys" and eliminated
it.
This commit is contained in:
Gregory Szorc 2015-06-25 12:12:15 -07:00
parent f9d09584a6
commit 63296e8c59
3 changed files with 6 additions and 4 deletions

View File

@ -10,7 +10,6 @@ import os
import json import json
import copy import copy
import sys import sys
import urllib2
from mach.decorators import ( from mach.decorators import (
CommandArgument, CommandArgument,
@ -58,6 +57,7 @@ def docker_image(name):
return '{}/{}:{}'.format(repository, name, version) return '{}/{}:{}'.format(repository, name, version)
def get_task(task_id): def get_task(task_id):
import urllib2
return json.load(urllib2.urlopen("https://queue.taskcluster.net/v1/task/" + task_id)) return json.load(urllib2.urlopen("https://queue.taskcluster.net/v1/task/" + task_id))

View File

@ -10,7 +10,6 @@ import argparse
import os import os
import shutil import shutil
import sys import sys
import urllib2
from mozlog import structured from mozlog import structured
@ -322,6 +321,8 @@ class B2GXPCShellRunner(MozbuildObject):
self.bin_dir = os.path.join(self.distdir, 'bin') self.bin_dir = os.path.join(self.distdir, 'bin')
def _download_busybox(self, b2g_home, emulator): def _download_busybox(self, b2g_home, emulator):
import urllib2
target_device = 'generic' target_device = 'generic'
if emulator == 'x86': if emulator == 'x86':
target_device = 'generic_x86' target_device = 'generic_x86'

View File

@ -8,7 +8,6 @@ import sys
import os import os
import stat import stat
import platform import platform
import urllib2
import errno import errno
from mach.decorators import ( from mach.decorators import (
@ -219,8 +218,8 @@ class PastebinProvider(object):
help='Specify the file to upload to pastebin.mozilla.org') help='Specify the file to upload to pastebin.mozilla.org')
def pastebin(self, language, poster, duration, file): def pastebin(self, language, poster, duration, file):
import sys
import urllib import urllib
import urllib2
URL = 'https://pastebin.mozilla.org/' URL = 'https://pastebin.mozilla.org/'
@ -299,6 +298,8 @@ class FormatProvider(MachCommandBase):
@CommandArgument('--show', '-s', action = 'store_true', @CommandArgument('--show', '-s', action = 'store_true',
help = 'Show diff output on instead of applying changes') help = 'Show diff output on instead of applying changes')
def clang_format(self, show=False): def clang_format(self, show=False):
import urllib2
plat = platform.system() plat = platform.system()
fmt = plat.lower() + "/clang-format-3.5" fmt = plat.lower() + "/clang-format-3.5"
fmt_diff = "clang-format-diff-3.5" fmt_diff = "clang-format-diff-3.5"