Meant to be used with open-source-billing.
Launch:
python3 wkhtmltopdf_update.pyMeant to be used with open-source-billing.
Launch:
python3 wkhtmltopdf_update.py| import ruamel.yaml | |
| import subprocess | |
| fname = "config/config.yml" | |
| config, ind, bsi = ruamel.yaml.util.load_yaml_guess_indent(open(fname)) | |
| wkhtmltopdf = subprocess.run(['which', 'wkhtmltopdf'], stdout=subprocess.PIPE) | |
| wkhtmltopdf_path = wkhtmltopdf.stdout.decode('utf-8').replace("\"", "").replace("\n", "") | |
| rake_secret_raw = subprocess.run(['rake', 'secret'], stdout=subprocess.PIPE) | |
| rake_secret = rake_secret_raw.stdout.decode('utf-8').split("\n")[-2] | |
| production = config['development'] | |
| production['wkhtmltopdf_path'] = wkhtmltopdf_path | |
| production['encryption_key'] = rake_secret | |
| yaml = ruamel.yaml.YAML() | |
| yaml.indent(mapping=ind, sequence=ind, offset=bsi) | |
| with open(fname, 'w') as fp: | |
| yaml.dump(config, fp) |