Using the Microsoft Graph API to retrieve Calendar and convert to Orgmode compatible plain text.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.4 KiB

  1. #!/usr/bin/python
  2. """Configuration settings for console app using device flow authentication
  3. """
  4. import re
  5. import os
  6. import configparser
  7. # Read Config from File
  8. config = configparser.RawConfigParser({
  9. 'machine': '',
  10. 'login': '',
  11. 'days_history': 7,
  12. 'days_future': 30,
  13. 'max_entries': 100
  14. })
  15. directory = os.path.dirname(os.path.realpath(__file__))
  16. config.read(os.path.join(directory, 'config.cfg'))
  17. def get_secret(machine, login, key):
  18. s = "^machine %s login %s[\^]%s password (.*)$" % (machine, login, key)
  19. p = re.compile(s, re.MULTILINE)
  20. authinfo = os.popen("gpg -q --no-tty -d ~/.authinfo.gpg").read()
  21. matches = p.search(authinfo)
  22. if matches is not None:
  23. return matches.group(1)
  24. else:
  25. return None
  26. RESOURCE = config.get('msgraph-orgmode', 'resource')
  27. API_VERSION = config.get('msgraph-orgmode', 'api_version')
  28. LOGIN = config.get('msgraph-orgmode', 'login')
  29. MACHINE = config.get('msgraph-orgmode', 'machine')
  30. CLIENT_ID = config.get('msgraph-orgmode', 'client_id')
  31. CLIENT_SECRET = get_secret(MACHINE, LOGIN, 'client_secret')
  32. daysHistory = config.getint('msgraph-orgmode', 'days_history')
  33. daysFuture = config.getint('msgraph-orgmode', 'days_future')
  34. maxEntries = config.getint('msgraph-orgmode', 'max_entries')
  35. if not CLIENT_ID and not CLIENT_SECRET:
  36. print('ERROR: CLIENT_ID and CLIENT_SECRET are required.')
  37. import sys
  38. sys.exit(1)