Ejemplo n.º 1
0
    def reset_config(self):
        p_bCheck = False
        self.m_sTemp = generate_random_temp_filename(RASP_BOOTCFG_FILE)
        touch_file(self.m_sTemp)
        p_lBaseCfg = {
            'pi4': [['dtoverlay', 'vc4-fkms-v3d'], ['max_framebuffers', '2']],
            'all': [['gpu_mem_256', '128'], ['gpu_mem_512', '256'],
                    ['gpu_mem_1024', '256']]
        }

        timings = " ".join(ini_getlist(RASP_BOOTCFG_FILE, 'hdmi_timings'))
        if not timings:
            res = ini_get(CRT_UTILITY_FILE, 'default') + '_timings'
            timings = " ".join(ini_getlist(CRT_UTILITY_FILE, res))
        line = 'hdmi_timings=' + timings
        add_line(self.m_sTemp, line)

        section_order = ['pi4', 'all']  # pi4 section must be before of all
        for section in section_order:
            list = p_lBaseCfg[section]
            for key, value in list:
                ini_sect_add_key(self.m_sTemp, section, key, value)

        self.set_cable(self.m_sTemp, 0)  # create cable config ID0 (default)
        ini_sect_create_section(self.m_sTemp, "CUSTOM-USER")

        os.system('sudo cp %s %s' % (self.m_sTemp, RASP_BOOTCFG_FILE))
        if md5_file(self.m_sTemp) == md5_file(RASP_BOOTCFG_FILE):
            p_bCheck = True
        self.__clean()
        return p_bCheck
Ejemplo n.º 2
0
def hash_check(p_sFile):
    """ 
    Compare saved hash of last es_system.cfg changes and 
    compare with current.
    """
    sHashLast = LAST_HASH
    sHashFile = md5_file(p_sFile)
    if sHashLast != sHashFile:
        return False
    return True
Ejemplo n.º 3
0
 def get_config(self):
     if not os.path.exists(CRT_OLED_FILE): touch_file(CRT_OLED_FILE)
     p_sHash = md5_file(CRT_OLED_FILE)
     if p_sHash != self.m_sHash_Prev:
         logging.info("INFO: getting configuration from file")
         for screen in self.m_lOLEDScrns:
             for item in screen:
                 if 'scr_' in item:
                     value = ini_get(CRT_OLED_FILE, item)
                     if value == False:
                         value = 0
                         remove_line(CRT_OLED_FILE, item)
                         add_line(CRT_OLED_FILE, "%s = 0" % item)
                     else: value = int(value)
                     if value > 0: 
                         screen[item] = True
                         screen['time'] = value * 60
                     elif value <= 0: 
                         screen[item] = False
                         screen['time'] = 0
         self.m_sHash_Prev = md5_file(CRT_OLED_FILE)
Ejemplo n.º 4
0
 def load_rpi_config(self, p_dConfig):
     if self.m_sMD5_Prev != md5_file(RASP_BOOTCFG_FILE):
         if ini_set_check_section(RASP_BOOTCFG_FILE, p_dConfig['section']):
             self.m_bOCEnabled = True
             for ini in p_dConfig['config']:
                 value = ini_sect_get_key(RASP_BOOTCFG_FILE,
                                          p_dConfig['section'], ini)
                 if value != None:
                     try:
                         value = int(value)
                     except Exception as e:
                         pass
                     if value not in p_dConfig['values'][ini][3]:
                         value = p_dConfig['values'][ini][0]
                     p_dConfig['config'][ini] = value
                 else:
                     p_dConfig['config'][ini] = p_dConfig['values'][ini][0]
         else:
             self.m_bOCEnabled = False
             for ini in p_dConfig['values']:
                 p_dConfig['config'][ini] = p_dConfig['values'][ini][0]
         m_sMD5_Prev = md5_file(RASP_BOOTCFG_FILE)
     self.m_dOCConfig = p_dConfig.copy()
Ejemplo n.º 5
0
 def change_cable(self, p_iCableID):
     """ change cable config on system: config.txt """
     p_bCheck = False
     p_iCableID = self.get_cable_id(p_iCableID)
     self.m_sTemp = generate_random_temp_filename(RASP_BOOTCFG_FILE)
     os.system('cp %s %s' % (RASP_BOOTCFG_FILE, self.m_sTemp))
     self.set_cable(self.m_sTemp, p_iCableID)
     os.system('sudo cp %s %s' % (self.m_sTemp, RASP_BOOTCFG_FILE))
     if md5_file(self.m_sTemp) == md5_file(RASP_BOOTCFG_FILE):
         p_bCheck = True
     self.__clean()
     value = self.m_oKeyboardMNGR.check_keyboard_enabled()
     if self.m_lCableList[p_iCableID]['kbd']:
         if not value: self.m_oKeyboardMNGR.pi2jamma_enable_controls()
     else:
         if ini_get(CRT_UTILITY_FILE, 'keyb_ipac') == 'true': ipac = True
         else: ipac = False
         if value and not ipac:
             self.m_oKeyboardMNGR.pi2jamma_disable_controls()
         if not value and ipac:
             self.m_oKeyboardMNGR.pi2jamma_enable_controls()
     self.check_cable()
     return p_bCheck
Ejemplo n.º 6
0
    def _get_ra_version_from_db(self):
        logging.info("INFO: checking retroarch version")
        self.m_sRAHash = md5_file(RA_BIN_FILE)
        f = open(CRT_RA_HASHDB_FILE, "r")
        full_lines = f.readlines()
        f.close()

        for line in full_lines:
            if line != "\n":
                lValues = line.strip().split(' ')
                if self.m_sRAHash == lValues[1]:
                    self.m_sRAVersion = lValues[2]
                    logging.info("INFO: found hash in db: {%s} {%s}" % \
                                (self.m_sRAHash, self.m_sRAVersion))
                    break
        if not self.m_sRAVersion:
            self._add_ra_version_to_db()
Ejemplo n.º 7
0
    def _get_config(self):
        """ get configuration from boot.txt """
        p_sHashTemp = md5_file(RASP_BOOTCFG_FILE)
        if p_sHashTemp != self.m_sHashConfig:
            self.m_iCableType = int(
                ini_sect_get_key(RASP_BOOTCFG_FILE, 'CRT-CABLE',
                                 'crt_cable_type'))
            self.m_bRecovery = int(
                ini_sect_get_key(RASP_BOOTCFG_FILE, 'CRT-RECOVERY',
                                 'crt_recovery_enabled'))
            self.m_bDaemonEna = int(
                ini_sect_get_key(RASP_BOOTCFG_FILE, 'CRT-RECOVERY',
                                 'crt_daemon_enabled'))

            if self.m_bRecovery:
                value = ini_sect_get_key(RASP_BOOTCFG_FILE, 'CRT-RECOVERY',
                                         'crt_recovery_mode')
                if value: self.m_bRecovMode = value
        self.m_sHashConfig = p_sHashTemp
Ejemplo n.º 8
0
def update_last_hash(p_sFile):
    """ Update last hash if any change """
    sHashFile = md5_file(p_sFile)
    modify_line(CRT_ES_SYSTEMDB_FILE, "LAST_HASH",
                "LAST_HASH = \"%s\"" % sHashFile)
Ejemplo n.º 9
0
def update_last_hash(p_sFile):
    """ Update last hash if any change """
    sHashFile = md5_file(p_sFile)
    ini_set(CRT_ES_SYSTEMDB_FILE, "LAST_HASH", sHashFile)