Merge branch 'feature-endpoints' into release-0.9
[kamaki] / kamaki / cli / commands / pithos.py
index 3bd0667..726cf22 100644 (file)
@@ -1091,7 +1091,9 @@ class file_upload(_file_container_command, _optional_output_cmd):
                 for f in files:
                     fpath = path.join(top, f)
                     if path.isfile(fpath):
-                        yield open(fpath, 'rb'), '%s/%s' % (rel_path, f)
+                        rel_path = rel_path.replace(path.sep, '/')
+                        pathfix = f.replace(path.sep, '/')
+                        yield open(fpath, 'rb'), '%s/%s' % (rel_path, pathfix)
                     else:
                         print('%s is not a regular file' % fpath)
         else:
@@ -1100,7 +1102,7 @@ class file_upload(_file_container_command, _optional_output_cmd):
             try:
                 robj = self.client.get_object_info(rpath)
                 if remote_path and self._is_dir(robj):
-                    rpath += '/%s' % short_path
+                    rpath += '/%s' % (short_path.replace(path.sep, '/'))
                     self.client.get_object_info(rpath)
                 if not self['overwrite']:
                     raiseCLIError(
@@ -1278,7 +1280,7 @@ class file_download(_file_container_command):
                 raiseCLIError(
                     'Illegal download: Remote object %s is a directory' % (
                         self.path),
-                    details=['To download a directory, try --recursive'])
+                    details=['To download a directory, try --recursive or -R'])
             if '/' in self.path.strip('/') and not local_path:
                 raiseCLIError(
                     'Illegal download: remote object %s contains "/"' % (
@@ -1292,8 +1294,7 @@ class file_download(_file_container_command):
             if self.path:
                 raiseCLIError(
                     'No matching path %s on container %s' % (
-                        self.path,
-                        self.container),
+                        self.path, self.container),
                     details=[
                         'To list the contents of %s, try:' % self.container,
                         '   /file list %s' % self.container])
@@ -1306,7 +1307,9 @@ class file_download(_file_container_command):
         lprefix = path.abspath(local_path or path.curdir)
         if path.isdir(lprefix):
             for rpath, remote_is_dir in remotes:
-                lpath = '/%s/%s' % (lprefix.strip('/'), rpath.strip('/'))
+                lpath = path.sep.join([
+                    lprefix[:-1] if lprefix.endswith(path.sep) else lprefix,
+                    rpath.strip('/').replace('/', path.sep)])
                 if remote_is_dir:
                     if path.exists(lpath) and path.isdir(lpath):
                         continue