Пример #1
0
        try:
            asset_info = AssetManager.acquire(map_asset_id)
        except AssetRetrievalError, e:
            log(logging.ERROR, "Error in retrieving assets for map: %s" % str(e))
            if Global.CLIENT:
                CModule.show_message("Error", "Could not retrieve assets for the map: " + str(e))
                CModule.disconnect()
                CModule.logout()
            return False
    else:
        # Working entirely locally - use config location and run from there
        asset_info = AssetInfo('xyz', map_asset_id, '?', 'NONE', [], 'b')

    log(logging.DEBUG, "final setting values: %s / %s" % (activity_id, map_asset_id))

    map_load_start.send(None, activity_id=activity_id, map_asset_id=map_asset_id)

    World.start_scenario()

    # Server may take a while to load and set up the map, so tell clients
    if Global.SERVER:
        MessageSystem.send(ALL_CLIENTS, CModule.PrepareForNewScenario, World.scenario_code)
        CModule.force_network_flush() # Flush message immediately to clients

    # Set globals

    set_curr_activity_id(activity_id)
    set_curr_map_asset_id(map_asset_id)
    World.asset_info = asset_info

    curr_map_prefix = asset_info.get_zip_location() + os.sep # asset_info.location
Пример #2
0
            if errors != []:
                log(logging.WARNING, 'urlretrieve errors: ' + str(errors))
                raise AssetRetrievalError(errors[0]) # Just one, to not fill screen. Rest are logged.

            if 'Content-Type: text/html' in str(headers):
                # We received an html/text response, containing an error, not a binary asset file. Raise the error
                ret = AssetRetrievalError(open(temp_filename, 'r').read())
                cleanup()
                raise ret

            # Original is a tempfile, and will be deleted by the OS in due time (doing 'move' here would fail on Windows, but not Linux)
            shutil.copyfile(temp_filename, self.get_full_location(asset_info))

            cleanup()

            asset_item_updated.send(None, asset_info=asset_info)

    #        except IOError, e: # Connection refused, etc. etc.
     #           log(logging.WARNING, "Cannot acquire AssetInfo for %s (%s), due to %s" % (asset_id, url, str(e)))
      #          return None

            if not self.check_existing(asset_info):
                log(logging.ERROR, "Failed to retrieve asset " + asset_info.asset_id)
                raise AssetRetrievalError("Failed to retrieve asset")

            # We get the asset, mark the asset's metadata
            metadata.update_acquire_time()

        # Mark the asset's metadata that we are attempting to use it now
        metadata.update_use_time()
Пример #3
0
            if errors != []:
                log(logging.WARNING, 'urlretrieve errors: ' + str(errors))
                raise AssetRetrievalError(errors[0]) # Just one, to not fill screen. Rest are logged.

            if 'Content-Type: text/html' in str(headers):
                # We received an html/text response, containing an error, not a binary asset file. Raise the error
                ret = AssetRetrievalError(open(temp_filename, 'r').read())
                cleanup()
                raise ret

            # Original is a tempfile, and will be deleted by the OS in due time (doing 'move' here would fail on Windows, but not Linux)
            shutil.copyfile(temp_filename, self.get_full_location(asset_info))

            cleanup()

            asset_item_updated.send(None, asset_info=asset_info)

    #        except IOError, e: # Connection refused, etc. etc.
     #           log(logging.WARNING, "Cannot acquire AssetInfo for %s (%s), due to %s" % (asset_id, url, str(e)))
      #          return None

            if not self.check_existing(asset_info):
                log(logging.ERROR, "Failed to retrieve asset " + asset_info.asset_id)
                raise AssetRetrievalError("Failed to retrieve asset")

            # We get the asset, mark the asset's metadata
            metadata.update_acquire_time()

        # Mark the asset's metadata that we are attempting to use it now
        metadata.update_use_time()
Пример #4
0
            if Global.CLIENT:
                CModule.show_message(
                    "Error",
                    "Could not retrieve assets for the map: " + str(e))
                CModule.disconnect()
                CModule.logout()
            return False
    else:
        # Working entirely locally - use config location and run from there
        asset_info = AssetInfo('xyz', map_asset_id, '?', 'NONE', [], 'b')

    log(logging.DEBUG,
        "final setting values: %s / %s" % (activity_id, map_asset_id))

    map_load_start.send(None,
                        activity_id=activity_id,
                        map_asset_id=map_asset_id)

    World.start_scenario()

    # Server may take a while to load and set up the map, so tell clients
    if Global.SERVER:
        MessageSystem.send(ALL_CLIENTS, CModule.PrepareForNewScenario,
                           World.scenario_code)
        CModule.force_network_flush()  # Flush message immediately to clients

    # Set globals

    set_curr_activity_id(activity_id)
    set_curr_map_asset_id(map_asset_id)
    World.asset_info = asset_info