예제 #1
0
def getnetloc(url, scheme=False):
    parsed = urlparse(url)
    netloc = parsed.netloc
    if netloc.endswith(":80"):
        netloc = netloc[:-3]
    if scheme:
        netloc = "%s://%s" % (parsed.scheme, netloc)
    return netloc
예제 #2
0
파일: bgserver.py 프로젝트: uceo/uceo-2015
def getnetloc(url, scheme=False):
    parsed = urlparse(url)
    netloc = parsed.netloc
    if netloc.endswith(":80"):
        netloc = netloc[:-3]
    if scheme:
        netloc = "%s://%s" %(parsed.scheme, netloc)
    return netloc
예제 #3
0
 def _waitup(self, url, count=1800):
     # try to start devpi-server (which remotely
     # receives a serials list which may take a while)
     session = new_requests_session()
     with no_proxy(urlparse(url).netloc):
         while count > 0:
             if not self.xproc.getinfo("devpi-server").isrunning():
                 return False
             try:
                 session.get(url)
             except session.Errors:
                 time.sleep(0.1)
                 count -= 1
             else:
                 return True
     return False
예제 #4
0
def gendeploycfg(config, venvdir, tw=None):
    """ generate etc/ structure with supervisord.conf for running
    devpi-server under supervisor control. """
    if tw is None:
        tw = py.io.TerminalWriter()
        tw.cwd = py.path.local()

    #tw.line("creating etc/ directory for supervisor configuration", bold=True)
    etc = venvdir.ensure("etc", dir=1)
    orig_args = list(config.args._raw)

    # filter out --gendeploy option
    for i, val in enumerate(orig_args):
        if val.startswith("--gendeploy="):
            del orig_args[i]
            break
        elif val == "--gendeploy":
            del orig_args[i:i+2]
            break

    if not config.args.serverdir:  # default
        serverdir = venvdir.ensure("data", dir=1)
    else:
        serverdir = config.serverdir
    orig_args.extend(["--serverdir", str(serverdir)])

    logdir = venvdir.ensure("log", dir=1)

    render(tw, etc, "supervisord.conf", venvdir=venvdir,
           server_args=subprocess.list2cmdline(orig_args),
           logdir=logdir)
    outside_url = config.args.outside_url
    if outside_url is None: # default
        outside_host = "localhost"
        outside_port = 80
    else:
        parsed = urlparse(outside_url)
        parts = list(parsed.netloc.split(":"))
        if len(parts) < 2:
            parts.append(80)
        outside_host, outside_port = parts

    nginxconf = render(tw, etc, "nginx-devpi.conf", format=1,
                       outside_host=outside_host,
                       outside_port=outside_port,
                       port=config.args.port,
                       serverdir=serverdir)
    devpictl = create_devpictl(tw, venvdir)
    cron = create_crontab(tw, etc, devpictl)
    tw.line("created and configured %s" % venvdir, bold=True)
    tw.line(py.std.textwrap.dedent("""\
    To control supervisor's deployment of devpi-server set:

        alias devpi-ctl='%(devpictl)s'

    and then start the server process:

        devpi-ctl start all
    %(cron)s
    We prepared an nginx configuration at:

        %(nginxconf)s

    which you might modify and copy to your /etc/nginx/sites-enabled
    directory.
    """) % locals())
    tw.line("may quick reliable pypi installations be with you :)",
            green=True)