Skip to content

Commit d19e301

Browse files
committed
.
1 parent b662669 commit d19e301

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

scratchattach/eventhandlers/cloud_events.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,30 @@ def _updater(self):
3232

3333
Thread(target=self.call_event, args=["on_ready"]).start()
3434

35+
if self.running is False:
36+
return
3537
while True:
36-
if self.running is False:
37-
return
3838
try:
39-
data = self.source_cloud.websocket.recv().split('\n')
40-
result = []
41-
for i in data:
42-
try:
43-
_a = cloud_activity.CloudActivity(timestamp=time.time()*1000, _session=self._session, cloud=self.cloud)
44-
if _a.timestamp < self.startup_time + 500: # catch the on_connect message sent by TurboWarp's (and sometimes Scratch's) cloud server
45-
continue
46-
data = json.loads(i)
47-
data["name"] = data["name"].replace("☁ ", "")
48-
_a._update_from_dict(data)
49-
self.call_event("on_"+_a.type, [_a])
50-
except Exception as e:
51-
pass
39+
while True:
40+
data = self.source_cloud.websocket.recv().split('\n')
41+
result = []
42+
for i in data:
43+
try:
44+
_a = cloud_activity.CloudActivity(timestamp=time.time()*1000, _session=self._session, cloud=self.cloud)
45+
if _a.timestamp < self.startup_time + 500: # catch the on_connect message sent by TurboWarp's (and sometimes Scratch's) cloud server
46+
continue
47+
data = json.loads(i)
48+
data["name"] = data["name"].replace("☁ ", "")
49+
_a._update_from_dict(data)
50+
self.call_event("on_"+_a.type, [_a])
51+
except Exception as e:
52+
pass
5253
except Exception:
53-
time.sleep(0.1) # cooldown
5454
print("CloudEvents: Disconnected. Reconnecting ...", time.time())
55-
self.source_cloud.connect()
56-
print("CloudEvents: Reconnected.", time.time())
57-
self.call_event("on_reconnect", [])
55+
time.sleep(0.1) # cooldown
56+
self.source_cloud.connect()
57+
print("CloudEvents: Reconnected.", time.time())
58+
self.call_event("on_reconnect", [])
5859

5960

6061
class CloudLogEvents(BaseEventHandler):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
name="scratchattach",
1212
version=VERSION,
1313
author="TimMcCool",
14-
author_email="",
14+
author_email="[email protected]",
1515
description=DESCRIPTION,
1616
long_description_content_type="text/markdown",
1717
long_description=open('README.md', encoding='utf-8').read(),

0 commit comments

Comments
 (0)