Accessing via websocket from Python

As described in this post in the Printer specific Forum of my printer i try to login to repetier server via Websocket from my raspberry pi with python.

When i delete all users and pw, it works, but i cannot figure out the right syntax for the login sending

Could someone provide a Python code Example how either the login with apikey ord with login credentials should look like? Am i doing the MD5 calclulation wrong?

Or does something need to be url encoded?

Not to get me wrong, i don't want to connect via ther browser address bar, i want to connect headlas from within a python script.

Help would be very appreciated


  • Posts: 0
    Since you are building md5 of md5 it is important if the hex digits are uppercase or lowercase. Not sure which one is correct, you might check communication with web frontend in chrome. There you can inspect the frame packages to see if it uses lower or upper case. Apart from this a first look seems correct. You can always compare to the api example which is a minimal javascript example which you could add some console.log outputs to for comparing.
  • edited January 8 Posts: 2
    mm i Tried with uppercasing and in lowercase, no luck, there must be somewhere a little think issue:

    here my code maybe someone has a clue:

            c = ws.send("""{"action":"ping","data":{},"printer":"MyPrinter","callback_id":""" + str(drucker_befehl_id) + "}")
            result =  ws.recv()
            if "session" in (result):
                sessionidtemp = (result.split("\"session\":",1)[1])
                sessionid = sessionidtemp[:-1]

            #userlogout=ws.send('{"action":logout","dara":{},"printer":"MyPrinter","callback_id":""" + str(drucker_befehl_id) + "}"')
            print("bnpwgesamtupper =     ", md5bnpwgesamt)
            sessionid = sessionid.upper()
            print("md5combineduppercase:     " + md5combined)
            md5final = '"'+md5combined+'"'
            print("md5final" + md5final)
            a = ('{"action": "login", "callback_id":' + str(drucker_befehl_id) + """, "data": {"login":"benutzername", "password":""" + md5final +'}}')

Sign In or Register to comment.