예제 #1
0
 def __init__(self):
     super().__init__()
     self.set_position(unit.MONITOR_X, unit.MONITOR_Y)
     self.set_size(unit.w(1), unit.h(1))
     self._init_content()
     if not arg_parser.get_args().debug:
         self.set_fullscreen(True)
예제 #2
0
파일: logger.py 프로젝트: Sasza/pisak
def get_logger(name):
    logger = logging.getLogger(name)
    logger.setLevel(LEVELS['debug'])

    console_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    console_formatter = logging.Formatter(console_format)

    console_handler = logging.StreamHandler()
    console_handler.setFormatter(console_formatter)

    file = 'pisak.log'
    path = os.path.expanduser('~/.pisak/logs/')
    if not os.path.exists(path):
        os.makedirs(path)
    file_format = '%(asctime)s - %(name)s - %(filename)s:%(lineno)d - %(levelname)s - %(message)s'
    file_formatter = logging.Formatter(file_format)

    file_handler = handlers.RotatingFileHandler(path + file,
                                                maxBytes=10**7,
                                                backupCount=10)
    if arg_parser.get_args().debug:
        file_handler.setLevel(LEVELS['debug'])
        console_handler.setLevel(LEVELS['debug'])
    else:
        file_handler.setLevel(LEVELS['warning'])
        console_handler.setLevel(LEVELS['error'])
    file_handler.setFormatter(file_formatter)

    logger.addHandler(file_handler)
    logger.addHandler(console_handler)

    return logger
예제 #3
0
    def create_window(self, argv, descriptor):
        """
        Create application main window as the Gtk.Window.

        :param: argv: application arguments.
        :param descriptor: general application descriptor.
        """
        gtk_window = Gtk.Window()
        embed = GtkClutter.Embed()
        gtk_window.add(embed)
        gtk_window.stage = embed.get_stage()
        clutter_window = window.Window(self, gtk_window.stage, descriptor)
        clutter_window.wrapper = gtk_window
        gtk_window.stage.set_title('PISAK')
        gtk_window.stage.set_position(unit.MONITOR_X, unit.MONITOR_Y)
        if arg_parser.get_args().debug:
            coeff = 0.7
            size = coeff * unit.w(1), coeff * unit.h(1)
            gtk_window.stage.set_size(*size)
            gtk_window.set_default_size(*size)
            gtk_window.set_resizable(True)
        else:
            gtk_window.stage.set_size(unit.w(1), unit.h(1))
            gtk_window.stage.set_fullscreen(True)
            gtk_window.fullscreen()
        gtk_window.connect("destroy", lambda _: Gtk.main_quit())
        return clutter_window
예제 #4
0
    def create_window(self, argv, descriptor):
        """
        Create application main window as the Gtk.Window.

        :param: argv: application arguments.
        :param descriptor: general application descriptor.
        """
        gtk_window = Gtk.Window()
        embed = GtkClutter.Embed()
        gtk_window.add(embed)
        gtk_window.stage = embed.get_stage()
        clutter_window = window.Window(self, gtk_window.stage, descriptor)
        clutter_window.wrapper = gtk_window
        gtk_window.stage.set_title('PISAK')
        gtk_window.stage.set_position(unit.MONITOR_X, unit.MONITOR_Y)
        if arg_parser.get_args().debug:
            coeff = 0.7
            size = coeff*unit.w(1), coeff*unit.h(1)
            gtk_window.stage.set_size(*size)
            gtk_window.set_default_size(*size)
            gtk_window.set_resizable(True)
        else:
            gtk_window.stage.set_size(unit.w(1), unit.h(1))
            gtk_window.stage.set_fullscreen(True)
            gtk_window.fullscreen()
        gtk_window.connect("destroy", lambda _: Gtk.main_quit())
        return clutter_window
예제 #5
0
파일: logger.py 프로젝트: Sasza/pisak
def get_logger(name):
    logger = logging.getLogger(name)
    logger.setLevel(LEVELS['debug'])

    console_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    console_formatter = logging.Formatter(console_format)

    console_handler = logging.StreamHandler()
    console_handler.setFormatter(console_formatter)

    file = 'pisak.log'
    path = os.path.expanduser('~/.pisak/logs/')
    if not os.path.exists(path):
        os.makedirs(path)
    file_format = '%(asctime)s - %(name)s - %(filename)s:%(lineno)d - %(levelname)s - %(message)s'
    file_formatter = logging.Formatter(file_format)

    file_handler = handlers.RotatingFileHandler(path + file,
                                                maxBytes=10**7,
                                                backupCount=10)
    if arg_parser.get_args().debug:
        file_handler.setLevel(LEVELS['debug'])
        console_handler.setLevel(LEVELS['debug'])
    else:
        file_handler.setLevel(LEVELS['warning'])
        console_handler.setLevel(LEVELS['error'])
    file_handler.setFormatter(file_formatter)

    logger.addHandler(file_handler)
    logger.addHandler(console_handler)

    return logger
