Skip to content

Commit 33cf5e2

Browse files
committed
fix breaking change in stomp.py
1 parent ee922f8 commit 33cf5e2

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

example_emails.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@
4747

4848

4949
class STOMPListener(stomp.ConnectionListener):
50-
def on_error(self, headers, body):
51-
print('report_error', body)
50+
def on_error(self, frame):
51+
print('report_error', frame.body)
5252

53-
def on_message(self, headers, body):
54-
msg_json = json.loads(body)
53+
def on_message(self, frame):
54+
msg_json = json.loads(frame.body)
5555

5656
for field, allowed in ALLOWLIST_FILTERS.items():
5757
if msg_json.get(field) not in allowed:
@@ -70,10 +70,10 @@ def on_message(self, headers, body):
7070
makedirs(path, exist_ok=True)
7171

7272
if WRITE_RAW_MAILS:
73-
with open(path_join(path, str(hash(body)) + '.eml'), 'wb') as f:
73+
with open(path_join(path, str(hash(frame.body)) + '.eml'), 'wb') as f:
7474
f.write(b64decode(msg_json['original_message_base64_encoded']))
7575
else:
76-
with open(path_join(path, str(hash(body)) + '.json'), 'w') as f:
76+
with open(path_join(path, str(hash(frame.body)) + '.json'), 'w') as f:
7777
json.dump(msg_json, f)
7878

7979

example_files_json.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939

4040

4141
class STOMPListener(stomp.ConnectionListener):
42-
def on_error(self, headers, body):
43-
print('report_error', body)
42+
def on_error(self, frame):
43+
print('report_error', frame.body)
4444

45-
def on_message(self, headers, body):
46-
msg_json = json.loads(body)
45+
def on_message(self, frame):
46+
msg_json = json.loads(frame.body)
4747

4848
for field, allowed in ALLOWLIST_FILTERS.items():
4949
if msg_json.get(field) not in allowed:
@@ -58,10 +58,10 @@ def on_message(self, headers, body):
5858
makedirs(path, exist_ok=True)
5959

6060
if WRITE_RAW_FILES:
61-
with open(path_join(path, str(hash(body)) + '.file'), 'wb') as f:
61+
with open(path_join(path, str(hash(frame.body)) + '.file'), 'wb') as f:
6262
f.write(b64decode(msg_json['attachment_base64_encoded']))
6363
else:
64-
with open(path_join(path, str(hash(body)) + '.json'), 'w') as f:
64+
with open(path_join(path, str(hash(frame.body)) + '.json'), 'w') as f:
6565
json.dump(msg_json, f)
6666

6767

example_files_raw.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919

2020

2121
class STOMPListener(stomp.ConnectionListener):
22-
def on_error(self, headers, body):
23-
print('report_error', body)
22+
def on_error(self, frame):
23+
print('report_error', frame.body)
2424

25-
def on_message(self, headers, body):
25+
def on_message(self, frame):
2626
msg_date = datetime.now()
2727
path = msg_date.strftime(OUTPUT_DIRECTORY)
2828
makedirs(path, exist_ok=True)
2929

30-
with open(path_join(path, str(hash(body)) + '.file'), 'wb') as f:
31-
f.write(b64decode(body))
30+
with open(path_join(path, str(hash(frame.body)) + '.file'), 'wb') as f:
31+
f.write(b64decode(frame.body))
3232

3333

3434
def listen():

example_ipdomains.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333

3434

3535
class STOMPListener(stomp.ConnectionListener):
36-
def on_error(self, headers, body):
37-
print('report_error', body)
36+
def on_error(self, frame):
37+
print('report_error', frame.body)
3838

39-
def on_message(self, headers, body):
40-
msg_json = json.loads(body)
39+
def on_message(self, frame):
40+
msg_json = json.loads(frame.body)
4141

4242
for field, allowed in ALLOWLIST_FILTERS.items():
4343
if msg_json.get(field) not in allowed:
@@ -51,7 +51,7 @@ def on_message(self, headers, body):
5151
path = msg_date.strftime(OUTPUT_DIRECTORY)
5252
makedirs(path, exist_ok=True)
5353

54-
with open(path_join(path, str(hash(body)) + '.json'), 'w') as f:
54+
with open(path_join(path, str(hash(frame.body)) + '.json'), 'w') as f:
5555
json.dump(msg_json, f)
5656

5757

example_urls_json.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333

3434

3535
class STOMPListener(stomp.ConnectionListener):
36-
def on_error(self, headers, body):
37-
print('report_error', body)
36+
def on_error(self, frame):
37+
print('report_error', frame.body)
3838

39-
def on_message(self, headers, body):
40-
msg_json = json.loads(body)
39+
def on_message(self, frame):
40+
msg_json = json.loads(frame.body)
4141

4242
if 'url_tld' not in msg_json:
4343
msg_json['url_tld'] = urlparse(msg_json.get('url')).hostname.split('.')[-1]

example_urls_raw.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818

1919

2020
class STOMPListener(stomp.ConnectionListener):
21-
def on_error(self, headers, body):
22-
print('report_error', body)
21+
def on_error(self, frame):
22+
print('report_error', frame.body)
2323

24-
def on_message(self, headers, body):
24+
def on_message(self, frame):
2525
msg_date = datetime.now()
2626
path = msg_date.strftime(OUTPUT_FILE)
2727
makedirs(dirname(path), exist_ok=True)
2828

2929
with open(path, 'a') as f:
30-
f.write(body + '\n')
30+
f.write(frame.body + '\n')
3131

3232

3333
def listen():

0 commit comments

Comments
 (0)