예제 #1
0
 def perform(self, dryrun=False):
     """ Perform the release: push source, deploy artifacts and upload
     packages."""
     cwd = os.getcwd()
     marketplaces_skipped = []
     for marketplace in self.get_packages_list():
         log("")
         if self.mp_config.has_option(marketplace, "skip"):
             log("[WARN] Skipped '%s' (%s)" % (marketplace,
                                 self.mp_config.get(marketplace, "skip")))
             marketplaces_skipped.append(marketplace)
             upgrade_only = True
         else:
             upgrade_only = False
         if not self.mp_config.getboolean(marketplace, "prepared"):
             log("[WARN] Skipped '%s' (%s)" % (marketplace, "Not prepared"))
             continue
         if self.mp_config.getboolean(marketplace, "performed"):
             log("Skipped '%s' (%s)" % (marketplace, "Already performed"))
             continue
         try:
             if upgrade_only:
                 log("Upgrade skipped %s..." % marketplace)
             else:
                 log("Perform %s" % marketplace)
             os.chdir(os.path.join(self.repo.mp_dir, marketplace))
             mp_repo = Repository(os.getcwd(), self.alias)
             # Perform release
             (_, branch, tag, next_snapshot, maintenance_version, is_final,
              skipTests, skipITs, _, other_versions,
              _, _) = Release.read_release_log(mp_repo.basedir)
             mp_release = Release(mp_repo, branch, tag, next_snapshot,
                                  maintenance_version, is_final=is_final,
                                  skipTests=skipTests, skipITs=skipITs,
                                  other_versions=other_versions)
             mp_release.perform(dryrun=dryrun, upgrade_only=upgrade_only)
             performed = True
         except Exception, e:
             stack = traceback.format_exc()
             if hasattr(e, 'message') and e.message is not None:
                 stack = e.message + "\n" + stack
             log("[ERROR] %s" % stack)
             performed = False
             stack = stack.replace("%", "%%")
             self.mp_config.set(marketplace, "skip", "Failed! %s" % stack)
         self.mp_config.set(marketplace, "performed", str(performed))
         self.repo.save_mp_config(self.mp_config)
         if performed and not upgrade_only:
             # Upload on Connect
             for dirpath, _, filenames in os.walk(mp_repo.basedir):
                 for name in filenames:
                     path = os.path.join(dirpath, name)
                     if (os.path.isfile(path) and
                         fnmatch.fnmatch(path[len(mp_repo.basedir) + 1:],
                         self.mp_config.get(marketplace, "mp_to_upload"))):
                         self.upload(CONNECT_PROD_URL, path, dryrun=dryrun)
                         self.mp_config.set(marketplace, "uploaded",
                                            CONNECT_PROD_URL + ": " + path)
                         self.repo.save_mp_config(self.mp_config)
예제 #2
0
    def test_repr(self):
        r = Release('The.Big.Bang.Theory.S06E12.720p.HDTV.X264-DIMENSION')
        assert_equal(('<Release: The.Big.Bang.Theory.S06E12.720p.HDTV.X264'
                      '-DIMENSION (PRE not fetched)>'), r.__repr__())

        r = Release('The.Big.Bang.Theory.S06E12.720p.HDTV.X264-DIMENSION')
        r.pre
        assert_true('TV-HD-X264' in r.__repr__())
예제 #3
0
 def release_branch(self, dryrun=False):
     """ Create the release branch."""
     cwd = os.getcwd()
     if not os.path.isdir(self.repo.mp_dir):
         self.clone()
     os.chdir(self.repo.mp_dir)
     marketplaces_skipped = []
     for marketplace in self.get_packages_list():
         log("")
         if self.mp_config.has_option(marketplace, "skip"):
             log("[%s]" % marketplace)
             log("[WARN] Skipped '%s' (%s)" % (marketplace,
                                 self.mp_config.get(marketplace, "skip")))
             marketplaces_skipped.append(marketplace)
             upgrade_only = True
         else:
             upgrade_only = False
         if self.mp_config.getboolean(marketplace, "branched"):
             log("[%s]" % marketplace)
             log("Skipped '%s' (%s)" % (marketplace, "Already branched"))
             continue
         try:
             mp_dir = os.path.join(self.repo.mp_dir, marketplace)
             if not os.path.isdir(mp_dir):
                 os.chdir(self.repo.mp_dir)
                 self.repo.git_pull(marketplace,
                                 self.mp_config.get(marketplace, "branch"))
             else:
                 log("[%s]" % marketplace)
             os.chdir(mp_dir)
             mp_repo = Repository(os.getcwd(), self.alias)
             if upgrade_only:
                 log("Upgrade skipped %s..." % marketplace)
             else:
                 log("Prepare release of %s..." % marketplace)
             mp_release = Release(mp_repo,
                                  self.mp_config.get(marketplace, "branch"),
                                  self.mp_config.get(marketplace, "tag"),
                                  self.mp_config.get(marketplace, "next_snapshot"),
                                  self.mp_config.get(marketplace, "maintenance_version"),
                                  is_final=True,
                                  skipTests=self.mp_config.getboolean(marketplace, "skipTests"),
                                  skipITs=self.mp_config.getboolean(marketplace, "skipITs"),
                                  other_versions=self.mp_config.get(marketplace, "other_versions", None))
             mp_release.log_summary()
             mp_release.release_branch(dryrun=dryrun, upgrade_only=upgrade_only)
             self.mp_config.set(marketplace, "next_snapshot", "done")
             branched = True
         except Exception, e:
             stack = traceback.format_exc()
             if hasattr(e, 'message') and e.message is not None:
                 stack = e.message + "\n" + stack
             log("[ERROR] %s" % stack)
             branched = False
             stack = stack.replace("%", "%%")
             self.mp_config.set(marketplace, "skip", "Failed! %s" % stack)
         self.mp_config.set(marketplace, "branched", str(branched))
         self.repo.save_mp_config(self.mp_config)
