Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » scratchattach - A Scratch API wrapper (Python)
- zaid1442011
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
What's the thing you are trying to make and what's your OS?It's supposed to be like that or it will be impractical. Hi!
I am new to scratchattach. My test project only works while the python code was running. What can I do?
You can do:If you want to make a forever loop on Python.while True: #Your code here will run till you close the python program
Does it work if I close the python page? (And the code didn't work, are there any other solutions?)
- TheCommCraft
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
(#2738)(#2726)Not wrong(#2674)Wrong(#2674)Only Scratch and TurboWarp are supported
How can I get cloud variables of custom cloud servers?
(#2740)It can be done using the cloud_host kwargHow can I do it then?(#2674)Wrong(#2674)Only Scratch and TurboWarp are supported
How can I get cloud variables of custom cloud servers?
Unless you mean the values and not a connection.
Edit: You could use a connection like this though:
try: conn = TwCloudConnection(project_id=project_id, _ws_timeout=1, purpose=purpose, contact=contact, cloud_host="yourcloudhost") data = conn.websocket.recv().split("\n") conn.disconnect() result = [] for i in data: try: result.append(json.loads(i)) except Exception: pass return result except websocket._exceptions.WebSocketTimeoutException: return [] except Exception: raise exceptions.FetchError
Last edited by TheCommCraft (Aug. 21, 2024 14:58:36)
- FutbolcuCiliPepe
- Scratcher
6 posts
scratchattach - A Scratch API wrapper (Python)
What's the thing you are trying to make and what's your OS?It's supposed to be like that or it will be impractical. Hi!
I am new to scratchattach. My test project only works while the python code was running. What can I do?
You can do:If you want to make a forever loop on Python.while True: #Your code here will run till you close the python program
Does it work if I close the python page? (And the code didn't work, are there any other solutions?)
I just want to know how to run scratchattach projects opening the python page (is this belongs to the platform i use?)
- -effortIess-
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
Hey I have a question.
So I was recently using sa to retrieve a list of managers from a studio. I retrieved the list successfully but the users were in the form of “user objects”. Any ideas on how to get a list of their actual usernames, and not just their SA IDs?
Also, I found out that if you print() one of the user objects it returns the username, but when you print() the whole list it returns a list of the user objects.
So I was recently using sa to retrieve a list of managers from a studio. I retrieved the list successfully but the users were in the form of “user objects”. Any ideas on how to get a list of their actual usernames, and not just their SA IDs?
Also, I found out that if you print() one of the user objects it returns the username, but when you print() the whole list it returns a list of the user objects.
- redspacecat
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
You could try Hey I have a question.
So I was recently using sa to retrieve a list of managers from a studio. I retrieved the list successfully but the users were in the form of “user objects”. Any ideas on how to get a list of their actual usernames, and not just their SA IDs?
Also, I found out that if you print() one of the user objects it returns the username, but when you print() the whole list it returns a list of the user objects.
for user in list: print(user)
- zaid1442011
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
(#2742)This seams too cluttered.(#2740)It can be done using the cloud_host kwargHow can I do it then?(#2674)Wrong(#2674)Only Scratch and TurboWarp are supported
How can I get cloud variables of custom cloud servers?
Unless you mean the values and not a connection.
Edit: You could use a connection like this though:try: conn = TwCloudConnection(project_id=project_id, _ws_timeout=1, purpose=purpose, contact=contact, cloud_host="yourcloudhost") data = conn.websocket.recv().split("\n") conn.disconnect() result = [] for i in data: try: result.append(json.loads(i)) except Exception: pass return result except websocket._exceptions.WebSocketTimeoutException: return [] except Exception: raise exceptions.FetchError
I made a pull request fixing this issue by adding the cloud host argument for the function. You can check it here.
- wvzack
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
So from what I read you are using the python application instead of a editor I would recommend a editor like virtual studio code (not to be confused with virtual studio).What's the thing you are trying to make and what's your OS?It's supposed to be like that or it will be impractical. Hi!
I am new to scratchattach. My test project only works while the python code was running. What can I do?
You can do:If you want to make a forever loop on Python.while True: #Your code here will run till you close the python program
Does it work if I close the python page? (And the code didn't work, are there any other solutions?)
- FutbolcuCiliPepe
- Scratcher
6 posts
scratchattach - A Scratch API wrapper (Python)
So from what I read you are using the python application instead of a editor I would recommend a editor like virtual studio code (not to be confused with virtual studio).What's the thing you are trying to make and what's your OS?It's supposed to be like that or it will be impractical. Hi!
I am new to scratchattach. My test project only works while the python code was running. What can I do?
You can do:If you want to make a forever loop on Python.while True: #Your code here will run till you close the python program
Does it work if I close the python page? (And the code didn't work, are there any other solutions?)
I use it too but I didn't work. I tried to use replit (I know that it has a function that runs the project when you close the page, too)
- jodon221
- Scratcher
20 posts
scratchattach - A Scratch API wrapper (Python)
can someone make a save system
- redspacecat
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
For what? can someone make a save system
- dyptfolt314
- Scratcher
25 posts
scratchattach - A Scratch API wrapper (Python)
make it yourself! -thats the cool thing about coding can someone make a save system
send packets through cloud variables that can be recieved and turned into an object/list and store in a txt file/json/db with os, sql or some other library. then use a search function to find the user's id/username in the file and send a packet back of all their data.
Last edited by dyptfolt314 (Aug. 27, 2024 15:42:55)
- -effortIess-
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
How do you access studio activity? I keep getting ‘BadRequest’ errors.
- MonkeyBean2
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
I used to get a similar error with some python http library In the past, many people reported they were unable to connect to Scratch's cloud variables because they got this error:ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)
I was never able to reproduce the error - until I recently stumbled upon it myself on a new device. I found a way to fix it which will be implemented in scratchattach soon / in a future update.
- AlexDF16
- Scratcher
9 posts
scratchattach - A Scratch API wrapper (Python)
WHY DOES SCRATCH KEEP GIVING ME MESSAGES ABOUT THIS FORUM?
Last edited by AlexDF16 (Aug. 31, 2024 13:54:29)
- wvzack
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
Your following it click Unfollow Discussion in the bottom right of the screen (why is this happening so much do people randomly follow it??) WHY DOES SCRATCH KEEP GIVING ME MESSAGES ABOUT THIS FORUM?
- TimMcCool
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
I added a new page to scratchattach's wiki, it lists different hosting options: https://github.com/TimMcCool/scratchattach/wiki/Hosting
Last edited by TimMcCool (Aug. 31, 2024 14:03:04)
- wvzack
- Scratcher
500+ posts
scratchattach - A Scratch API wrapper (Python)
Try How do you access studio activity? I keep getting ‘BadRequest’ errors.
#put in your login scripts here
studio = session.connect_studio(studio_id) #the number that comes after the url eg. https://scratch.mit.edu/studios/#########/
print(studio.activity(limit=24, offset=0))
If this doesn't work try upgrading scratchattach.
Last edited by wvzack (Aug. 31, 2024 14:14:28)
- redspacecat
- Scratcher
100+ posts
scratchattach - A Scratch API wrapper (Python)
https://github.com/TimMcCool/scratchattach/wiki/HostingCan you add SillyDev as a free hosting service? It's similar to ScratchHost I added a new page to scratchattach's wiki, it lists different hosting options: