SOGo Addons for WAPT
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.

setup.py 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # -*- coding: UTF-8 -*-
  2. from setuphelpers import *
  3. import os
  4. from jinja2 import Environment, FileSystemLoader
  5. uninstallkey = []
  6. variables = {
  7. 'sogo_server': 'mail.server.local'
  8. }
  9. # Read local variables file if available
  10. if isfile(makepath(programfiles32,'wapt','private','symetric.txt')) and isfile(makepath(programfiles32,'wapt','private','variables.txt')):
  11. print('Reading local encrypted variables file')
  12. from cryptography.fernet import Fernet
  13. import yaml
  14. f = Fernet(open(makepath(programfiles32,'wapt','private','symetric.txt'),'r').read())
  15. variables.update(yaml.safe_load(f.decrypt(open(makepath(programfiles32,'wapt','private','variables.txt'),'r').read())))
  16. def install():
  17. connector_version = control['version'].split('-',1)[0]
  18. integrator_version = connector_version
  19. for extension in ['connector','integrator']:
  20. if isdir(makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-%s@inverse.ca' % extension)):
  21. remove_tree(makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-%s@inverse.ca' % extension))
  22. mkdirs(makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-%s@inverse.ca' % extension))
  23. # connector can be extracted as is
  24. unzip('sogo-connector-%s.xpi' % connector_version, makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-connector@inverse.ca'))
  25. # Integrator must be customized, so first extract it
  26. unzip('sogo-integrator-%s-sogo-demo.xpi' % integrator_version, makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-integrator@inverse.ca'))
  27. # And replace the extensions.rdf content
  28. jinja2 = Environment(
  29. loader=FileSystemLoader(os.path.dirname(os.path.abspath(__file__))),
  30. trim_blocks=True
  31. )
  32. open(makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-integrator@inverse.ca','chrome','content','extensions.rdf'),'w').write(
  33. jinja2.get_template('extensions.rdf.j2').render(
  34. sogo_server = variables['sogo_server']
  35. )
  36. )
  37. # Also remove custom settings
  38. os.unlink(makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-integrator@inverse.ca','defaults','preferences','site.js'))
  39. def uninstall():
  40. print('Removing SOGo extensions for Thunderbird')
  41. for extension in ['connector','integrator']:
  42. remove_tree(makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-%s@inverse.ca' % extension))
  43. def audit():
  44. connector_version = control['version'].split('-',1)[0]
  45. integrator_version = connector_version
  46. try:
  47. run('type "%s" | find /I "em:version=" | find "%s"' % (makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-connector@inverse.ca','install.rdf'), connector_version))
  48. except:
  49. print('SOGO connector version check failed')
  50. return "ERROR"
  51. try:
  52. run('type "%s" | find /I "em:version=" | find "%s"' % (makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-integrator@inverse.ca','install.rdf'), integrator_version))
  53. except:
  54. print('SOGO integrator version check failed')
  55. return "ERROR"
  56. return "OK"