예제 #4
0
 def perform(self, dryrun=False):
     """ Perform the release: push source, deploy artifacts and upload
     packages."""
     cwd = os.getcwd()
     marketplaces_skipped = []
     for marketplace in self.get_packages_list():
         log("")
         if self.mp_config.has_option(marketplace, "skip"):
             log("[WARN] Skipped '%s' (%s)" %
                 (marketplace, self.mp_config.get(marketplace, "skip")))
             marketplaces_skipped.append(marketplace)
             upgrade_only = True
         else:
             upgrade_only = False
         if not self.mp_config.getboolean(marketplace, "prepared"):
             log("[WARN] Skipped '%s' (%s)" % (marketplace, "Not prepared"))
             continue
         if self.mp_config.getboolean(marketplace, "performed"):
             log("Skipped '%s' (%s)" % (marketplace, "Already performed"))
             continue
         try:
             if upgrade_only:
                 log("Upgrade skipped %s..." % marketplace)
             else:
                 log("Perform %s" % marketplace)
             os.chdir(os.path.join(self.repo.mp_dir, marketplace))
             mp_repo = Repository(os.getcwd(), self.alias)
             # Perform release
             release_info = ReleaseInfo()
             release_info.read_release_log(
                 ReleaseInfo.get_release_log(mp_repo.basedir))
             mp_release = Release(mp_repo, release_info)
             mp_release.perform(dryrun=dryrun, upgrade_only=upgrade_only)
             performed = True
         except Exception, e:
             stack = traceback.format_exc()
             if hasattr(e, 'message') and e.message is not None:
                 stack = e.message + "\n" + stack
             log("[ERROR] %s" % stack)
             performed = False
             stack = stack.replace("%", "%%")
             self.mp_config.set(marketplace, "skip", "Failed! %s" % stack)
         self.mp_config.set(marketplace, "performed", str(performed))
         self.repo.save_mp_config(self.mp_config)
         if performed and not upgrade_only:
             owner = None
             if self.mp_config.has_option(marketplace, "owner"):
                 owner = self.mp_config.get(marketplace, "owner")
             creds = ":".join(self.nos_credentials().prod)
             self.upload(creds,
                         CONNECT_PROD_URL,
                         marketplace,
                         dryrun=dryrun,
                         owner=owner)
예제 #5
0
 def perform(self, dryrun=False):
     """ Perform the release: push source, deploy artifacts and upload
     packages."""
     cwd = os.getcwd()
     marketplaces_skipped = []
     for marketplace in self.get_packages_list():
         log("")
         if self.mp_config.has_option(marketplace, "skip"):
             log("[WARN] Skipped '%s' (%s)" %
                 (marketplace, self.mp_config.get(marketplace, "skip")))
             marketplaces_skipped.append(marketplace)
             upgrade_only = True
         else:
             upgrade_only = False
         if not self.mp_config.getboolean(marketplace, "prepared"):
             log("[WARN] Skipped '%s' (%s)" % (marketplace, "Not prepared"))
             continue
         if self.mp_config.getboolean(marketplace, "performed"):
             log("Skipped '%s' (%s)" % (marketplace, "Already performed"))
             continue
         try:
             if upgrade_only:
                 log("Upgrade skipped %s..." % marketplace)
             else:
                 log("Perform %s" % marketplace)
             os.chdir(os.path.join(self.repo.mp_dir, marketplace))
             mp_repo = Repository(os.getcwd(), self.alias)
             # Perform release
             (_, branch, tag, next_snapshot, maintenance_version, is_final,
              skipTests, skipITs, _, other_versions, _,
              _) = Release.read_release_log(mp_repo.basedir)
             mp_release = Release(mp_repo,
                                  branch,
                                  tag,
                                  next_snapshot,
                                  maintenance_version,
                                  is_final=is_final,
                                  skipTests=skipTests,
                                  skipITs=skipITs,
                                  other_versions=other_versions)
             mp_release.perform(dryrun=dryrun, upgrade_only=upgrade_only)
             performed = True
         except Exception, e:
             stack = traceback.format_exc()
             if hasattr(e, 'message') and e.message is not None:
                 stack = e.message + "\n" + stack
             log("[ERROR] %s" % stack)
             performed = False
             stack = stack.replace("%", "%%")
             self.mp_config.set(marketplace, "skip", "Failed! %s" % stack)
         self.mp_config.set(marketplace, "performed", str(performed))
         self.repo.save_mp_config(self.mp_config)
         if performed and not upgrade_only:
             self.upload(CONNECT_PROD_URL, marketplace, dryrun=dryrun)
예제 #6
0
파일: release_mp.py 프로젝트: davaou/nuxeo
 def perform(self):
     """ Perform the release: push source, deploy artifacts and upload
     packages."""
     cwd = os.getcwd()
     marketplaces = self.mp_config.sections()
     if self.restart_from:
         idx = marketplaces.index(self.restart_from)
         marketplaces = marketplaces[idx:]
     for marketplace in marketplaces:
         if self.mp_config.has_option(marketplace, "skip"):
             log("[WARN] Skipped '%s' (%s)" % (marketplace,
                                 self.mp_config.get(marketplace, "skip")))
             continue
         if not self.mp_config.getboolean(marketplace, "prepared"):
             log("[WARN] Skipped '%s' (%s)" % (marketplace, "Not prepared"))
             continue
         if self.mp_config.getboolean(marketplace, "performed"):
             log("Skipped '%s' (%s)" % (marketplace, "Already performed"))
             continue
         try:
             log("Perform %s" % marketplace)
             os.chdir(os.path.join(self.repo.mp_dir, marketplace))
             mp_repo = Repository(os.getcwd(), self.alias)
             # Perform release
             (_, branch, tag, next_snapshot, maintenance_version, is_final,
              skipTests, _, other_versions,
              _, _) = Release.read_release_log(mp_repo.basedir)
             mp_release = Release(mp_repo, branch, tag, next_snapshot,
                                  maintenance_version, is_final=is_final,
                                  skipTests=skipTests,
                                  other_versions=other_versions)
             mp_release.perform()
             performed = True
         except:
             stack = traceback.format_exc()
             log("[ERROR] %s" % stack)
             performed = False
             self.mp_config.set(marketplace, "skip", "Failed! %s" % stack)
         self.mp_config.set(marketplace, "performed", performed)
         self.repo.save_mp_config(self.mp_config)
         if performed:
             # Upload on Connect
             for dirpath, _, filenames in os.walk(mp_repo.basedir):
                 for name in filenames:
                     path = os.path.join(dirpath, name)
                     if (os.path.isfile(path) and
                         fnmatch.fnmatch(path[len(mp_repo.basedir) + 1:],
                         self.mp_config.get(marketplace, "mp_to_upload"))):
                         self.upload(CONNECT_PROD_URL, path)
                         self.mp_config.set(marketplace, "uploaded",
                                            CONNECT_PROD_URL + ": " + path)
                         self.repo.save_mp_config(self.mp_config)
     os.chdir(cwd)
