Mercurial > sat_docs
annotate flatpak/sat_wrapper.py @ 155:5af7c3d4fab2
flatpak (build_manifest): fixed ordering when a one-short temporary directory is used
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 28 Jun 2019 15:21:10 +0200 |
parents | 2602c690806b |
children |
rev | line source |
---|---|
138
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python2 |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 """This script launch SàT backend if it's not before running command""" |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 import os |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 import sys |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 import dbus |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 import subprocess |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 command = "##COMMAND##" |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 const_INT_PREFIX = "org.salutatoi.SAT" |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 const_OBJ_PATH = '/org/salutatoi/SAT/bridge' |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 |
142
2602c690806b
flatpak (sat_wrapper): don't use packages from $HOME in PYTHONPATH to avoid conflicts:
Goffi <goffi@goffi.org>
parents:
138
diff
changeset
|
14 # we remove any path with "/home" from PYTHONPATH because we have |
2602c690806b
flatpak (sat_wrapper): don't use packages from $HOME in PYTHONPATH to avoid conflicts:
Goffi <goffi@goffi.org>
parents:
138
diff
changeset
|
15 # "--filesystem=home" permission and packages in .local/lib/python2.7/site-packages may |
2602c690806b
flatpak (sat_wrapper): don't use packages from $HOME in PYTHONPATH to avoid conflicts:
Goffi <goffi@goffi.org>
parents:
138
diff
changeset
|
16 # conflict with the ones from flatpak |
2602c690806b
flatpak (sat_wrapper): don't use packages from $HOME in PYTHONPATH to avoid conflicts:
Goffi <goffi@goffi.org>
parents:
138
diff
changeset
|
17 clean_pythonpath = ':'.join(p for p in sys.path if p and not p.startswith('/home')) |
2602c690806b
flatpak (sat_wrapper): don't use packages from $HOME in PYTHONPATH to avoid conflicts:
Goffi <goffi@goffi.org>
parents:
138
diff
changeset
|
18 os.environ['PYTHONPATH'] = clean_pythonpath |
2602c690806b
flatpak (sat_wrapper): don't use packages from $HOME in PYTHONPATH to avoid conflicts:
Goffi <goffi@goffi.org>
parents:
138
diff
changeset
|
19 os.environ['PYTHONNOUSERSITE'] = '1' |
138
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 try: |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 sessions_bus = dbus.SessionBus() |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 db_object = sessions_bus.get_object(const_INT_PREFIX, |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 const_OBJ_PATH) |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 except dbus.exceptions.DBusException as e: |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 if e._dbus_error_name != 'org.freedesktop.DBus.Error.ServiceUnknown': |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 raise e |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 # backend not found, we need to launch it |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 print("Launching SàT backend") |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 subprocess.check_call("sat") |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 |
274af514a5cf
flatpak: reworked packages + made a building script:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 os.execlp(command, command, *sys.argv[1:]) |