|
39 | 39 |
|
40 | 40 | LOG = logging.getLogger(".")
|
41 | 41 |
|
42 |
| -from gi.repository import GLib |
| 42 | +try: |
| 43 | + from gi.repository import GLib |
| 44 | + |
| 45 | + _GOBJECT_AVAILABLE = True |
| 46 | +except ModuleNotFoundError: |
| 47 | + _GOBJECT_AVAILABLE = False |
43 | 48 |
|
44 | 49 | # -------------------------------------------------------------------------
|
45 | 50 | #
|
|
117 | 122 | shutil.move(OLD_HOME, USER_DATA)
|
118 | 123 | else:
|
119 | 124 | USER_HOME = get_env_var("HOME")
|
120 |
| - USER_DATA = os.path.join(GLib.get_user_data_dir(), "gramps") |
121 |
| - USER_CONFIG = os.path.join(GLib.get_user_config_dir(), "gramps") |
| 125 | + USER_DATA = os.path.join( |
| 126 | + GLib.get_user_data_dir() if _GOBJECT_AVAILABLE else USER_HOME, "gramps" |
| 127 | + ) |
| 128 | + USER_CONFIG = os.path.join( |
| 129 | + GLib.get_user_config_dir() if _GOBJECT_AVAILABLE else USER_HOME, "gramps" |
| 130 | + ) |
122 | 131 | # Copy the database directory into the XDG directory.
|
123 | 132 | OLD_HOME = os.path.join(USER_HOME, ".gramps")
|
124 | 133 | if os.path.exists(OLD_HOME):
|
|
129 | 138 | if os.path.exists(db_dir):
|
130 | 139 | shutil.copytree(db_dir, os.path.join(USER_DATA, "grampsdb"))
|
131 | 140 |
|
132 |
| -USER_CACHE = os.path.join(GLib.get_user_cache_dir(), "gramps") |
| 141 | +USER_CACHE = os.path.join(GLib.get_user_cache_dir(), "gramps") if _GOBJECT_AVAILABLE else os.path.join(USER_HOME, "cache") |
133 | 142 |
|
134 | 143 | if "SAFEMODE" in os.environ:
|
135 | 144 | USER_CONFIG = get_env_var("SAFEMODE")
|
136 | 145 |
|
137 |
| -USER_PICTURES = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES) |
138 |
| -if not USER_PICTURES: |
139 |
| - USER_PICTURES = USER_DATA |
| 146 | +USER_PICTURES = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES) if _GOBJECT_AVAILABLE else USER_DATA |
140 | 147 |
|
141 | 148 | VERSION_DIR_NAME = "gramps%s%s" % (VERSION_TUPLE[0], VERSION_TUPLE[1])
|
142 | 149 | VERSION_DIR = os.path.join(USER_CONFIG, VERSION_DIR_NAME)
|
|
0 commit comments