예제 #7
0
    def test_search_imdb_id(self):
        imdb_id = Release.search_imdb_id(('nfo nfo http://www.imdb.com/title'
                                          '/tt1285016/'))
        assert_equal('tt1285016', imdb_id)

        r = Release('The.Big.Bang.Theory.S01E01.720p.HDTV.X264-DIMENSION')
        imdb_id = r.search_imdb_id(('nfo nfo http://www.imdb.com/title'
                                    '/tt1285016/'))
        assert_equal('tt1285016', imdb_id)

        imdb_id = Release.search_imdb_id('nfo nfo')
        assert_false(imdb_id)
예제 #8
0
파일: release_mp.py 프로젝트: davaou/nuxeo
 def prepare(self, dryrun=False):
     """ Prepare the release."""
     cwd = os.getcwd()
     marketplaces = self.mp_config.sections()
     if self.restart_from:
         idx = marketplaces.index(self.restart_from)
         marketplaces = marketplaces[idx:]
     for marketplace in marketplaces:
         if self.mp_config.has_option(marketplace, "skip"):
             log("[WARN] Skipped '%s' (%s)" % (marketplace,
                                 self.mp_config.get(marketplace, "skip")))
             continue
         if self.mp_config.getboolean(marketplace, "prepared"):
             log("Skipped '%s' (%s)" % (marketplace, "Already prepared"))
             continue
         try:
             log("Prepare %s" % marketplace)
             os.chdir(os.path.join(self.repo.mp_dir, marketplace))
             mp_repo = Repository(os.getcwd(), self.alias)
             # Prepare release
             mp_release = Release(mp_repo,
                     self.mp_config.get(marketplace, "branch"),
                     self.mp_config.get(marketplace, "tag"),
                     self.mp_config.get(marketplace, "next_snapshot"),
                     self.mp_config.get(marketplace, "maintenance_version"),
                     is_final=True, skipTests=False,
                     other_versions=self.mp_config.get(
                                             marketplace, "other_versions",
                                             None))
             mp_release.log_summary()
             mp_release.prepare(dryrun=dryrun)
             prepared = True
         except:
             stack = traceback.format_exc()
             log("[ERROR] %s" % stack)
             prepared = False
             self.mp_config.set(marketplace, "skip", "Failed! %s" % stack)
         self.mp_config.set(marketplace, "prepared", prepared)
         self.repo.save_mp_config(self.mp_config)
         if (prepared):
             # Upload on Connect test
             for dirpath, _, filenames in os.walk(mp_repo.basedir):
                 for name in filenames:
                     path = os.path.join(dirpath, name)
                     if (os.path.isfile(path) and
                         fnmatch.fnmatch(path[len(mp_repo.basedir) + 1:],
                         self.mp_config.get(marketplace, "mp_to_upload"))):
                         self.upload(CONNECT_TEST_URL, path)
                         self.mp_config.set(marketplace, "uploaded",
                                            CONNECT_TEST_URL + ": " + path)
                         self.repo.save_mp_config(self.mp_config)
     os.chdir(cwd)
예제 #9
0
    def test_imdb(self):
        r = Release('The.Big.Bang.Theory.S01E01.720p.HDTV.X264-DIMENSION')
        assert_false(r.imdb)

        r = Release('Michael.Clayton.720p.iNTERNAL.BluRay.x264-MOOVEE')
        assert_false(r.imdb)

        r = Release('Michael.Clayton.2007.720p.iNTERNAL.BluRay.x264-MOOVEE')
        assert_equal('Michael Clayton', r.imdb.title)

        r = Release('Michael.Clayton.2007.720p.iNTERNAL.BluRay.x264-MOOVEE')
        r.imdb_id = 'tt0468569'
        assert_equal('The Dark Knight', r.imdb.title)
예제 #10
0
    def assertNextSnapshot(self, current, expected, policy='auto_last'):
        self.mocks.etree_parse.return_value.getroot.return_value.find.return_value.text = current

        release_info = ReleaseInfo(branch='some_branch', tag='auto', maintenance_version='auto', is_final=True,
                                   auto_increment_policy=policy)
        self.assertEqual(expected,
                         Release(Repository(os.getcwd(), 'nuxeo_scripts'), release_info).next_snapshot)
예제 #11
0
 def get_releases(self) -> List[Release]:
     response = self.__session.get(
         url=self.__releases_url.replace("{/id}", ""))
     return [
         Release(session=self.__session, data=data)
         for data in response.json()
     ]
