License and setup updates
This commit is contained in:
parent
a1691007b0
commit
ecdfb1ecdd
55
bin/mugshot
55
bin/mugshot
|
@ -1,47 +1,32 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
||||||
### BEGIN LICENSE
|
# Mugshot - Lightweight user configuration utility
|
||||||
# Copyright (C) 2013 Sean Davis <smd.seandavis@gmail.com>
|
# Copyright (C) 2013-2014 Sean Davis <smd.seandavis@gmail.com>
|
||||||
# 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
|
# This program is free software: you can redistribute it and/or modify it
|
||||||
# by the Free Software Foundation.
|
# 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
|
# This program is distributed in the hope that it will be useful, but
|
||||||
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
||||||
# PURPOSE. See the GNU General Public License for more details.
|
# 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/>.
|
# You should have received a copy of the GNU General Public License along
|
||||||
### END LICENSE
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
### DO NOT EDIT THIS FILE ###
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import locale
|
import gi
|
||||||
locale.textdomain('mugshot')
|
gi.require_version('Gtk', '3.0')
|
||||||
|
|
||||||
# Add project root directory (enable symlink and trunk execution)
|
# Get project root directory (enable symlink and trunk execution)
|
||||||
PROJECT_ROOT_DIRECTORY = os.path.abspath(
|
PROJECT_ROOT_DIRECTORY = os.path.abspath(
|
||||||
os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))))
|
os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))))
|
||||||
|
|
||||||
python_path = []
|
# Add project root directory to python search path
|
||||||
if os.path.abspath(__file__).startswith('/opt'):
|
sys.path.append(PROJECT_ROOT_DIRECTORY)
|
||||||
locale.bindtextdomain('mugshot', '/opt/extras.ubuntu.com/mugshot/share/locale')
|
|
||||||
syspath = sys.path[:] # copy to avoid infinite loop in pending objects
|
|
||||||
for path in syspath:
|
|
||||||
opt_path = path.replace('/usr', '/opt/extras.ubuntu.com/mugshot')
|
|
||||||
python_path.insert(0, opt_path)
|
|
||||||
sys.path.insert(0, opt_path)
|
|
||||||
os.putenv("XDG_DATA_DIRS", "%s:%s" % ("/opt/extras.ubuntu.com/mugshot/share/", os.getenv("XDG_DATA_DIRS", "/usr/local/share/:/usr/share/")))
|
|
||||||
if (os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, 'mugshot'))
|
|
||||||
and PROJECT_ROOT_DIRECTORY not in sys.path):
|
|
||||||
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 mugshot
|
import mugshot
|
||||||
mugshot.main()
|
mugshot.main()
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
.de URL
|
||||||
|
\\$2 \(laURL: \\$1 \(ra\\$3
|
||||||
|
..
|
||||||
|
.if \n[.g] .mso www.tmac
|
||||||
|
.TH MUGSHOT "1" "January 2014" "mugshot 0.1" "User Commands"
|
||||||
|
.SH NAME
|
||||||
|
mugshot \- lightweight user configuration utility
|
||||||
|
.SH DESCRIPTION
|
||||||
|
Mugshot is a lightweight user configuration utility. Mugshot allows you to easily set profile image and user details for your user profile and any supported applications.
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B mugshot
|
||||||
|
[\fIoptions\fR]
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
\fB\-\-version\fR
|
||||||
|
show program's version number and exit
|
||||||
|
.TP
|
||||||
|
\fB\-h\fR, \fB\-\-help\fR
|
||||||
|
show this help message and exit
|
||||||
|
.TP
|
||||||
|
\fB\-v\fR, \fB\-\-verbose\fR
|
||||||
|
Show debug messages (\fB\-vv\fR debugs mugshot_lib also)
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
The full documentation for
|
||||||
|
.B mugshot
|
||||||
|
is maintained online at
|
||||||
|
.URL "http://wiki.smdavis.us/doku.php?id=mugshot-docs" "the authors documentation portal" "."
|
||||||
|
.SH BUGS
|
||||||
|
Please report bugs at
|
||||||
|
.URL "https://bugs.launchpad.net/mugshot" "the Mugshot Bugs page" "."
|
||||||
|
.SH AUTHOR
|
||||||
|
Sean Davis (smd.seandavis@gmail.com)
|
|
@ -1,20 +1,22 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
||||||
### BEGIN LICENSE
|
# Mugshot - Lightweight user configuration utility
|
||||||
# Copyright (C) 2013 Sean Davis <smd.seandavis@gmail.com>
|
# Copyright (C) 2013-2014 Sean Davis <smd.seandavis@gmail.com>
|
||||||
# Copyright (C) 2010 Rick Spencer <rick.spencer@canonical.com>
|
|
||||||
# Portions of this code are inspired by web_cam_box by Rick Spencer.
|
|
||||||
# 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
|
# Portions of this file are adapted from web_cam_box,
|
||||||
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
# Copyright (C) 2010 Rick Spencer <rick.spencer@canonical.com>
|
||||||
# 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
|
# This program is free software: you can redistribute it and/or modify it
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# under the terms of the GNU General Public License version 3, as published
|
||||||
### END LICENSE
|
# 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/>.
|
||||||
|
|
||||||
from locale import gettext as _
|
from locale import gettext as _
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
||||||
### BEGIN LICENSE
|
# Mugshot - Lightweight user configuration utility
|
||||||
# Copyright (C) 2013 Sean Davis <smd.seandavis@gmail.com>
|
# Copyright (C) 2013-2014 Sean Davis <smd.seandavis@gmail.com>
|
||||||
# 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
|
# This program is free software: you can redistribute it and/or modify it
|
||||||
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
# under the terms of the GNU General Public License version 3, as published
|
||||||
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
# by the Free Software Foundation.
|
||||||
# PURPOSE. See the GNU General Public License for more details.
|
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License along
|
# This program is distributed in the hope that it will be useful, but
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
||||||
### END LICENSE
|
# 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/>.
|
||||||
|
|
||||||
from locale import gettext as _
|
from locale import gettext as _
|
||||||
|
|
||||||
|
@ -134,9 +135,9 @@ def get_confirmation_dialog(parent, primary_message, secondary_message,
|
||||||
"""Display a confirmation (yes/no) dialog configured with primary and
|
"""Display a confirmation (yes/no) dialog configured with primary and
|
||||||
secondary messages, as well as a custom icon if requested."""
|
secondary messages, as well as a custom icon if requested."""
|
||||||
dialog = Gtk.MessageDialog(transient_for=parent, flags=0,
|
dialog = Gtk.MessageDialog(transient_for=parent, flags=0,
|
||||||
type=Gtk.MessageType.QUESTION,
|
message_type=Gtk.MessageType.QUESTION,
|
||||||
buttons=Gtk.ButtonsType.YES_NO,
|
buttons=Gtk.ButtonsType.YES_NO,
|
||||||
message_format=primary_message)
|
text=primary_message)
|
||||||
dialog.format_secondary_text(secondary_message)
|
dialog.format_secondary_text(secondary_message)
|
||||||
if icon_name:
|
if icon_name:
|
||||||
image = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.DIALOG)
|
image = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.DIALOG)
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
||||||
### BEGIN LICENSE
|
# Mugshot - Lightweight user configuration utility
|
||||||
# Copyright (C) 2013 Sean Davis <smd.seandavis@gmail.com>
|
# Copyright (C) 2013-2014 Sean Davis <smd.seandavis@gmail.com>
|
||||||
# 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
|
# This program is free software: you can redistribute it and/or modify it
|
||||||
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
# under the terms of the GNU General Public License version 3, as published
|
||||||
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
# by the Free Software Foundation.
|
||||||
# PURPOSE. See the GNU General Public License for more details.
|
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License along
|
# This program is distributed in the hope that it will be useful, but
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
||||||
### END LICENSE
|
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
||||||
|
# PURPOSE. See the GNU General Public License for more details.
|
||||||
### DO NOT EDIT THIS FILE ###
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along
|
||||||
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'''Enhances builder connections, provides object to access glade objects'''
|
'''Enhances builder connections, provides object to access glade objects'''
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
||||||
### BEGIN LICENSE
|
# Mugshot - Lightweight user configuration utility
|
||||||
# Copyright (C) 2013 Sean Davis <smd.seandavis@gmail.com>
|
# Copyright (C) 2013-2014 Sean Davis <smd.seandavis@gmail.com>
|
||||||
# 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
|
# This program is free software: you can redistribute it and/or modify it
|
||||||
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
# under the terms of the GNU General Public License version 3, as published
|
||||||
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
# by the Free Software Foundation.
|
||||||
# PURPOSE. See the GNU General Public License for more details.
|
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License along
|
# This program is distributed in the hope that it will be useful, but
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
||||||
### END LICENSE
|
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
||||||
|
# PURPOSE. See the GNU General Public License for more details.
|
||||||
### DO NOT EDIT THIS FILE ###
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along
|
||||||
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from gi.repository import Gtk # pylint: disable=E0611
|
from gi.repository import Gtk # pylint: disable=E0611
|
||||||
import logging
|
import logging
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
||||||
### BEGIN LICENSE
|
# Mugshot - Lightweight user configuration utility
|
||||||
# Copyright (C) 2013 Sean Davis <smd.seandavis@gmail.com>
|
# Copyright (C) 2013-2014 Sean Davis <smd.seandavis@gmail.com>
|
||||||
# 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
|
# This program is free software: you can redistribute it and/or modify it
|
||||||
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
# under the terms of the GNU General Public License version 3, as published
|
||||||
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
# by the Free Software Foundation.
|
||||||
# PURPOSE. See the GNU General Public License for more details.
|
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License along
|
# This program is distributed in the hope that it will be useful, but
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
||||||
### END LICENSE
|
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
||||||
|
# PURPOSE. See the GNU General Public License for more details.
|
||||||
### DO NOT EDIT THIS FILE ###
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along
|
||||||
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from gi.repository import Gio, Gtk # pylint: disable=E0611
|
from gi.repository import Gio, Gtk # pylint: disable=E0611
|
||||||
import logging
|
import logging
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
||||||
### BEGIN LICENSE
|
# Mugshot - Lightweight user configuration utility
|
||||||
# Copyright (C) 2013 Sean Davis <smd.seandavis@gmail.com>
|
# Copyright (C) 2013-2014 Sean Davis <smd.seandavis@gmail.com>
|
||||||
# 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
|
# This program is free software: you can redistribute it and/or modify it
|
||||||
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
# under the terms of the GNU General Public License version 3, as published
|
||||||
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
# by the Free Software Foundation.
|
||||||
# PURPOSE. See the GNU General Public License for more details.
|
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License along
|
# This program is distributed in the hope that it will be useful, but
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
||||||
### END LICENSE
|
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
||||||
|
# PURPOSE. See the GNU General Public License for more details.
|
||||||
### DO NOT EDIT THIS FILE ###
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along
|
||||||
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
"""Helpers for an Ubuntu application."""
|
"""Helpers for an Ubuntu application."""
|
||||||
import logging
|
import logging
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
||||||
### BEGIN LICENSE
|
# Mugshot - Lightweight user configuration utility
|
||||||
# Copyright (C) 2013 Sean Davis <smd.seandavis@gmail.com>
|
# Copyright (C) 2013-2014 Sean Davis <smd.seandavis@gmail.com>
|
||||||
# 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
|
# This program is free software: you can redistribute it and/or modify it
|
||||||
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
# under the terms of the GNU General Public License version 3, as published
|
||||||
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
# by the Free Software Foundation.
|
||||||
# PURPOSE. See the GNU General Public License for more details.
|
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License along
|
# This program is distributed in the hope that it will be useful, but
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
||||||
### END LICENSE
|
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
||||||
|
# PURPOSE. See the GNU General Public License for more details.
|
||||||
### DO NOT EDIT THIS FILE ###
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along
|
||||||
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'project_path_not_found',
|
'project_path_not_found',
|
||||||
|
|
208
setup.py
208
setup.py
|
@ -1,21 +1,19 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/python3
|
||||||
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
||||||
### BEGIN LICENSE
|
# Mugshot - Lightweight user configuration utility
|
||||||
# Copyright (C) 2013 Sean Davis <smd.seandavis@gmail.com>
|
# Copyright (C) 2013-2014 Sean Davis <smd.seandavis@gmail.com>
|
||||||
# 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
|
# This program is free software: you can redistribute it and/or modify it
|
||||||
# by the Free Software Foundation.
|
# 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
|
# This program is distributed in the hope that it will be useful, but
|
||||||
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
# WITHOUT ANY WARRANTY; without even the implied warranties of
|
||||||
# PURPOSE. See the GNU General Public License for more details.
|
# 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/>.
|
# You should have received a copy of the GNU General Public License along
|
||||||
### END LICENSE
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
###################### DO NOT TOUCH THIS (HEAD TO THE SECOND PART) ######################
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -23,20 +21,23 @@ import sys
|
||||||
try:
|
try:
|
||||||
import DistUtilsExtra.auto
|
import DistUtilsExtra.auto
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print >> sys.stderr, 'To build mugshot you need https://launchpad.net/python-distutils-extra'
|
sys.stderr.write("To build mugshot you need "
|
||||||
|
"https://launchpad.net/python-distutils-extra\n")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
assert DistUtilsExtra.auto.__version__ >= '2.18', 'needs DistUtilsExtra.auto >= 2.18'
|
assert DistUtilsExtra.auto.__version__ >= '2.18', \
|
||||||
|
'needs DistUtilsExtra.auto >= 2.18'
|
||||||
|
|
||||||
def update_config(libdir, values = {}):
|
|
||||||
|
|
||||||
filename = os.path.join(libdir, 'mugshot_lib/mugshotconfig.py')
|
def update_config(libdir, values={}):
|
||||||
|
"""Update the configuration file at installation time."""
|
||||||
|
filename = os.path.join(libdir, 'mugshot_lib', 'mugshotconfig.py')
|
||||||
oldvalues = {}
|
oldvalues = {}
|
||||||
try:
|
try:
|
||||||
fin = file(filename, 'r')
|
fin = open(filename, 'r')
|
||||||
fout = file(filename + '.new', 'w')
|
fout = open(filename + '.new', 'w')
|
||||||
|
|
||||||
for line in fin:
|
for line in fin:
|
||||||
fields = line.split(' = ') # Separate variable from value
|
fields = line.split(' = ') # Separate variable from value
|
||||||
if fields[0] in values:
|
if fields[0] in values:
|
||||||
oldvalues[fields[0]] = fields[1].strip()
|
oldvalues[fields[0]] = fields[1].strip()
|
||||||
line = "%s = %s\n" % (fields[0], values[fields[0]])
|
line = "%s = %s\n" % (fields[0], values[fields[0]])
|
||||||
|
@ -46,73 +47,64 @@ def update_config(libdir, values = {}):
|
||||||
fout.close()
|
fout.close()
|
||||||
fin.close()
|
fin.close()
|
||||||
os.rename(fout.name, fin.name)
|
os.rename(fout.name, fin.name)
|
||||||
except (OSError, IOError), e:
|
except (OSError, IOError):
|
||||||
print ("ERROR: Can't find %s" % filename)
|
print(("ERROR: Can't find %s" % filename))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
return oldvalues
|
return oldvalues
|
||||||
|
|
||||||
|
|
||||||
def move_icon_file(root, target_data, prefix):
|
def move_icon_file(root, target_data, prefix):
|
||||||
old_icon_path = os.path.normpath(root + target_data + '/share/mugshot/media')
|
"""Move the icon files to their installation prefix."""
|
||||||
for icon_size in ['16x16', '22x22', '24x24', '48x48', '64x64', 'scalable']:
|
old_icon_path = os.path.normpath(
|
||||||
|
os.path.join(root, target_data, 'share', 'mugshot', 'media'))
|
||||||
|
for icon_size in ['16x16', '24x24', '32x32', '48x48', '64x64', 'scalable']:
|
||||||
if icon_size == 'scalable':
|
if icon_size == 'scalable':
|
||||||
old_icon_file = old_icon_path + '/mugshot.svg'
|
old_icon_file = os.path.join(old_icon_path, 'mugshot.svg')
|
||||||
else:
|
else:
|
||||||
old_icon_file = old_icon_path + '/mugshot_%s.svg' % icon_size.split('x')[0]
|
old_icon_file = os.path.join(old_icon_path,
|
||||||
icon_path = os.path.normpath(root + prefix + '/share/icons/hicolor/%s/apps' % icon_size)
|
'mugshot_%s.svg' % icon_size.split('x')[0])
|
||||||
icon_file = icon_path + '/mugshot.svg'
|
icon_path = os.path.normpath(
|
||||||
|
os.path.join(root, target_data, 'share', 'icons', 'hicolor',
|
||||||
|
icon_size, 'apps'))
|
||||||
|
icon_file = os.path.join(icon_path, 'mugshot.svg')
|
||||||
|
old_icon_file = os.path.realpath(old_icon_file)
|
||||||
|
icon_file = os.path.realpath(icon_file)
|
||||||
|
|
||||||
if not os.path.exists(old_icon_file):
|
if not os.path.exists(old_icon_file):
|
||||||
print ("ERROR: Can't find", old_icon_file)
|
print(("ERROR: Can't find", old_icon_file))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if not os.path.exists(icon_path):
|
if not os.path.exists(icon_path):
|
||||||
os.makedirs(icon_path)
|
os.makedirs(icon_path)
|
||||||
if old_icon_file != icon_file:
|
if old_icon_file != icon_file:
|
||||||
|
print(("Moving icon file: %s -> %s" % (old_icon_file, icon_file)))
|
||||||
os.rename(old_icon_file, icon_file)
|
os.rename(old_icon_file, icon_file)
|
||||||
|
|
||||||
|
# Media is now empty
|
||||||
|
if len(os.listdir(old_icon_path)) == 0:
|
||||||
|
print(("Removing emptry directory: %s" % old_icon_path))
|
||||||
|
os.rmdir(old_icon_path)
|
||||||
|
|
||||||
return icon_file
|
return icon_file
|
||||||
|
|
||||||
def move_desktop_file(root, target_data, prefix):
|
|
||||||
# The desktop file is rightly installed into install_data. But it should
|
|
||||||
# always really be installed into prefix, because while we can install
|
|
||||||
# normal data files anywhere we want, the desktop file needs to exist in
|
|
||||||
# the main system to be found. Only actually useful for /opt installs.
|
|
||||||
|
|
||||||
old_desktop_path = os.path.normpath(root + target_data +
|
|
||||||
'/share/applications')
|
|
||||||
old_desktop_file = old_desktop_path + '/mugshot.desktop'
|
|
||||||
desktop_path = os.path.normpath(root + prefix + '/share/applications')
|
|
||||||
desktop_file = desktop_path + '/mugshot.desktop'
|
|
||||||
|
|
||||||
if not os.path.exists(old_desktop_file):
|
|
||||||
print ("ERROR: Can't find", old_desktop_file)
|
|
||||||
sys.exit(1)
|
|
||||||
elif target_data != prefix + '/':
|
|
||||||
# This is an /opt install, so rename desktop file to use extras-
|
|
||||||
desktop_file = desktop_path + '/extras-mugshot.desktop'
|
|
||||||
try:
|
|
||||||
if not os.path.exists(desktop_path):
|
|
||||||
os.makedirs(desktop_path)
|
|
||||||
if old_desktop_file != desktop_file:
|
|
||||||
os.rename(old_desktop_file, desktop_file)
|
|
||||||
for filename in os.listdir(old_desktop_path):
|
|
||||||
os.remove( os.path.join(old_desktop_path, filename) )
|
|
||||||
os.rmdir(old_desktop_path)
|
|
||||||
except OSError as e:
|
|
||||||
print ("ERROR: Can't rename", old_desktop_file, ":", e)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
def get_desktop_file(root, target_data, prefix):
|
||||||
|
"""Move the desktop file to its installation prefix."""
|
||||||
|
desktop_path = os.path.realpath(
|
||||||
|
os.path.join(root, target_data, 'share', 'applications'))
|
||||||
|
desktop_file = os.path.join(desktop_path, 'mugshot.desktop')
|
||||||
return desktop_file
|
return desktop_file
|
||||||
|
|
||||||
def update_desktop_file(filename, target_pkgdata, target_scripts):
|
|
||||||
|
|
||||||
|
def update_desktop_file(filename, script_path):
|
||||||
|
"""Update the desktop file with prefixed paths."""
|
||||||
try:
|
try:
|
||||||
fin = file(filename, 'r')
|
fin = open(filename, 'r')
|
||||||
fout = file(filename + '.new', 'w')
|
fout = open(filename + '.new', 'w')
|
||||||
|
|
||||||
for line in fin:
|
for line in fin:
|
||||||
if 'Exec=' in line:
|
if 'Exec=' in line:
|
||||||
cmd = line.split("=")[1].split(None, 1)
|
cmd = line.split("=")[1].split(None, 1)
|
||||||
line = "Exec=%s" % (target_scripts + 'mugshot')
|
line = "Exec=%s" % os.path.join(script_path, 'mugshot')
|
||||||
if len(cmd) > 1:
|
if len(cmd) > 1:
|
||||||
line += " %s" % cmd[1].strip() # Add script arguments back
|
line += " %s" % cmd[1].strip() # Add script arguments back
|
||||||
line += "\n"
|
line += "\n"
|
||||||
|
@ -121,53 +113,73 @@ def update_desktop_file(filename, target_pkgdata, target_scripts):
|
||||||
fout.close()
|
fout.close()
|
||||||
fin.close()
|
fin.close()
|
||||||
os.rename(fout.name, fin.name)
|
os.rename(fout.name, fin.name)
|
||||||
except (OSError, IOError), e:
|
except (OSError, IOError):
|
||||||
print ("ERROR: Can't find %s" % filename)
|
print(("ERROR: Can't find %s" % filename))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def compile_schemas(root, target_data):
|
|
||||||
if target_data == '/usr/':
|
|
||||||
return # /usr paths don't need this, they will be handled by dpkg
|
|
||||||
schemadir = os.path.normpath(root + target_data + 'share/glib-2.0/schemas')
|
|
||||||
if (os.path.isdir(schemadir) and
|
|
||||||
os.path.isfile('/usr/bin/glib-compile-schemas')):
|
|
||||||
os.system('/usr/bin/glib-compile-schemas "%s"' % schemadir)
|
|
||||||
|
|
||||||
|
|
||||||
class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
|
class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
|
||||||
|
"""Command Class to install and update the directory."""
|
||||||
def run(self):
|
def run(self):
|
||||||
|
"""Run the setup commands."""
|
||||||
DistUtilsExtra.auto.install_auto.run(self)
|
DistUtilsExtra.auto.install_auto.run(self)
|
||||||
|
|
||||||
if not self.root:
|
print(("=== Installing %s, version %s ===" %
|
||||||
|
(self.distribution.get_name(), self.distribution.get_version())))
|
||||||
|
|
||||||
|
if not self.prefix:
|
||||||
|
self.prefix = ''
|
||||||
|
|
||||||
|
if self.root:
|
||||||
|
target_data = os.path.relpath(self.install_data, self.root) + os.sep
|
||||||
|
target_pkgdata = os.path.join(target_data, 'share', 'mugshot', '')
|
||||||
|
target_scripts = os.path.join(self.install_scripts, '')
|
||||||
|
|
||||||
|
data_dir = os.path.join(self.prefix, 'share', 'mugshot', '')
|
||||||
|
script_path = os.path.join(self.prefix, 'bin')
|
||||||
|
else:
|
||||||
|
# --user install
|
||||||
self.root = ''
|
self.root = ''
|
||||||
|
target_data = os.path.relpath(self.install_data) + os.sep
|
||||||
|
target_pkgdata = os.path.join(target_data, 'share', 'mugshot', '')
|
||||||
|
target_scripts = os.path.join(self.install_scripts, '')
|
||||||
|
|
||||||
target_data = '/' + os.path.relpath(self.install_data, self.root) + '/'
|
# Use absolute paths
|
||||||
target_pkgdata = target_data + 'share/mugshot/'
|
target_data = os.path.realpath(target_data)
|
||||||
target_scripts = '/' + os.path.relpath(self.install_scripts, self.root) + '/'
|
target_pkgdata = os.path.realpath(target_pkgdata)
|
||||||
|
target_scripts = os.path.realpath(target_scripts)
|
||||||
|
|
||||||
values = {'__mugshot_data_directory__': "'%s'" % (target_pkgdata),
|
data_dir = target_pkgdata
|
||||||
|
script_path = target_scripts
|
||||||
|
|
||||||
|
print(("Root: %s" % self.root))
|
||||||
|
print(("Prefix: %s\n" % self.prefix))
|
||||||
|
|
||||||
|
print(("Target Data: %s" % target_data))
|
||||||
|
print(("Target PkgData: %s" % target_pkgdata))
|
||||||
|
print(("Target Scripts: %s\n" % target_scripts))
|
||||||
|
print(("Mugshot Data Directory: %s" % data_dir))
|
||||||
|
|
||||||
|
values = {'__mugshot_data_directory__': "'%s'" % (data_dir),
|
||||||
'__version__': "'%s'" % self.distribution.get_version()}
|
'__version__': "'%s'" % self.distribution.get_version()}
|
||||||
update_config(self.install_lib, values)
|
update_config(self.install_lib, values)
|
||||||
|
|
||||||
desktop_file = move_desktop_file(self.root, target_data, self.prefix)
|
desktop_file = get_desktop_file(self.root, target_data, self.prefix)
|
||||||
icon_file = move_icon_file(self.root, target_data, self.prefix)
|
print(("Desktop File: %s\n" % desktop_file))
|
||||||
update_desktop_file(desktop_file, target_pkgdata, target_scripts)
|
move_icon_file(self.root, target_data, self.prefix)
|
||||||
compile_schemas(self.root, target_data)
|
update_desktop_file(desktop_file, script_path)
|
||||||
|
|
||||||
|
|
||||||
##################################################################################
|
|
||||||
###################### YOU SHOULD MODIFY ONLY WHAT IS BELOW ######################
|
|
||||||
##################################################################################
|
|
||||||
|
|
||||||
DistUtilsExtra.auto.setup(
|
DistUtilsExtra.auto.setup(
|
||||||
name='mugshot',
|
name='mugshot',
|
||||||
version='0.1',
|
version='2.0',
|
||||||
license='GPL-3',
|
license='GPL-3',
|
||||||
author='Sean Davis',
|
author='Sean Davis',
|
||||||
author_email='smd.seandavis@gmail.com',
|
author_email='smd.seandavis@gmail.com',
|
||||||
#description='UI for managing …',
|
description='lightweight user configuration utility',
|
||||||
#long_description='Here a longer description',
|
long_description='A lightweight user configuration utility. It allows you '
|
||||||
|
'to easily set profile image and user details for your '
|
||||||
|
'user profile and any supported applications.',
|
||||||
url='https://launchpad.net/mugshot',
|
url='https://launchpad.net/mugshot',
|
||||||
|
data_files=[('share/man/man1', ['mugshot.1'])],
|
||||||
cmdclass={'install': InstallAndUpdateDataDirectory}
|
cmdclass={'install': InstallAndUpdateDataDirectory}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue