Discuss Scratch

TimMcCool
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchcatandGobo wrote:

How are you even supposed to set a cloud variable to a python variable? This is really bugging me…
conn = session.connect_cloud(project_id=“688967859”)
user = session.connect_user(“griffpatch”)
session.get_linked_user()
variable = user.follower_count()
conn.set_var(“Username”, variable)

To fix the problem, replace
 conn.set_var("Username", variable) 
with
 conn.set_var("Username", str(variable)) 

Or update to the latest scratchattach version using
 pip install scratchattach --upgrade
ScratchTheCoder12345
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

What caused you to rename it? Just curious.
coolcoder1213
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchTheCoder12345 wrote:

What caused you to rename it? Just curious.


Yeah?
BLUE_2030
Scratcher
3 posts

scratchattach - A Scratch API wrapper (Python)

Traceback (most recent call last):
File “C:\Users\X240\PycharmProjects\pythonProject6\scratch3.py\test.py”, line 1, in <module>
import scratch3
File “C:\Users\X240\PycharmProjects\pythonProject6\venv\scratch3.py”, line 3, in <module>
session = scratch3.login(“username”, “passwordo”) #replace with your data
AttributeError: partially initialized module ‘scratch3’ has no attribute ‘login’ (most likely due to a circular import)

Last edited by BLUE_2030 (May 11, 2022 23:42:51)

ScratchcatandGobo
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

BLUE_2030 wrote:

Traceback (most recent call last):
File “C:\Users\X240\PycharmProjects\pythonProject6\scratch3.py\test.py”, line 1, in <module>
import scratch3
File “C:\Users\X240\PycharmProjects\pythonProject6\venv\scratch3.py”, line 3, in <module>
session = scratch3.login(“username”, “passwordo”) #replace with your data
AttributeError: partially initialized module ‘scratch3’ has no attribute ‘login’ (most likely due to a circular import)
add ()
kccuber
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchTheCoder12345 wrote:

What caused you to rename it? Just curious.
It sounded like it was the name of a python file before

BLUE_2030 wrote:

Traceback (most recent call last):
File “C:\Users\X240\PycharmProjects\pythonProject6\scratch3.py\test.py”, line 1, in <module>
import scratch3
File “C:\Users\X240\PycharmProjects\pythonProject6\venv\scratch3.py”, line 3, in <module>
session = scratch3.login(“username”, “passwordo”) #replace with your data
AttributeError: partially initialized module ‘scratch3’ has no attribute ‘login’ (most likely due to a circular import)
update the module, it's called scratchattach now and shouldn't be causing circular import error because it's not named scratch3.py anymore
pip install scratchattach --upgrade

Last edited by kccuber (May 12, 2022 01:26:39)

-FreeEngines-
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchcatandGobo wrote:

How are you even supposed to set a cloud variable to a python variable? This is really bugging me…
conn = session.connect_cloud(project_id=“688967859”)
user = session.connect_user(“griffpatch”)
session.get_linked_user()
variable = user.follower_count()
conn.set_var(“Username”, variable)

scratchAttach.get_var(“project_id”, “variable”)
(thats whati get from the github docs, you should read it)
this function returns the value of the variable, so you can kind catch it with
variableOfYourChoice = scratch3.get_var(“project_id”, “variable”)
-FreeEngines-
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchcatandGobo wrote:

How are you even supposed to set a cloud variable to a python variable? This is really bugging me…
conn = session.connect_cloud(project_id=“688967859”)
user = session.connect_user(“griffpatch”)
session.get_linked_user()
variable = user.follower_count()
conn.set_var(“Username”, variable)

oh im stupid, cloud variable to python variable..
so the first thing you wanna do is create an VALID session, which you do by doing
session = scratchattach.login(“username”, “password”)
not that the password must be correct.
connection = session.connect_cloud(project_id=“project_id”)
this sends a handshake to the scratch servers to know you want to connect to the cloud
connection.set_var(“variable”, “value”)
this now sets the variable on the project you specified when connecting to the project with session.connect_cloud(project_id=“yourprojectid”)
so thats it. just replace everything that is in “” with the values you have
_Paxw_
Scratcher
1 post