예제 #12
0
파일: release_mp.py 프로젝트: ron1/nuxeo
 def perform(self, dryrun=False):
     """ Perform the release: push source, deploy artifacts and upload
     packages."""
     cwd = os.getcwd()
     marketplaces_skipped = []
     for marketplace in self.get_packages_list():
         log("")
         if self.mp_config.has_option(marketplace, "skip"):
             log("[WARN] Skipped '%s' (%s)" % (marketplace, self.mp_config.get(marketplace, "skip")))
             marketplaces_skipped.append(marketplace)
             upgrade_only = True
         else:
             upgrade_only = False
         if not self.mp_config.getboolean(marketplace, "prepared"):
             log("[WARN] Skipped '%s' (%s)" % (marketplace, "Not prepared"))
             continue
         if self.mp_config.getboolean(marketplace, "performed"):
             log("Skipped '%s' (%s)" % (marketplace, "Already performed"))
             continue
         try:
             if upgrade_only:
                 log("Upgrade skipped %s..." % marketplace)
             else:
                 log("Perform %s" % marketplace)
             os.chdir(os.path.join(self.repo.mp_dir, marketplace))
             mp_repo = Repository(os.getcwd(), self.alias)
             # Perform release
             release_info = ReleaseInfo()
             release_info.read_release_log(ReleaseInfo.get_release_log(mp_repo.basedir))
             mp_release = Release(mp_repo, release_info)
             mp_release.perform(dryrun=dryrun, upgrade_only=upgrade_only)
             performed = True
         except Exception, e:
             stack = traceback.format_exc()
             if hasattr(e, 'message') and e.message is not None:
                 stack = e.message + "\n" + stack
             log("[ERROR] %s" % stack)
             performed = False
             stack = stack.replace("%", "%%")
             self.mp_config.set(marketplace, "skip", "Failed! %s" % stack)
         self.mp_config.set(marketplace, "performed", str(performed))
         self.repo.save_mp_config(self.mp_config)
         if performed and not upgrade_only:
             owner = None
             if self.mp_config.has_option(marketplace, "owner"):
                 owner = self.mp_config.get(marketplace, "owner")
             self.upload(CONNECT_PROD_URL, marketplace, dryrun=dryrun, owner=owner)
예제 #13
0
    def get_latest_release(self) -> Release:
        response = self.__session.get(
            url=self.__releases_url.replace("{/id}", "/latest"))

        if ("message" in response.json()
                and response.json()["message"] == "Not Found"):
            raise NameError("There are no releases on the chosen repository.")

        return Release(session=self.__session, data=response.json())
예제 #14
0
    def run(self, type='development', files='all', release=today):
        self.checkSetup()

        if not os.path.isdir(os.path.join(
                self.buildDir, release)) and not os.path.isdir(
                    os.path.join(self.buildDir, self.today)):
            Release().create(files)
        else:
            print('Do you want to update your release build [Y/n]?')
            if sys.stdin.readline() != 'n\n':
                Release().create(files)

        if type == 'catroidtest':
            for line in fileinput.FileInput(os.path.join(
                    self.buildDir, release, 'config.php'),
                                            inplace=1):
                if "define('UPDATE_AUTH_TOKEN" in line:
                    line = "define('UPDATE_AUTH_TOKEN',true);\n"
                sys.stdout.write(line)

        if type == 'public':
            for line in fileinput.FileInput(os.path.join(
                    self.buildDir, release, 'config.php'),
                                            inplace=1):
                if "define('DEVELOPMENT_MODE" in line:
                    line = "define('DEVELOPMENT_MODE',false);\n"
                sys.stdout.write(line)

        print type
        if type == 'development':
            sqlShell = Sql(self.remoteCommand, 'webtest')
        else:
            sqlShell = Sql(self.remoteCommand, 'catroweb')

        if sqlShell.checkConnection():
            self.upload(os.path.join(self.buildDir, release), self.remoteDir)
            self.moveFilesIntoPlace(os.path.join(self.buildDir, release),
                                    release)
            sqlShell.initDbs()
        else:
            print('ERROR: deployment failed!')
            self.sftp.put(os.path.join(self.basePath, 'passwords.php'),
                          os.path.join(self.remoteDir, 'passwords.php'))
예제 #15
0
def get_commits_between_releases(
        release: release.Release, last_release: release.Release,
        repo: repository.Repository) -> [commit.Commit]:

    commits = []
    for c in repo.get_commits():
        if (c.get_date() >= last_release.get_creation_time()
                and c.get_date() <= release.get_creation_time()):
            commits.append(c)
    return commits
예제 #16
0
    def setPayload(self):
        payload = {}
        payload["cmdrName"] = self.cmdr
        payload["isBeta"] = self.is_beta
        payload["clientVersion"] = self.client
        if Release.get_auto() == 1:
            payload["AutoUpdateDisabled"] = False
        else:
            payload["AutoUpdateDisabled"] = True

        return payload
예제 #17
0
 def prepare(self, dryrun=False):
     """ Prepare the release."""
     cwd = os.getcwd()
     if not os.path.isdir(self.repo.mp_dir):
         self.clone()
     os.chdir(self.repo.mp_dir)
     marketplaces_skipped = []
     for marketplace in self.get_packages_list():
         log("")
         if self.mp_config.has_option(marketplace, "skip"):
             log("[%s]" % marketplace)
             log("[WARN] Skipped '%s' (%s)" % (marketplace, self.mp_config.get(marketplace, "skip")))
             marketplaces_skipped.append(marketplace)
             upgrade_only = True
         else:
             upgrade_only = False
         if self.mp_config.getboolean(marketplace, "prepared"):
             log("[%s]" % marketplace)
             log("Skipped '%s' (%s)" % (marketplace, "Already prepared"))
             continue
         try:
             mp_dir = os.path.join(self.repo.mp_dir, marketplace)
             if not os.path.isdir(mp_dir):
                 os.chdir(self.repo.mp_dir)
                 self.repo.git_pull(marketplace, self.mp_config.get(marketplace, "branch"))
             else:
                 log("[%s]" % marketplace)
             os.chdir(mp_dir)
             mp_repo = Repository(os.getcwd(), self.alias)
             if upgrade_only:
                 log("Upgrade skipped %s..." % marketplace)
             else:
                 log("Prepare release of %s..." % marketplace)
             mp_release = Release(mp_repo,
                                  self.mp_config.get(marketplace, "branch"),
                                  self.mp_config.get(marketplace, "tag"),
                                  self.mp_config.get(marketplace, "next_snapshot"),
                                  self.mp_config.get(marketplace, "maintenance_version"),
                                  is_final=True,
                                  skipTests=self.mp_config.getboolean(marketplace, "skipTests"),
                                  skipITs=self.mp_config.getboolean(marketplace, "skipITs"),
                                  other_versions=self.mp_config.get(marketplace, "other_versions", None),
                                  auto_increment_policy=self.mp_config.get(marketplace, "auto_increment_policy",
                                                                           "auto_patch"))
             mp_release.log_summary()
             mp_release.prepare(dryrun=dryrun, upgrade_only=upgrade_only, dodeploy=True)
             prepared = True
         except Exception, e:
             stack = traceback.format_exc()
             if hasattr(e, 'message') and e.message is not None:
                 stack = e.message + "\n" + stack
             log("[ERROR] %s" % stack)
             prepared = False
             stack = stack.replace("%", "%%")
             self.mp_config.set(marketplace, "skip", "Failed! %s" % stack)
         self.mp_config.set(marketplace, "prepared", str(prepared))
         self.repo.save_mp_config(self.mp_config)
         if prepared and not upgrade_only:
             self.upload(CONNECT_TEST_URL, marketplace, dryrun=dryrun)
예제 #18
0
    def __release_adapter(self):
        distros = os.listdir(self.__path_config)

        releases = []
        for distro in distros:
            release_file = self.__path_config + distro + '/releases.yml'
            stream = yaml.load(open(release_file, 'r'))
            if stream:
                for release, values in stream.items():
                    releases.append(
                        Release(distro, values["base"], values["tag"],
                                values["base_file"], self.__path_config,
                                self.__build_folder))

        return releases
예제 #19
0
def get_cached_release(index, dist_name, cache=None, allow_lazy_load=False):
    if cache is None:
        try:
            cache = get_release_cache(index, dist_name)
        except Exception:
            if not allow_lazy_load:
                raise
            # create empty cache instance
            rel_file_data = _get_dist_file_data(index, dist_name, 'release')
            cache = ReleaseCache(dist_name, rel_file_data=rel_file_data)
    rel = Release(cache.release_file, [
        CachedManifestProvider(
            cache,
            Release.default_manifest_providers if allow_lazy_load else None)
    ])
    assert cache.release_file.name == dist_name
    return rel
예제 #20
0
    def next_state(self):
        if self.current_input == 0:
            return search.Search(self.next_input())

        elif self.current_input == 5:
            return Release(self.next_input())

        elif self.current_input == 6:
            return PrepareToCatch(self.next_input())

        elif self.current_input == 8:
            return PrepareToCatch(self.next_input())

        elif self.current_input == 9:
            return PrepareToCatch(self.next_input())

        return Stop(self.next_input())
def generateReleaseFunction(nReleases: int):
    """Generates mock release objects array"""
    releases = []
    ORIGINAL_EXPECTED_DATE_STRING = '2021-01-17T09:11:55Z'
    EXPECTED_DATE = datetime.strptime(
        ORIGINAL_EXPECTED_DATE_STRING, "%Y-%m-%dT%XZ") + timedelta(
            seconds=5)  # 5 seconds after repo init
    for i in range(nReleases):
        EXPECTED_DATE_STRING = (
            EXPECTED_DATE +
            timedelta(seconds=(i * 60))).strftime("%Y-%m-%dT%XZ")
        RELEASE_DATA_OBJECT = {
            "created_at": EXPECTED_DATE_STRING,
            "url": "latest_release['url']",
            'tag_name': TAG_NAME,
            "id": i
        }
        releases.insert(0, Release(session, RELEASE_DATA_OBJECT))

    def get_releases():
        return releases

    return get_releases
예제 #22
0
def get_release_template(release: release.Release,
                         prev_release: release.Release,
                         repo: repository.Repository) -> str:

    with open('ltfc/templates/default.md') as file:
        template = file.read()
    lead_time = get_lead_time(release, repo)
    if lead_time.days >= 30:
        lead_time_colour = 'critical'
    elif lead_time.days >= 10 and lead_time.days < 30:
        lead_time_colour = 'important'
    else:
        lead_time_colour = 'success'
    if prev_release:
        prev_lead_time = get_lead_time(prev_release, repo)
        prev_version = prev_release.get_tag_name()
        if lead_time > prev_lead_time:
            lead_time_difference = ''.join(
                ['+', format_urlsafe_time(lead_time - prev_lead_time)])
            lead_time_difference_colour = 'critical'
        else:
            lead_time_difference = ''.join(
                ['--', format_urlsafe_time(prev_lead_time - lead_time)])
            lead_time_difference_colour = 'success'
    else:
        prev_version = release.get_tag_name()
        lead_time_difference = '0m'
        lead_time_difference_colour = 'yellow'

    return template.format(
        version=release.get_tag_name(),
        lead_time=format_urlsafe_time(lead_time),
        lead_time_colour=lead_time_colour,
        prev_version=prev_version,
        repository=repo.get_full_name(),
        lead_time_difference=lead_time_difference,
        lead_time_difference_colour=lead_time_difference_colour)
