Use YAML formatted variable file

master
Daniel Berteaud 6 years ago
parent fd692fce9e
commit e5803c65f2
  1. 2
      WAPT/control
  2. 14
      setup.py

@ -1,5 +1,5 @@
package : fws-thunderbird-config package : fws-thunderbird-config
version : 6 version : 7
architecture : all architecture : all
section : base section : base
priority : optional priority : optional

@ -1,7 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from setuphelpers import * from setuphelpers import *
import json
from cryptography.fernet import Fernet
import os import os
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
@ -14,8 +12,10 @@ variables = {
# Read local variables file if available # Read local variables file if available
if isfile(makepath(programfiles32,'wapt','private','symetric.txt')) and isfile(makepath(programfiles32,'wapt','private','variables.txt')): if isfile(makepath(programfiles32,'wapt','private','symetric.txt')) and isfile(makepath(programfiles32,'wapt','private','variables.txt')):
print('Reading local encrypted variables file') print('Reading local encrypted variables file')
from cryptography.fernet import Fernet
import yaml
f = Fernet(open(makepath(programfiles32,'wapt','private','symetric.txt'),'r').read()) f = Fernet(open(makepath(programfiles32,'wapt','private','symetric.txt'),'r').read())
variables.update(json.loads(f.decrypt(open(makepath(programfiles32,'wapt','private','variables.txt'),'r').read()))) variables.update(yaml.safe_load(f.decrypt(open(makepath(programfiles32,'wapt','private','variables.txt'),'r').read())))
def install(): def install():
filecopyto('autoconf.js', makepath(programfiles,'Mozilla Thunderbird','defaults','pref')) filecopyto('autoconf.js', makepath(programfiles,'Mozilla Thunderbird','defaults','pref'))
@ -23,7 +23,7 @@ def install():
mkdirs(makepath(programfiles, 'Mozilla Thunderbird','chrome')) mkdirs(makepath(programfiles, 'Mozilla Thunderbird','chrome'))
filecopyto('custom-strings.txt', makepath(programfiles,'Mozilla Thunderbird','chrome')) filecopyto('custom-strings.txt', makepath(programfiles,'Mozilla Thunderbird','chrome'))
jinja2 = Environment( jinja2 = Environment(
loader=FileSystemLoader(os.path.dirname(os.path.abspath(__file__))), loader=FileSystemLoader(os.getcwd()),
trim_blocks=True trim_blocks=True
) )
open(makepath(programfiles,'Mozilla Thunderbird','thunderbird.cfg'),'w').write( open(makepath(programfiles,'Mozilla Thunderbird','thunderbird.cfg'),'w').write(
@ -34,9 +34,9 @@ def install():
) )
def uninstall(): def uninstall():
os.unlink(makepath(programfiles,'Mozilla Thunderbird','defaults','pref','autoconf.js')) remove_file(makepath(programfiles,'Mozilla Thunderbird','defaults','pref','autoconf.js'))
os.unlink(makepath(programfiles,'Mozilla Thunderbird','chrome','custom-strings.txt')) remove_file(makepath(programfiles,'Mozilla Thunderbird','chrome','custom-strings.txt'))
os.unlink(makepath(programfiles,'Mozilla Thunderbird','thunderbird.cfg')) remove_file(makepath(programfiles,'Mozilla Thunderbird','thunderbird.cfg'))
def audit(): def audit():
if ( if (

Loading…
Cancel
Save