Discuss Scratch

zaid1442011
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

FutbolcuCiliPepe wrote:

zaid1442011 wrote:

FutbolcuCiliPepe wrote:

Hi!

I am new to scratchattach. My test project only works while the python code was running. What can I do?
It's supposed to be like that or it will be impractical.
You can do:
while True:
    #Your code here will run till you close the python program
If you want to make a forever loop on Python.

Does it work if I close the python page? (And the code didn't work, are there any other solutions?)

What's the thing you are trying to make and what's your OS?
zaid1442011
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

TheCommCraft wrote:

elip100 wrote:

(#2674)

zaid1442011 wrote:

(#2674)
How can I get cloud variables of custom cloud servers?
Only Scratch and TurboWarp are supported
Wrong
How can I do it then?
TheCommCraft
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

elip100 wrote:

(#2738)

TheCommCraft wrote:

(#2726)

elip100 wrote:

(#2674)

zaid1442011 wrote:

(#2674)
How can I get cloud variables of custom cloud servers?
Only Scratch and TurboWarp are supported
Wrong
Not wrong

zaid1442011 wrote:

(#2740)

TheCommCraft wrote:

elip100 wrote:

(#2674)

zaid1442011 wrote:

(#2674)
How can I get cloud variables of custom cloud servers?
Only Scratch and TurboWarp are supported
Wrong
How can I do it then?
It can be done using the cloud_host kwarg
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)

zaid1442011 wrote:

FutbolcuCiliPepe wrote:

zaid1442011 wrote:

FutbolcuCiliPepe wrote:

Hi!

I am new to scratchattach. My test project only works while the python code was running. What can I do?
It's supposed to be like that or it will be impractical.
You can do:
while True:
    #Your code here will run till you close the python program
If you want to make a forever loop on Python.

Does it work if I close the python page? (And the code didn't work, are there any other solutions?)

What's the thing you are trying to make and what's your OS?

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.

redspacecat
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

-effortIess- wrote:

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.

You could try
for user in list:
    print(user)
I'm not sure what you're currently doing though, so I could be wrong.
zaid1442011
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

TheCommCraft wrote:

(#2742)

zaid1442011 wrote:

(#2740)

TheCommCraft wrote:

elip100 wrote:

(#2674)

zaid1442011 wrote:

(#2674)
How can I get cloud variables of custom cloud servers?
Only Scratch and TurboWarp are supported
Wrong
How can I do it then?
It can be done using the cloud_host kwarg
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
This seams too cluttered.

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)

zaid1442011 wrote:

FutbolcuCiliPepe wrote:

zaid1442011 wrote:

FutbolcuCiliPepe wrote:

Hi!

I am new to scratchattach. My test project only works while the python code was running. What can I do?
It's supposed to be like that or it will be impractical.
You can do:
while True:
    #Your code here will run till you close the python program
If you want to make a forever loop on Python.

Does it work if I close the python page? (And the code didn't work, are there any other solutions?)

What's the thing you are trying to make and what's your OS?
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).
FutbolcuCiliPepe
Scratcher
6 posts

scratchattach - A Scratch API wrapper (Python)

wvzack wrote:

zaid1442011 wrote:

FutbolcuCiliPepe wrote:

zaid1442011 wrote:

FutbolcuCiliPepe wrote:

Hi!

I am new to scratchattach. My test project only works while the python code was running. What can I do?
It's supposed to be like that or it will be impractical.
You can do:
while True:
    #Your code here will run till you close the python program
If you want to make a forever loop on Python.

Does it work if I close the python page? (And the code didn't work, are there any other solutions?)

What's the thing you are trying to make and what's your OS?
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).

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)

jodon221 wrote:

can someone make a save system
For what?
dyptfolt314
Scratcher
25 posts

scratchattach - A Scratch API wrapper (Python)

jodon221 wrote:

can someone make a save system
make it yourself! -thats the cool thing about coding

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)

TimMcCool wrote:

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.
I used to get a similar error with some python http library
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)

AlexDF16 wrote:

WHY DOES SCRATCH KEEP GIVING ME MESSAGES ABOUT THIS FORUM?
Your following it click Unfollow Discussion in the bottom right of the screen (why is this happening so much do people randomly follow it??)
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)

-effortIess- wrote:

How do you access studio activity? I keep getting ‘BadRequest’ errors.
Try
 
#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)

TimMcCool wrote:

I added a new page to scratchattach's wiki, it lists different hosting options: https://github.com/TimMcCool/scratchattach/wiki/Hosting
Can you add SillyDev as a free hosting service? It's similar to ScratchHost

Powered by DjangoBB