Skip to content
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

Convert port to string for SCP command building #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jhollowe
Copy link

If the port is an int, scp fails due to scp_command's final b_list trying to convert the int to a string which does not work.

This mirrors what ssh_command does.

e.g. with a port number (before fix)

>>> ret = conn.scp(("test.txt",), target="/root/test.txt")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/openssh_wrapper.py", line 219, in scp
    scp_command = self.scp_command(filenames, target)
  File "/usr/local/lib/python3.7/site-packages/openssh_wrapper.py", line 372, in scp_command
    return b_list(cmd)
  File "/usr/local/lib/python3.7/site-packages/openssh_wrapper.py", line 46, in b_list
    return [b(item) for item in items]
  File "/usr/local/lib/python3.7/site-packages/openssh_wrapper.py", line 46, in <listcomp>
    return [b(item) for item in items]
  File "/usr/local/lib/python3.7/site-packages/openssh_wrapper.py", line 30, in b
    return string.encode('utf-8')
AttributeError: 'int' object has no attribute 'encode'

@jhollowe
Copy link
Author

PR #13 is better, I just wanted to put in a quick fix and draw attention to this issue and that its solution is easy to implement.

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

Successfully merging this pull request may close these issues.

1 participant