]> code.ossystems Code Review - openembedded-core.git/commitdiff
*: use utils.remove() some more
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Mon, 10 Jan 2011 22:05:19 +0000 (23:05 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 12 Jan 2011 13:47:14 +0000 (13:47 +0000)
(Bitbake rev: d3489b141cac1197324661680fe38b8a88bc49b4)

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/build.py
bitbake/lib/bb/fetch/__init__.py
bitbake/lib/bb/fetch/osc.py
bitbake/lib/bb/fetch2/__init__.py
bitbake/lib/bb/utils.py

index f127796c077f290c4e51dbe6564a4603e4ea7f84..bd9b93a12d09b1b322c5aa4adc2ca5c2d4bda6c4 100644 (file)
@@ -405,9 +405,8 @@ def make_stamp(task, d, file_name = None):
     stamp = stamp_internal(task, d, file_name)
     # Remove the file and recreate to force timestamp
     # change on broken NFS filesystems
-    if os.access(stamp, os.F_OK):
-        os.remove(stamp)
     if stamp:
+        bb.utils.remove(stamp)
         f = open(stamp, "w")
         f.close()
 
@@ -417,8 +416,7 @@ def del_stamp(task, d, file_name = None):
     (d can be a data dict or dataCache)
     """
     stamp = stamp_internal(task, d, file_name)
-    if os.access(stamp, os.F_OK):
-        os.remove(stamp)
+    bb.utils.remove(stamp)
 
 def stampfile(taskname, d):
     return stamp_internal(taskname, d, None)
index 07eb77dbfc3134115112e306bdefd657bfa755ef..cd9410d04ca979a6f5973ab356d5c6140f96df53 100644 (file)
@@ -31,6 +31,7 @@ import logging
 import bb
 from   bb import data
 from   bb import persist_data
+from   bb import utils
 
 logger = logging.getLogger("BitBake.Fetch")
 
@@ -217,12 +218,6 @@ def init(urls, d, setup = True):
 def mirror_from_string(data):
     return [ i.split() for i in (data or "").replace('\\n','\n').split('\n') if i ]
 
-def removefile(f):
-    try:
-        os.remove(f)
-    except:
-        pass
-
 def verify_checksum(u, ud, d):
     """
     verify the MD5 and SHA256 checksum for downloaded src
@@ -293,7 +288,7 @@ def go(d, urls = None):
                 localpath = ud.localpath
             except FetchError:
                 # Remove any incomplete file
-                removefile(ud.localpath)
+                bb.utils.remove(ud.localpath)
                 # Finally, try fetching uri, u, from MIRRORS
                 mirrors = mirror_from_string(bb.data.getVar('MIRRORS', d, True))
                 localpath = try_mirrors (d, u, mirrors)
@@ -517,7 +512,7 @@ def try_mirrors(d, uri, mirrors, check = False, force = False):
                 import sys
                 (type, value, traceback) = sys.exc_info()
                 logger.debug(2, "Mirror fetch failure: %s", value)
-                removefile(ud.localpath)
+                bb.utils.remove(ud.localpath)
                 continue
     return None
 
index 26820967a3549c4769635bfee0f332b0036b41a1..8e0423d7627c751c27d7504dba1951709f66323b 100644 (file)
@@ -11,6 +11,7 @@ import  sys
 import logging
 import  bb
 from    bb       import data
+from    bb       import utils
 from    bb.fetch import Fetch
 from    bb.fetch import FetchError
 from    bb.fetch import MissingParameterError
@@ -123,8 +124,7 @@ class Osc(Fetch):
         """
 
         config_path = os.path.join(data.expand('${OSCDIR}', d), "oscrc")
-        if (os.path.exists(config_path)):
-            os.remove(config_path)
+        bb.utils.remove(config_path)
 
         f = open(config_path, 'w')
         f.write("[general]\n")
index 751e514121ef4996442bd599a68827e9e4275041..2aeb8b8fe14f84e8f4d26c7e0475e816dc853888 100644 (file)
@@ -31,6 +31,7 @@ import logging
 import bb
 from   bb import data
 from   bb import persist_data
+from   bb import utils
 
 logger = logging.getLogger("BitBake.Fetch")
 
@@ -217,12 +218,6 @@ def init(urls, d, setup = True):
 def mirror_from_string(data):
     return [ i.split() for i in (data or "").replace('\\n','\n').split('\n') if i ]
 
-def removefile(f):
-    try:
-        os.remove(f)
-    except:
-        pass
-
 def verify_checksum(u, ud, d):
     """
     verify the MD5 and SHA256 checksum for downloaded src
@@ -293,7 +288,7 @@ def go(d, urls = None):
                 localpath = ud.localpath
             except FetchError:
                 # Remove any incomplete file
-                removefile(ud.localpath)
+                bb.utils.remove(ud.localpath)
                 # Finally, try fetching uri, u, from MIRRORS
                 mirrors = mirror_from_string(bb.data.getVar('MIRRORS', d, True))
                 localpath = try_mirrors (d, u, mirrors)
@@ -503,7 +498,7 @@ def try_mirrors(d, uri, mirrors, check = False, force = False):
                 import sys
                 (type, value, traceback) = sys.exc_info()
                 logger.debug(2, "Mirror fetch failure: %s", value)
-                removefile(ud.localpath)
+                bb.utils.remove(ud.localpath)
                 continue
     return None
 
index 5b3710f84fbd048976184e2c176cb1219a6e0602..40b5f2f3dcf2d79ecce43c2a4060084e3c8ebcd8 100644 (file)
@@ -582,10 +582,12 @@ def build_environment(d):
 
 def remove(path, recurse=False):
     """Equivalent to rm -f or rm -rf"""
+    if not path:
+        return
     import os, errno, shutil
     try:
         os.unlink(path)
-    except OSError, exc:
+    except OSError as exc:
         if recurse and exc.errno == errno.EISDIR:
             shutil.rmtree(path)
         elif exc.errno != errno.ENOENT: