File tree Expand file tree Collapse file tree 3 files changed +35
-4
lines changed
servercom/implementations Expand file tree Collapse file tree 3 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -366,7 +366,16 @@ def post(self, point: DataPoint) -> bool:
366366 '/data' ,
367367 point .dumps (),
368368 content_type = 'application/json' ,
369- headers = ['User-Agent: Dude' ]
369+ headers = ['User-Agent: CircuitPython, dude!' ]
370+ ).code == 201
371+
372+ def email (self , msg : Email ) -> bool :
373+ return self .request (
374+ 'POST' ,
375+ '/email' ,
376+ msg .dumps (),
377+ content_type = 'application/json' ,
378+ headers = ['User-Agent: CircuitPython, dude!' ]
370379 ).code == 201
371380
372381 def __exit__ (self ):
Original file line number Diff line number Diff line change 77 pass
88
99from collections import namedtuple
10-
10+ from json import dumps
1111
1212# Constants:
1313DEGREE_SIGN = u"\xb0 "
@@ -44,3 +44,18 @@ class ConnectionConfig:
4444 API_PORT : int = 8081
4545
4646CUBESERVER_DEFAULT_CONFIG = ConnectionConfig ()
47+
48+ class Email :
49+ """Holds an email to be sent to the team"""
50+
51+ def __init__ (self , subject , message ) -> None :
52+ self .subject = subject
53+ self .message = message
54+
55+ def dumps (self ) -> str :
56+ return dumps (
57+ {
58+ 'subject' : self .subject ,
59+ 'message' : self .message
60+ }
61+ )
Original file line number Diff line number Diff line change @@ -344,9 +344,16 @@ def post(self, point: DataPoint) -> bool:
344344 '/data' ,
345345 point .dumps (),
346346 content_type = 'application/json' ,
347- headers = ['User-Agent: Dude' ]
347+ headers = ['User-Agent: CPython, dude!' ]
348+ ).code == 201
349+ def email (self , msg : Email ) -> bool :
350+ return self .request (
351+ 'POST' ,
352+ '/email' ,
353+ msg .dumps (),
354+ content_type = 'application/json' ,
355+ headers = ['User-Agent: CPython, dude!' ]
348356 ).code == 201
349-
350357 def __exit__ (self ):
351358 if self .v :
352359 print ("Closing the server connection-" )
You can’t perform that action at this time.
0 commit comments