Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » scratchattach - A Scratch API wrapper (Python)
- Erichsu903
- Scratcher
20 posts
scratchattach - A Scratch API wrapper (Python)
i am using scratchattach to code a project but it will not connect here is the terminal
/usr/local/bin/python3 “/Volumes/yeshua's disc/scratchhost.py”
yeshua@yeshuas-iMac ~ % /usr/local/bin/python3 “/Volumes/yeshua's disc/
scratchhost.py”
Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scratchattach/_cloud.py”, line 67, in _connect
self.websocket.connect(
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/websocket/_core.py”, line 244, in connect
self.sock, addrs = connect(url, self.sock_opt, proxy_info(**options),
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/websocket/_http.py”, line 136, in connect
sock = _ssl_socket(sock, options.sslopt, hostname)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/websocket/_http.py”, line 271, in _ssl_socket
sock = _wrap_sni_socket(sock, sslopt, hostname, check_hostname)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/websocket/_http.py”, line 247, in _wrap_sni_socket
return context.wrap_socket(
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py”, line 513, in wrap_socket
return self.sslsocket_class._create(
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py”, line 1071, in _create
self.do_handshake()
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py”, line 1342, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/Volumes/yeshua's disc/scratchhost.py”, line 4, in <module>
conn = session.connect_cloud(project_id=“719566754”) #replace with your project id
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scratchattach/_session.py”, line 242, in connect_cloud
return _cloud.CloudConnection(username = self._username, session_id = self.session_id, project_id = int(project_id))
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scratchattach/_cloud.py”, line 19, in __init__
self._connect(cloud_host=cloud_host)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scratchattach/_cloud.py”, line 74, in _connect
raise(_exceptions.ConnectionError)
scratchattach._exceptions.ConnectionError
yeshua@yeshuas-iMac ~ %
here is the codeimport scratchattach as scratch3 session = scratch3.login("randomuser", "apassword") #replace with your data conn = session.connect_cloud(project_id="myprojectid") #replace with your project id client.run(data_from_websocket=False) client = scratch3.CloudRequests(conn) #optional argument: ignore_exceptions=True @client.request def ping(): #called when client receives request print("Ping request received") return "pong" #sends back 'pong' to the Scratch project @client.event def on_ready(): print("Request handler is ready") client.run()
I think you put the “client.run()” before you define what is client and you put the requests below it, so it wont run.
- LD123Rises
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
when green flag clicked
change [my followers v] by (1)
wait a [few v] [days v] :: control ::
Last edited by LD123Rises (Aug. 9, 2022 20:51:01)
- --TheDynamicDude--
- Scratcher
2 posts
scratchattach - A Scratch API wrapper (Python)
Scratchcloud and Scratchclient, so you may want to use one of those instead of creating an entirely new library. That being said, this still looks really cool and has a lot of potential.There are a bunch of other Scratch Python libraries out there already, such as
what is scratchattach?
when green flag clicked
say [How to be popular. Be nice, fair and respect the community guidlines.]
- NFlex23
- Scratcher
1000+ posts
scratchattach - A Scratch API wrapper (Python)
You can find more info here: https://scratch.mit.edu/discuss/post/6284165/Scratchcloud and Scratchclient, so you may want to use one of those instead of creating an entirely new library. That being said, this still looks really cool and has a lot of potential.There are a bunch of other Scratch Python libraries out there already, such as
what is scratchattach?
Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
- Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
- The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
- Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
- Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
- Issues with Scratch itself should be put in Bugs and Glitches.
- ZZC12345
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
Lol, I was sleeping – didn't read the code through since I would have assumed that the error would have been caught by ScratchAttach before it propagated to the HTTP implementations.ZZC12345, you listening?Remove the client.run(data_from_websocket=False) at line 4, it prevents code after it from running ~snip~
here is the codeimport scratchattach as scratch3 session = scratch3.login("randomuser", "apassword") #replace with your data conn = session.connect_cloud(project_id="myprojectid") #replace with your project id client.run(data_from_websocket=False) client = scratch3.CloudRequests(conn) #optional argument: ignore_exceptions=True @client.request def ping(): #called when client receives request print("Ping request received") return "pong" #sends back 'pong' to the Scratch project @client.event def on_ready(): print("Request handler is ready") client.run()
This is my signature. Go check out my GitHub if you want to!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Make sure to check out these cool projects, written in real code! (outdated, sorry)
Aviate - Itinerary - Scratch Auth - Orange OS Linux Distro - ocular - Leopard - PyHelp - My GitHub
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Make sure to check out these cool projects, written in real code! (outdated, sorry)
Aviate - Itinerary - Scratch Auth - Orange OS Linux Distro - ocular - Leopard - PyHelp - My GitHub
- opel-GT
- Scratcher
1 post
scratchattach - A Scratch API wrapper (Python)
cvhjNot sure Can it work with Turbowarp Packager?
- DifferentDance8
- Scratcher
1000+ posts
scratchattach - A Scratch API wrapper (Python)
You are starting on page 53. Go back to Page 1, Post 1 for details on ScratchAttach.Scratchcloud and Scratchclient, so you may want to use one of those instead of creating an entirely new library. That being said, this still looks really cool and has a lot of potential.There are a bunch of other Scratch Python libraries out there already, such as
what is scratchattach?
R.I.P Zydrolic, 2023-2024
- ZZC12345
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
[Feature Request/Bug]
I know you already do, but several people have been having issues with the SSL certificates not working lately. I'm not sure why this is the case (it should fail after the handshake, not during it), but either way, could you clarify in the documentation (make it nice and big) that `client.run` needs to be called at the end of the file, and only at the end of the file.
I know you already do, but several people have been having issues with the SSL certificates not working lately. I'm not sure why this is the case (it should fail after the handshake, not during it), but either way, could you clarify in the documentation (make it nice and big) that `client.run` needs to be called at the end of the file, and only at the end of the file.
Btw, @DifferentDance8, the error is a protocol error in Python's websocket protocol implementation during the SSL certificate exchange to ensure encryption on the websocket between Scratch and the client. I'm not sure why calling client.run too early makes this happen, but I was at least sort of correct earlier. I don't think Python's implementations are that buggy, since so many people depend on them.Which formerly has something to do with SA, because SA was the library which used the buggy low-level libs. I don't think think this has anything to do with ScratchAttach, probably a weird HTTPS certificate error that the low-level libraries that SA uses threw.
Last edited by ZZC12345 (Aug. 10, 2022 02:28:24)
This is my signature. Go check out my GitHub if you want to!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Make sure to check out these cool projects, written in real code! (outdated, sorry)
Aviate - Itinerary - Scratch Auth - Orange OS Linux Distro - ocular - Leopard - PyHelp - My GitHub
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Make sure to check out these cool projects, written in real code! (outdated, sorry)
Aviate - Itinerary - Scratch Auth - Orange OS Linux Distro - ocular - Leopard - PyHelp - My GitHub
- infintyrussia
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
I made a server for scratch with the signing-in and everything using cloud requests. Then I wanted to make a second server for Turbowarp but it did not work. There are no errors and it says “Request handler is ready”. I am not sure what the issue is but the project is unshared right now so that may be it.
conn = scratch3.TwCloudConnection(project_id="720176265") #replace with your project id
client = scratch3.TwCloudRequests(conn) #optional argument: ignore_exceptions=True
client = scratch3.CloudRequests(conn, used_cloud_vars=["1","2","3"])
app = Flask('')
@app.route('/')
def home():
return "I'm alive"
def run():
app.run(host='0.0.0.0',port=8080)
def keep_alive():
t = Thread(target=run)
t.start()
keep_alive()
@client.request
def online():
return "Online!"
@client.event
def on_ready():
print("Request handler is ready")
client.run()
- infintyrussia
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
I made a server for scratch with the signing-in and everything using cloud requests. Then I wanted to make a second server for Turbowarp but it did not work. There are no errors and it says “Request handler is ready”. I am not sure what the issue is but the project is unshared right now so that may be it.conn = scratch3.TwCloudConnection(project_id="720176265") #replace with your project id
client = scratch3.TwCloudRequests(conn) #optional argument: ignore_exceptions=True
client = scratch3.CloudRequests(conn, used_cloud_vars=["1","2","3"])
app = Flask('')
@app.route('/')
def home():
return "I'm alive"
def run():
app.run(host='0.0.0.0',port=8080)
def keep_alive():
t = Thread(target=run)
t.start()
keep_alive()
@client.request
def online():
return "Online!"
@client.event
def on_ready():
print("Request handler is ready")
client.run()[/quote]
Looks like the issue is this:
client = scratch3.CloudRequests(conn, used_cloud_vars=["1","2","3"])
After I removed it, it started receiving requests but it won't send them back since I selected some of the cloud vars. I think TimMcCool forgot to make this command take effect for Turbowarp too.
Please fix it.
- ZZC12345
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
Yes, they didn't do a very good OOP class in the source code; they copy-pasted the source code for the client into a new class for TW then modified the hardcoded constants, so when the first part got changed, the second likely didn't.I made a server for scratch with the signing-in and everything using cloud requests. Then I wanted to make a second server for Turbowarp but it did not work. There are no errors and it says “Request handler is ready”. I am not sure what the issue is but the project is unshared right now so that may be it.conn = scratch3.TwCloudConnection(project_id="720176265") #replace with your project id
client = scratch3.TwCloudRequests(conn) #optional argument: ignore_exceptions=True
client = scratch3.CloudRequests(conn, used_cloud_vars=["1","2","3"])
app = Flask('')
@app.route('/')
def home():
return "I'm alive"
def run():
app.run(host='0.0.0.0',port=8080)
def keep_alive():
t = Thread(target=run)
t.start()
keep_alive()
@client.request
def online():
return "Online!"
@client.event
def on_ready():
print("Request handler is ready")
client.run()
Looks like the issue is this:
client = scratch3.CloudRequests(conn, used_cloud_vars
After I removed it, it started receiving requests but it won't send them back since I selected some of the cloud vars. I think TimMcCool forgot to make this command take effect for Turbowarp too.
Please fix it.
Also, why did Paddle2See edit out the GitHub links and put the reason as “personal information/email”?!? Did GitHub get censored too for “personal information” now?!? Now that the link is removed, you can find the repository on GitHub at TimMcCool/scratchattach. For now, you can see the old version on ScratchDB: https://scratchdb.lefty.one/v3/forum/post/info/6284165
Last edited by ZZC12345 (Aug. 11, 2022 00:38:55)
This is my signature. Go check out my GitHub if you want to!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Make sure to check out these cool projects, written in real code! (outdated, sorry)
Aviate - Itinerary - Scratch Auth - Orange OS Linux Distro - ocular - Leopard - PyHelp - My GitHub
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Make sure to check out these cool projects, written in real code! (outdated, sorry)
Aviate - Itinerary - Scratch Auth - Orange OS Linux Distro - ocular - Leopard - PyHelp - My GitHub
- -FreeEngines-
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
1.) “pyprojectid” is not a projectid i am using scratchattach to code a project but it will not connect here is the terminal
/usr/local/bin/python3 “/Volumes/yeshua's disc/scratchhost.py”
yeshua@yeshuas-iMac ~ % /usr/local/bin/python3 “/Volumes/yeshua's disc/
scratchhost.py”
Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scratchattach/_cloud.py”, line 67, in _connect
self.websocket.connect(
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/websocket/_core.py”, line 244, in connect
self.sock, addrs = connect(url, self.sock_opt, proxy_info(**options),
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/websocket/_http.py”, line 136, in connect
sock = _ssl_socket(sock, options.sslopt, hostname)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/websocket/_http.py”, line 271, in _ssl_socket
sock = _wrap_sni_socket(sock, sslopt, hostname, check_hostname)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/websocket/_http.py”, line 247, in _wrap_sni_socket
return context.wrap_socket(
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py”, line 513, in wrap_socket
return self.sslsocket_class._create(
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py”, line 1071, in _create
self.do_handshake()
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py”, line 1342, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/Volumes/yeshua's disc/scratchhost.py”, line 4, in <module>
conn = session.connect_cloud(project_id=“719566754”) #replace with your project id
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scratchattach/_session.py”, line 242, in connect_cloud
return _cloud.CloudConnection(username = self._username, session_id = self.session_id, project_id = int(project_id))
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scratchattach/_cloud.py”, line 19, in __init__
self._connect(cloud_host=cloud_host)
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scratchattach/_cloud.py”, line 74, in _connect
raise(_exceptions.ConnectionError)
scratchattach._exceptions.ConnectionError
yeshua@yeshuas-iMac ~ %
here is the codeimport scratchattach as scratch3 session = scratch3.login("randomuser", "apassword") #replace with your data conn = session.connect_cloud(project_id="myprojectid") #replace with your project id client.run(data_from_websocket=False) client = scratch3.CloudRequests(conn) #optional argument: ignore_exceptions=True @client.request def ping(): #called when client receives request print("Ping request received") return "pong" #sends back 'pong' to the Scratch project @client.event def on_ready(): print("Request handler is ready") client.run()
2.) does randomuser actully exist and is the given password right?
- DifferentDance8
- Scratcher
1000+ posts
scratchattach - A Scratch API wrapper (Python)
1.) Those are EXAMPLE data. I guarantee that if you enter in valid details for both, the same issue will occur. 1.) “pyprojectid” is not a projectid
2.) does randomuser actully exist and is the given password right?
2.) This was confirmed to be a misplaced line somewhere in the code.
R.I.P Zydrolic, 2023-2024
- DifferentDance8
- Scratcher
1000+ posts
scratchattach - A Scratch API wrapper (Python)
Why is the GitHub links suddenly removed for “personal contact”? There literally is no contact info anywhere on the repo.
R.I.P Zydrolic, 2023-2024
- Remixsuper_Sims
- Scratcher
4 posts
scratchattach - A Scratch API wrapper (Python)
We can create bots who posts comments on scratch or we can be banned if we does that ?
- DifferentDance8
- Scratcher
1000+ posts
scratchattach - A Scratch API wrapper (Python)
Well, this topic says nothing about chat bots being banned, but Paddle2See (a st member) have said We can create bots who posts comments on scratch or we can be banned if we does that ? this on the matter of bots:
Scratch is a site for human interaction. Bots in general are not welcome as they can (and have) been used to spam, consume resources, and distort site usage statistics.
But, the ST revoked their own rules in a sort of “rules for thee and not for me” way, because guess what? Every april fools, the ScratchCat account replies to every profile comment with cat noises. And yet accounts like GreenCat get banned for using comment bots. So, take what Paddle2See said with a grain of salt. In fact, let me rework what they said:
Scratch is usually a site for human interaction. Although bots are allowed, granted we approve your usage and it doesn't do anything inappropriate or otherwise breaks the CG, we usually ban them because of spamming, consuming resources, and distorting site usage statistics..
Last edited by DifferentDance8 (Aug. 11, 2022 10:24:02)
R.I.P Zydrolic, 2023-2024
- infintyrussia
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
It says that I have no Requests added yet.You need to define Turbowarp cloud requests in another variable, like tw_client. In your code, you assign the variable client to turbowarp cloud requests, then to scratch cloud requests. Fixed code: I made a server for scratch with the signing-in and everything using cloud requests. Then I wanted to make a second server for Turbowarp but it did not work. There are no errors and it says “Request handler is ready”. I am not sure what the issue is but the project is unshared right now so that may be it.conn = scratch3.TwCloudConnection(project_id="720176265") #replace with your project id
client = scratch3.TwCloudRequests(conn) #optional argument: ignore_exceptions=True
client = scratch3.CloudRequests(conn, used_cloud_vars=["1","2","3"])
app = Flask('')
@app.route('/')
def home():
return "I'm alive"
def run():
app.run(host='0.0.0.0',port=8080)
def keep_alive():
t = Thread(target=run)
t.start()
keep_alive()
@client.request
def online():
return "Online!"
@client.event
def on_ready():
print("Request handler is ready")
client.run()conn = scratch3.TwCloudConnection(project_id="720176265") #replace with your project id
tw_client = scratch3.TwCloudRequests(conn) #optional argument: ignore_exceptions=True
client = scratch3.CloudRequests(conn, used_cloud_vars=["1","2","3"])
app = Flask('')
@app.route('/')
def home():
return "I'm alive"
def run():
app.run(host='0.0.0.0',port=8080)
def keep_alive():
t = Thread(target=run)
t.start()
keep_alive()
@client.request
def online():
return "Online!"
@client.event
def on_ready():
print("Request handler is ready")
@tw_client.request
def online():
return "Online!"
@tw_client.event
def on_ready():
print("Request handler is ready")
client.run(thread=True)
tw_client.run(thread=True)
- cjp123456789
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
which one to use pls help me
- DifferentDance8
- Scratcher
1000+ posts
scratchattach - A Scratch API wrapper (Python)
? which one to use pls help me
R.I.P Zydrolic, 2023-2024
- NeonG4
- Scratcher
1000+ posts
scratchattach - A Scratch API wrapper (Python)
Can I import this into replit or github, or do I have to use the official python compiler?
Visit my shop!
Be high contrast
Hi! I'm NeonG4! I help on the HWS forum, create lame projects, and give advice.
My advice: Read this => https://en.scratch-wiki.info/wiki/User:Jvvg/Essays/Some_thoughts_on_the_forums
ROYGBIV (Rainbow text)
Sigs can go on for a while lol
Hi
when green flag clicked
set [move (10) steps] to [10]
think [move (10) steps]
Golly gee, what if I say something important like: I'm making minecraft in scratch! Follow me or I'll steal your ovens' fans' cabinets' glass. Or just a glass from your cabinet next to your oven fan. Do ovens have fans? Maybe its a stove fan, idk.
]
Generation 3: The first time you see this, copy and paste it on top of your signature in the Scratch forums, and increase the generation by 1. Social experiment.
Never gonna give you up, never gonna let you down.
You didn't learn.