SDK and Python 3, errors and improvements 2

6 posts / 0 new
Last post
solarjoe
SDK and Python 3, errors and improvements 2

Hello Paul,

I downloaded the new release of the SDK but the Python files did not change since the release
mid of December. Only the file ssc.pyc was added.

I attached my script to this new thread because I could not attach it to the other one.
There was a brower error message:

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /file/ajax/upload/und/form-DuZKA4pRL0p8w4i30-DUNxKR8csYRsLETV7LQhq576w
StatusText: n/a
ResponseText: The specified URL cannot be found.
ReadyState: undefined

About the Python script, the UTF-8 error is related to the function info_label().

return t.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x91 in position 19: invalid start byte

You can also check the other changes to convert from Python 2 to 3, maybe you have better
ideas.

Kind regards,
Joe

solarjoe

Hello Paul,

any news on what might cause the UnicodeDecodeError in Python 3?

Kind regards,
Joe

Paul Gilman

Sorry for the delay, Joe. Thank you for posting your Python example. We're investigating the unicode issue now. I just posted an update to the SDK for SAM 2015.1.30.

Best regards,
Paul.

Paul Gilman

Hi Joe,

We've finally tracked down the cause of the unicode error and have a fix. The error is caused by C++ code in the SSC module for the HCPV module that uses a single quote in one of the output variable labels. The solution for the Python wrapper is to modify the definition of info_label() in sscapi.py.

Old:

def info_label( self, p_inf ): 
     self.pdll.ssc_info_label.restype = c_char_p
     return self.pdll.ssc_info_label( c_void_p(p_inf) )

New:

def info_label( self, p_inf ):
     self.pdll.ssc_info_label.restype = c_char_p
     t = self.pdll.ssc_info_label( c_void_p(p_inf) )
     return t.decode('utf-8', 'ignore')

Here is a link to a version of sscapi.py with the correction:

sscapy-3-4-2.py.txt (PY 104 KB). You'll have to remove the .txt extension after you download the file.

We will include this file in the next version of the SDK

Best regards
Paul.

sjschneider

Hello,

I've ported SAM's Python 2 API to Python 3 and set it up as a Python module: py3samsdk. It is compatible with the latest March 14, 2016 release. I've set up some unit tests, but it has not undergone extensive platform testing, etc. Please feel free to use and contribute!

- Stephen

solarjoe

Hello Paul,

will you deploy py3samsdk with the SAM SDK in the future?

Joe

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer