diff options
author | Peter Wu <lekensteyn@gmail.com> | 2013-08-12 16:20:11 +0200 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2013-08-12 16:20:11 +0200 |
commit | 98d5f7c43312e5cba33d7dca38b3fcffc10cd645 (patch) | |
tree | cb0b5837983e40584df0541a27d3b3639ca51d2b | |
parent | eeb5f89ba0000edf6a5480a38ff6fca958c4ef32 (diff) | |
download | scripts-98d5f7c43312e5cba33d7dca38b3fcffc10cd645.tar.gz |
ftp: ignore ms in mlsd, process path in ftp-get
- ftp-get: when 'get bar.ext' on ftp.example.com/foo/, the directory
'foo' won't be created.
-rwxr-xr-x | ftp-get.py | 9 | ||||
-rwxr-xr-x | ftp-list.py | 1 | ||||
-rwxr-xr-x | ftp.py | 1 |
3 files changed, 8 insertions, 3 deletions
@@ -48,7 +48,10 @@ if len(sys.argv) >= 2: port = int(m.group("port")) if m.group("path") is not None: path = m.group("path") - print("Warning: path component is ignored", file=sys.stderr) + if not path.endswith("/"): + print("Path must be a directory", + file=sys.stderr) + sys.exit(1) if host is None: print("Usage: python", sys.argv[0], @@ -59,11 +62,11 @@ if host is None: files = [] for line in sys.stdin: - file_path = line.rstrip("\r\n") + file_path = line.rstrip("\r\n").lstrip("/") # note: os.path.join(outdir, file_path) throws away if file_path # is absolute. That is *not* intended here. local_file_path = outdir + "/" + file_path - files.append((file_path, local_file_path)) + files.append((path + file_path, local_file_path)) if not files: print("Nothing to do", file=sys.stderr) diff --git a/ftp-list.py b/ftp-list.py index 057b117..8aa073c 100755 --- a/ftp-list.py +++ b/ftp-list.py @@ -126,6 +126,7 @@ def format_type_fact(type): return "?" def dt_from_ftp(timeval): + timeval = timeval.split(".")[0] return datetime.strptime(timeval, "%Y%m%d%H%M%S").replace(tzinfo=timezone.utc) def format_mlsd(name, facts): @@ -93,6 +93,7 @@ def format_type_fact(type): return "?" def dt_from_ftp(timeval): + timeval = timeval.split(".")[0] return datetime.strptime(timeval, "%Y%m%d%H%M%S").replace(tzinfo=timezone.utc) def format_mlsd(name, facts): |