def unfreeze(self): from infi.projector.helper.utils import unfreeze_versions from gitpy import LocalRepository from os import curdir versions = unfreeze_versions(self.arguments.get("--with-install-requires", False)) if self.arguments.get("--commit-changes", False): repository = LocalRepository(curdir) repository.add("buildout.cfg") repository.commit("Unfreezing dependencies") push_changes = self.arguments.get("--push-changes", False) if push_changes: repository._executeGitCommandAssertSuccess("git push")
def unfreeze(self): from infi.projector.helper.utils import unfreeze_versions from gitpy import LocalRepository from os import curdir unfreeze_versions(self.arguments.get("--with-install-requires", False)) if self.arguments.get("--commit-changes", False): repository = LocalRepository(curdir) repository.add("buildout.cfg") repository.commit("Unfreezing dependencies") push_changes = self.arguments.get("--push-changes", False) if push_changes: repository._executeGitCommandAssertSuccess("git push")
def unfreeze(self): from gitpy import LocalRepository from os import curdir with open_buildout_configfile(write_on_exit=True) as buildout_cfg: if not buildout_cfg.has_section('js-requirements'): print("Missing js-requirements section") return buildout_cfg.remove_option("buildout", "js_versions") buildout_cfg.remove_section("js_versions") # Git operations repository = LocalRepository(curdir) if self.arguments.get("--commit-changes", False): repository.add("buildout.cfg") repository.commit("Unfreezing javascript dependencies") push_changes = self.arguments.get("--push-changes", False) if push_changes: repository._executeGitCommandAssertSuccess("git push")
def freeze(self): from infi.projector.helper.utils import freeze_versions, buildout_parameters_context, open_tempfile from infi.projector.plugins.builtins.devenv import DevEnvPlugin from gitpy import LocalRepository from os import curdir from re import sub, findall, MULTILINE plugin = DevEnvPlugin() plugin.arguments = { '--newest': self.arguments.get("--newest", False), '--use-isolated-python': True } with open_tempfile() as tempfile: with buildout_parameters_context([ "buildout:update-versions-file={0}".format(tempfile), "buildout:versions=" ]): plugin.build() with open(tempfile) as fd: content = fd.read() post_releases = findall(r'^[^#].* = .*\.post.*', content, MULTILINE) if post_releases: if self.arguments.get('--allow-post-releases'): pass elif self.arguments.get('--strip-suffix-from-post-releases'): content = sub(r'\.post\d+', '', content) else: msg = "freeze found the follwing post-releases, see the dependency tree above:\n{}" formatted_post_releases = "\n".join( item for item in post_releases) logger.info(content) logger.error(msg.format(formatted_post_releases)) raise SystemExit(1) with open(tempfile, 'w') as fd: fd.write("[versions]\n" + "\n".join(set(content.splitlines()))) freeze_versions( tempfile, self.arguments.get("--with-install-requires", False)) if self.arguments.get("--commit-changes", False): repository = LocalRepository(curdir) repository.add("buildout.cfg") repository.commit("Freezing dependencies", allowEmpty=True) push_changes = self.arguments.get("--push-changes", False) if push_changes: repository._executeGitCommandAssertSuccess("git push")
def freeze(self): from gitpy import LocalRepository from os import curdir import json # Read/write the buildout.cfg with open_buildout_configfile(write_on_exit=True) as buildout_cfg: if not buildout_cfg.has_section('js-requirements'): print("Missing js-requirements section") return packages_path = buildout_cfg.get( 'js-requirements', 'js-directory') or self.DEFAULT_DIRECTORY try: with open(os.path.join(packages_path, '.package-lock.json'), 'r') as pljson: selected_versions = json.load(pljson) if buildout_cfg.has_section("js_versions"): buildout_cfg.remove_section("js_versions") buildout_cfg.add_section("js_versions") for key in sorted(selected_versions.keys(), key=lambda s: s.lower()): buildout_cfg.set("js_versions", key, selected_versions[key]) buildout_cfg.set('buildout', 'js_versions', 'True') except IOError as e: import errno print(str(e)) if hasattr(e, 'errno') and e.errno == errno.ENOENT: print( '.package-lock.json file is missing, try running projector devenv build to create the file' ) # Git operations repository = LocalRepository(curdir) if self.arguments.get("--commit-changes", False): repository.add("buildout.cfg") repository.commit("Freezing javascript dependencies") push_changes = self.arguments.get("--push-changes", False) if push_changes: repository._executeGitCommandAssertSuccess("git push")
def freeze(self): from infi.projector.helper.utils import freeze_versions, buildout_parameters_context, open_tempfile from infi.projector.plugins.builtins.devenv import DevEnvPlugin from gitpy import LocalRepository from os import curdir plugin = DevEnvPlugin() plugin.arguments = {'--newest': self.arguments.get("--newest", False)} with open_tempfile() as tempfile: with buildout_parameters_context(["buildout:update-versions-file={0}".format(tempfile)]): plugin.build() with open(tempfile) as fd: content = fd.read() with open(tempfile, 'w') as fd: fd.write("[versions]\n" + content) freeze_versions(tempfile, self.arguments.get("--with-install-requires", False)) if self.arguments.get("--commit-changes", False): repository = LocalRepository(curdir) repository.add("buildout.cfg") repository.commit("Freezing dependencies") push_changes = self.arguments.get("--push-changes", False) if push_changes: repository._executeGitCommandAssertSuccess("git push")
def freeze(self): from infi.projector.helper.utils import freeze_versions, buildout_parameters_context, open_tempfile from infi.projector.plugins.builtins.devenv import DevEnvPlugin from gitpy import LocalRepository from os import curdir from re import sub, findall, MULTILINE plugin = DevEnvPlugin() plugin.arguments = {'--newest': self.arguments.get("--newest", False), '--use-isolated-python': True} with open_tempfile() as tempfile: with buildout_parameters_context(["buildout:update-versions-file={0}".format(tempfile), "buildout:versions="]): plugin.build() with open(tempfile) as fd: content = fd.read() post_releases = findall(r'^[^#].* = .*\.post.*', content, MULTILINE) if post_releases: if self.arguments.get('--allow-post-releases'): pass elif self.arguments.get('--strip-suffix-from-post-releases'): content = sub(r'\.post\d+', '', content) else: msg = "freeze found the follwing post-releases, see the dependency tree above:\n{}" formatted_post_releases = "\n".join(item for item in post_releases) logger.info(content) logger.error(msg.format(formatted_post_releases)) raise SystemExit(1) with open(tempfile, 'w') as fd: fd.write("[versions]\n" + "\n".join(set(content.splitlines()))) freeze_versions(tempfile, self.arguments.get("--with-install-requires", False)) if self.arguments.get("--commit-changes", False): repository = LocalRepository(curdir) repository.add("buildout.cfg") repository.commit("Freezing dependencies", allowEmpty=True) push_changes = self.arguments.get("--push-changes", False) if push_changes: repository._executeGitCommandAssertSuccess("git push")
def freeze(self): from infi.projector.helper.utils import freeze_versions, buildout_parameters_context, open_tempfile from infi.projector.plugins.builtins.devenv import DevEnvPlugin from gitpy import LocalRepository from os import curdir plugin = DevEnvPlugin() plugin.arguments = {'--newest': self.arguments.get("--newest", False)} with open_tempfile() as tempfile: with buildout_parameters_context( ["buildout:update-versions-file={0}".format(tempfile)]): plugin.build() with open(tempfile) as fd: content = fd.read() with open(tempfile, 'w') as fd: fd.write("[versions]\n" + content) freeze_versions( tempfile, self.arguments.get("--with-install-requires", False)) if self.arguments.get("--commit-changes", False): repository = LocalRepository(curdir) repository.add("buildout.cfg") repository.commit("Freezing dependencies") push_changes = self.arguments.get("--push-changes", False) if push_changes: repository._executeGitCommandAssertSuccess("git push")