예제 #23
0
 def perform(self, dryrun=False):
     """ Perform the release: push source, deploy artifacts and upload
     packages."""
     cwd = os.getcwd()
     marketplaces = self.mp_config.sections()
     marketplaces_skipped = []
     if self.restart_from:
         idx = marketplaces.index(self.restart_from)
         marketplaces = marketplaces[idx:]
     for marketplace in marketplaces:
         log("")
         if self.mp_config.has_option(marketplace, "skip"):
             log("[WARN] Skipped '%s' (%s)" %
                 (marketplace, self.mp_config.get(marketplace, "skip")))
             marketplaces_skipped.append(marketplace)
             upgrade_only = True
         else:
             upgrade_only = False
         if not self.mp_config.getboolean(marketplace, "prepared"):
             log("[WARN] Skipped '%s' (%s)" % (marketplace, "Not prepared"))
             continue
         if self.mp_config.getboolean(marketplace, "performed"):
             log("Skipped '%s' (%s)" % (marketplace, "Already performed"))
             continue
         try:
             if upgrade_only:
                 log("Upgrade skipped %s..." % marketplace)
             else:
                 log("Perform %s" % marketplace)
             os.chdir(os.path.join(self.repo.mp_dir, marketplace))
             mp_repo = Repository(os.getcwd(), self.alias)
             # Perform release
             (_, branch, tag, next_snapshot, maintenance_version, is_final,
              skipTests, skipITs, _, other_versions, _,
              _) = Release.read_release_log(mp_repo.basedir)
             mp_release = Release(mp_repo,
                                  branch,
                                  tag,
                                  next_snapshot,
                                  maintenance_version,
                                  is_final=is_final,
                                  skipTests=skipTests,
                                  skipITs=skipITs,
                                  other_versions=other_versions)
             mp_release.perform(dryrun=dryrun, upgrade_only=upgrade_only)
             performed = True
         except Exception, e:
             stack = traceback.format_exc()
             if hasattr(e, 'message') and e.message is not None:
                 stack = e.message + "\n" + stack
             log("[ERROR] %s" % stack)
             performed = False
             stack = stack.replace("%", "%%")
             self.mp_config.set(marketplace, "skip", "Failed! %s" % stack)
         self.mp_config.set(marketplace, "performed", str(performed))
         self.repo.save_mp_config(self.mp_config)
         if performed and not upgrade_only:
             # Upload on Connect
             for dirpath, _, filenames in os.walk(mp_repo.basedir):
                 for name in filenames:
                     path = os.path.join(dirpath, name)
                     if (os.path.isfile(path) and fnmatch.fnmatch(
                             path[len(mp_repo.basedir) + 1:],
                             self.mp_config.get(marketplace,
                                                "mp_to_upload"))):
                         self.upload(CONNECT_PROD_URL, path, dryrun=dryrun)
                         self.mp_config.set(marketplace, "uploaded",
                                            CONNECT_PROD_URL + ": " + path)
                         self.repo.save_mp_config(self.mp_config)
예제 #24
0
    def prepare(self, dryrun=False):
        """ Prepare the release."""
        cwd = os.getcwd()
        if not os.path.isdir(self.repo.mp_dir):
            self.clone()
        os.chdir(self.repo.mp_dir)
        marketplaces_skipped = []
        for marketplace in self.get_packages_list():
            log("")
            if self.mp_config.has_option(marketplace, "skip"):
                log("[%s]" % marketplace)
                log("[WARN] Skipped '%s' (%s)" %
                    (marketplace, self.mp_config.get(marketplace, "skip")))
                marketplaces_skipped.append(marketplace)
                upgrade_only = True
            else:
                upgrade_only = False
            if self.mp_config.getboolean(marketplace, "prepared"):
                log("[%s]" % marketplace)
                log("Skipped '%s' (%s)" % (marketplace, "Already prepared"))
                continue
            try:
                mp_dir = os.path.join(self.repo.mp_dir, marketplace)
                if not os.path.isdir(mp_dir):
                    os.chdir(self.repo.mp_dir)
                    self.repo.git_pull(
                        marketplace, self.mp_config.get(marketplace, "branch"))
                else:
                    log("[%s]" % marketplace)
                os.chdir(mp_dir)
                mp_repo = Repository(os.getcwd(), self.alias)
                if upgrade_only:
                    log("Upgrade skipped %s..." % marketplace)
                else:
                    log("Prepare release of %s..." % marketplace)

                release_info = ReleaseInfo(
                    module=marketplace,
                    remote_alias=self.alias,
                    branch=self.mp_config.get(marketplace, "branch"),
                    tag=self.mp_config.get(marketplace, "tag"),
                    next_snapshot=self.mp_config.get(marketplace,
                                                     "next_snapshot"),
                    maintenance_version=self.mp_config.get(
                        marketplace, "maintenance_version"),
                    is_final=self.mp_config.getboolean(marketplace,
                                                       "is_final"),
                    skip_tests=self.mp_config.getboolean(
                        marketplace, "skipTests"),
                    skip_its=self.mp_config.getboolean(marketplace, "skipITs"),
                    profiles=self.mp_config.get(marketplace, "profiles"),
                    other_versions=self.mp_config.get(marketplace,
                                                      "other_versions"),
                    #files_pattern, props_pattern, msg_commit, msg_tag,
                    auto_increment_policy=self.mp_config.get(
                        marketplace, "auto_increment_policy"),
                    dryrun=dryrun)
                mp_release = Release(mp_repo, release_info)
                release_log = mp_release.log_summary()
                release_info.read_release_log(release_log)
                if dryrun:
                    print "DEBUG -- init %s with:" % marketplace
                for key, value in vars(release_info).iteritems():
                    if dryrun:
                        print "DEBUG: %s-%s=%s" % (marketplace, key, value)
                    self.mp_config.set("DEFAULT", marketplace + "-" + key,
                                       str(value))
                if dryrun:
                    print

                mp_release.prepare(dryrun=dryrun,
                                   upgrade_only=upgrade_only,
                                   dodeploy=True)
                prepared = True
            except Exception, e:
                stack = traceback.format_exc()
                if hasattr(e, 'message') and e.message is not None:
                    stack = e.message + "\n" + stack
                log("[ERROR] %s" % stack)
                prepared = False
                stack = stack.replace("%", "%%")
                self.mp_config.set(marketplace, "skip", "Failed! %s" % stack)
            self.mp_config.set(marketplace, "prepared", str(prepared))
            self.repo.save_mp_config(self.mp_config)
            if prepared and not upgrade_only:
                self.upload(CONNECT_TEST_URL, marketplace, dryrun=dryrun)
