Skip to main content

An event-based asynchronous wrapper for scratch.mit.edu cloud variables.

Project description

scratchcloud

An asynchronous pythonic wrapper for scratch.mit.edu cloud websocket connections.

Features

  • Event-based handling
  • Pythonic async and await syntax
  • Built-in reconnecting

Extensions

  • Fetching data from the Scratch API
  • Easy encoding and decoding of variables
  • Sending and receiving large cloud payloads
  • Finding who changed a cloud variable gt

Example

from scratchcloud import CloudClient, CloudChange

client = CloudClient('SS-2', '588579111')

@client.event
async def on_connect():
    print('Connected!')

@client.event
async def on_disconnect():
    print('Disconnected :(')

@client.event
async def on_message(cloud: CloudChange):
    print(f"{cloud.name} was set to {cloud.value}!")
    await client.set_cloud(cloud.name, "123")

client.run("SuperSecretPassword22")

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scratchcloud-0.0.1.tar.gz (12.1 kB view hashes)

Uploaded Source

Built Distribution

scratchcloud-0.0.1-py3-none-any.whl (13.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page