def save_hardware_info(): """Saves hardware information related to the Raspberry Pi / Kano Kit""" from kano.logging import logger from kano.utils import get_cpu_id, get_mac_address, detect_kano_keyboard logger.info('save_hardware_info') state = { 'cpu_id': get_cpu_id(), 'mac_address': get_mac_address(), 'kano_keyboard': detect_kano_keyboard(), } save_app_state_variable('kano-tracker', 'hardware_info', state)
def __init__(self, win): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL) self.win = win self.win.set_main_widget(self) self.win.top_bar.enable_prev() self.win.change_prev_callback(self.win.go_to_home) image = Gtk.Image.new_from_file(media + "/Graphics/about-screen.png") version_number, os_name = get_current_version() os_variant = read_file_contents('/etc/kanux_version_variant') cpu_id = get_cpu_id() version_align = self.create_align( "Kano OS: {name} v{version}".format(name=os_name, version=version_number), 'about_version' ) if os_variant: variant_align = self.create_align( "{variant}".format(variant=os_variant), 'about_version' ) space_align = self.create_align( _("Disk space used: {used}B / {total}B").format(**get_space_available()) ) try: celsius = u"{:.1f}\N{DEGREE SIGN}C".format(get_temperature()) except ValueError: celsius = "?" temperature_align = self.create_align( _(u"Temperature: {celsius}").format(celsius=celsius) ) model_align = self.create_align( _("Model: {model}").format(model=get_model_name()) ) cpu_id_align = self.create_align( _("CPU ID: {id}").format(id=cpu_id) ) terms_and_conditions = OrangeButton(_("Terms and conditions")) terms_and_conditions.connect( 'button_release_event', self.show_terms_and_conditions ) credits_button = OrangeButton(_("Meet the team")) credits_button.connect( 'button_release_event', self.show_credits ) self.kano_button = KanoButton(_("BACK")) self.kano_button.pack_and_align() hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0) hbox.pack_start(terms_and_conditions, False, False, 4) hbox.pack_start(credits_button, False, False, 4) hbutton_container = Gtk.Alignment( xalign=0.5, xscale=0, yalign=0, yscale=0 ) hbutton_container.add(hbox) image.set_margin_top(10) self.pack_start(image, False, False, 10) self.pack_start(version_align, False, False, 2) if os_variant: self.pack_start(variant_align, False, False, 2) self.pack_start(space_align, False, False, 1) self.pack_start(temperature_align, False, False, 1) self.pack_start(model_align, False, False, 1) self.pack_start(cpu_id_align, False, False, 1) self.pack_start(hbutton_container, False, False, 3) self.pack_start(self.kano_button.align, False, False, 10) self.kano_button.connect('button-release-event', self.win.go_to_home) self.kano_button.connect('key-release-event', self.win.go_to_home) # Refresh window self.win.show_all()
# Make sure that the events file exist try: f = open(tracker_events_file, 'a') except IOError as e: logger.error('Error opening tracker events file {}'.format(e)) else: f.close() if 'SUDO_USER' in os.environ: chown_path(tracker_events_file) return token OS_VERSION = str(read_file_contents('/etc/kanux_version')) CPU_ID = str(get_cpu_id()) TOKEN = load_token() def get_session_file_path(name, pid): return "{}/{}-{}.json".format(tracker_dir, pid, name) def session_start(name, pid=None): if not pid: pid = os.getpid() pid = int(pid) data = { "pid": pid, "name": name,
def __init__(self, win): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL) self.win = win self.win.set_main_widget(self) self.win.top_bar.enable_prev() self.win.change_prev_callback(self.win.go_to_home) image = Gtk.Image.new_from_file(media + "/Graphics/about-screen.png") version_number, os_name = get_current_version() os_variant = read_file_contents('/etc/kanux_version_variant') cpu_id = get_cpu_id() version_align = self.create_align( "Kano OS: {name} v{version}".format(name=os_name, version=version_number), 'about_version') if os_variant: variant_align = self.create_align( "{variant}".format(variant=os_variant), 'about_version') space_align = self.create_align( _("Disk space used: {used}B / {total}B").format( **get_space_available())) try: celsius = u"{:.1f}\N{DEGREE SIGN}C".format(get_temperature()) except ValueError: celsius = "?" temperature_align = self.create_align( _(u"Temperature: {celsius}").format(celsius=celsius)) model_align = self.create_align( _("Model: {model}").format(model=get_model_name())) cpu_id_align = self.create_align(_("CPU ID: {id}").format(id=cpu_id)) terms_and_conditions = OrangeButton(_("Terms and conditions")) terms_and_conditions.connect('button_release_event', self.show_terms_and_conditions) credits_button = OrangeButton(_("Meet the team")) credits_button.connect('button_release_event', self.show_credits) self.kano_button = KanoButton(_("BACK")) self.kano_button.pack_and_align() hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0) hbox.pack_start(terms_and_conditions, False, False, 4) hbox.pack_start(credits_button, False, False, 4) hbutton_container = Gtk.Alignment(xalign=0.5, xscale=0, yalign=0, yscale=0) hbutton_container.add(hbox) image.set_margin_top(10) self.pack_start(image, False, False, 10) self.pack_start(version_align, False, False, 2) if os_variant: self.pack_start(variant_align, False, False, 2) self.pack_start(space_align, False, False, 1) self.pack_start(temperature_align, False, False, 1) self.pack_start(model_align, False, False, 1) self.pack_start(cpu_id_align, False, False, 1) self.pack_start(hbutton_container, False, False, 3) self.pack_start(self.kano_button.align, False, False, 10) self.kano_button.connect('button-release-event', self.win.go_to_home) self.kano_button.connect('key-release-event', self.win.go_to_home) # Refresh window self.win.show_all()