Example #1
0
    def validate_environment(self, app_settings, users):
        """
        Validate that the current environment meets all of Ice's requirements.
        """
        with EnvironmentChecker(self.filesystem) as env_checker:
            if not self.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)
            # This is used to store history information and such
            env_checker.require_directory_exists(paths.application_data_directory())

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

            for user in users:
                # 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(user.steam.userdata_directory)
                # 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)
                )
Example #2
0
  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))
Example #3
0
 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
Example #4
0
 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
Example #5
0
 def test_console_roms_directory(self, console, config_path, expected):
     config = mock()
     config.roms_directory = config_path
     self.assertEqual(consoles.console_roms_directory(config, console),
                      expected)
Example #6
0
 def test_console_roms_directory(self, console, config_path, expected):
   config = mock()
   when(config).roms_directory().thenReturn(config_path)
   self.assertEqual(consoles.console_roms_directory(config, console), expected)
Example #7
0
 def test_console_roms_directory(self, console, config_path, expected):
     config = mock()
     config.roms_directory = config_path
     self.assertEqual(consoles.console_roms_directory(config, console), expected)