Пример #1
0
def main():
    """
	Start the Safe Eyes.
	"""
    # Initialize the logging
    Utility.intialize_logging()

    logging.info("Starting Safe Eyes")

    # Import the dependencies
    Utility.import_dependencies()

    if not running():

        global break_screen
        global core
        global config
        global notification
        global tray_icon
        global language
        global context
        global plugins
        global system_lock_command

        config = Utility.read_config()

        context = {}
        language = Utility.load_language(config['language'])
        # Get the lock command only one time
        if config['lock_screen_command']:
            system_lock_command = config['lock_screen_command']
        else:
            system_lock_command = Utility.lock_screen_command()

        # Initialize the Safe Eyes Context
        context['version'] = SAFE_EYES_VERSION
        context['desktop'] = Utility.desktop_environment()

        tray_icon = TrayIcon(config, language, show_settings, show_about,
                             enable_safeeyes, disable_safeeyes, on_quit)
        break_screen = BreakScreen(context, on_skipped, on_postponed,
                                   break_screen_glade,
                                   Utility.style_sheet_path)
        break_screen.initialize(config, language)
        notification = Notification(context, language)
        plugins = Plugins(config)
        core = SafeEyesCore(context, show_notification, show_alert,
                            close_alert, break_screen.show_count_down,
                            tray_icon.next_break_time)
        core.initialize(config, language)
        plugins.start(context)  # Call the start method of all plugins
        core.start()

        handle_system_suspend()

        Gtk.main()
    else:
        logging.info('Another instance of safeeyes is already running')
        sys.exit(0)
Пример #2
0
def main():
	"""
	Start the Safe Eyes.
	"""

	# Create the directory to store log file if not exist
	if not os.path.exists(Utility.config_directory):
		try:
			os.makedirs(Utility.config_directory)
		except:
			pass

	# Configure logging.
	logging.basicConfig(format='%(asctime)s [%(levelname)s]:[%(threadName)s] %(message)s', filename=log_file_path, filemode='w', level=logging.INFO)
	logging.info("Starting Safe Eyes")

	if not running():

		global break_screen
		global core
		global config
		global notification
		global tray_icon
		global language
		global context
		global plugins
		global system_lock_command

		config = Utility.read_config()

		context = {}
		language = Utility.load_language(config['language'])
		# Get the lock command only one time
		if config['lock_screen_command']:
			system_lock_command = config['lock_screen_command']
		else:
			system_lock_command = Utility.lock_screen_command()


		# Initialize the Safe Eyes Context
		context['version'] = SAFE_EYES_VERSION

		tray_icon = TrayIcon(config, language, show_settings, show_about, enable_safeeyes, disable_safeeyes, on_quit)
		break_screen = BreakScreen(on_skipped, on_postponed, break_screen_glade, Utility.style_sheet_path)
		break_screen.initialize(config, language)
		notification = Notification(language)
		plugins = Plugins(config)
		core = SafeEyesCore(context, show_notification, show_alert, close_alert, break_screen.show_count_down, tray_icon.next_break_time)
		core.initialize(config, language)
		plugins.start(context)		# Call the start method of all plugins
		core.start()

		handle_system_suspend()

		Gtk.main()
	else:
		logging.info('SafeEyes is already running')
		sys.exit(0)