scratchattach - A Scratch API wrapper (Python)

how are you
ScratchTheCoder12345
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

kccuber wrote:

ScratchTheCoder12345 wrote:

What caused you to rename it? Just curious.
It sounded like it was the name of a python file before

BLUE_2030 wrote:

Traceback (most recent call last):
File “C:\Users\X240\PycharmProjects\pythonProject6\scratch3.py\test.py”, line 1, in <module>
import scratch3
File “C:\Users\X240\PycharmProjects\pythonProject6\venv\scratch3.py”, line 3, in <module>
session = scratch3.login(“username”, “passwordo”) #replace with your data
AttributeError: partially initialized module ‘scratch3’ has no attribute ‘login’ (most likely due to a circular import)
update the module, it's called scratchattach now and shouldn't be causing circular import error because it's not named scratch3.py anymore
pip install scratchattach --upgrade
ohhhh, I'm so stupid lol
PoIygon
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchTheCoder12345 wrote:

What caused you to rename it? Just curious.
Why would a person name it “scratch3” or something like that when it can only do cloud stuff? He changed it because it can only do cloud stuff and “scratch3” implies that it can do everything in the scratch website
UxuginAI
Scratcher
4 posts

scratchattach - A Scratch API wrapper (Python)

scratchfan321 wrote:

Danger comes from myself + terminal
More danger comes from You + Terminal + Sudo
ScratchcatandGobo
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

project.set_title(“This project has ”project.views“ Views and ”project.loves“ Loves”)
Syntax error
coolcoder1213
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchTheCoder12345 wrote:

kccuber wrote:

ScratchTheCoder12345 wrote:

What caused you to rename it? Just curious.
It sounded like it was the name of a python file before

BLUE_2030 wrote:

Traceback (most recent call last):
File “C:\Users\X240\PycharmProjects\pythonProject6\scratch3.py\test.py”, line 1, in <module>
import scratch3
File “C:\Users\X240\PycharmProjects\pythonProject6\venv\scratch3.py”, line 3, in <module>
session = scratch3.login(“username”, “passwordo”) #replace with your data
AttributeError: partially initialized module ‘scratch3’ has no attribute ‘login’ (most likely due to a circular import)
update the module, it's called scratchattach now and shouldn't be causing circular import error because it's not named scratch3.py anymore
pip install scratchattach --upgrade
ohhhh, I'm so stupid lol


Yeah. I asked the same question.
SansStudios
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchcatandGobo wrote:

project.set_title(“This project has ”project.views“ Views and ”project.loves“ Loves”)
Syntax error

That isn't how you combine strings in python.

You can use an addition operator:

text = "This project has " + str(project.views) + " Views and " + str(project.loves) + " Loves"

Or a f-string:

text = f"This project has {project.views} Views and {project.loves} Loves"

Or others like `str.format`
Wolf_Hunter77
Scratcher
37 posts

scratchattach - A Scratch API wrapper (Python)

Sounds hard but good. I hope to see more projects using it in the future.
scratchyjimjam
Scratcher
90 posts

scratchattach - A Scratch API wrapper (Python)

this is really good! I'm using it on one of my projects right now!
729593Patrek
Scratcher
12 posts

scratchattach - A Scratch API wrapper (Python)

What server do you recommend? Replit shuts down all the time for me? I have to keep it free though…
CST1229
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

729593Patrek wrote:

(#60)
What server do you recommend? Replit shuts down all the time for me? I have to keep it free though…
Personally I'd use Replit + some library to have the server serve a HTTP page somewhere + some pinger that pings said page (uptimerobot or verixion's pinger also on replit)
-FreeEngines-
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

If replit shuts down, you're most likely using it wrongly

Powered by DjangoBB