Exemplo n.º 1
0
    def test_config_pref_write(self):
        newdata = preferences.load_file(self.paths.preferences)
        newdata["controller"]["landing_tab"] = 2
        preferences.save_file(self.paths.preferences, newdata)

        data = preferences.load_file(self.paths.preferences)
        self.assertEqual(data["controller"]["landing_tab"], 2, "Could not write to preferences file")
Exemplo n.º 2
0
 def save_profile_from_memory(self, uuid):
     """
     Commit profile from module memory to file system.
     """
     self.backup_profile(uuid)
     profile_path = os.path.join(path.profile_folder, uuid + '.json')
     data = self.memory
     pref.save_file(profile_path, data)
Exemplo n.º 3
0
 def save_profile_from_memory(self, uuid):
     """
     Commit profile from module memory to file system.
     """
     self.backup_profile(uuid)
     profile_path = os.path.join(path.profile_folder, uuid + '.json')
     data = self.memory
     pref.save_file(profile_path, data)
Exemplo n.º 4
0
    def test_config_pref_force_invalid_data(self):
        newdata = preferences.load_file(self.paths.preferences)
        newdata["controller"]["system_qt_theme"] = 123456
        preferences.save_file(self.paths.preferences, newdata)

        # load_file._validate() should correct this
        data = preferences.load_file(self.paths.preferences)
        self.assertFalse(data["controller"]["system_qt_theme"], "Invalid data was not corrected")
Exemplo n.º 5
0
 def set_metadata(self, uuid, key, value):
     """
     Set meta data for a particular profile, then save immediately.
     """
     # uuid  = string of UUID filename
     # key   = group, e.g. "name"
     # value = what to set, e.g. "Test Application"
     self.backup_profile(uuid)
     profile_path = os.path.join(path.profile_folder, uuid + '.json')
     newdata = pref.load_file(profile_path)
     newdata[key] = value
     pref.save_file(profile_path, newdata)
Exemplo n.º 6
0
 def set_metadata(self, uuid, key, value):
     """
     Set meta data for a particular profile, then save immediately.
     """
     # uuid  = string of UUID filename
     # key   = group, e.g. "name"
     # value = what to set, e.g. "Test Application"
     self.backup_profile(uuid)
     profile_path = os.path.join(path.profile_folder, uuid + '.json')
     newdata = pref.load_file(profile_path)
     newdata[key] = value
     pref.save_file(profile_path, newdata)
Exemplo n.º 7
0
    def new_profile(self):
        """
        Create profile on the file system.
        """
        uuid = pref.generate_uuid()
        self.selected_uuid = uuid
        filepath = os.path.join(path.profile_folder, uuid + '.json')

        template = {"name": "", "icon": "", "rows": {}}

        for row in range(0, 6):
            template["rows"][str(row)] = []
            for col in range(0, 22):
                template["rows"][str(row)].append([0, 0, 0])

        pref.save_file(filepath, template)
        return str(uuid)
Exemplo n.º 8
0
    def new_profile(self):
        """
        Create profile on the file system.
        """
        uuid = pref.generate_uuid()
        self.selected_uuid = uuid
        filepath = os.path.join(path.profile_folder, uuid + '.json')

        template = {
            "name": "",
            "icon": "",
            "rows": {}
        }

        for row in range(0, 6):
            template["rows"][str(row)] = []
            for col in range(0, 22):
                template["rows"][str(row)].append([0, 0, 0])

        pref.save_file(filepath, template)
        return str(uuid)