boxconfig.py 834 B

123456789101112131415161718192021222324252627
  1. import json
  2. import os
  3. AZAP_PATH = os.path.expanduser('~/.azap')
  4. CHANNELS_PATH = os.path.join(AZAP_PATH, 'channels.conf')
  5. def parse_config(filename='/code/fourier-config.json'):
  6. with open(filename, 'r') as fp:
  7. the_config = json.loads(fp.read())
  8. if 'localDatabase' not in the_config:
  9. the_config['localDatabase'] = os.path.join(
  10. the_config['basepath'],
  11. the_config['device_id'],
  12. 'files.db'
  13. )
  14. return the_config
  15. def prepare_channels(channels):
  16. if not os.path.isdir(AZAP_PATH):
  17. os.mkdir(AZAP_PATH)
  18. with open(CHANNELS_PATH, 'w') as f:
  19. for channel in channels:
  20. f.write((
  21. '{id}:{herz}:{modulation}:'
  22. '{videoID}:{audioID}:{serviceID}\n'
  23. ).format(**channel))