-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
49 lines (39 loc) · 1.33 KB
/
Copy pathmain.py
File metadata and controls
49 lines (39 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import asyncio
import signal
from adapter import Config, MSGraphClient, SMTPServer
from adapter.msgraph import MockMSGraphClient
async def main():
config = Config()
if config.use_mock_msgraph:
print("Using Mock MS Graph Client for testing")
msgraph_client = MockMSGraphClient(simulate_failures=config.mock_simulate_failures)
else:
print("Using Real MS Graph Client")
msgraph_client = MSGraphClient(
tenant_id=config.msgraph_tenant_id,
client_id=config.msgraph_client_id,
client_secret=config.msgraph_client_secret
)
smtp_server = SMTPServer(
host='0.0.0.0',
port=config.smtp_port,
tls_cert_path=config.smtp_tls_cert_path,
tls_key_path=config.smtp_tls_key_path,
msgraph_client=msgraph_client,
user_mappings=config.smtp_users
)
try:
await smtp_server.start()
while True:
await asyncio.sleep(1)
except KeyboardInterrupt:
print("\nShutting down...")
if isinstance(msgraph_client, MockMSGraphClient):
msgraph_client.print_summary()
await smtp_server.stop()
except Exception as e:
print(f"Error: {str(e)}")
await smtp_server.stop()
raise
if __name__ == '__main__':
asyncio.run(main())