summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-17 11:40:01 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-17 12:42:08 +0300
commit4d3a53ff36526669fcde7b64dc947e8d76aba56b (patch)
tree659ef2923ef2123a008394fefc066cc69585aaa0 /bitbake
parent0a52bdfb9a63a0cc5654406f98b5bbcd2de3aad8 (diff)
downloadpoky-4d3a53ff36526669fcde7b64dc947e8d76aba56b.tar.gz
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>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py11
-rw-r--r--bitbake/lib/bb/utils.py7
2 files changed, 8 insertions, 10 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index dd1cc932d4..9029a5a83c 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -28,6 +28,8 @@ BitBake build tools.
28from __future__ import absolute_import 28from __future__ import absolute_import
29from __future__ import print_function 29from __future__ import print_function
30import os, re 30import os, re
31import signal
32import glob
31import logging 33import logging
32import urllib 34import urllib
33import urlparse 35import urlparse
@@ -38,6 +40,8 @@ import operator
38import bb.persist_data, bb.utils 40import bb.persist_data, bb.utils
39import bb.checksum 41import bb.checksum
40from bb import data 42from bb import data
43import bb.process
44import subprocess
41 45
42__version__ = "2" 46__version__ = "2"
43_checksum_cache = bb.checksum.FileChecksumCache() 47_checksum_cache = bb.checksum.FileChecksumCache()
@@ -584,7 +588,6 @@ def update_stamp(u, ud, d):
584 open(ud.donestamp, 'w').close() 588 open(ud.donestamp, 'w').close()
585 589
586def subprocess_setup(): 590def subprocess_setup():
587 import signal
588 # Python installs a SIGPIPE handler by default. This is usually not what 591 # Python installs a SIGPIPE handler by default. This is usually not what
589 # non-Python subprocesses expect. 592 # non-Python subprocesses expect.
590 # SIGPIPE errors are known issues with gzip/bash 593 # SIGPIPE errors are known issues with gzip/bash
@@ -653,9 +656,6 @@ def runfetchcmd(cmd, d, quiet = False, cleanup = []):
653 Optionally remove the files/directories listed in cleanup upon failure 656 Optionally remove the files/directories listed in cleanup upon failure
654 """ 657 """
655 658
656 import bb.process
657 import subprocess
658
659 # Need to export PATH as binary could be in metadata paths 659 # Need to export PATH as binary could be in metadata paths
660 # rather than host provided 660 # rather than host provided
661 # Also include some other variables. 661 # Also include some other variables.
@@ -913,7 +913,6 @@ def get_file_checksums(filelist, pn):
913 try: 913 try:
914 checksum = _checksum_cache.get_checksum(f) 914 checksum = _checksum_cache.get_checksum(f)
915 except OSError as e: 915 except OSError as e:
916 import traceback
917 bb.warn("Unable to get checksum for %s SRC_URI entry %s: %s" % (pn, os.path.basename(f), e)) 916 bb.warn("Unable to get checksum for %s SRC_URI entry %s: %s" % (pn, os.path.basename(f), e))
918 return None 917 return None
919 return checksum 918 return checksum
@@ -923,7 +922,6 @@ def get_file_checksums(filelist, pn):
923 checksum = None 922 checksum = None
924 if '*' in pth: 923 if '*' in pth:
925 # Handle globs 924 # Handle globs
926 import glob
927 for f in glob.glob(pth): 925 for f in glob.glob(pth):
928 checksum = checksum_file(f) 926 checksum = checksum_file(f)
929 if checksum: 927 if checksum:
@@ -1133,7 +1131,6 @@ class FetchMethod(object):
1133 raise NoMethodError(url) 1131 raise NoMethodError(url)
1134 1132
1135 def unpack(self, urldata, rootdir, data): 1133 def unpack(self, urldata, rootdir, data):
1136 import subprocess
1137 iterate = False 1134 iterate = False
1138 file = urldata.localpath 1135 file = urldata.localpath
1139 1136
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 2e10fc24dd..1ecc44a01a 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -27,6 +27,10 @@ import bb
27import bb.msg 27import bb.msg
28import multiprocessing 28import multiprocessing
29import fcntl 29import fcntl
30import subprocess
31import glob
32import traceback
33import errno
30from commands import getstatusoutput 34from commands import getstatusoutput
31from contextlib import contextmanager 35from contextlib import contextmanager
32 36
@@ -276,7 +280,6 @@ def better_compile(text, file, realfile, mode = "exec"):
276def _print_exception(t, value, tb, realfile, text, context): 280def _print_exception(t, value, tb, realfile, text, context):
277 error = [] 281 error = []
278 try: 282 try:
279 import traceback
280 exception = traceback.format_exception_only(t, value) 283 exception = traceback.format_exception_only(t, value)
281 error.append('Error executing a python function in %s:\n' % realfile) 284 error.append('Error executing a python function in %s:\n' % realfile)
282 285
@@ -565,11 +568,9 @@ def remove(path, recurse=False):
565 if not path: 568 if not path:
566 return 569 return
567 if recurse: 570 if recurse:
568 import subprocess, glob
569 # shutil.rmtree(name) would be ideal but its too slow 571 # shutil.rmtree(name) would be ideal but its too slow
570 subprocess.call(['rm', '-rf'] + glob.glob(path)) 572 subprocess.call(['rm', '-rf'] + glob.glob(path))
571 return 573 return
572 import os, errno, glob
573 for name in glob.glob(path): 574 for name in glob.glob(path):
574 try: 575 try:
575 os.unlink(name) 576 os.unlink(name)