Use GLib for better reliability
This commit is contained in:
parent
83544bda79
commit
07403bc380
|
@ -29,19 +29,17 @@ import dbus
|
||||||
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from gi.repository import Gtk, GdkPixbuf # pylint: disable=E0611
|
from gi.repository import Gtk, GdkPixbuf, GLib # pylint: disable=E0611
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger('mugshot')
|
logger = logging.getLogger('mugshot')
|
||||||
|
|
||||||
from mugshot_lib import Window
|
from mugshot_lib import Window
|
||||||
from mugshot.CameraMugshotDialog import CameraMugshotDialog
|
from mugshot.CameraMugshotDialog import CameraMugshotDialog
|
||||||
|
|
||||||
username = os.getenv('USER')
|
username = GLib.get_user_name()
|
||||||
if not username:
|
home = GLib.get_home_dir()
|
||||||
username = os.getenv('USERNAME')
|
libreoffice_prefs = os.path.join(GLib.get_user_config_dir(), 'libreoffice',
|
||||||
home = os.path.expanduser('~')
|
'4', 'user', 'registrymodifications.xcu')
|
||||||
libreoffice_prefs = os.path.join(home, '.config', 'libreoffice', '4', 'user',
|
|
||||||
'registrymodifications.xcu')
|
|
||||||
pidgin_prefs = os.path.join(home, '.purple', 'prefs.xml')
|
pidgin_prefs = os.path.join(home, '.purple', 'prefs.xml')
|
||||||
faces_dir = '/usr/share/pixmaps/faces/'
|
faces_dir = '/usr/share/pixmaps/faces/'
|
||||||
|
|
||||||
|
@ -217,7 +215,7 @@ class MugshotWindow(Window):
|
||||||
"""Initialize the user details entries and variables."""
|
"""Initialize the user details entries and variables."""
|
||||||
# Check for .face and set profile image.
|
# Check for .face and set profile image.
|
||||||
logger.debug('Checking for ~/.face profile image')
|
logger.debug('Checking for ~/.face profile image')
|
||||||
face = os.path.expanduser('~/.face')
|
face = os.path.join(home, '.face')
|
||||||
if os.path.isfile(face):
|
if os.path.isfile(face):
|
||||||
self.set_user_image(face)
|
self.set_user_image(face)
|
||||||
else:
|
else:
|
||||||
|
@ -349,7 +347,7 @@ class MugshotWindow(Window):
|
||||||
logger.debug('Photo not updated, not saving changes.')
|
logger.debug('Photo not updated, not saving changes.')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
face = os.path.expanduser('~/.face')
|
face = os.path.join(home, '.face')
|
||||||
|
|
||||||
# If the .face file already exists, remove it first.
|
# If the .face file already exists, remove it first.
|
||||||
logger.debug('Photo updated, saving changes.')
|
logger.debug('Photo updated, saving changes.')
|
||||||
|
@ -445,7 +443,6 @@ class MugshotWindow(Window):
|
||||||
if not password:
|
if not password:
|
||||||
return return_codes
|
return return_codes
|
||||||
|
|
||||||
username = os.getenv('USER')
|
|
||||||
sudo = which('sudo')
|
sudo = which('sudo')
|
||||||
chfn = which('chfn')
|
chfn = which('chfn')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue