<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_html(self, html_dir='/tmp', include_osd=False, osd_width=500, osd_height=500):
 """Write HTML test page using OpenSeadragon for the tiles generated. Assumes that the generate(..) method has already been called to set up identifier etc. Parameters: html_dir - output directory for HTML files, will be created if it does not already exist include_osd - true to include OpenSeadragon code osd_width - width of OpenSeadragon pane in pixels osd_height - height of OpenSeadragon pane in pixels """

        osd_config = self.get_osd_config(self.osd_version)
        osd_base = osd_config['base']
        osd_dir = osd_config['dir']  # relative to base
        osd_js = os.path.join(osd_dir, osd_config['js'])
        osd_images = os.path.join(osd_dir, osd_config['images'])
        if (os.path.isdir(html_dir)):
            # Exists, fine
            pass
        elif (os.path.isfile(html_dir)):
            raise IIIFStaticError(
                "Can't write to directory %s: a file of that name exists" % html_dir)
        else:
            os.makedirs(html_dir)
        self.logger.info("Writing HTML to %s" % (html_dir))
        with open(os.path.join(self.template_dir, 'static_osd.html'), 'r') as f:
            template = f.read()
        outfile = self.identifier + '.html'
        outpath = os.path.join(html_dir, outfile)
        with open(outpath, 'w') as f:
            info_json_uri = '/'.join([self.identifier, 'info.json'])
            if (self.prefix):
                info_json_uri = '/'.join([self.prefix, info_json_uri])
            d = dict(identifier=self.identifier,
                     api_version=self.api_version,
                     osd_version=self.osd_version,
                     osd_uri=osd_js,
                     osd_images_prefix=osd_images,
                     osd_height=osd_width,
                     osd_width=osd_height,
                     info_json_uri=info_json_uri)
            f.write(Template(template).safe_substitute(d))
            self.logger.info("%s / %s" % (html_dir, outfile))
        # Do we want to copy OSD in there too? If so, do it only if
        # we haven't already
        if (include_osd):
            if (self.copied_osd):
                self.logger.info("OpenSeadragon already copied")
            else:
                # Make directory, copy JavaScript and icons (from osd_images)
                osd_path = os.path.join(html_dir, osd_dir)
                if (not os.path.isdir(osd_path)):
                    os.makedirs(osd_path)
                shutil.copyfile(os.path.join(osd_base, osd_js),
                                os.path.join(html_dir, osd_js))
                self.logger.info("%s / %s" % (html_dir, osd_js))
                osd_images_path = os.path.join(html_dir, osd_images)
                if (os.path.isdir(osd_images_path)):
                    self.logger.warning(
                        "OpenSeadragon images directory (%s) already exists, skipping"
                        % osd_images_path)
                else:
                    shutil.copytree(os.path.join(osd_base, osd_images),
                                    osd_images_path)
                    self.logger.info("%s / %s/*" % (html_dir, osd_images))
                self.copied_osd = True