add unmap_potential_url()
git-svn-id: http://test.kernel.org/svn/autotest/trunk@60 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/bin/autotest_utils.py b/bin/autotest_utils.py
index 855de80..667aac5 100755
--- a/bin/autotest_utils.py
+++ b/bin/autotest_utils.py
@@ -49,12 +49,17 @@
return newfile
raise NameError, "extracting tarball produced no dir"
-
+def is_url(path):
+ if (path.startswith('http://')) or (path.startswith('ftp://')):
+ # should cope with other url types here, but we don't handle them yet
+ return 1
+ return 0
+
def get_file(src, dest):
if (src == dest): # no-op here allows clean overrides in tests
return
# get a file, either from url or local
- if (src.startswith('http://')) or (src.startswith('ftp://')):
+ if (is_url(src)):
print 'PWD: ' + os.getcwd()
print 'Fetching \n\t', src, '\n\t->', dest
try:
@@ -66,6 +71,15 @@
shutil.copyfile(src, dest)
return dest
+
+def unmap_potential_url(src, destdir = '.'):
+ if is_url(src):
+ dest = destdir + '/' + os.path.basename(src)
+ get_file(src, dest)
+ return dest
+ return src
+
+
def basename(path):
i = path.rfind('/');
return path[i+1:]