Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hakaishi opened this issue Nov 6, 2020 · 6 comments · Fixed by #142

Comments

@hakaishi
Copy link

hakaishi commented Nov 6, 2020

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
Copy link
Author

hakaishi commented Nov 6, 2020

No such trouble under Ubuntu (python 3.8.5 though)

@pkittenis
Copy link
Member

pkittenis commented Nov 8, 2020

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

@hakaishi
Copy link
Author

hakaishi commented Nov 8, 2020

okay... paramiko does not have this limitation.

@hakaishi
Copy link
Author

hakaishi commented Nov 8, 2020

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 pkittenis reopened this Dec 1, 2020
@pkittenis pkittenis changed the title Windows - FileInfo object has no attribute XXX error Check enabling fileinfo attributes on Windows - (FileInfo object has no attribute XXX error) Dec 1, 2020
@pkittenis
Copy link
Member

pkittenis commented Dec 1, 2020

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
Copy link
Member

Resolved by #142
In 0.26.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants