示例#1
0
    def test_tlp_file_vs_json_config(self):
        # tlp file config
        configfilelist = read_tlp_file_config("/etc/default/tlp")

        # json config
        jsoncategories = get_json_schema_object_from_file('categories', 'configschema.json')
        jsonconfigcount = get_config_count(jsoncategories)

        self.assertEqual(len(configfilelist), 80)
        self.assertEqual(len(configfilelist), jsonconfigcount)
示例#2
0
文件: mainui.py 项目: linrunner/TLPUI
def load_tlp_config(self, filenamepointer, window):
    filename = filenamepointer()
    tlpconfig = read_tlp_file_config(filename)

    newmainbox = create_main_box(window, filename, tlpconfig)
    children = window.get_children()
    for child in children:
        window.remove(child)
    window.add(newmainbox)
    window.show_all()
示例#3
0
def load_tlp_config(self, filenamepointer, window):
    filename = filenamepointer()
    tlpconfig = read_tlp_file_config(filename)

    newmainbox = create_main_box(window, filename, tlpconfig)
    children = window.get_children()
    for child in children:
        window.remove(child)
    window.add(newmainbox)
    window.show_all()
示例#4
0
    def test_tlp_version_1_1(self):
        version = "1_1"
        tlpconfig = read_tlp_file_config('unittests/tlp-config-{}'.format(version))
        jsoncategories = get_json_schema_object_from_file('categories', 'configschema/{}.json'.format(version))

        configfilecategories = get_tlp_categories(Gtk.Window(), jsoncategories)
        jsonconfigcount = get_config_count(jsoncategories)

        self.assertEqual(len(configfilecategories), 11)
        self.assertEqual(91, len(tlpconfig))
        self.assertEqual(jsonconfigcount, len(tlpconfig))
示例#5
0
    def test_tlp_file_vs_json_config(self):
        # tlp file config
        configfilelist = read_tlp_file_config("/etc/default/tlp")

        # json config
        jsoncategories = get_json_schema_object_from_file(
            'categories', 'configschema.json')
        jsonconfigcount = get_config_count(jsoncategories)

        self.assertEqual(len(configfilelist), 80)
        self.assertEqual(len(configfilelist), jsonconfigcount)
示例#6
0
文件: mainui.py 项目: mantaroh/TLPUI
def load_tlp_config(self, window, reloadtlpconfig):

    if reloadtlpconfig:
        settings.tlpconfig = read_tlp_file_config(settings.tlpconfigfile)
        settings.tlpconfig_original = copy.deepcopy(settings.tlpconfig)

    newmainbox = create_main_box(window)
    children = window.get_children()
    for child in children:
        window.remove(child)
    window.add(newmainbox)
    window.show_all()
示例#7
0
文件: tlpui.py 项目: amateusz/TLPUI
from gi.repository import Gtk, Gdk

from os import path
from css import get_css_provider
from file import read_tlp_file_config
from mainui import create_main_box, close_window

Gtk.StyleContext.add_provider_for_screen(
    Gdk.Screen.get_default(), get_css_provider(),
    Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

defaultconfigpath = '/etc/default/tlp'

window = Gtk.Window()
window.set_title('TLP-UI')
window.set_default_size(900, 600)

if path.exists(defaultconfigpath):
    tlpconfig = read_tlp_file_config(defaultconfigpath)
    window.add(create_main_box(window, defaultconfigpath, tlpconfig))
else:
    noconfiglabel = Gtk.Label("No config file found at " + defaultconfigpath)
    noconfigbox = Gtk.Box()
    noconfigbox.pack_start(noconfiglabel, True, True, 0)
    window.add(noconfigbox)

window.connect('delete-event', Gtk.main_quit)
window.connect('key-press-event', close_window)
window.show_all()
Gtk.main()
示例#8
0
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk

from css import get_css_provider
from file import read_tlp_file_config
from mainui import create_main_box, store_windowsize, window_key_events, close_main_window, tlp_file_chooser
from pathlib import Path
import copy
import settings

Gtk.StyleContext.add_provider_for_screen(
    Gdk.Screen.get_default(), get_css_provider(),
    Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

window = Gtk.Window()

if not Path(settings.tlpconfigfile).exists():
    tlp_file_chooser(window)

settings.tlpconfig = read_tlp_file_config(settings.tlpconfigfile)
settings.tlpconfig_original = copy.deepcopy(settings.tlpconfig)

window.set_title('TLP-UI')
window.set_default_size(settings.windowxsize, settings.windowysize)
window.add(create_main_box(window))
window.connect('check-resize', store_windowsize)
window.connect('delete-event', close_main_window)
window.connect('key-press-event', window_key_events)
window.show_all()
Gtk.main()
示例#9
0
文件: tlpui.py 项目: linrunner/TLPUI
from os import path
from css import get_css_provider
from file import read_tlp_file_config
from mainui import create_main_box, close_window

Gtk.StyleContext.add_provider_for_screen(
    Gdk.Screen.get_default(),
    get_css_provider(),
    Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)

defaultconfigpath = '/etc/default/tlp'

window = Gtk.Window()
window.set_title('TLP-UI')
window.set_default_size(900, 600)

if path.exists(defaultconfigpath):
    tlpconfig = read_tlp_file_config(defaultconfigpath)
    window.add(create_main_box(window, defaultconfigpath, tlpconfig))
else:
    noconfiglabel = Gtk.Label("No config file found at " + defaultconfigpath)
    noconfigbox = Gtk.Box()
    noconfigbox.pack_start(noconfiglabel, True, True, 0)
    window.add(noconfigbox)

window.connect('delete-event', Gtk.main_quit)
window.connect('key-press-event', close_window)
window.show_all()
Gtk.main()
示例#10
0
    def test_config_categories(self):
        configfilelist = read_tlp_file_config("/etc/default/tlp")
        configfilecategories = get_tlp_categories(configfilelist)

        self.assertEqual(len(configfilecategories), 12)
示例#11
0
    def test_config_categories(self):
        configfilelist = read_tlp_file_config("/etc/default/tlp")
        configfilecategories = get_tlp_categories(configfilelist)

        self.assertEqual(len(configfilecategories), 12)