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.

23 lines
751 B

  1. """
  2. Util for talking to the client program in order to retrieve
  3. dynamic defaults for the UI
  4. """
  5. import json
  6. import subprocess
  7. def fetchDynamicProperties(target, encoding):
  8. """
  9. Sends a gooey-seed-ui request to the client program it retrieve
  10. dynamically generated defaults with which to seed the UI
  11. """
  12. # TODO: this needs to apply the same argpase_to_json data cleaning rules
  13. cmd = '{} {}'.format(target, 'gooey-seed-ui --ignore-gooey')
  14. proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
  15. if proc.returncode != 0:
  16. out, _ = proc.communicate()
  17. return json.loads(out.decode(encoding))
  18. else:
  19. # TODO: useful feedback
  20. return {}