HEX
Server: Apache/2.4.38 (Debian)
System: Linux mtefpls 4.19.0-18-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64
User: www-data (33)
PHP: 7.3.31-1~deb10u1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: //bin/gnome-music
#! /usr/bin/python3
# Copyright © 2018 The GNOME Music Developers
#
# GNOME Music is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# GNOME Music is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY 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 GNOME Music; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# The GNOME Music authors hereby grant permission for non-GPL compatible
# GStreamer plugins to be used and distributed together with GStreamer
# and GNOME Music.  This permission is above and beyond the permissions
# granted by the GPL license by which GNOME Music is covered.  If you
# modify this code, you may extend this exception to your version of the
# code, but you are not obligated to do so.  If you do not wish to do so,
# delete this exception statement from your version.

import argparse
import gettext
import locale
import logging
import os
import signal
import sys

# Make sure we'll find the pygobject module, even in JHBuild
sys.path.insert(1, '/usr/lib/python3.7')
# Make sure we'll find the gnomemusic module, even in JHBuild
sys.path.insert(1, '/usr/lib/python3.7/site-packages')

_LOCAL = False

# In the local use case the installed schemas go in <builddir>/data
if _LOCAL:
    os.environ["XDG_DATA_DIRS"] = ':' + os.environ.get("XDG_DATA_DIRS", "")

import gi

gi.require_version('Gtk', '3.0')
gi.require_version('GIRepository', '2.0')
gi.require_version('Gst', '1.0')
from gi.repository import GIRepository, Gio, Gtk, Gst

Gst.init(None)

LOCALE_DIR = '/usr/share/locale'
PKGDATA_DIR = '/usr/share/org.gnome.Music'

# Log settings
LOG_FORMAT = '%(asctime)s %(levelname)s\t%(message)s'
LOG_DATE_FORMAT = '%H:%M:%S'


def set_libgd():
    """Configures application to run our own libgd copy."""
    libgd_libdir = '/usr/lib/x86_64-linux-gnu/org.gnome.Music'
    if _LOCAL:
        libgd_typelibdir = '/usr/lib/x86_64-linux-gnu/org.gnome.Music'
    else:
        libgd_typelibdir = '/usr/lib/x86_64-linux-gnu/org.gnome.Music/girepository-1.0'

    GIRepository.Repository.prepend_search_path(libgd_typelibdir)
    GIRepository.Repository.prepend_library_path(libgd_libdir)


def set_exception_hook():
    """Configures sys.excepthook to enforce Gtk application exiting."""

    def new_hook(etype, evalue, etb):
        old_hook(etype, evalue, etb)
        while Gtk.main_level():
            Gtk.main_quit()
        sys.exit()

    old_hook = sys.excepthook
    sys.excepthook = new_hook


def set_log_level():
    """Sets application log level according to debug value."""
    parser = argparse.ArgumentParser()
    parser.add_argument('-d', '--debug', action='store_true',
                        default=False, dest='debug')
    args = parser.parse_args()
    if args.debug:
        logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT,
                            datefmt=LOG_DATE_FORMAT)
        # Gtk hates "-d" switch, so lets drop it
        if '-d' in sys.argv:
            sys.argv.remove('-d')
        if '--debug' in sys.argv:
            sys.argv.remove('--debug')
    else:
        logging.basicConfig(level=logging.WARN, format=LOG_FORMAT,
                            datefmt=LOG_DATE_FORMAT)


def set_internationalization():
    """Sets application internationalization."""
    locale.bindtextdomain('org.gnome.Music', LOCALE_DIR)
    locale.textdomain('org.gnome.Music')
    gettext.bindtextdomain('org.gnome.Music', LOCALE_DIR)
    gettext.textdomain('org.gnome.Music')


def set_resources():
    """Sets application ressource file."""
    resource = Gio.resource_load(
        os.path.join(PKGDATA_DIR, 'org.gnome.Music.gresource'))
    Gio.Resource._register(resource)  # nopep8


def run_application():
    """Runs GNOME Music application and returns its exit code."""
    from gnomemusic.application import Application

    app = Application('org.gnome.Music')
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    return app.run(sys.argv)


def main():
    """Sets environment and runs GNOME Music."""
    set_libgd()
    set_exception_hook()
    set_log_level()
    set_internationalization()
    set_resources()
    return run_application()

if __name__ == '__main__':
    if _LOCAL:
        print('Running from source tree, using local files.')
    sys.exit(main())