[U-Boot] [PATCH] fill_scrapyard.py: Pass a directory to tempfile.mkstemp()

In some cases os.rename() may later fail due to "Cross-device link" issues. The easy way to deal with this is to simply make our temporary file here as well rather than TMPDIR.
Cc: Masahiro Yamada yamada.masahiro@socionext.com Signed-off-by: Tom Rini trini@konsulko.com --- scripts/fill_scrapyard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/fill_scrapyard.py b/scripts/fill_scrapyard.py index 9a94354..cd630ef 100755 --- a/scripts/fill_scrapyard.py +++ b/scripts/fill_scrapyard.py @@ -119,7 +119,7 @@ class TmpFile:
def __init__(self): """Constructor - create a temporary file""" - fd, self.filename = tempfile.mkstemp() + fd, self.filename = tempfile.mkstemp(dir='.') self.file = os.fdopen(fd, 'w')
def __del__(self):

Hi Tom,
2015-10-19 23:56 GMT+09:00 Tom Rini trini@konsulko.com:
In some cases os.rename() may later fail due to "Cross-device link" issues. The easy way to deal with this is to simply make our temporary file here as well rather than TMPDIR.
Cc: Masahiro Yamada yamada.masahiro@socionext.com Signed-off-by: Tom Rini trini@konsulko.com
scripts/fill_scrapyard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/fill_scrapyard.py b/scripts/fill_scrapyard.py index 9a94354..cd630ef 100755 --- a/scripts/fill_scrapyard.py +++ b/scripts/fill_scrapyard.py @@ -119,7 +119,7 @@ class TmpFile:
def __init__(self): """Constructor - create a temporary file"""
fd, self.filename = tempfile.mkstemp()
fd, self.filename = tempfile.mkstemp(dir='.') self.file = os.fdopen(fd, 'w')
def __del__(self):
I personally prefer replacing "os.rename(tmpfile.filename, DOC)" with "shutil.move(tmpfile.filename, DOC)".

On Tue, Oct 20, 2015 at 11:10:23AM +0900, Masahiro Yamada wrote:
Hi Tom,
2015-10-19 23:56 GMT+09:00 Tom Rini trini@konsulko.com:
In some cases os.rename() may later fail due to "Cross-device link" issues. The easy way to deal with this is to simply make our temporary file here as well rather than TMPDIR.
Cc: Masahiro Yamada yamada.masahiro@socionext.com Signed-off-by: Tom Rini trini@konsulko.com
scripts/fill_scrapyard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/fill_scrapyard.py b/scripts/fill_scrapyard.py index 9a94354..cd630ef 100755 --- a/scripts/fill_scrapyard.py +++ b/scripts/fill_scrapyard.py @@ -119,7 +119,7 @@ class TmpFile:
def __init__(self): """Constructor - create a temporary file"""
fd, self.filename = tempfile.mkstemp()
fd, self.filename = tempfile.mkstemp(dir='.') self.file = os.fdopen(fd, 'w')
def __del__(self):
I personally prefer replacing "os.rename(tmpfile.filename, DOC)" with "shutil.move(tmpfile.filename, DOC)".
Yeah, I saw that too but wasn't sure if we wanted to depend on that package.
participants (2)
-
Masahiro Yamada
-
Tom Rini