Esempio n. 1
0
  def start_build(self, version, builder, repo_configuration):
    repo_configuration_str = tabularize(repo_configuration)
    
    build = Build(project = self.project, version = version, builder = builder, created_by = self.user,
      repo_configuration = repo_configuration_str, state = BUILD_QUEUED,
      has_server_overrides = repo_configuration.has_overrides())
    build.put()

    body = "SET\tver\t%s\nPROJECT\t%s\t%s\n%s\n%s\n%s" % (version, self.project.permalink, self.project.name,
      self.config.common_script, repo_configuration_str, self.project.script)

    message = Message(builder = builder, build = build, body = body)
    message.put()
Esempio n. 2
0
  def post(self, project_key):
    version = self.request.get('version')
    if version == None or len(version) == 0:
      logging.warning("BuildProjectHandler: version is not specified")
      self.error(500)
      return
      
    existing_count = self.project.builds.filter('version =', version).count()
    if existing_count > 0:
      logging.info("Ignoring build request with the same version number (%s, project %s)" % (version, self.project.name))
      self.redirect_and_finish('/projects/%s' % self.project.urlname(),
        flash = "Version %s already exists. Please pick another." % version)

    script_info = self.project.script_info()
    repo_configuration = repo_configuration_info()
    for repos in script_info.alternable_repositories:
      chosen_location_name = (self.request.get("location_%s" % repos.permalink) or '')
      if chosen_location_name == '':
        self.redirect_and_finish('/projects/%s' % self.project.urlname(),
          flash = "Sorry, please also choose a repository for %s." % (repos.name))
      default_location = repos.locations[0]
      if chosen_location_name == default_location.name:
        repo_configuration.set(repos.name, 'default', default_location.name)
      elif chosen_location_name in map(lambda l: l.name, repos.locations):
        repo_configuration.set(repos.name, 'manual', chosen_location_name)
      else:
        raise str("Sorry, location %s is no longer available for repository %s." % (chosen_location_name, repos.name))
        self.redirect_and_finish('/projects/%s' % self.project.urlname(),
          flash = "Sorry, location %s is no longer available for repository %s." % (chosen_location_name, repos.name))

    self.start_build(version, self.builder, repo_configuration)
    
    self.profile.last_used_builder = self.builder
    self.profile.put()
        
    update_or_insert(ProfileProjectPreferences, dict(profile = self.profile, project = self.project),
      repository_choices = tabularize(repo_configuration.without_default_choices()),
      initial_values = dict(project = self.project.key(), profile = self.profile.key()))
    
    self.redirect_and_finish('/projects/%s' % self.project.urlname(),
      flash = "Started bulding version %s. Please refresh this page to track status." % version)
Esempio n. 3
0
 def derive_info_from_script(self, common_script):
   self._script_info = untabularize(script_info(), common_script + "\n" + self.script)
   self._script_info.postprocess()
   self.script_info_tab = db.Text(tabularize(self._script_info))