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

winrm-exec.py Errors #27

Closed
hs-hub-world opened this issue May 1, 2019 · 21 comments
Closed

winrm-exec.py Errors #27

hs-hub-world opened this issue May 1, 2019 · 21 comments

Comments

@hs-hub-world
Copy link
Contributor

Hi, with the latest release of py-winrm-plugin I am seeing these errors when executing PS scripts.
Note, I rolled back to previous version 2.0.0 and that works fine.

Hope the image provides enough data.

image

Thanks,
HS

@ltamaster
Copy link
Contributor

Hi @hs-hub-world:

Can you share some info about your environment?

  • python version
  • windows remote version
  • an example of your script if it is possible.

Thanks
Luis

@hs-hub-world
Copy link
Contributor Author

Hello @ltamaster

Python version = 2.7.5
PIP PyWinrM = pywinrm (0.3.0)

sorry I don't have the example to share at the moment. I'll have to reinstall the latest version of pywinrm to recreate some examples. I'll try to do it later this week.

Thank you
HS

@ltamaster
Copy link
Contributor

no problem, which is your remote windows version?

@hs-hub-world
Copy link
Contributor Author

hs-hub-world commented May 6, 2019

Windows 2016

PS version:
image

@ltamaster
Copy link
Contributor

I wasn't able to reproduce it with python 2.7.10 and a Windows Server 2012.
Checking it with 2.7.5

@hs-hub-world
Copy link
Contributor Author

sorry I had a typo, I update the post it's Win version 2016

@ltamaster
Copy link
Contributor

ltamaster commented May 6, 2019

Sorry I wasn't able to reproduce it with the same scenario.
Please let me know if you can share your job (it could be useful).

I have the feeling that the line 70-71 is producing the error

print("Warning: there was a problem converting the Powershell"
                  " error message: %s" % (e))

But I need to know why that handler is reached
I will remove that line, let me know if you get a different result.
(can you try with:
https://github.com/rundeck-plugins/py-winrm-plugin/releases/tag/2.0.2-SNAPSHOT
)
Thanks
Luis

@ondrejbaranek
Copy link

ondrejbaranek commented May 9, 2019

Hi, i get similar issue:

UnicodeDecodeError: 'utf8' codec can't decode byte 0x83 in position 56: invalid start byte
Traceback (most recent call last):
File "/var/lib/rundeck/libext/cache/py-winrm-plugin-2.0.1/winrm-exec.py", line 163, in
errorread=session._clean_error_msg(sys.stderr.read())
File "/var/lib/rundeck/libext/cache/py-winrm-plugin-2.0.1/winrm_session.py", line 49, in _clean_error_msg
msg = msg.decode('utf-8')
File "/usr/lib64/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)

python: 2.7.5
winrm on remote: win 2016
image

AFAIK this is most likely issue with encoding - line 46 in winrm_session.py: msg = msg.decode('utf-8')

@ltamaster
Copy link
Contributor

Hi @ondrejbaranek,
what kind of command or string are you running?

I would like to reproduce that error.

Thanks
Luis

@ondrejbaranek
Copy link

ondrejbaranek commented May 9, 2019

@ltamaster It is PowerShell script, runs fine until section with: puppet apply site.pp --modulepath=modules --hiera_config=hiera.yaml

@ltamaster
Copy link
Contributor

ltamaster commented May 9, 2019

@ondrejbaranek
Copy link

Already tried, same error.

@ltamaster
Copy link
Contributor

Did you tried py-winrm-plugin-2.0.3-SNAPSHOT.zip? or the previous one?
Notice that I generated a new SNAPSHOT version when I sent you the previous message
Luis

@hs-hub-world
Copy link
Contributor Author

I'll try the snapshot version later today or tomorrow, to add little more context, the error occurred when executing PS1 from the remote node and not when doing direct execution from rundeck/adhoc command. Maybe related to encoding?

@ondrejbaranek
Copy link

2.0.3 snapshot is even worse, it is translating the characters wrongly: it is inline script copied from UTF8 CRLF
in the script it is: Remove-Item -path "c:\ProgramData\PuppetLabs\puppet\cache"
Remove-Item ?"path "c:\ProgramData\PuppetLabs\puppet\cache"

  • CategoryInfo : ObjectNotFound: (?path c:String) [Remove-Item], DriveNotFoundException

@ltamaster
Copy link
Contributor

ltamaster commented May 10, 2019

@ondrejbaranek
I wasn't able to reproduce that.
To replicate what you did, are you running a remote script that contains that Remove-Item -path "xxx" command, or are you running that from rundeck (like part of an inline script step)?
I tested both cases and I didn't get the issue.

What I got, which is probably the issue, that it is not displayed correctly some special characters like write-host "Ñuñoa"

@ltamaster
Copy link
Contributor

ltamaster commented May 10, 2019

@hs-hub-world @ondrejbaranek
I generated a new snapshot version. I was able to deal with special characters.
Please let me know if this works for you
https://github.com/rundeck-plugins/py-winrm-plugin/releases/tag/2.0.2-SNAPSHOT

Screenshot 2019-05-10 14 11 57

Screenshot 2019-05-10 14 12 50

Screenshot 2019-05-10 14 16 12

Screenshot 2019-05-10 14 34 20

Screenshot 2019-05-10 14 34 28

@hs-hub-world
Copy link
Contributor Author

the snapshot version seems to be working fine for me...

Thank you
HS

@ltamaster
Copy link
Contributor

great @hs-hub-world thanks for the feedback

@ondrejbaranek
Copy link

@ltamaster the latest snapshot works so far. Thanks!

@ltamaster
Copy link
Contributor

I generated a new release.

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

No branches or pull requests

3 participants