Ejemplo n.º 1
0
def xdg_data_home(request):
    """A fixure that creates a temporary $XDG_DATA_HOME directory."""
    d = tempfile.mkdtemp()
    with ENV.swap(XDG_DATA_HOME=d):
        with environ.context():
            yield d
    shutil.rmtree(d)
Ejemplo n.º 2
0
def jobfile(request):
    """A fixure that creates a temporary jobs file and assigns it in the environment.
    """
    with environ.context(), tempfile.NamedTemporaryFile() as f:
        name = f.name
        orig, ENV['FIXIE_JOBID_FILE'] = ENV['FIXIE_JOBID_FILE'], name
        yield name
        ENV['FIXIE_JOBID_FILE'] = orig
Ejemplo n.º 3
0
def xdg(request):
    """A fixure that creates a temporary XDG base directory and sets
    $XDG_DATA_HOME={xdg-base}/share and $XDG_CONFIG_HOME={xdg-base}/config.
    """
    d = tempfile.mkdtemp()
    data = os.path.join(d, 'share')
    conf = os.path.join(d, 'config')
    with ENV.swap(XDG_DATA_HOME=data, XDG_CONFIG_HOME=conf):
        with environ.context():
            yield d
    shutil.rmtree(d)
Ejemplo n.º 4
0
def main(args=None):
    args = sys.argv if args is None else args
    services = parse_services(args)
    services = load_services(services)
    with context():
        p = make_parser()
        ns = p.parse_args(args)
        ns.args = args
        ns.services = services
        set_envvars(ns)
        run_application(ns)
Ejemplo n.º 5
0
def credsdir(seed42):
    """A fixure that creates a temporary credsdir and assigns it to the cache.
    """
    request = seed42
    name = request.node.name
    credsdir = os.path.join(tempfile.gettempdir(), name)
    if os.path.exists(credsdir):
        shutil.rmtree(credsdir)
    with environ.context():
        orig, CACHE.credsdir = CACHE.credsdir, credsdir
        yield credsdir
        CACHE.credsdir = orig
    shutil.rmtree(credsdir)