def build(self):
    # If there is a docker file or url hand off to Docker builder    
    if 'buildspec' in self.config:
      if self.config['buildspec']:
        if 'dockerfile' in self.config['buildspec']:
          self._build(dockerfile=self.config['buildspec']['dockerfile'])
        elif 'url' in self.config['buildspec']:
          self._build(url=self.config['buildspec']['url'])
      else:
        raise exceptions.TemplateError("Template: " + self.name + " Buildspec specified but no dockerfile or url found.")
    else:
      # verify the base image and pull it if necessary
      try:
        base = self.config['base_image']    
        self.backend.inspect_image(base)
      except HTTPError:
        # Attempt to pull the image.
        self.log.info('Attempting to pull base: %s', base)
        result = self.backend.pull_image(base)
        if 'error' in result:
          self.log.error('No base image could be pulled under the name: %s', base)      
          raise exceptions.TemplateError("No base image could be pulled under the name: " + base)
      except __HOLE__:
        raise exceptions.TemplateError("Template: " + self.name + "No base image specified.")

      # There doesn't seem to be a way to currently remove tags so we'll generate a new image.
      # More consistent for all cases this way too but it does feel kinda wrong.
      dockerfile = """
      FROM %s
      MAINTAINER %s
      """ % (base, self._mid())
      self._build(dockerfile=dockerfile)

    return True

  # Launches an instance of the template in a new container
dataset/ETHPy150Open toscanini/maestro/maestro/template.py/Template.build