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.

22 lines
661 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. cmd = '{} {}'.format(target, 'gooey-seed-ui --ignore-gooey')
  13. proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  14. if proc.returncode != 0:
  15. out, _ = proc.communicate()
  16. return json.loads(out.decode(encoding))
  17. else:
  18. # TODO: useful feedback
  19. return {}