PolyEdge / scratchapi

[CURRENTLY UNMAINTAINED] Scratch API Interface
40 stars 15 forks source link

Unicode Decode Error #10

Closed NWalker1208 closed 8 years ago

NWalker1208 commented 8 years ago

I am running this off of a Raspberry Pi, and whenever I use the "get_vars" function, I get the following error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128) I believe this is because you use the cloud character, but the default codec does not include that character. I've tried multiple things on my side, but I think that you just need to explicitly state your codec as utf-8 somewhere in your code. I can't figure out how to modify your code from my pi, but you should probably fix this for everyone's sake.

PS: I get similar errors for almost every cloud related function

PolyEdge commented 8 years ago

Hmm... :/

Not seeing any issues on my RPi. Are you using python2 or python3?

NWalker1208 commented 8 years ago

Python 2. When I have time, I'll upload a screen shot of the error.

NWalker1208 commented 8 years ago

Here is my python code:

import scratchapi

pj = 101956224
s = scratchapi.ScratchUserSession('MyUsername', 'MyPassword')
print(s.cloud.get_vars(pj))
if s.tools.verify_session():
    while True:
        if s.cloud.get_var('client01', pj) == 1:
            s.cloud.set_var('server01', 123, pj)
            s.cloud.set_var('client01', 0, pj)
        print('test')

Here is the error I get:

Traceback (most recent call last):
  File "/home/pi/Desktop/practice.py", line 5, in <module>
    print(s.cloud.get_vars(pj))
  File "build/bdist.linux-armv6l/egg/scratchapi.py", line 170, in _cloud_getvars
    if xn.startswith('☁'+chr(32)):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)
PolyEdge commented 8 years ago

Okay, fixed :)