示例#1
0
    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)
示例#2
0
    def __init__(self, steam, filesystem, app_settings):
        self.steam = steam
        self.filesystem = filesystem

        # We want to ignore the anonymous context, cause theres no reason to sync
        # ROMs for it since you cant log in as said user.
        is_user_context = lambda context: context.user_id != 'anonymous'
        self.users = filter(is_user_context,
                            steam_module.local_user_contexts(self.steam))

        logger.debug("Initializing Ice")

        self.app_settings = app_settings

        parser = ROMParser()
        self.rom_finder = ROMFinder(app_settings.config, filesystem, parser)
示例#3
0
  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)
示例#4
0
文件: main.py 项目: KevinAnthony/Ice
  def __init__(self, steam, filesystem, app_settings,options):
    self.app = Qt.QApplication(sys.argv)
    QtWidgets.QMainWindow.__init__(self)
    self.steam = steam
    self.filesystem = filesystem

    is_user_context = lambda context: context.user_id != 'anonymous'
    self.users = filter(is_user_context, steam_module.local_user_contexts(self.steam))

    logger.debug("Initializing Ice")

    self.app_settings = app_settings

    parser = ROMParser()
    self.rom_finder = ROMFinder(app_settings.config, filesystem, parser)
    self.options = options
示例#5
0
    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
    """
        self.validated_base_environment = False
        self.validated_configuration = False
        self.filesystem = filesystem
        logger.debug("Initializing Ice")
        config_data_path = _path_with_override(filesystem, options.config,
                                               "config.txt")
        consoles_data_path = _path_with_override(filesystem, options.consoles,
                                                 "consoles.txt")
        emulators_data_path = _path_with_override(filesystem,
                                                  options.emulators,
                                                  "emulators.txt")
        self.config = Configuration(
            ConfigFileBackingStore(config_data_path),
            ConfigFileBackingStore(consoles_data_path),
            ConfigFileBackingStore(emulators_data_path),
            filesystem,
        )
        self.steam = steam

        parser = ROMParser()
        self.rom_finder = ROMFinder(self.config, filesystem, parser)
        archive_data_path = paths.highest_precedent_data_file(
            filesystem, "archive.json")
        managed_rom_archive = ManagedROMArchive(archive_data_path)
        self.shortcut_synchronizer = SteamShortcutSynchronizer(
            managed_rom_archive)

        provider = CombinedProvider(
            LocalProvider(),
            ConsoleGridProvider(),
        )
        self.grid_updater = SteamGridUpdater(provider)
示例#6
0
    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)
示例#7
0
  def __init__(self, steam, filesystem, app_settings):
    self.steam = steam
    self.filesystem = filesystem

    # We want to ignore the anonymous context, cause theres no reason to sync
    # ROMs for it since you cant log in as said user.
    is_user_context = lambda context: context.user_id != 'anonymous'
    self.users = filter(is_user_context, steam_module.local_user_contexts(self.steam))

    logger.debug("Initializing Ice")

    self.app_settings = app_settings

    parser = ROMParser()
    self.rom_finder = ROMFinder(app_settings.config, filesystem, parser)
示例#8
0
  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)
示例#9
0
  def __init__(self, filesystem):
    self.filesystem = filesystem

    self.rom_finder = ROMFinder(self.filesystem, ROMParser())
示例#10
0
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")
示例#11
0
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")
示例#12
0
文件: main.py 项目: KevinAnthony/Ice
class GraphicalRunner(QtWidgets.QMainWindow):
  def __init__(self, steam, filesystem, app_settings,options):
    self.app = Qt.QApplication(sys.argv)
    QtWidgets.QMainWindow.__init__(self)
    self.steam = steam
    self.filesystem = filesystem

    is_user_context = lambda context: context.user_id != 'anonymous'
    self.users = filter(is_user_context, steam_module.local_user_contexts(self.steam))

    logger.debug("Initializing Ice")

    self.app_settings = app_settings

    parser = ROMParser()
    self.rom_finder = ROMFinder(app_settings.config, filesystem, parser)
    self.options = options

  def validate_environment(self, skip_steam_check):
    """
    Validate that the current environment meets all of Ice's requirements.
    """
    with EnvironmentChecker(self.filesystem) as env_checker:
      if not skip_steam_check:
        # If Steam is running then any changes we make will be overwritten
        env_checker.require_program_not_running("Steam")
      else:
        logger.warning(STEAM_CHECK_SKIPPED_WARNING)
      # 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(paths.application_data_directory())

      for console in self.app_settings.consoles:
        # Consoles assume they have a ROMs directory
        env_checker.require_directory_exists(consoles.console_roms_directory(self.app_settings.config, console))

      for user in self.users:
        # 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(steam_paths.custom_images_directory(user))
        # And it needs to be writable if we are going to save images there
        env_checker.require_writable_path(steam_paths.custom_images_directory(user))
  def run(self):
    if self.steam is None:
      logger.error("Cannot run Ice because Steam doesn't appear to be installed")
      return

    logger.info("=========== Starting Ice ===========")
    try:
      self.validate_environment(self.options.skip_steam_check)
    except EnvCheckerError as e:
      logger.info("Ice cannot run because of issues with your system.\n")
      logger.info("* %s" % e.message)
      logger.info("\nPlease resolve these issues and try running Ice again")
      return

    self.__roms = self.rom_finder.roms_for_consoles(self.app_settings.consoles)
    self.__init__gui()
    self.show()
    sys.exit(self.app.exec_())

  def __init__gui(self):
    #setup window
    self.setGeometry(200,200,800, 600)
    self.resizeEvent = self.on_resize
    #Setup StatusBar
    self.statusBar = QtWidgets.QStatusBar()#self.statusBar().showMessage()
    self.setStatusBar(self.statusBar)
    self.statusBar.showMessage(str.format("{0} roms found", len(self.__roms)))
    self.statusBar.resizeEvent = self.on_resize

    #Setup Toolbar
    self.toolBar = QtWidgets.QToolBar(self)
    self.addToolBar(self.toolBar)
    self.toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
    self.toolBar.resizeEvent = self.on_resize

    emulatorAction = QtWidgets.QAction(self)
    emulatorAction.setIcon(QtGui.QIcon("../icon.ico"))
    emulatorAction.setIconText("Emulators")
    emulatorAction.setShortcut('Ctrl+E')
    emulatorAction.triggered.connect(self.on_emulators_pressed)
    self.toolBar.addAction(emulatorAction)

    consoleAction = QtWidgets.QAction(self)
    consoleAction.setIcon(QtGui.QIcon("../icon.ico"))
    consoleAction.setIconText("Console")
    consoleAction.setShortcut('Ctrl+S')
    consoleAction.triggered.connect(self.on_consoles_pressed)
    self.toolBar.addAction(consoleAction)

    self.toolBar.addSeparator()

    runAction = QtWidgets.QAction(self)
    runAction.setIcon(QtGui.QIcon("../icon.ico"))
    runAction.setIconText("Update Steam")
    runAction.setShortcut('Ctrl+R')
    runAction.triggered.connect(self.on_run_pressed)
    self.toolBar.addAction(runAction)

    #Setup Main Widget
    self.centralWidget = QtWidgets.QWidget(self)
    self.centralWidget.setMaximumWidth(16777215)
    self.centralWidget.setMaximumHeight(16777215)
    self.centralWidget.setContentsMargins(0,0,0,0)
    self.centralWidget.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred))
    self.centralWidget.setGeometry(0,0 ,self.width(),self.height())

    #setup layout
    layout = QtWidgets.QVBoxLayout(self.centralWidget)
    layout.setContentsMargins(0, 0, 0, 0)
    layout.setSpacing(0)

    #setup table
    self.romTable = RomTableWidget(self.__roms)
    layout.addWidget(self.romTable)

    #setup dialogs
    self.emulators = EmulatoreGui(self, self.app_settings)
    self.consoles = ConsoleGui(self, self.app_settings)

  @QtCore.pyqtSlot()
  def on_emulators_pressed(self):
    self.emulators.exec_()

  @QtCore.pyqtSlot()
  def on_consoles_pressed(self):
    self.consoles.exec_()

  def on_run_pressed(self):
    pass

  def on_resize(self, event):
    tbHeight = self.toolBar.height()
    sbHeight = self.statusBar.height()
    # This line may seem strange but basically we need need to move the central Widget down the height of the
    # ToolBar and we want it to be the height of the window less the heights of the ToolBar and StatusBar
    self.centralWidget.setGeometry(0, tbHeight , self.width(), self.height() - sbHeight - tbHeight)

  def delete_event(self, widget, event, data=None):
    print "delete event occurred"
    return False

  def destroy(self, widget, data=None):
      print "destroy signal occurred"
     # gtk.main_quit()
      exit(0)
示例#13
0
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
    """
        self.validated_base_environment = False
        self.validated_configuration = False
        self.filesystem = filesystem
        logger.debug("Initializing Ice")
        config_data_path = _path_with_override(filesystem, options.config,
                                               "config.txt")
        consoles_data_path = _path_with_override(filesystem, options.consoles,
                                                 "consoles.txt")
        emulators_data_path = _path_with_override(filesystem,
                                                  options.emulators,
                                                  "emulators.txt")
        self.config = Configuration(
            ConfigFileBackingStore(config_data_path),
            ConfigFileBackingStore(consoles_data_path),
            ConfigFileBackingStore(emulators_data_path),
            filesystem,
        )
        self.steam = steam

        parser = ROMParser()
        self.rom_finder = ROMFinder(self.config, filesystem, parser)
        archive_data_path = paths.highest_precedent_data_file(
            filesystem, "archive.json")
        managed_rom_archive = ManagedROMArchive(archive_data_path)
        self.shortcut_synchronizer = SteamShortcutSynchronizer(
            managed_rom_archive)

        provider = CombinedProvider(
            LocalProvider(),
            ConsoleGridProvider(),
        )
        self.grid_updater = SteamGridUpdater(provider)

    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(
                paths.application_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(
                        consoles.console_roms_directory(
                            configuration, 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(
                steam_paths.custom_images_directory(user))
            # And it needs to be writable if we are going to save images there
            env_checker.require_writable_path(
                steam_paths.custom_images_directory(user))

    def main(self, dry_run=False):
        if self.steam is None:
            logger.error(
                "Cannot run Ice because Steam doesn't appear to be installed")
            return

        logger.info("=========== Starting Ice ===========")
        try:
            self.validate_base_environment()
            self.validate_configuration(self.config)
        except EnvCheckerError as e:
            logger.info("Ice cannot run because of issues with your system.\n")
            logger.info("* %s" % e.message)
            logger.info(
                "\nPlease resolve these issues and try running Ice again")
            return
        # TODO: Create any missing directories that Ice will need
        log_configuration(self.config)
        for user_context in steam.local_user_contexts(self.steam):
            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:
            logger.info("Ice cannot run because of issues with your system.\n")
            logger.info("\t%s\n" % e.message)
            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:
            logger.exception("An exception occurred while running Ice")

    def _create_backup(self, user, dry_run=False):
        if dry_run:
            logger.debug("Not creating backup because its a dry run")
            return

        backup_path = self.config.shortcuts_backup_path(user)
        if backup_path is None:
            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))
示例#14
0
class TaskEngine(object):

  def __init__(self, steam, filesystem, app_settings):
    self.steam = steam
    self.filesystem = filesystem

    # We want to ignore the anonymous context, cause theres no reason to sync
    # ROMs for it since you cant log in as said user.
    is_user_context = lambda context: context.user_id != 'anonymous'
    self.users = filter(is_user_context, steam_module.local_user_contexts(self.steam))

    logger.debug("Initializing Ice")

    self.app_settings = app_settings

    parser = ROMParser()
    self.rom_finder = ROMFinder(app_settings.config, filesystem, parser)

  def validate_environment(self, skip_steam_check):
    """
    Validate that the current environment meets all of Ice's requirements.
    """
    with EnvironmentChecker(self.filesystem) as env_checker:
      if not skip_steam_check:
        # If Steam is running then any changes we make will be overwritten
        env_checker.require_program_not_running("Steam")
      else:
        logger.warning(STEAM_CHECK_SKIPPED_WARNING)
      # 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(paths.application_data_directory())

      for console in self.app_settings.consoles:
        # Consoles assume they have a ROMs directory
        env_checker.require_directory_exists(consoles.console_roms_directory(self.app_settings.config, console))

      for user in self.users:
        # 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(steam_paths.custom_images_directory(user))
        # And it needs to be writable if we are going to save images there
        env_checker.require_writable_path(steam_paths.custom_images_directory(user))

  def run(self, tasks, skip_steam_check=False, dry_run=False):
    if self.steam is None:
      logger.error("Cannot run Ice because Steam doesn't appear to be installed")
      return

    logger.info("=========== Starting Ice ===========")
    try:
      self.validate_environment(skip_steam_check)
    except EnvCheckerError as e:
      logger.info("Ice cannot run because of issues with your system.\n")
      logger.info("* %s" % e.message)
      logger.info("\nPlease resolve these issues and try running Ice again")
      return

    roms = self.rom_finder.roms_for_consoles(self.app_settings.consoles)

    for task in tasks:
      task(self.users, roms, dry_run=dry_run)
示例#15
0
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))
示例#16
0
class TaskEngine(object):
    def __init__(self, steam, filesystem, app_settings):
        self.steam = steam
        self.filesystem = filesystem

        # We want to ignore the anonymous context, cause theres no reason to sync
        # ROMs for it since you cant log in as said user.
        is_user_context = lambda context: context.user_id != 'anonymous'
        self.users = filter(is_user_context,
                            steam_module.local_user_contexts(self.steam))

        logger.debug("Initializing Ice")

        self.app_settings = app_settings

        parser = ROMParser()
        self.rom_finder = ROMFinder(app_settings.config, filesystem, parser)

    def validate_environment(self, skip_steam_check):
        """
    Validate that the current environment meets all of Ice's requirements.
    """
        with EnvironmentChecker(self.filesystem) as env_checker:
            if not skip_steam_check:
                # If Steam is running then any changes we make will be overwritten
                env_checker.require_program_not_running("Steam")
            else:
                logger.warning(STEAM_CHECK_SKIPPED_WARNING)
            # 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(
                paths.application_data_directory())

            for console in self.app_settings.consoles:
                # Consoles assume they have a ROMs directory
                env_checker.require_directory_exists(
                    consoles.console_roms_directory(self.app_settings.config,
                                                    console))

            for user in self.users:
                # 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(
                    steam_paths.custom_images_directory(user))
                # And it needs to be writable if we are going to save images there
                env_checker.require_writable_path(
                    steam_paths.custom_images_directory(user))

    def run(self, tasks, skip_steam_check=False, dry_run=False):
        if self.steam is None:
            logger.error(
                "Cannot run Ice because Steam doesn't appear to be installed")
            return

        logger.info("=========== Starting Ice ===========")
        try:
            self.validate_environment(skip_steam_check)
        except EnvCheckerError as e:
            logger.info("Ice cannot run because of issues with your system.\n")
            logger.info("* %s" % e.message)
            logger.info(
                "\nPlease resolve these issues and try running Ice again")
            return

        roms = self.rom_finder.roms_for_consoles(self.app_settings.consoles)

        for task in tasks:
            task(self.users, roms, dry_run=dry_run)