Lines 1-7
Link Here
|
1 |
#!/usr/bin/env python-thinlinc |
1 |
#!/usr/bin/env python-thinlinc |
2 |
# -*- mode: python; coding: utf-8 -*- |
2 |
# -*- mode: python; coding: utf-8 -*- |
3 |
# |
3 |
# |
4 |
# Copyright 2014 Cendio AB. |
4 |
# Copyright 2014-2018 Cendio AB. |
5 |
# For more information, see http://www.cendio.com |
5 |
# For more information, see http://www.cendio.com |
6 |
|
6 |
|
7 |
import sys |
7 |
import sys |
Lines 8-13
Link Here
|
8 |
import os |
8 |
import os |
9 |
import pipes |
9 |
import pipes |
10 |
import re |
10 |
import re |
|
|
11 |
import subprocess |
11 |
|
12 |
|
12 |
# Add modules dirs. FIXME: Use relative paths. |
13 |
# Add modules dirs. FIXME: Use relative paths. |
13 |
sys.path = ["/opt/thinlinc/modules"] + sys.path |
14 |
sys.path = ["/opt/thinlinc/modules"] + sys.path |
Lines 33-38
Link Here
|
33 |
escaped_argv.append(pipes.quote(arg)) |
34 |
escaped_argv.append(pipes.quote(arg)) |
34 |
return " ".join(escaped_argv) |
35 |
return " ".join(escaped_argv) |
35 |
|
36 |
|
|
|
37 |
def update_dbus_environ(environ): |
38 |
if which.which("dbus-update-activation-environment") is None: |
39 |
return |
40 |
|
41 |
print 'Updating D-Bus and systemd environment...' |
42 |
p = subprocess.Popen(["dbus-update-activation-environment", |
43 |
"--systemd", "--all"], |
44 |
env=environ) |
45 |
p.wait() |
46 |
if p.returncode != 0: |
47 |
print >>sys.stderr, "tl-run-profile: Failed to update D-Bus and systemd environment" |
48 |
|
36 |
if __name__ == "__main__": |
49 |
if __name__ == "__main__": |
37 |
if len(sys.argv) != 1: |
50 |
if len(sys.argv) != 1: |
38 |
print >>sys.stderr, "Usage:" |
51 |
print >>sys.stderr, "Usage:" |
Lines 46-51
Link Here
|
46 |
if not os.getenv("TLCOMMAND").strip(): |
59 |
if not os.getenv("TLCOMMAND").strip(): |
47 |
print >>sys.stderr, "tl-run-profile: Ignoring existing but empty TLCOMMAND." |
60 |
print >>sys.stderr, "tl-run-profile: Ignoring existing but empty TLCOMMAND." |
48 |
else: |
61 |
else: |
|
|
62 |
update_dbus_environ(os.environ.copy()) |
49 |
print "Executing start program command: %s" % os.environ["TLCOMMAND"] |
63 |
print "Executing start program command: %s" % os.environ["TLCOMMAND"] |
50 |
sys.stdout.flush() |
64 |
sys.stdout.flush() |
51 |
try: |
65 |
try: |
Lines 152-157
Link Here
|
152 |
|
166 |
|
153 |
break |
167 |
break |
154 |
|
168 |
|
|
|
169 |
update_dbus_environ(environ) |
170 |
|
155 |
if (cmdline is not None) and (cmdline != ""): |
171 |
if (cmdline is not None) and (cmdline != ""): |
156 |
# Explicit command line |
172 |
# Explicit command line |
157 |
print 'Executing profile command: %s' % cmdline |
173 |
print 'Executing profile command: %s' % cmdline |