def __init__(self, config_override=None, consoles_override=None, emulators_override=None): self.validated_base_environment = False self.validated_configuration = False self.logger = IceLogger() self.logger.debug("Initializing Ice") config_data_path = _path_with_override(config_override, "config.txt") consoles_data_path = _path_with_override(consoles_override, "consoles.txt") emulators_data_path = _path_with_override(emulators_override, "emulators.txt") self.config = Configuration( ConfigFileBackingStore(config_data_path), ConfigFileBackingStore(consoles_data_path), ConfigFileBackingStore(emulators_data_path), ) self.steam = Steam() # TODO: Query the list of users some other way self.users = self.steam.local_users() filesystem = Filesystem() parser = ROMParser(self.logger) self.rom_finder = ROMFinder(self.config, filesystem, parser) archive_data_path = Configuration.path_for_data_file("archive.json") managed_rom_archive = ManagedROMArchive(archive_data_path) self.shortcut_synchronizer = SteamShortcutSynchronizer( managed_rom_archive, self.logger) provider = CombinedProvider( LocalProvider(self.logger), ConsoleGridProvider(self.logger), ) self.grid_updater = SteamGridUpdater(provider, self.logger)
def __init__(self): self.validated_base_environment = False self.validated_configuration = False self.logger = IceLogger() self.logger.debug("Initializing Ice") config_data_path = Configuration.path_for_data_file("config.txt") consoles_data_path = Configuration.path_for_data_file("consoles.txt") emulators_data_path = Configuration.path_for_data_file("emulators.txt") self.config = Configuration( ConfigFileBackingStore(config_data_path), ConfigFileBackingStore(consoles_data_path), ConfigFileBackingStore(emulators_data_path), ) self.steam = Steam() # TODO: Query the list of users some other way self.users = self.steam.local_users() filesystem = Filesystem() parser = ROMParser(self.logger) self.rom_finder = ROMFinder(self.config, filesystem, parser) archive_data_path = Configuration.path_for_data_file("archive.json") managed_rom_archive = ManagedROMArchive(archive_data_path) self.shortcut_synchronizer = SteamShortcutSynchronizer(managed_rom_archive, self.logger) provider = CombinedProvider( LocalProvider(self.logger), ConsoleGridProvider(self.logger), ) self.grid_updater = SteamGridUpdater(provider, self.logger)
def __init__(self, options): """Valid options for creating an IceEngine are as follows: * config - The path to the config file to use. Searches the default paths for 'config.txt' otherwise * consoles - The path to the consoles file to use. Searches the default paths for 'consoles.txt' if none is provided * emulators - The path to the emulators file to use. Searches the default paths for 'emulators.txt' if none is provided * verbose - Turn on debug logging. """ self.validated_base_environment = False self.validated_configuration = False self.logger = IceLogger(verbose=options.verbose) self.logger.debug("Initializing Ice") config_data_path = _path_with_override(options.config, "config.txt") consoles_data_path = _path_with_override(options.consoles, "consoles.txt") emulators_data_path = _path_with_override(options.emulators, "emulators.txt") self.config = Configuration( ConfigFileBackingStore(config_data_path), ConfigFileBackingStore(consoles_data_path), ConfigFileBackingStore(emulators_data_path), ) self.steam = Steam() # TODO: Query the list of users some other way self.users = self.steam.local_users() filesystem = Filesystem() parser = ROMParser(self.logger) self.rom_finder = ROMFinder(self.config, filesystem, parser) archive_data_path = Configuration.path_for_data_file("archive.json") managed_rom_archive = ManagedROMArchive(archive_data_path) self.shortcut_synchronizer = SteamShortcutSynchronizer( managed_rom_archive, self.logger) provider = CombinedProvider( LocalProvider(self.logger), ConsoleGridProvider(self.logger), ) self.grid_updater = SteamGridUpdater(provider, self.logger)
def __init__(self, steam, filesystem, options): """Valid options for creating an IceEngine are as follows: * config - The path to the config file to use. Searches the default paths for 'config.txt' otherwise * consoles - The path to the consoles file to use. Searches the default paths for 'consoles.txt' if none is provided * emulators - The path to the emulators file to use. Searches the default paths for 'emulators.txt' if none is provided * verbose - Turn on debug logging. """ self.validated_base_environment = False self.validated_configuration = False self.filesystem = filesystem self.logger = IceLogger(verbose=options.verbose) self.logger.debug("Initializing Ice") config_data_path = _path_with_override(options.config, "config.txt") consoles_data_path = _path_with_override(options.consoles, "consoles.txt") emulators_data_path = _path_with_override(options.emulators, "emulators.txt") self.config = Configuration( ConfigFileBackingStore(config_data_path), ConfigFileBackingStore(consoles_data_path), ConfigFileBackingStore(emulators_data_path), self.logger, filesystem, ) self.steam = steam parser = ROMParser(self.logger) self.rom_finder = ROMFinder(self.logger, self.config, filesystem, parser) archive_data_path = Configuration.path_for_data_file("archive.json") managed_rom_archive = ManagedROMArchive(archive_data_path) self.shortcut_synchronizer = SteamShortcutSynchronizer(managed_rom_archive, self.logger) provider = CombinedProvider( LocalProvider(self.logger), ConsoleGridProvider(self.logger), ) self.grid_updater = SteamGridUpdater(provider, self.logger)
class IceEngine(object): def __init__(self, config_override=None, consoles_override=None, emulators_override=None): self.validated_base_environment = False self.validated_configuration = False self.logger = IceLogger() self.logger.debug("Initializing Ice") config_data_path = _path_with_override(config_override, "config.txt") consoles_data_path = _path_with_override(consoles_override, "consoles.txt") emulators_data_path = _path_with_override(emulators_override, "emulators.txt") self.config = Configuration( ConfigFileBackingStore(config_data_path), ConfigFileBackingStore(consoles_data_path), ConfigFileBackingStore(emulators_data_path), ) self.steam = Steam() # TODO: Query the list of users some other way self.users = self.steam.local_users() filesystem = Filesystem() parser = ROMParser(self.logger) self.rom_finder = ROMFinder(self.config, filesystem, parser) archive_data_path = Configuration.path_for_data_file("archive.json") managed_rom_archive = ManagedROMArchive(archive_data_path) self.shortcut_synchronizer = SteamShortcutSynchronizer( managed_rom_archive, self.logger) provider = CombinedProvider( LocalProvider(self.logger), ConsoleGridProvider(self.logger), ) self.grid_updater = SteamGridUpdater(provider, self.logger) def validate_base_environment(self): """ Validate that the current environment meets all of Ice's requirements. """ if self.validated_base_environment: return with EnvironmentChecker() as env_checker: # If Steam is running then any changes we make will be overwritten env_checker.require_program_not_running("Steam") # I'm not sure if there are situations where this won't exist, but I # assume that it does everywhere and better safe than sorry env_checker.require_directory_exists( self.steam.userdata_location()) # This is used to store history information and such env_checker.require_directory_exists( Configuration.data_directory()) self.validated_base_environment = True def validate_configuration(self, configuration): if self.validated_configuration: return with EnvironmentChecker() as env_checker: for console in configuration.console_manager: if console.is_enabled(): # Consoles assume they have a ROMs directory env_checker.require_directory_exists( configuration.roms_directory_for_console(console)) self.validated_configuration = True def validate_user_environment(self, user): """ Validate that the current environment for a given user meets all of Ice's requirements. """ with EnvironmentChecker() as env_checker: # If the user hasn't added any grid images on their own then this # directory wont exist, so we require it explicitly here env_checker.require_directory_exists(user.grid_directory()) # And it needs to be writable if we are going to save images there env_checker.require_writable_path(user.grid_directory()) def main(self): self.logger.info("=========== Starting Ice ===========") try: self.validate_base_environment() self.validate_configuration(self.config) except EnvCheckerError as e: self.logger.info( "Ice cannot run because of issues with your system.\n") self.logger.info("* %s" % e.message) self.logger.info( "\nPlease resolve these issues and try running Ice again") return # TODO: Create any missing directories that Ice will need self.logger.log_configuration(self.config) for user in self.users: self.logger.info("=========== User: %s ===========" % str(user.id32)) self.run_for_user(user) def run_for_user(self, user): try: self.validate_base_environment() self.validate_configuration(self.config) self.validate_user_environment(user) except EnvCheckerError as e: self.logger.info( "Ice cannot run because of issues with your system.\n") self.logger.info("\t%s\n" % e.message) self.logger.info( "Please resolve these issues and try running Ice again") return backup_path = self.config.shortcuts_backup_path(user) user.save_shortcuts(backup_path) # Find all of the ROMs that are currently in the designated folders roms = self.rom_finder.roms_for_consoles(self.config.console_manager) self.shortcut_synchronizer.sync_roms_for_user(user, roms, self.config) self.grid_updater.update_artwork_for_rom_collection(user, roms) def run(self): try: self.main() except Exception as error: self.logger.exception("An exception occurred while running Ice")
class IceEngine(object): def __init__(self): self.validated_base_environment = False self.validated_configuration = False self.logger = IceLogger() self.logger.debug("Initializing Ice") config_data_path = Configuration.path_for_data_file("config.txt") consoles_data_path = Configuration.path_for_data_file("consoles.txt") emulators_data_path = Configuration.path_for_data_file("emulators.txt") self.config = Configuration( ConfigFileBackingStore(config_data_path), ConfigFileBackingStore(consoles_data_path), ConfigFileBackingStore(emulators_data_path), ) self.steam = Steam() # TODO: Query the list of users some other way self.users = self.steam.local_users() filesystem = Filesystem() parser = ROMParser(self.logger) self.rom_finder = ROMFinder(self.config, filesystem, parser) archive_data_path = Configuration.path_for_data_file("archive.json") managed_rom_archive = ManagedROMArchive(archive_data_path) self.shortcut_synchronizer = SteamShortcutSynchronizer(managed_rom_archive, self.logger) provider = CombinedProvider( LocalProvider(self.logger), ConsoleGridProvider(self.logger), ) self.grid_updater = SteamGridUpdater(provider, self.logger) def validate_base_environment(self): """ Validate that the current environment meets all of Ice's requirements. """ if self.validated_base_environment: return with EnvironmentChecker() as env_checker: # If Steam is running then any changes we make will be overwritten env_checker.require_program_not_running("Steam") # I'm not sure if there are situations where this won't exist, but I # assume that it does everywhere and better safe than sorry env_checker.require_directory_exists(self.steam.userdata_location()) # This is used to store history information and such env_checker.require_directory_exists(Configuration.data_directory()) self.validated_base_environment = True def validate_configuration(self, configuration): if self.validated_configuration: return with EnvironmentChecker() as env_checker: for console in configuration.console_manager: if console.is_enabled(): # Consoles assume they have a ROMs directory env_checker.require_directory_exists(configuration.roms_directory_for_console(console)) self.validated_configuration = True def validate_user_environment(self, user): """ Validate that the current environment for a given user meets all of Ice's requirements. """ with EnvironmentChecker() as env_checker: # If the user hasn't added any grid images on their own then this # directory wont exist, so we require it explicitly here env_checker.require_directory_exists(user.grid_directory()) # And it needs to be writable if we are going to save images there env_checker.require_writable_path(user.grid_directory()) def main(self): self.logger.info("=========== Starting Ice ===========") try: self.validate_base_environment() self.validate_configuration(self.config) except EnvCheckerError as e: self.logger.info("Ice cannot run because of issues with your system.\n") self.logger.info("* %s" % e.message) self.logger.info("\nPlease resolve these issues and try running Ice again") return # TODO: Create any missing directories that Ice will need self.logger.log_configuration(self.config) for user in self.users: self.logger.info("=========== User: %s ===========" % str(user.id32)) self.run_for_user(user) def run_for_user(self, user): try: self.validate_base_environment() self.validate_configuration(self.config) self.validate_user_environment(user) except EnvCheckerError as e: self.logger.info("Ice cannot run because of issues with your system.\n") self.logger.info("\t%s\n" % e.message) self.logger.info("Please resolve these issues and try running Ice again") return backup_path = self.config.shortcuts_backup_path(user) user.save_shortcuts(backup_path) # Find all of the ROMs that are currently in the designated folders roms = self.rom_finder.roms_for_consoles(self.config.console_manager) self.shortcut_synchronizer.sync_roms_for_user(user, roms) self.grid_updater.update_artwork_for_rom_collection(user, roms) def run(self): try: self.main() except Exception as error: self.logger.exception("An exception occurred while running Ice")
class IceEngine(object): def __init__(self, steam, filesystem, options): """Valid options for creating an IceEngine are as follows: * config - The path to the config file to use. Searches the default paths for 'config.txt' otherwise * consoles - The path to the consoles file to use. Searches the default paths for 'consoles.txt' if none is provided * emulators - The path to the emulators file to use. Searches the default paths for 'emulators.txt' if none is provided * verbose - Turn on debug logging. """ self.validated_base_environment = False self.validated_configuration = False self.filesystem = filesystem self.logger = IceLogger(verbose=options.verbose) self.logger.debug("Initializing Ice") config_data_path = _path_with_override(options.config, "config.txt") consoles_data_path = _path_with_override(options.consoles, "consoles.txt") emulators_data_path = _path_with_override(options.emulators, "emulators.txt") self.config = Configuration( ConfigFileBackingStore(config_data_path), ConfigFileBackingStore(consoles_data_path), ConfigFileBackingStore(emulators_data_path), self.logger, filesystem, ) self.steam = steam parser = ROMParser(self.logger) self.rom_finder = ROMFinder(self.logger, self.config, filesystem, parser) archive_data_path = Configuration.path_for_data_file("archive.json") managed_rom_archive = ManagedROMArchive(archive_data_path) self.shortcut_synchronizer = SteamShortcutSynchronizer(managed_rom_archive, self.logger) provider = CombinedProvider( LocalProvider(self.logger), ConsoleGridProvider(self.logger), ) self.grid_updater = SteamGridUpdater(provider, self.logger) def validate_base_environment(self): """ Validate that the current environment meets all of Ice's requirements. """ if self.validated_base_environment: return with EnvironmentChecker(self.filesystem) as env_checker: # If Steam is running then any changes we make will be overwritten env_checker.require_program_not_running("Steam") # I'm not sure if there are situations where this won't exist, but I # assume that it does everywhere and better safe than sorry env_checker.require_directory_exists(self.steam.userdata_directory) # This is used to store history information and such env_checker.require_directory_exists(Configuration.data_directory()) self.validated_base_environment = True def validate_configuration(self, configuration): if self.validated_configuration: return with EnvironmentChecker(self.filesystem) as env_checker: for console in configuration.console_manager: if consoles.console_is_enabled(console): # Consoles assume they have a ROMs directory env_checker.require_directory_exists(configuration.roms_directory_for_console(console)) self.validated_configuration = True def validate_user_environment(self, user): """ Validate that the current environment for a given user meets all of Ice's requirements. """ with EnvironmentChecker(self.filesystem) as env_checker: # If the user hasn't added any grid images on their own then this # directory wont exist, so we require it explicitly here env_checker.require_directory_exists(paths.custom_images_directory(user)) # And it needs to be writable if we are going to save images there env_checker.require_writable_path(paths.custom_images_directory(user)) def main(self, dry_run=False): if self.steam is None: self.logger.error("Cannot run Ice because Steam doesn't appear to be installed") return self.logger.info("=========== Starting Ice ===========") try: self.validate_base_environment() self.validate_configuration(self.config) except EnvCheckerError as e: self.logger.info("Ice cannot run because of issues with your system.\n") self.logger.info("* %s" % e.message) self.logger.info("\nPlease resolve these issues and try running Ice again") return # TODO: Create any missing directories that Ice will need log_configuration(self.logger, self.config) for user_context in steam.local_user_contexts(self.steam): self.logger.info("=========== User: %s ===========" % str(user_context.user_id)) self.run_for_user(user_context, dry_run=dry_run) def run_for_user(self, user, dry_run=False): try: self.validate_base_environment() self.validate_configuration(self.config) self.validate_user_environment(user) except EnvCheckerError as e: self.logger.info("Ice cannot run because of issues with your system.\n") self.logger.info("\t%s\n" % e.message) self.logger.info("Please resolve these issues and try running Ice again") return self._create_backup(user, dry_run=dry_run) # Find all of the ROMs that are currently in the designated folders roms = self.rom_finder.roms_for_consoles(self.config.console_manager) self.shortcut_synchronizer.sync_roms_for_user(user, roms, self.config, dry_run=dry_run) self.grid_updater.update_artwork_for_rom_collection(user, roms, dry_run=dry_run) def run(self, dry_run=False): try: self.main(dry_run=dry_run) except Exception as error: self.logger.exception("An exception occurred while running Ice") def _create_backup(self, user, dry_run=False): if dry_run: self.logger.debug("Not creating backup because its a dry run") return backup_path = self.config.shortcuts_backup_path(user) if backup_path is None: self.logger.info("No backups directory specified, so not backing up shortcuts.vdf before overwriting. See config.txt for more info") return shortcuts.write_shortcuts(backup_path, shortcuts.get_shortcuts(user))