ParallelSSH / ssh2-python

Python bindings for libssh2 C library.
https://parallel-ssh.org
GNU Lesser General Public License v2.1
228 stars 72 forks source link

Check enabling fileinfo attributes on Windows - (FileInfo object has no attribute XXX error) #131

Closed hakaishi closed 3 years ago

hakaishi commented 3 years ago

OS: Windows 10 64 bit Python: 3.8.4 (64 bit) ssh2-python: 0.23.0 Code snippet:

res = connection.session.scp_recv2(file)
print(res[1], dir(res[1]))
with open(join(destination_, file_), "wb+") as f:
    size = 0
    while True:
        siz, tbuff = res[0].read()
        if siz < 0:
            print("error code:", siz)
            res[0].close()
            break
        size += siz
        if size > res[1].st_size:
            sz = res[1].st_size - size
            f.write(tbuff[:sz])
        else:
            f.write(tbuff)
        if size >= res[1].st_size:
            res[0].close()
            break
utime(join(destination_, file_), (res[1].st_atime, res[1].st_mtime))

print result: image

hakaishi commented 3 years ago

No such trouble under Ubuntu (python 3.8.5 though)

pkittenis commented 3 years ago

Only st_size and st_mode are supported by libssh2 on Windows due to Windows limitations.

hakaishi commented 3 years ago

okay... paramiko does not have this limitation.

hakaishi commented 3 years ago

Are you speaking generally? SSH2 does support it using SFTP. Using stat/fstat gives me atime/mtime etc even under Windows.

No one seems to mention that SSH2 does not support mtime etc. when running on Windows, are you really sure about this?

pkittenis commented 3 years ago

If I recall correctly the compiler on windows did not understand the types libssh2 uses for those attributes. This may have been an old compiler for python 2.

Needs retesting on windows.

pkittenis commented 3 years ago

Resolved by #142 In 0.26.0.