예제 #6
0
 def __init__(self):
     super().__init__()
     self.set_position(unit.MONITOR_X, unit.MONITOR_Y)
     self.set_size(unit.w(1), unit.h(1))
     self._init_content()
     if not arg_parser.get_args().debug:
         self.set_fullscreen(True)
예제 #7
0
파일: app_manager.py 프로젝트: Sasza/pisak
 def minimize_panel(self):
     """
     Deactivate the main panel and all its content.
     """
     pisak.app.window.input_group.stop_middleware()
     self.loading_stage.show()
     if not arg_parser.get_args().debug:
         self.loading_stage.set_fullscreen(True)
예제 #8
0
파일: app_manager.py 프로젝트: Sasza/pisak
 def minimize_panel(self):
     """
     Deactivate the main panel and all its content.
     """
     pisak.app.window.input_group.stop_middleware()
     self.loading_stage.show()
     if not arg_parser.get_args().debug:
         self.loading_stage.set_fullscreen(True)
예제 #9
0
파일: application.py 프로젝트: Sasza/pisak
 def create_window(self, argv, descriptor):
     clutter_window = window.Window(self, Clutter.Stage(), descriptor)
     clutter_window.stage.set_title('Pisak Main')
     if arg_parser.get_args().debug:
         coeff = 0.7
         clutter_window.stage.set_size(coeff * unit.w(1), coeff * unit.h(1))
         clutter_window.stage.set_user_resizable(True)
     else:
         clutter_window.stage.set_size(unit.w(1), unit.h(1))
         clutter_window.stage.set_fullscreen(True)
     clutter_window.stage.connect("destroy", lambda _: Clutter.main_quit())
     return clutter_window
예제 #10
0
파일: application.py 프로젝트: Sasza/pisak
 def create_window(self, argv, descriptor):
     clutter_window = window.Window(self, Clutter.Stage(), descriptor)
     clutter_window.stage.set_title('Pisak Main')
     if arg_parser.get_args().debug:
         coeff = 0.7
         clutter_window.stage.set_size(coeff*unit.w(1), coeff*unit.h(1))
         clutter_window.stage.set_user_resizable(True)
     else:
         clutter_window.stage.set_size(unit.w(1), unit.h(1))
         clutter_window.stage.set_fullscreen(True)
     clutter_window.stage.connect("destroy", lambda _: Clutter.main_quit())
     return clutter_window
예제 #11
0
파일: application.py 프로젝트: Sasza/pisak
 def create_window(self, argv, descriptor):
     gtk_window = Gtk.Window()
     embed = GtkClutter.Embed()
     gtk_window.add(embed)
     gtk_window.stage = embed.get_stage()
     clutter_window = window.Window(self, gtk_window.stage, descriptor)
     clutter_window.wrapper = gtk_window
     gtk_window.stage.set_title('Pisak Main')
     if arg_parser.get_args().debug:
         coeff = 0.7
         size = coeff * unit.w(1), coeff * unit.h(1)
         gtk_window.stage.set_size(*size)
         gtk_window.set_default_size(*size)
         gtk_window.set_resizable(True)
     else:
         gtk_window.stage.set_fullscreen(True)
         gtk_window.fullscreen()
     gtk_window.connect("destroy", lambda _: Gtk.main_quit())
     return clutter_window
예제 #12
0
파일: application.py 프로젝트: Sasza/pisak
 def create_window(self, argv, descriptor):
     gtk_window = Gtk.Window()
     embed = GtkClutter.Embed()
     gtk_window.add(embed)
     gtk_window.stage = embed.get_stage()
     clutter_window = window.Window(self, gtk_window.stage, descriptor)
     clutter_window.wrapper = gtk_window
     gtk_window.stage.set_title('Pisak Main')
     if arg_parser.get_args().debug:
         coeff = 0.7
         size = coeff*unit.w(1), coeff*unit.h(1)
         gtk_window.stage.set_size(*size)
         gtk_window.set_default_size(*size)
         gtk_window.set_resizable(True)
     else:
         gtk_window.stage.set_fullscreen(True)
         gtk_window.fullscreen()
     gtk_window.connect("destroy", lambda _: Gtk.main_quit())
     return clutter_window
