How to use the safeeyes.Utility.load_json function in safeeyes

To help you get started, we’ve selected a few safeeyes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github slgobinath / SafeEyes / safeeyes / model.py View on Github external
def __init__(self, init=True):
        # Read the config files
        self.__user_config = Utility.load_json(Utility.CONFIG_FILE_PATH)
        self.__system_config = Utility.load_json(
            Utility.SYSTEM_CONFIG_FILE_PATH)
        self.__force_upgrade = ['long_breaks', 'short_breaks']

        if init:
            if self.__user_config is None:
                Utility.initialize_safeeyes()
                self.__user_config = self.__system_config
                self.save()
            else:
                system_config_version = self.__system_config['meta']['config_version']
                meta_obj = self.__user_config.get('meta', None)
                if meta_obj is None:
                    # Corrupted user config
                    self.__user_config = self.__system_config
                else:
github slgobinath / SafeEyes / safeeyes / PluginManager.py View on Github external
# Look for plugin.py
        plugin_dir = None
        if os.path.isfile(os.path.join(Utility.SYSTEM_PLUGINS_DIR, plugin['id'], 'plugin.py')):
            plugin_dir = Utility.SYSTEM_PLUGINS_DIR
        elif os.path.isfile(os.path.join(Utility.USER_PLUGINS_DIR, plugin['id'], 'plugin.py')):
            plugin_dir = Utility.USER_PLUGINS_DIR
        else:
            logging.error('plugin.py not found for the plugin: %s', plugin['id'])
            return
        # Look for config.json
        plugin_path = os.path.join(plugin_dir, plugin['id'])
        plugin_config_path = os.path.join(plugin_path, 'config.json')
        if not os.path.isfile(plugin_config_path):
            logging.error('config.json not found for the plugin: %s', plugin['id'])
            return
        plugin_config = Utility.load_json(plugin_config_path)
        if plugin_config is None:
            return

        if (plugin_enabled or plugin_config.get('break_override_allowed', False)):
            if plugin['id'] in self.__plugins:
                # The plugin is already enabled or partially loaded due to break_override_allowed
                # Use the existing plugin object
                plugin_obj = self.__plugins[plugin['id']]
                
                # Update the config
                plugin_obj['config'] = dict(plugin.get('settings', {}))
                plugin_obj['config']['path'] = os.path.join(plugin_dir, plugin['id'])

                if plugin_obj['enabled']:
                    # Already loaded completely
                    return
github slgobinath / SafeEyes / safeeyes / model.py View on Github external
def __init__(self, init=True):
        # Read the config files
        self.__user_config = Utility.load_json(Utility.CONFIG_FILE_PATH)
        self.__system_config = Utility.load_json(
            Utility.SYSTEM_CONFIG_FILE_PATH)
        self.__force_upgrade = ['long_breaks', 'short_breaks']

        if init:
            if self.__user_config is None:
                Utility.initialize_safeeyes()
                self.__user_config = self.__system_config
                self.save()
            else:
                system_config_version = self.__system_config['meta']['config_version']
                meta_obj = self.__user_config.get('meta', None)
                if meta_obj is None:
                    # Corrupted user config
                    self.__user_config = self.__system_config
                else:
                    user_config_version = str(