Module spotify_state -> mqtt
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

__install__.py 889B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/python
  2. #
  3. import os
  4. import sys
  5. SERVICE_FILE = """
  6. [Unit]
  7. Description=Spotify Service
  8. After=mosquitto.target
  9. [Service]
  10. User=%(UID)d
  11. Group=%(GID)d
  12. ExecStart=%(MY_PATH)s/spotify.sh
  13. Type=simple
  14. [Install]
  15. WantedBy=default.target
  16. """
  17. def help():
  18. print("Usage: prog <UID> <GID> <TARGET_PATH>")
  19. if __name__ == "__main__":
  20. if len(sys.argv) == 4:
  21. try:
  22. uid = int(sys.argv[1])
  23. gid = int(sys.argv[2])
  24. except ValueError:
  25. help()
  26. else:
  27. if os.path.isdir(sys.argv[3]):
  28. with open(os.path.join(sys.argv[3], 'spotify.service'), "w") as fh:
  29. fh.write(SERVICE_FILE % {
  30. "MY_PATH": os.path.dirname(os.path.abspath(__file__)),
  31. "UID": uid,
  32. "GID": gid})
  33. else:
  34. help()
  35. else:
  36. help()