Debian Codegraph @

scripts/displaycal-apply-profiles-launcher

raw
1 #!/usr/bin/env python3
2 import sys
3 import time
4
5 if sys.platform != "win32":
6 print("This stub is only used on Windows.")
7 sys.exit(1)
8
9 import os
10 import subprocess as sp
11
12 appname = "DisplayCAL"
13
14 if getattr(sys, "frozen", False):
15 args = [
16 os.path.join(os.path.dirname(sys.executable), f"{appname}-apply-profiles.exe")
17 ]
18 else:
19 args = [sys.executable]
20 dirname = os.path.dirname(__file__)
21 pyw = os.path.join(dirname, "..", f"{appname}-apply-profiles.pyw")
22 if os.path.isfile(pyw):
23 args.append(os.path.normpath(pyw))
24 else:
25 args.append(os.path.join(dirname, f"{appname.lower()}-apply-profiles"))
26
27 args.append("--task")
28 if "--oneshot" in sys.argv[1:]:
29 args.append("--oneshot")
30
31 sp.Popen(args, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.STDOUT)
32
33 # Sleep a few seconds so task scheduler can see an instance already running and
34 # won't start another one due to multiple triggers firing at the same time
35 time.sleep(9)