Skip to contentSkip to conversation

lib/oeqa/decorators: handle broken links when creating new symlink

PATCH In review Ross Burton 2 participants 4 messages Jul 22, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/oeqa/decorators: handle broken links when creating new symlink

When checking if a link exists before creating it, use os.path.lexists() as otherwise os.path.exists() on a broken link will return False.

---
 meta/lib/oeqa/utils/decorators.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oeqa/utils/decorators.py +1 -1
index 0b23565..615fd95 100644
@@ -190,7 +190,7 @@ def LogResults(original_class):
             local_log.results("Testcase "+str(test_case)+": PASSED")
 
         # Create symlink to the current log
-        if os.path.exists(linkfile):
+        if os.path.lexists(linkfile):
             os.remove(linkfile)
         os.symlink(logfile, linkfile)
 
Signature · 1 line
2.8.1
#1 lore raw
Quoted 13 lines · Ross Burton

When checking if a link exists before creating it, use os.path.lexists() as otherwise os.path.exists() on a broken link will return False.

---
 meta/lib/oeqa/utils/decorators.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oeqa/utils/decorators.py +0 -0
index 0b23565..615fd95 100644

meta/lib/oeqa/utils/decorators.py def LogResults(original_class): · line 193

Quoted 5 lines
meta/lib/oeqa/utils/decorators.py +1 -1
@@ -190,7 +190,7 @@ def LogResults(original_class):
             local_log.results("Testcase "+str(test_case)+": PASSED")
 
         # Create symlink to the current log
-        if os.path.exists(linkfile):
+        if os.path.lexists(linkfile):

I think it will fail if the existing file is not a symlink ?

Quoted 11 lines
meta/lib/oeqa/utils/decorators.py +0 -1
             os.remove(linkfile)
         os.symlink(logfile, linkfile)
 
--

2.8.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#2 lore raw
Quoted 2 lines · Khem Raj

I think it will fail if the existing file is not a symlink ?

No, the only difference between lexists and exists is that exists follows links. So in the case of a broken link, exists returns false.

Ross

#3 lore raw

Yes ok

Quoted 12 lines · Ross
Quoted 2 lines · Khem Raj

I think it will fail if the existing file is not a symlink ?

No, the only difference between lexists and exists is that exists follows links. So in the case of a broken link, exists returns false.

Ross