Exemplo n.º 1
0
def main():

    if getuser() != 'root':
        print(TEXT_ONLY_ROOT)
        exit()

    os.chdir(os.path.dirname(os.path.realpath(__file__)))

    _ = BlockTesting()
    Gtk.main()
Exemplo n.º 2
0
def main():

    if getuser() != 'root':
        gtk_dialog_info(None,
                        TEXT_ONLY_ROOT,
                        icon=_SOFTWARE_PATHS._small_icon_file)
        exit()

    os.chdir(os.path.dirname(os.path.realpath(__file__)))
    ModelChooser()
    Gtk.main()
Exemplo n.º 3
0
def main():
    if getuser() != 'root':
        print(TEXT_ONLY_ROOT)
    else:
        os.chdir(os.path.dirname(os.path.realpath(__file__)))
        _ = ConnectDaemon()
Exemplo n.º 4
0
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('AppIndicator3', '0.1')
from gi.repository import Gtk

import os
from traceback import format_exc
import subprocess

from AKBL.texts import (TEXT_DEVICE_FOUND, TEXT_DEVICE_NOT_FOUND,
                        TEXT_BLOCK_TEST, TEXT_BLOCK_LIGHTS_OFF, TEXT_ONLY_ROOT)

from AKBL.utils import getuser
from AKBL.Configuration.Paths import Paths

if getuser() == 'root':
    from AKBL.Engine.Core.Driver import Driver
    from AKBL.Engine.Core.Controller import Controller


def get_alienware_device_info():

    bash_output = subprocess.run("lsusb",
                                 shell=True,
                                 stdout=subprocess.PIPE,
                                 universal_newlines=True)

    device_info = str(bash_output.stdout)

    for line in device_info.split("\n"):
Exemplo n.º 5
0
    def __init__(self, user=getuser()):

        ## System
        ##
        self.COMPUTERS_CONFIGURATION_FOLDER = "/usr/share/AKBL/computers"
        self.DAEMON_PYRO_PATH = '/etc/akbl-daemon-adress'
        self.SYSTEMCTL_PATH = '/bin/systemctl'
        self.MAIN = '/usr/lib/python3/AKBL'

        ## User
        ##

        if user == 'root':
            self.CONFIGURATION_PATH = '/root/.config/alienware-kbl.ini'
            self.PROFILES_PATH = '/root/.local/share/alienware-kbl/'
        else:
            self.CONFIGURATION_PATH = '/home/{}/.config/alienware-kbl.ini'.format(
                user)
            self.PROFILES_PATH = '/home/{}/.local/share/alienware-kbl/'.format(
                user)

        ## GUI
        ##
        self.GLADE_FILE = '{}/Addons/GUI/GUI.glade'.format(self.MAIN)

        ## Block testing window
        ##
        self.BLOCK_TESTING_GLADE_FILE = '{}/Addons/BlockTesting/BlockTesting.glade'.format(
            self.MAIN)

        ## GUI & Others
        ##
        self.IMAGES = '{}/Addons/GUI/images/'.format(self.MAIN)
        self.SMALL_ICON = self.IMAGES + 'icon.png'
        self.MEDIUM_ICON = self.IMAGES + 'icon-m.png'

        ## Indicator
        ##
        self.INDICATOR_IMAGES_DIR = '{}/Addons/Indicator/images/'.format(
            self.MAIN)
        self.INDICATOR_ON_ICON = self.INDICATOR_IMAGES_DIR + 'icon-on.png'
        self.INDICATOR_OFF_ICON = self.INDICATOR_IMAGES_DIR + 'icon-off.png'
        self.INDICATOR_NO_DAEMON_ICON = self.INDICATOR_IMAGES_DIR + 'icon-no-daemon.png'
        """
            This is to add support to older versions where the profiles and
            config was stored in the same directory than the code
        """
        self.BACKUP_CONFIG = '/etc/alienware-kbl/alienware-kbl.ini'
        self.BACKUP_PROFILES = '/etc/alienware-kbl/profiles/'
        self.GLOBAL_CONFIG = '/etc/alienware-kbl/gobal-config.ini'
        """
            Create the tree dirs
        """

        # In case there be a folder instead of the configuration file, delete the folder. Bug #84
        # Old versions of alienware-kbl may still creating the folder. The bug was in the Paths class.
        #

        if os.path.isdir(self.CONFIGURATION_PATH):
            rmtree(self.CONFIGURATION_PATH)
        #
        #
        for dir_path in (os.path.dirname(self.CONFIGURATION_PATH),
                         self.PROFILES_PATH):
            if not os.path.exists(dir_path):
                os.makedirs(dir_path)
Exemplo n.º 6
0
    def __init__(self, user=getuser()):

        ## System
        ##
        self._systemctl_dir = '/bin/systemctl'
        self._akbl_module_dir = '/usr/lib/python3/AKBL'
        self._computers_configuration_dir = "/usr/share/AKBL/computers"
        self._default_computer_file = '/etc/AKBL/default_computer.ini'
        self._daemon_pyro_file = '/etc/AKBL/pyro-adress'

        ## User
        ##

        # These "alienware-kbl" paths shall be updated to "akbl"  but users will have to migrate their data.
        if user == 'root':
            self._configuration_file = '/root/.config/alienware-kbl.ini'
            self._profiles_dir = '/root/.local/share/alienware-kbl/'
        else:
            self._configuration_file = '/home/{}/.config/alienware-kbl.ini'.format(
                user)
            self._profiles_dir = '/home/{}/.local/share/alienware-kbl/'.format(
                user)

        ## GUI
        ##
        self._gui_glade_file = '{}/Addons/GUI/GUI.glade'.format(
            self._akbl_module_dir)

        ## GUI & Others
        ##
        self._images_dir = '{}/Addons/GUI/images/'.format(
            self._akbl_module_dir)
        self._small_icon_file = self._images_dir + 'icon.png'
        self._medium_icon_file = self._images_dir + 'icon-m.png'

        ## Block testing window
        ##
        self._block_testing_glade_file = '{}/Addons/BlockTesting/BlockTesting.glade'.format(
            self._akbl_module_dir)

        ## Indicator
        ##
        self._indicator_images_dir = '{}/Addons/Indicator/images/'.format(
            self._akbl_module_dir)
        self._indicator_on_icon_file = self._indicator_images_dir + 'icon-on.png'
        self._indicator_off_icon_file = self._indicator_images_dir + 'icon-off.png'
        self._indicator_no_daemon_icon = self._indicator_images_dir + 'icon-no-daemon.png'

        ## ModelChooser
        ##
        self._model_chooser_glade_file = '{}/Addons/ModelChooser/ModelChooser.glade'.format(
            self._akbl_module_dir)
        """
            Create the necessary folders.
        """

        #
        # Create the system folders
        #
        if user == 'root':
            system_write_folders = [
                os.path.dirname(self._default_computer_file),
                os.path.dirname(self._daemon_pyro_file)
            ]

            for dir_path in system_write_folders:
                if not os.path.exists(dir_path):
                    os.makedirs(dir_path)

        #
        # Create the user folders
        #
        for dir_path in (os.path.dirname(self._configuration_file),
                         self._profiles_dir):
            if not os.path.exists(dir_path):
                os.makedirs(dir_path)

        #
        # Bug #84: In case there be a folder instead of the configuration file, delete the folder.
        # Old versions of alienware-kbl may still creating the folder, the bug was in the Paths class.
        #
        if os.path.isdir(self._configuration_file):
            rmtree(self._configuration_file)