<commit_before>import gui  # needed for kivy objects
import os
import comms
import alarm
import helper
import subprocess

os.environ['DISPLAY'] = "0"

from kivy.app import App
from kivy.lang import Builder


class Jarvus(App):
    comms_system = comms.Comms()
    alarm = alarm.Alarm(comms_system)
    screen_on = True

    def build(self):
        # comms thread
        self.comms_system.setDaemon(True)
        self.comms_system.start()
        self.comms_system.log('comms started')
        # alarm thread
        self.alarm.setDaemon(True)
        self.alarm.start()
        self.comms_system.log('alarm started')
        # pass threads to a helper to make more accessible
        helper.set_alarm(self.alarm)
        helper.set_comms(self.comms_system)

        this_app = Builder.load_file('gui.kv')
        return this_app

    def turn_screen_on(self):
        try:
            bash_command = "./screen_on.sh"
            subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
            self.screen_on = True
        except Exception as ee:
            self.comms_system.log("Failed to power screen on: " + ee.__str__())

    def turn_screen_off(self):
        try:
            bash_command = "./screen_off.sh"
            subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
            self.screen_on = False
        except Exception as ee:
            self.comms_system.log("Failed to power screen off: " + ee.__str__())

    def screen_toggle(self):
        print('Turning screen off')
        # Doesn't work
        try:
            if self.screen_on:
                self.turn_screen_off()
                self.comms_system.play_fx(helper.DING1)
                '''
                bash_command = "sudo rpi-backlight off"
                subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
                '''

            else:
                '''
                bash_command = "sudo rpi-backlight on"
                subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
                '''
                self.turn_screen_on()
                self.comms_system.play_fx(helper.DING2)<commit_msg>Using xset for screen toggle<commit_after>import gui  # needed for kivy objects
import os
import comms
import alarm
import helper
import subprocess

os.environ['DISPLAY'] = "0"

from kivy.app import App
from kivy.lang import Builder


class Jarvus(App):
    comms_system = comms.Comms()
    alarm = alarm.Alarm(comms_system)
    screen_on = True

    def build(self):
        # comms thread
        self.comms_system.setDaemon(True)
        self.comms_system.start()
        self.comms_system.log('comms started')
        # alarm thread
        self.alarm.setDaemon(True)
        self.alarm.start()
        self.comms_system.log('alarm started')
        # pass threads to a helper to make more accessible
        helper.set_alarm(self.alarm)
        helper.set_comms(self.comms_system)

        this_app = Builder.load_file('gui.kv')
        return this_app

    def turn_screen_on(self):
        try:
            bash_command = "sudo ./screen_on.sh"
            subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
            self.screen_on = True
        except Exception as ee:
            self.comms_system.log("Failed to power screen on: " + ee.__str__())

    def turn_screen_off(self):
        try:
            bash_command = "sudo ./screen_off.sh"
            subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
            self.screen_on = False
        except Exception as ee:
            self.comms_system.log("Failed to power screen off: " + ee.__str__())

    def screen_toggle(self):
        print('Turning screen off')
        # Doesn't work
        try:
            if self.screen_on:
                self.turn_screen_off()
                self.comms_system.play_fx(helper.DING1)
                '''
                bash_command = "sudo rpi-backlight off"
                subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
                '''

            else:
                '''
                bash_command = "sudo rpi-backlight on"
                subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
                '''
                self.turn_screen_on()
                self.comms_system.play_fx(helper.DING2)
{'fraction_non_alphanumeric': 0.09600738518347565, 'fraction_numerical': 0.0013847219016847449, 'mean_word_length': 1.9869055823569952, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1480955', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1300, 'n_words': 261}