Example #1
0
File: use.py Project: t-8ch/devpi
 def __init__(self, path):
     self.path = path
     self._currentdict = {}
     if self.path.check():
         log.debug("loading current from %s" % self.path)
         self._currentdict.update(json.loads(self.path.read()))
     else:
         log.debug("no client config found at %s" % self.path)
Example #2
0
 def check_setversion(self, path, newversion):
     log.debug("check_setversion", path)
     content = path.read()
     newcontent = setversion(content, str(newversion))
     if newcontent != content:
         log.debug("changing", path)
         path.write(newcontent)
         return True
Example #3
0
File: use.py Project: t-8ch/devpi
 def __init__(self, path):
     self.path = path
     self._currentdict = {}
     if self.path.check():
         log.debug("loading current from %s" % self.path)
         self._currentdict.update(json.loads(self.path.read()))
     else:
         log.debug("no client config found at %s" % self.path)
Example #4
0
 def reconfigure(self, data):
     for name in data:
         oldval = getattr(self, name)
         newval = data[name]
         if oldval != newval:
             setattr(self, name, newval)
             log.debug("changing %r to %r", name, newval)
     log.debug("writing config %s", self.path)
     self.path.write(json.dumps(self._configdict))
Example #5
0
File: use.py Project: t-8ch/devpi
 def reconfigure(self, data):
     for name in data:
         oldval = getattr(self, name)
         newval = data[name]
         if oldval != newval:
             setattr(self, name, newval)
             log.info("changing %r to %r", name, newval)
     log.debug("writing current %s", self.path)
     oldumask = os.umask(7 * 8 + 7)
     try:
         self.path.write(json.dumps(self._currentdict))
     finally:
         os.umask(oldumask)
Example #6
0
File: use.py Project: t-8ch/devpi
 def reconfigure(self, data):
     for name in data:
         oldval = getattr(self, name)
         newval = data[name]
         if oldval != newval:
             setattr(self, name, newval)
             log.info("changing %r to %r", name, newval)
     log.debug("writing current %s", self.path)
     oldumask = os.umask(7*8+7)
     try:
         self.path.write(json.dumps(self._currentdict))
     finally:
         os.umask(oldumask)
Example #7
0
def setenv_devpi(env, posturl, packageurl, packagemd5):
    if not packagemd5:
        packagemd5 = ""
    if sys.version_info[0] < 3:
        posturl = posturl.encode("utf8")
        packageurl = packageurl.encode("utf8")
        packagemd5 = packagemd5.encode("utf8")
    env["DEVPY_POSTURL"] = posturl.encode("utf8")
    env["DEVPY_PACKAGEURL"] = packageurl.encode("utf8")
    env["DEVPY_PACKAGEMD5"] = (packagemd5 or "").encode("utf8")
    for name in env:
        if name.startswith("DEVPY"):
            log.debug("setenv_devpi", name, env[name])
Example #8
0
 def export(self, basetemp):
     newrepo = basetemp.join(self.rootpath.basename)
     out = self.hub.popen_output("hg st -nmardc", cwd=self.rootpath)
     num = 0
     for fn in out.split("\n"):
         if fn.strip():
             source = self.rootpath.join(fn)
             dest = newrepo.join(fn)
             dest.dirpath().ensure(dir=1)
             source.copy(dest)
             num += 1
     log.debug("copied", num, "files to", newrepo)
     return Exported(self.hub, newrepo, self.rootpath)
Example #9
0
 def export(self, basetemp):
     if not self.hasvcs:
         return Exported(self.hub, self.rootpath, self.rootpath)
     newrepo = basetemp.join(self.rootpath.basename)
     if self.hasvcs == "hg":
         out = self.hub.popen_output("hg st -nmac .", cwd=self.rootpath)
     elif self.hasvcs == "git":
         out = self.hub.popen_output("git ls-files .", cwd=self.rootpath)
     num = 0
     for fn in out.split("\n"):
         if fn.strip():
             source = self.rootpath.join(fn)
             dest = newrepo.join(fn)
             dest.dirpath().ensure(dir=1)
             source.copy(dest)
             num += 1
     log.debug("copied %s files to %s", num, newrepo)
     self.hub.info("%s-exported project to %s -> new CWD" %
                   (self.hasvcs, newrepo))
     return Exported(self.hub, newrepo, self.rootpath)
Example #10
0
 def export(self, basetemp):
     if not self.hasvcs:
         return Exported(self.hub, self.rootpath, self.rootpath)
     newrepo = basetemp.join(self.rootpath.basename)
     if self.hasvcs == "hg":
         out = self.hub.popen_output("hg st -nmac .", cwd=self.rootpath)
     elif self.hasvcs == "git":
         out = self.hub.popen_output("git ls-files .", cwd=self.rootpath)
     num = 0
     for fn in out.split("\n"):
         if fn.strip():
             source = self.rootpath.join(fn)
             dest = newrepo.join(fn)
             dest.dirpath().ensure(dir=1)
             source.copy(dest)
             num += 1
     log.debug("copied %s files to %s", num, newrepo)
     self.hub.info("%s-exported project to %s -> new CWD" %(
                   self.hasvcs, newrepo))
     return Exported(self.hub, newrepo, self.rootpath)
Example #11
0
    def runtox(self, link, Popen, venv=None):
        path_archive = link.pkg.path_archive

        assert pytestpluginpath.check()

        # the env var is picked up by pytest-devpi plugin
        env = os.environ.copy()
        setenv_devpi(env, posturl=self.config.resultlog,
                          packageurl=link.href,
                          packagemd5=link.md5)
        # to get pytest to pick up our devpi plugin
        # XXX in the future we rather want to instruct tox to use
        # a pytest driver with our plugin enabled and maybe
        # move reporting and posting of resultlogs to tox
        env["PYTHONPATH"] = pytestpluginpath.dirname
        log.debug("setting PYTHONPATH", env["PYTHONPATH"])
        env["PYTEST_PLUGINS"] = x = pytestpluginpath.purebasename
        log.debug("setting PYTEST_PLUGINS", env["PYTEST_PLUGINS"])
        for name, val in env.items():
            assert isinstance(val, str), (name, val)
        log.debug("pytestplugin", x)
        toxargs = ["tox", "--installpkg", str(path_archive),
                   "-i ALL=%s" % self.config.simpleindex,
        ]
        if venv is not None:
            toxargs.append("-e" + venv)

        log.info("%s$ %s" %(link.pkg.path_unpacked, " ".join(toxargs)))
        popen = Popen(toxargs, cwd=str(link.pkg.path_unpacked), env=env)
        popen.communicate()
        if popen.returncode != 0:
            log.error("tox command failed", popen.returncode)
            return 1
        return 0
Example #12
0
 def _setupconfigdict(self):
     self._configdict = d = {}
     if self.path.check():
         log.debug("loading config from %s", self.path)
         d.update(json.loads(self.path.read()))