def PrepareAssembler(self, base_path):
    """Set up build directory and paths to be used by assembler."""
    self.base_path = base_path
    self.maps_data_dir = MAPS_DATA_DIR % self.base_path
    self.earth_data_dir = EARTH_DATA_DIR % self.base_path
    self.search_dir = SEARCH_DIR % self.base_path
    self.kml_dir = KML_DIR % self.base_path
    self.polygon_file = POLYGON_FILE % self.base_path
    self.meta_dbroot_file = META_DBROOT_FILE % self.base_path
    self.map_json_file = MAP_JSON_FILE % self.base_path
    self.extract_map_json_file = EXTRACT_MAP_JSON_FILE % self.base_path
    self.layers_info_file = LAYERS_INFO_FILE % self.base_path
    self.dbroot_layers_info_file = DBROOT_LAYERS_INFO_FILE % self.base_path
    self.info_file = INFO_FILE % self.base_path
    self.temp_glc = TEMP_GLC_FILE % self.base_path

    logger = self.GetLogger()
    utils.PrintAndLog("Prepare assembler...", logger)
    utils.PrintAndLog("Base dir: %s" % self.base_path, logger)
    utils.CreateDirectory(self.base_path)
    utils.CopyDirectory("%s/earth" % TEMPLATE_DIR, self.earth_data_dir, logger)
    utils.CopyDirectory("%s/maps" % TEMPLATE_DIR, self.maps_data_dir, logger)
    utils.CreateDirectory(self.search_dir)
    utils.CreateDirectory(self.kml_dir)
    utils.PrintAndLog("Prepare assembler done.", logger)
    return logger
    def DisassembleGlc(self, form_):
        """Extract glms or glbs from a glc."""
        try:
            glc_path = form_.getvalue_path("path")
            output_dir = form_.getvalue_path("dir")
            try:
                utils.CreateDirectory(output_dir)
            except OSError:
                pass  # Allow use of existing directory.

            # Extra check to prevent XSS attack.
            if self.IsPathInvalid({
                    "glc_path": glc_path,
                    "output_dir": output_dir,
            }):
                return ""

            glx_entries = self.ExtractFilelistFromGlx(glc_path,
                                                      GLX_ENTRY_REGEX)
            msg = ""
            for glx_entry in glx_entries:
                glx_name = glx_entry.split("/")[-1]
                extracted_glx = "%s/%s" % (output_dir, glx_name)
                if os.path.isfile(extracted_glx):
                    return msg + "FAILED: %s already exists." % extracted_glx

                print "Extracting %s to %s ..." % (glx_entry, extracted_glx)
                msg += self.ExtractFileFromGlx(glc_path, glx_entry,
                                               extracted_glx)
            return "SUCCESS"
        except Exception as e:
            return "FAILED %s" % e.__str__()