1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-31 00:39:46 +00:00

bitbake: fetch2/utils: Clean up imports

Move various random imports to the start of the modules as cleanup
and avoid an import issue with bb.process on python 2.6.

(Bitbake rev: aed4adfbe3a591ca4f8e41fb763c9f961bf2e6d5)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2013-05-17 11:40:01 +03:00
parent 0a52bdfb9a
commit 4d3a53ff36
2 changed files with 8 additions and 10 deletions
+4 -7
View File
@@ -28,6 +28,8 @@ BitBake build tools.
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import print_function from __future__ import print_function
import os, re import os, re
import signal
import glob
import logging import logging
import urllib import urllib
import urlparse import urlparse
@@ -38,6 +40,8 @@ import operator
import bb.persist_data, bb.utils import bb.persist_data, bb.utils
import bb.checksum import bb.checksum
from bb import data from bb import data
import bb.process
import subprocess
__version__ = "2" __version__ = "2"
_checksum_cache = bb.checksum.FileChecksumCache() _checksum_cache = bb.checksum.FileChecksumCache()
@@ -584,7 +588,6 @@ def update_stamp(u, ud, d):
open(ud.donestamp, 'w').close() open(ud.donestamp, 'w').close()
def subprocess_setup(): def subprocess_setup():
import signal
# Python installs a SIGPIPE handler by default. This is usually not what # Python installs a SIGPIPE handler by default. This is usually not what
# non-Python subprocesses expect. # non-Python subprocesses expect.
# SIGPIPE errors are known issues with gzip/bash # SIGPIPE errors are known issues with gzip/bash
@@ -653,9 +656,6 @@ def runfetchcmd(cmd, d, quiet = False, cleanup = []):
Optionally remove the files/directories listed in cleanup upon failure Optionally remove the files/directories listed in cleanup upon failure
""" """
import bb.process
import subprocess
# Need to export PATH as binary could be in metadata paths # Need to export PATH as binary could be in metadata paths
# rather than host provided # rather than host provided
# Also include some other variables. # Also include some other variables.
@@ -913,7 +913,6 @@ def get_file_checksums(filelist, pn):
try: try:
checksum = _checksum_cache.get_checksum(f) checksum = _checksum_cache.get_checksum(f)
except OSError as e: except OSError as e:
import traceback
bb.warn("Unable to get checksum for %s SRC_URI entry %s: %s" % (pn, os.path.basename(f), e)) bb.warn("Unable to get checksum for %s SRC_URI entry %s: %s" % (pn, os.path.basename(f), e))
return None return None
return checksum return checksum
@@ -923,7 +922,6 @@ def get_file_checksums(filelist, pn):
checksum = None checksum = None
if '*' in pth: if '*' in pth:
# Handle globs # Handle globs
import glob
for f in glob.glob(pth): for f in glob.glob(pth):
checksum = checksum_file(f) checksum = checksum_file(f)
if checksum: if checksum:
@@ -1133,7 +1131,6 @@ class FetchMethod(object):
raise NoMethodError(url) raise NoMethodError(url)
def unpack(self, urldata, rootdir, data): def unpack(self, urldata, rootdir, data):
import subprocess
iterate = False iterate = False
file = urldata.localpath file = urldata.localpath
+4 -3
View File
@@ -27,6 +27,10 @@ import bb
import bb.msg import bb.msg
import multiprocessing import multiprocessing
import fcntl import fcntl
import subprocess
import glob
import traceback
import errno
from commands import getstatusoutput from commands import getstatusoutput
from contextlib import contextmanager from contextlib import contextmanager
@@ -276,7 +280,6 @@ def better_compile(text, file, realfile, mode = "exec"):
def _print_exception(t, value, tb, realfile, text, context): def _print_exception(t, value, tb, realfile, text, context):
error = [] error = []
try: try:
import traceback
exception = traceback.format_exception_only(t, value) exception = traceback.format_exception_only(t, value)
error.append('Error executing a python function in %s:\n' % realfile) error.append('Error executing a python function in %s:\n' % realfile)
@@ -565,11 +568,9 @@ def remove(path, recurse=False):
if not path: if not path:
return return
if recurse: if recurse:
import subprocess, glob
# shutil.rmtree(name) would be ideal but its too slow # shutil.rmtree(name) would be ideal but its too slow
subprocess.call(['rm', '-rf'] + glob.glob(path)) subprocess.call(['rm', '-rf'] + glob.glob(path))
return return
import os, errno, glob
for name in glob.glob(path): for name in glob.glob(path):
try: try:
os.unlink(name) os.unlink(name)