|
4 | 4 | __author__ = 'Simon Robinson'
|
5 | 5 | __copyright__ = 'Copyright (c) 2021 Simon Robinson'
|
6 | 6 | __license__ = 'Apache 2.0'
|
7 |
| -__version__ = '2022-03-21' # ISO 8601 |
| 7 | +__version__ = '2022-03-24' # ISO 8601 |
8 | 8 |
|
9 | 9 | import argparse
|
10 | 10 | import asyncore
|
@@ -906,6 +906,9 @@ def handle_accepted(self, connection, address):
|
906 | 906 | error_text = '%s encountered an SSL error - is the server\'s starttls setting correct? Current ' \
|
907 | 907 | 'value: %s' % (self.info_string(), self.custom_configuration['starttls'])
|
908 | 908 | Log.info(error_text)
|
| 909 | + if sys.platform == 'darwin': |
| 910 | + Log.info('If you repeatedly encounter this error, please check that you have correctly configured ' |
| 911 | + 'python root certificates - see: https://github.com/simonrob/email-oauth2-proxy/issues/14') |
909 | 912 | connection.send(b'%s\r\n' % self.bye_message(error_text).encode('utf-8'))
|
910 | 913 | connection.close()
|
911 | 914 | else:
|
@@ -1471,15 +1474,25 @@ def toggle_verbose(_, item):
|
1471 | 1474 | global VERBOSE
|
1472 | 1475 | VERBOSE = not item.checked
|
1473 | 1476 |
|
| 1477 | + # noinspection PyUnresolvedReferences |
1474 | 1478 | def notify(self, title, text):
|
1475 | 1479 | if self.icon and self.icon.HAS_NOTIFICATION:
|
1476 | 1480 | self.icon.remove_notification()
|
1477 | 1481 | self.icon.notify('%s: %s' % (title, text))
|
| 1482 | + |
1478 | 1483 | elif sys.platform == 'darwin':
|
1479 |
| - for replacement in (('\\', '\\\\'), ('"', '\\"')): # direct use of osascript requires a bit of sanitisation |
1480 |
| - text = text.replace(*replacement) |
1481 |
| - title = title.replace(*replacement) |
1482 |
| - os.system('osascript -e \'display notification "%s" with title "%s"\'' % (text, title)) |
| 1484 | + user_notification = AppKit.NSUserNotification.alloc().init() |
| 1485 | + user_notification.setTitle_(title) |
| 1486 | + user_notification.setInformativeText_(text) |
| 1487 | + notification_centre = AppKit.NSUserNotificationCenter.defaultUserNotificationCenter() |
| 1488 | + try: |
| 1489 | + notification_centre.deliverNotification_(user_notification) |
| 1490 | + except Exception: |
| 1491 | + for replacement in (('\\', '\\\\'), ('"', '\\"')): # osascript approach requires a bit of sanitisation |
| 1492 | + text = text.replace(*replacement) |
| 1493 | + title = title.replace(*replacement) |
| 1494 | + os.system('osascript -e \'display notification "%s" with title "%s"\'' % (text, title)) |
| 1495 | + |
1483 | 1496 | else:
|
1484 | 1497 | Log.info(title, text) # last resort
|
1485 | 1498 |
|
|
0 commit comments