1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-18 20:11:20 +00:00

getters: fix some issues

- get_by_extension was comparing the expected extension to the entire
  tuple returned by os.path.splitext(), rather than just the extension
  part.
- UserDirectory getter was looking in the root dependencies directory,
  rather than the subdirectory for the owner.
- Filer getter was not handling non-existing paths properly.
This commit is contained in:
Sergei Trofimov 2017-03-28 09:44:24 +01:00
parent 4006e998c2
commit fed454fc74

View File

@ -52,7 +52,7 @@ def get_by_extension(path, ext):
found = []
for entry in os.listdir(path):
entry_ext = os.path.splitext(entry)
entry_ext = os.path.splitext(entry)[1]
if entry_ext == ext:
found.append(os.path.join(path, entry))
return found
@ -112,7 +112,8 @@ class UserDirectory(ResourceGetter):
def get(self, resource):
basepath = settings.dependencies_directory
return get_from_location(basepath, resource)
directory = _d(os.path.join(basepath, resource.owner.name))
return get_from_location(directory, resource)
class Http(ResourceGetter):
@ -318,7 +319,9 @@ class Filer(ResourceGetter):
result = get_from_location(local_path, resource)
if result:
return result
if remote_path:
if not os.path.exists(local_path):
return None
if os.path.exists(remote_path):
# Didn't find it cached locally; now check the remoted
result = get_from_location(remote_path, resource)
if not result: