Skip to content

Instantly share code, notes, and snippets.

@bitprophet
Created August 20, 2011 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitprophet/a3dfba88d1f72dc23dba to your computer and use it in GitHub Desktop.
Save bitprophet/a3dfba88d1f72dc23dba to your computer and use it in GitHub Desktop.
--- operations.py Thu Jan 15 03:14:12 1970
+++ operations.py Thu Jan 15 03:14:12 1970
@@ -9,6 +9,7 @@
import re
import stat
import subprocess
+import posixpath
import sys
import time
from glob import glob
@@ -567,7 +568,7 @@
# Otherwise, be relative to remote home directory (SFTP server's
# '.')
else:
- remote_path = os.path.join(home, remote_path)
+ remote_path = posixpath.join(home, remote_path)
# Track final local destination files so we can return a list
local_files = []
--- sftp.py Thu Jan 15 03:14:12 1970
+++ sftp.py Thu Jan 15 03:14:12 1970
@@ -4,6 +4,7 @@
import os
import stat
import tempfile
+import posixpath
from fnmatch import filter as fnfilter
from fabric.state import output, connections, env
@@ -57,7 +58,7 @@
s = '/'
ret = [dirpart.rstrip(s) + s + name.lstrip(s) for name in names]
if not win32:
- ret = [os.path.join(dirpart, name) for name in names]
+ ret = [posixpath.join(dirpart, name) for name in names]
return ret
@@ -182,8 +183,8 @@
# Download any files in current directory
for f in files:
# Construct full and relative remote paths to this file
- rpath = os.path.join(context, f)
- rremote = os.path.join(rcontext, f)
+ rpath = posixpath.join(context, f)
+ rremote = posixpath.join(rcontext, f)
# If local_path isn't using a format string that expands to
# include its remote path, we need to add it here.
if "%(path)s" not in local_path \
@@ -205,12 +206,12 @@
pre = pre if pre else ''
if local_is_path and self.isdir(remote_path):
basename = os.path.basename(local_path)
- remote_path = os.path.join(remote_path, basename)
+ remote_path = posixpath.join(remote_path, basename)
if output.running:
print("[%s] put: %s -> %s" % (
env.host_string,
local_path if local_is_path else '<file obj>',
- os.path.join(pre, remote_path)
+ posixpath.join(pre, remote_path)
))
# When using sudo, "bounce" the file through a guaranteed-unique file
# path in the default remote CWD (which, typically, the login user will
@@ -266,19 +267,19 @@
for context, dirs, files in os.walk(local_path):
rcontext = context.replace(strip, '', 1)
rcontext = rcontext.lstrip('/')
- rcontext = os.path.join(remote_path, rcontext)
+ rcontext = posixpath.join(remote_path, rcontext)
if not self.exists(rcontext):
self.mkdir(rcontext, use_sudo)
for d in dirs:
- n = os.path.join(rcontext,d)
+ n = posixpath.join(rcontext,d)
if not self.exists(n):
self.mkdir(n, use_sudo)
for f in files:
local_path = os.path.join(context,f)
- n = os.path.join(rcontext,f)
+ n = posixpath.join(rcontext,f)
p = self.put(local_path, n, use_sudo, mirror_local_mode, mode,
True)
remote_paths.append(p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment