[_modules] restore from URL or file
authorArthur Lutz <arthur.lutz@logilab.fr>
Thu, 11 Feb 2016 14:30:48 +0100
changeset 71 6b48c4f8656e
parent 70 1f0307851fd5
child 72 e30b533a587c
[_modules] restore from URL or file
_modules/cubicweb.py
--- a/_modules/cubicweb.py	Thu Feb 11 14:30:27 2016 +0100
+++ b/_modules/cubicweb.py	Thu Feb 11 14:30:48 2016 +0100
@@ -298,7 +298,13 @@
     try:
         os.chdir(tmpdir)
         dst = os.path.join(tmpdir, os.path.basename(dumpfile))
-        out = __salt__['cp.get_url'](dumpfileurl, dst)
+        if dumpfileurl.startswith('http') or dumpfileurl.startswith('salt'):
+            out = __salt__['cp.get_url'](dumpfileurl, dst)
+        else:
+            # TODO sanitize/check variables 
+            # TODO there must be a better way, cp.get_file with file:// ? 
+            out = __salt__['cmd.run']('mkdir {0}'.format(tmpdir))
+            out = __salt__['cmd.run']('cp {0} {1}'.format(dumpfileurl, dst))
 
         ret['cp'] = out
         ret['tmpdir'] = tmpdir