forked from varietywalls/variety
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variety-bin
66 lines (60 loc) · 2.72 KB
/
variety-bin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/python3
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
### BEGIN LICENSE
# Copyright (c) 2012, Peter Levi <[email protected]>
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
### END LICENSE
import os
import sys
#if os.geteuid() == 0:
# print(
# 'Variety is not supposed to run as root.\n'
# 'You should NEVER run desktop apps as root, unless they are supposed to make '
# 'system-global changes and you know very well what you are doing.\n'
# 'Please run it with your normal user.\n'
# '\n'
# 'If you are trying to run as root because Variety does not start at all with your normal '
# 'user, you may be hitting a file permission issue or a bug.\n'
# 'Here is what to do to troubleshoot:\n'
# '\n'
# '1. Open a terminal and run "variety -v" with your normal user.\n'
# 'Look for exceptions and hints in the log for what the problem might be.\n'
# '\n'
# '2. You may try to rename ~/.config/variety to ~/.config/variety_bak and try again.\n'
# 'This will have Variety start from a clean state.\n'
# 'Your old config and images will remain in variety_bak\n'
# '\n'
# '3. If none of these helps, open a bug in https://github.com/varietywalls/variety/issues '
# 'and follow the instructions there.'
# )
# exit(1)
# Add project root directory (enable symlink and trunk execution)
PROJECT_ROOT_DIRECTORY = os.path.abspath(
os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0])))
)
python_path = []
if os.path.abspath(__file__).startswith("/opt"):
syspath = sys.path[:] # copy to avoid infinite loop in pending objects
for path in syspath:
opt_path = path.replace("/usr", "/opt/extras.ubuntu.com/variety")
python_path.insert(0, opt_path)
sys.path.insert(0, opt_path)
if os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, "variety")):
python_path.insert(0, PROJECT_ROOT_DIRECTORY)
sys.path.insert(0, PROJECT_ROOT_DIRECTORY)
if python_path:
os.putenv(
"PYTHONPATH", "%s:%s" % (os.getenv("PYTHONPATH", ""), ":".join(python_path))
) # for subprocesses
import variety # isort:skip
variety.main()