예제 #13
0
    def create_window(self, argv, descriptor):
        """
        Create application main window as the Clutter.Stage.

        :param: argv: application arguments.
        :param descriptor: general application descriptor.
        """
        clutter_window = window.Window(self, Clutter.Stage(), descriptor)
        clutter_window.stage.set_title('PISAK')
        clutter_window.stage.set_position(unit.MONITOR_X, unit.MONITOR_Y)
        if arg_parser.get_args().debug:
            coeff = 0.7
            clutter_window.stage.set_size(coeff * unit.w(1), coeff * unit.h(1))
            clutter_window.stage.set_user_resizable(True)
        else:
            clutter_window.stage.set_size(unit.w(1), unit.h(1))
            clutter_window.stage.set_fullscreen(True)
        clutter_window.stage.connect("destroy", lambda _: Clutter.main_quit())
        return clutter_window
예제 #14
0
    def create_window(self, argv, descriptor):
        """
        Create application main window as the Clutter.Stage.

        :param: argv: application arguments.
        :param descriptor: general application descriptor.
        """
        clutter_window = window.Window(self, Clutter.Stage(), descriptor)
        clutter_window.stage.set_title('PISAK')
        clutter_window.stage.set_position(unit.MONITOR_X, unit.MONITOR_Y)
        if arg_parser.get_args().debug:
            coeff = 0.7
            clutter_window.stage.set_size(coeff*unit.w(1), coeff*unit.h(1))
            clutter_window.stage.set_user_resizable(True)
        else:
            clutter_window.stage.set_size(unit.w(1), unit.h(1))
            clutter_window.stage.set_fullscreen(True)
        clutter_window.stage.connect("destroy", lambda _: Clutter.main_quit())
        return clutter_window
예제 #15
0
파일: logger.py 프로젝트: BrainTech/pisak
def get_logger(name):
    """
    Creates and returns new logger, registers it with the given name.
    Logger output files are rotated when their size exceeds 10**7 bytes,
    10 back-ups are stored at a time.

    :param name: name that a logger should be registered with.

    :return: logger instance.
    """
    logger = logging.getLogger(name)
    logger.setLevel(LEVELS['debug'])

    console_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    console_formatter = logging.Formatter(console_format)

    console_handler = logging.StreamHandler()
    console_handler.setFormatter(console_formatter)

    file = 'pisak.log'
    path = os.path.expanduser('~/.pisak/logs/')
    if not os.path.exists(path):
        os.makedirs(path)
    file_format = '%(asctime)s - %(name)s - %(filename)s:%(lineno)d - %(levelname)s - %(message)s'
    file_formatter = logging.Formatter(file_format)

    file_handler = handlers.RotatingFileHandler(path + file,
                                                maxBytes=10**7,
                                                backupCount=10)
    if arg_parser.get_args().debug:
        file_handler.setLevel(LEVELS['debug'])
        console_handler.setLevel(LEVELS['debug'])
    else:
        file_handler.setLevel(LEVELS['warning'])
        console_handler.setLevel(LEVELS['error'])
    file_handler.setFormatter(file_formatter)

    logger.addHandler(file_handler)
    logger.addHandler(console_handler)

    return logger
예제 #16
0
def get_logger(name):
    """
    Creates and returns new logger, registers it with the given name.
    Logger output files are rotated when their size exceeds 10**7 bytes,
    10 back-ups are stored at a time.

    :param name: name that a logger should be registered with.

    :return: logger instance.
    """
    logger = logging.getLogger(name)
    logger.setLevel(LEVELS['debug'])

    console_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    console_formatter = logging.Formatter(console_format)

    console_handler = logging.StreamHandler()
    console_handler.setFormatter(console_formatter)

    file = 'pisak.log'
    path = os.path.expanduser('~/.pisak/logs/')
    if not os.path.exists(path):
        os.makedirs(path)
    file_format = '%(asctime)s - %(name)s - %(filename)s:%(lineno)d - %(levelname)s - %(message)s'
    file_formatter = logging.Formatter(file_format)

    file_handler = handlers.RotatingFileHandler(path + file,
                                                maxBytes=10**7,
                                                backupCount=10)
    if arg_parser.get_args().debug:
        file_handler.setLevel(LEVELS['debug'])
        console_handler.setLevel(LEVELS['debug'])
    else:
        file_handler.setLevel(LEVELS['warning'])
        console_handler.setLevel(LEVELS['error'])
    file_handler.setFormatter(file_formatter)

    logger.addHandler(file_handler)
    logger.addHandler(console_handler)

    return logger