예제 #25
0
def get_release(index, dist_name):
    rel_file = get_release_file(index, dist_name)
    return Release(rel_file)
예제 #26
0
파일: release_mp.py 프로젝트: ron1/nuxeo
    def prepare(self, dryrun=False):
        """ Prepare the release."""
        cwd = os.getcwd()
        if not os.path.isdir(self.repo.mp_dir):
            self.clone()
        os.chdir(self.repo.mp_dir)
        marketplaces_skipped = []
        for marketplace in self.get_packages_list():
            log("")
            if self.mp_config.has_option(marketplace, "skip"):
                log("[%s]" % marketplace)
                log("[WARN] Skipped '%s' (%s)" % (marketplace, self.mp_config.get(marketplace, "skip")))
                marketplaces_skipped.append(marketplace)
                upgrade_only = True
            else:
                upgrade_only = False
            if self.mp_config.getboolean(marketplace, "prepared"):
                log("[%s]" % marketplace)
                log("Skipped '%s' (%s)" % (marketplace, "Already prepared"))
                continue
            try:
                mp_dir = os.path.join(self.repo.mp_dir, marketplace)
                if not os.path.isdir(mp_dir):
                    os.chdir(self.repo.mp_dir)
                    self.repo.git_pull(marketplace, self.mp_config.get(marketplace, "branch"))
                else:
                    log("[%s]" % marketplace)
                os.chdir(mp_dir)
                mp_repo = Repository(os.getcwd(), self.alias)
                if upgrade_only:
                    log("Upgrade skipped %s..." % marketplace)
                else:
                    log("Prepare release of %s..." % marketplace)

                release_info = ReleaseInfo(module=marketplace, remote_alias=self.alias,
                                           branch=self.mp_config.get(marketplace, "branch"),
                                           tag=self.mp_config.get(marketplace, "tag"),
                                           next_snapshot=self.mp_config.get(marketplace, "next_snapshot"),
                                           maintenance_version=self.mp_config.get(marketplace, "maintenance_version"),
                                           is_final=self.mp_config.getboolean(marketplace, "is_final"),
                                           skip_tests=self.mp_config.getboolean(marketplace, "skipTests"),
                                           skip_its=self.mp_config.getboolean(marketplace, "skipITs"),
                                           profiles=self.mp_config.get(marketplace, "profiles"),
                                           other_versions=self.mp_config.get(marketplace, "other_versions"),
                                           #files_pattern, props_pattern, msg_commit, msg_tag,
                                           auto_increment_policy=self.mp_config.get(marketplace,
                                                                                    "auto_increment_policy"),
                                           dryrun=dryrun)
                mp_release = Release(mp_repo, release_info)
                release_log = mp_release.log_summary()
                release_info.read_release_log(release_log)
                if dryrun:
                    print "DEBUG -- init %s with:" % marketplace
                for key, value in vars(release_info).iteritems():
                    if dryrun:
                        print "DEBUG: %s-%s=%s" % (marketplace, key, value)
                    self.mp_config.set("DEFAULT", marketplace + "-" + key, str(value))
                if dryrun:
                    print

                mp_release.prepare(dryrun=dryrun, upgrade_only=upgrade_only, dodeploy=True)
                prepared = True
            except Exception, e:
                stack = traceback.format_exc()
                if hasattr(e, 'message') and e.message is not None:
                    stack = e.message + "\n" + stack
                log("[ERROR] %s" % stack)
                prepared = False
                stack = stack.replace("%", "%%")
                self.mp_config.set(marketplace, "skip", "Failed! %s" % stack)
            self.mp_config.set(marketplace, "prepared", str(prepared))
            self.repo.save_mp_config(self.mp_config)
            if prepared and not upgrade_only:
                owner = None
                if self.mp_config.has_option(marketplace, "owner"):
                    owner = self.mp_config.get(marketplace, "owner")
                self.upload(CONNECT_TEST_URL, marketplace, dryrun=dryrun, owner=owner)
예제 #27
0
        for css in glob.glob(os.path.join(self.cacheDir, "*.css")):
            os.remove(css)

    def removeSQLoverview(self):
        if os.path.isdir(self.sqlOverviewDir):
            shutil.rmtree(self.sqlOverviewDir)


