-
Notifications
You must be signed in to change notification settings - Fork 0
Cloud API
You can request Cloud data from Scratch API only.
from ScraGet import ScraGet #import the package
data = ScraGet.get_cloud_data() #create a class
data.updateScratch("431041540",limit="10",offset="0") #update data
print(data.cloud_data) #print required info
data.cloud_data #yes. That's it.
ScratchDB doesn't support/return Cloud data.
This is a feature where the package continuously scans the cloud for changes. If any, it runs your code that you specified it. (It's in form of a python decorator). it might be a bit complex to use but is a great tool!
from ScraGet import ScraGet
Cloud = ScraGet.cloud()
@Cloud.scan(ID="612229554",delay=1,NewThread=False) #params explained below
def hello(change): #change parameter is automatically passed.
print(change.var)
Cloud.stop = True #this stops the scanning. Don't put if u want to keep scanning
ID
- (str or int) here, you need to enter the project ID of the project you want to scan. It's mandatory.
delay
- (int or float) You need to set the delay between 2 scans. Note that it's better to set a high delay if this code is going to run for a long time. Better set it to 1 second or more. You will not lose data until 100 people change cloud variables. It's optional. Default=1.0
NewThread
- (bool) Specify whether you want to create a new thread(it will allow you to run this parallel to your own code) or run in the main thread itself(any code below this will not run). It's optional. Default=True
change.change_log #list of all changes. Max len = 100
#all the below is related to the 1st item of change_log
change.recent #1st item of the change
change.user #person who changed the cloud most recently
change.type #the action of cloud change (set,delete, etc...)
change.var #variable name
change.value #the cloud value
change.time #time when the change happened
change.thread #given when NewThread = True. This contains the thread object
change.stop #this is used to check whether the scanner is running or stopped
Any API you know not covered by this library? Any mistake in this wiki? Create an issue!
Have questions? Ask in the Q/A section!