예제 #17
0
def run(descriptor, on_init=None):
    """
    Run an application.

    :param descriptor: dictionary containing general application description.
    It should specify what type of application should be launched and provide
     all the basic data required for a proper application functioning.
     It should contain following items: 'type' - type of an application
     to be launched ('clutter' or 'gtk'); 'app' - name of the application;
     'views' - list of all the application views, each view is a tuple with
     the view name and a function responsible for the view preparation.
    :param on_init: callable, function that should be called on application init,
    before GUI scene creation.
    """
    input_process = None
    device_server = None
    if '--child' not in sys.argv:
        input_process, device_server = inputs.run_input_process()

    pisak.app = None

    app_type = descriptor['type']
    if app_type == 'clutter':
        AppType = application.ClutterApp
    elif app_type == 'gtk':
        AppType = application.GtkApp
    else:
        raise RuntimeError('Unknown application type!')

    pisak.app = AppType(arg_parser.get_args(), descriptor)

    pisak.app.window.load_initial_view(on_init)
    pisak.app.main()

    pisak.app = None

    if input_process:
        input_process.terminate()
    if device_server:
        device_server.stop()
예제 #18
0
def run(descriptor, on_init=None):
    """
    Run an application.

    :param descriptor: dictionary containing general application description.
    It should specify what type of application should be launched and provide
     all the basic data required for a proper application functioning.
     It should contain following items: 'type' - type of an application
     to be launched ('clutter' or 'gtk'); 'app' - name of the application;
     'views' - list of all the application views, each view is a tuple with
     the view name and a function responsible for the view preparation.
    :param on_init: callable, function that should be called on application init,
    before GUI scene creation.
    """
    input_process = None
    device_server = None
    if '--child' not in sys.argv:
        input_process, device_server = inputs.run_input_process()

    pisak.app = None

    app_type = descriptor['type']
    if app_type == 'clutter':
        AppType = application.ClutterApp
    elif app_type == 'gtk':
        AppType = application.GtkApp
    else:
        raise RuntimeError('Unknown application type!')

    pisak.app = AppType(arg_parser.get_args(), descriptor)

    pisak.app.window.load_initial_view(on_init)
    pisak.app.main()

    pisak.app = None

    if input_process:
        input_process.terminate()
    if device_server:
        device_server.stop()
예제 #19
0
import threading

import gi
gi.require_version('Gst', '1.0')

from gi.repository import GObject, Gst

import pisak
from pisak import arg_parser
from pisak import logger

_LOG = logger.get_logger(__name__)


GObject.threads_init()
Gst.init(arg_parser.get_args().args)


class SoundEffectsPlayer(object):
    def __init__(self, sounds_dict):
        super().__init__()
        self.sounds = sounds_dict
        self._volume = pisak.config.as_int('sound_effects_volume') / 100
        self._playbin = Gst.ElementFactory.make('playbin', 'button_sound')
        self._playbin.set_property("volume", self.volume)
        self._bus = self._playbin.get_bus()
        self._bus.connect('message', self.on_message)

    @property
    def volume(self):
        return self._volume
예제 #20
0
import subprocess
import threading

import gi
gi.require_version('Gst', '1.0')

from gi.repository import GObject, Gst

import pisak
from pisak import arg_parser
from pisak import logger

_LOG = logger.get_logger(__name__)

GObject.threads_init()
Gst.init(arg_parser.get_args().args)


class SoundEffectsPlayer:
    """
    Player of some simple sound effects. Audio files are loaded just
    once when registered and then they are stored and available in a sounds pool,
    throughout the class' entire lifetime.

    :param sounds_dict: dictionary of sounds.
    """
    def __init__(self, sounds_dict):
        super().__init__()
        self.sounds = sounds_dict
        self._volume = pisak.config.as_int('sound_effects_volume') / 100
        self._playbin = Gst.ElementFactory.make('playbin', 'button_sound')