if __name__ == '__main__':
    parameter = 'empty'
    try:
        if sys.argv[1] == 'website':
            clean = Cleaner()
            clean.clearCache()
            clean.cleanResources()
            Release().removeBuildDir()
            Sql().purgeDbs()
            clean.removeSQLoverview()
            Pootle().cleanGeneratedFiles()
        elif sys.argv[1] == 'tools':
            Selenium().removeSeleniumLibs()
            JSCompiler().removeCompiler()
            CSSCompiler().removeCompiler()
        else:
            parameter = '%s:' % sys.argv[1]
            raise IndexError()
    except IndexError:
        print('%s parameter not supported' % parameter)
        print('')
        print('Options:')
        print(
예제 #28
0
def test_release():
    release = Release(session, DATA_OBJECT)
    assert release.get_tag_name() == DATA_OBJECT['tag_name'], "get_tag_name output did not match"
    assert release.get_creation_time() == EXPECTED_DATE, "get_creation_time output did not match"
예제 #29
0
 def prepare(self, dryrun=False):
     """ Prepare the release."""
     cwd = os.getcwd()
     if not os.path.isdir(self.repo.mp_dir):
         self.clone()
     os.chdir(self.repo.mp_dir)
     marketplaces = self.mp_config.sections()
     marketplaces_skipped = []
     if self.restart_from:
         idx = marketplaces.index(self.restart_from)
         marketplaces = marketplaces[idx:]
     for marketplace in marketplaces:
         log("")
         if self.mp_config.has_option(marketplace, "skip"):
             log("[%s]" % marketplace)
             log("[WARN] Skipped '%s' (%s)" % (marketplace,
                                 self.mp_config.get(marketplace, "skip")))
             marketplaces_skipped.append(marketplace)
             upgrade_only = True
         else:
             upgrade_only = False
         if self.mp_config.getboolean(marketplace, "prepared"):
             log("[%s]" % marketplace)
             log("Skipped '%s' (%s)" % (marketplace, "Already prepared"))
             continue
         try:
             mp_dir = os.path.join(self.repo.mp_dir, marketplace)
             if not os.path.isdir(mp_dir):
                 os.chdir(self.repo.mp_dir)
                 self.repo.git_pull(marketplace,
                                 self.mp_config.get(marketplace, "branch"))
             else:
                 log("[%s]" % marketplace)
             os.chdir(mp_dir)
             mp_repo = Repository(os.getcwd(), self.alias)
             if upgrade_only:
                 log("Upgrade skipped %s..." % marketplace)
             else:
                 log("Prepare release of %s..." % marketplace)
             mp_release = Release(mp_repo,
                     self.mp_config.get(marketplace, "branch"),
                     self.mp_config.get(marketplace, "tag"),
                     self.mp_config.get(marketplace, "next_snapshot"),
                     self.mp_config.get(marketplace, "maintenance_version"),
                     is_final=True, skipTests=False, skipITs=False,
                     other_versions=self.mp_config.get(
                                             marketplace, "other_versions",
                                             None))
             mp_release.log_summary()
             mp_release.prepare(dryrun=dryrun, upgrade_only=upgrade_only,
                                dodeploy=True)
             prepared = True
         except Exception, e:
             stack = traceback.format_exc()
             if hasattr(e, 'message') and e.message is not None:
                 stack = e.message + "\n" + stack
             log("[ERROR] %s" % stack)
             prepared = False
             stack = stack.replace("%", "%%")
             self.mp_config.set(marketplace, "skip", "Failed! %s" % stack)
         self.mp_config.set(marketplace, "prepared", str(prepared))
         self.repo.save_mp_config(self.mp_config)
         if prepared and not upgrade_only:
             # Upload on Connect test
             for dirpath, _, filenames in os.walk(mp_repo.basedir):
                 for name in filenames:
                     path = os.path.join(dirpath, name)
                     if (os.path.isfile(path) and
                         fnmatch.fnmatch(path[len(mp_repo.basedir) + 1:],
                         self.mp_config.get(marketplace, "mp_to_upload"))):
                         self.upload(CONNECT_TEST_URL, path, dryrun=dryrun)
                         self.mp_config.set(marketplace, "uploaded",
                                            CONNECT_TEST_URL + ": " + path)
                         self.repo.save_mp_config(self.mp_config)
예제 #30
0
 def prepare(self, dryrun=False):
     """ Prepare the release."""
     cwd = os.getcwd()
     if not os.path.isdir(self.repo.mp_dir):
         self.clone()
     os.chdir(self.repo.mp_dir)
     marketplaces = self.mp_config.sections()
     marketplaces_skipped = []
     if self.restart_from:
         idx = marketplaces.index(self.restart_from)
         marketplaces = marketplaces[idx:]
     for marketplace in marketplaces:
         log("")
         if self.mp_config.has_option(marketplace, "skip"):
             log("[%s]" % marketplace)
             log("[WARN] Skipped '%s' (%s)" %
                 (marketplace, self.mp_config.get(marketplace, "skip")))
             marketplaces_skipped.append(marketplace)
             upgrade_only = True
         else:
             upgrade_only = False
         if self.mp_config.getboolean(marketplace, "prepared"):
             log("[%s]" % marketplace)
             log("Skipped '%s' (%s)" % (marketplace, "Already prepared"))
             continue
         try:
             mp_dir = os.path.join(self.repo.mp_dir, marketplace)
             if not os.path.isdir(mp_dir):
                 os.chdir(self.repo.mp_dir)
                 self.repo.git_pull(
                     marketplace, self.mp_config.get(marketplace, "branch"))
             else:
                 log("[%s]" % marketplace)
             os.chdir(mp_dir)
             mp_repo = Repository(os.getcwd(), self.alias)
             if upgrade_only:
                 log("Upgrade skipped %s..." % marketplace)
             else:
                 log("Prepare release of %s..." % marketplace)
             mp_release = Release(
                 mp_repo,
                 self.mp_config.get(marketplace, "branch"),
                 self.mp_config.get(marketplace, "tag"),
                 self.mp_config.get(marketplace, "next_snapshot"),
                 self.mp_config.get(marketplace, "maintenance_version"),
                 is_final=True,
                 skipTests=False,
                 skipITs=False,
                 other_versions=self.mp_config.get(marketplace,
                                                   "other_versions", None))
             mp_release.log_summary()
             mp_release.prepare(dryrun=dryrun,
                                upgrade_only=upgrade_only,
                                dodeploy=True)
             prepared = True
         except Exception, e:
             stack = traceback.format_exc()
             if hasattr(e, 'message') and e.message is not None:
                 stack = e.message + "\n" + stack
             log("[ERROR] %s" % stack)
             prepared = False
             stack = stack.replace("%", "%%")
             self.mp_config.set(marketplace, "skip", "Failed! %s" % stack)
         self.mp_config.set(marketplace, "prepared", str(prepared))
         self.repo.save_mp_config(self.mp_config)
         if prepared and not upgrade_only:
             # Upload on Connect test
             for dirpath, _, filenames in os.walk(mp_repo.basedir):
                 for name in filenames:
                     path = os.path.join(dirpath, name)
                     if (os.path.isfile(path) and fnmatch.fnmatch(
                             path[len(mp_repo.basedir) + 1:],
                             self.mp_config.get(marketplace,
                                                "mp_to_upload"))):
                         self.upload(CONNECT_TEST_URL, path, dryrun=dryrun)
                         self.mp_config.set(marketplace, "uploaded",
                                            CONNECT_TEST_URL + ": " + path)
                         self.repo.save_mp_config(self.mp_config)