Ejemplo n.º 1
0
def test_unauthenticated_push_and_require_browser_auth():
    with pytest.raises(ValueError):
        klaus.make_app([],
                       None,
                       use_smarthttp=True,
                       unauthenticated_push=True,
                       require_browser_auth=True)
Ejemplo n.º 2
0
 def app(environ, start_response):
     if S.should_reload:
         # Refresh inner application with new repo list
         print("Reloading repository list...")
         S.inner_app = make_app(glob.glob(repos_root + "/*"), *args,
                                **kwargs)
         S.should_reload = False
     return S.inner_app(environ, start_response)
Ejemplo n.º 3
0
def application(environ, start_response):
    global inner_app
    global reload
    if reload:
        inner_app = make_app(
            [os.path.join(repos_root, x) for x in os.listdir(repos_root)],
            "unrelenting.technology/git", "1", None)
        reload = False
    return inner_app(environ, start_response)
Ejemplo n.º 4
0
 def app(environ, start_response):
     if _.should_reload:
         # Refresh inner application with new repo list
         print "Reloading repository list..."
         _.inner_app = make_app(
             [os.path.join(repos_root, x) for x in os.listdir(repos_root)],
             *args, **kwargs)
         _.should_reload = False
     return _.inner_app(environ, start_response)
Ejemplo n.º 5
0
 def app(environ, start_response):
     if _.should_reload:
         # Refresh inner application with new repo list
         print "Reloading repository list..."
         _.inner_app = make_app(
             [os.path.join(repos_root, x) for x in os.listdir(repos_root)],
             *args, **kwargs
         )
         _.should_reload = False
     return _.inner_app(environ, start_response)
Ejemplo n.º 6
0
Archivo: utils.py Proyecto: hiciu/klaus
def serve(*args, **kwargs):
    app = klaus.make_app(ALL_TEST_REPOS, TEST_SITE_NAME, *args, **kwargs)
    server = werkzeug.serving.make_server("localhost", 9876, app)
    thread = threading.Thread(target=server.serve_forever)
    thread.start()
    try:
        yield
    finally:
        server.server_close()
        if 'TRAVIS' in os.environ:
            # This fixes some "Address already in use" cases on Travis.
            time.sleep(1)
Ejemplo n.º 7
0
Archivo: utils.py Proyecto: sbraz/klaus
def serve(*args, **kwargs):
    app = klaus.make_app(ALL_TEST_REPOS, TEST_SITE_NAME, *args, **kwargs)
    server = werkzeug.serving.make_server("localhost", 9876, app)
    thread = threading.Thread(target=server.serve_forever)
    thread.start()
    try:
        yield
    finally:
        server.server_close()
        if 'TRAVIS' in os.environ:
            # This fixes some "Address already in use" cases on Travis.
            time.sleep(1)
Ejemplo n.º 8
0
def application(environ, start_response):
    global inner_app
    global reload
    if reload:
        inner_app = make_app(
            [os.path.join(repos_root, x) for x in os.listdir(repos_root)],
            "unrelenting.technology/git",
            "1",
            None
        )
        reload = False
    return inner_app(environ, start_response)
Ejemplo n.º 9
0
def make_autodetecting_app(
    repos_root,
    *args,
    detect_removals=None,
    export_ok_path=None,
    **kwargs,
):
    return klaus.make_app(
        repos_root,
        *args,
        repo_container_factory=functools.partial(
            AutodetectingRepoContainer,
            detect_removals=detect_removals,
            export_ok_path=export_ok_path,
        ),
        **kwargs,
    )
Ejemplo n.º 10
0
    def app(environ, start_response):
        if _.should_reload:
            # Refresh inner application with new repo list
            print("Reloading repository list...")
            inner_app = make_app(
                [os.path.join(repos_root, x) for x in os.listdir(repos_root)],
                *args, **kwargs)

            @inner_app.errorhandler(404)
            def not_found(e):
                # defining function
                return render_template("404.html")

            _.inner_app = inner_app
            _.should_reload = False

        return _.inner_app(environ, start_response)
Ejemplo n.º 11
0
def test_make_app_using_list():
    app = klaus.make_app(REPOS, TEST_SITE_NAME)
    with serve_app(app):
        response = requests.get(UNAUTH_TEST_SERVER).text
        assert TEST_REPO_NO_NEWLINE_BASE_URL in response
Ejemplo n.º 12
0
def test_unauthenticated_push_with_disable_push():
    with pytest.raises(ValueError):
        klaus.make_app([], None, unauthenticated_push=True, disable_push=True)
Ejemplo n.º 13
0
def test_unauthenticated_push_without_use_smarthttp():
    with pytest.raises(ValueError):
        klaus.make_app([], None, unauthenticated_push=True)
Ejemplo n.º 14
0
Archivo: wsgi.py Proyecto: jahir/klaus
from klaus import make_app
from .app_args import get_args_from_env

args, kwargs = get_args_from_env()

if kwargs['htdigest_file']:
    with open(kwargs['htdigest_file']) as file:
        kwargs['htdigest_file'] = file
        application = make_app(*args, **kwargs)
else:
    application = make_app(*args, **kwargs)
Ejemplo n.º 15
0
def test_htdigest_file_without_smarthttp_or_require_browser_auth():
    with pytest.raises(ValueError):
        klaus.make_app([], None, htdigest_file=object())
Ejemplo n.º 16
0
# make sure to end with "/"
PATH_TO_REPOS = u"/home/git/" 

# search for git repos in path_to_repos
def isGit(path):
	ends_with_git = len(path) > 4 and path[-4:] == '.git'
	blacklisted = False
	return ends_with_git and not blacklisted

from os import listdir
REPOSITORIES = [PATH_TO_REPOS+repo for repo in filter(isGit, listdir(PATH_TO_REPOS))]

# don't include private repos
from private import PRIVATE_REPOS
for repo in PRIVATE_REPOS:
	R = PATH_TO_REPOS+repo
	if R in REPOSITORIES:
		REPOSITORIES.remove(R)

# klaus provides a make_app function that creates a WSGI application
# Don't forget to add the path to klaus to WSGIPythonPath in your Apache config
import sys
sys.path.append('/usr/local/lib/python2.6/dist-packages')
sys.path.append('/usr/local/lib/python2.6/dist-packages/klaus')
sys.path.append('/usr/local/lib/python2.6/dist-packages/klaus/klaus')

# Export WSGI application
from klaus import make_app
application = make_app(REPOSITORIES, TITLE)
Ejemplo n.º 17
0
Archivo: wsgi.py Proyecto: sbraz/klaus
import os
from klaus import make_app

if 'KLAUS_HTDIGEST_FILE' in os.environ:
    with open(os.environ['KLAUS_HTDIGEST_FILE']) as file:
        application = make_app(
            os.environ['KLAUS_REPOS'].split(),
            os.environ['KLAUS_SITE_NAME'],
            os.environ.get('KLAUS_USE_SMARTHTTP'),
            file,
        )
else:
    application = make_app(
        os.environ['KLAUS_REPOS'].split(),
        os.environ['KLAUS_SITE_NAME'],
        os.environ.get('KLAUS_USE_SMARTHTTP'),
        None,
    )
Ejemplo n.º 18
0
    ends_with_git = len(path) > 4 and path[-4:] == '.git'
    blacklisted = False
    return ends_with_git and not blacklisted


from os import listdir

REPOSITORIES = [
    PATH_TO_REPOS + repo for repo in filter(isGit, listdir(PATH_TO_REPOS))
]

# don't include private repos
from private import PRIVATE_REPOS
for repo in PRIVATE_REPOS:
    R = PATH_TO_REPOS + repo
    if R in REPOSITORIES:
        REPOSITORIES.remove(R)

# klaus provides a make_app function that creates a WSGI application
# Don't forget to add the path to klaus to WSGIPythonPath in your Apache config
import sys

sys.path.append('/usr/local/lib/python2.6/dist-packages')
sys.path.append('/usr/local/lib/python2.6/dist-packages/klaus')
sys.path.append('/usr/local/lib/python2.6/dist-packages/klaus/klaus')

# Export WSGI application
from klaus import make_app

application = make_app(REPOSITORIES, TITLE)
Ejemplo n.º 19
0
import os
from klaus import make_app

application = make_app(
    os.environ['KLAUS_REPOS'].split(),
    os.environ['KLAUS_SITE_TITLE'],
    os.environ.get('KLAUS_USE_SMARTHTTP'),
    os.environ.get('KLAUS_HTDIGEST_FILE'),
)
Ejemplo n.º 20
0
def test_unauthenticated_push_without_use_smarthttp():
    with pytest.raises(ValueError):
        klaus.make_app([], None, unauthenticated_push=True)
Ejemplo n.º 21
0
from klaus import make_app
from .app_args import get_args_from_env
from flask import render_template

args, kwargs = get_args_from_env()

if kwargs['htdigest_file']:
    with open(kwargs['htdigest_file']) as file:
        kwargs['htdigest_file'] = file
        application = make_app(*args, **kwargs)
else:
    application = make_app(*args, **kwargs)


@application.errorhandler(404)
def not_found(e):
    # defining function
    return render_template("404.html")
Ejemplo n.º 22
0
Archivo: wsgi.py Proyecto: Dafvid/klaus
import os
from klaus import make_app

if 'KLAUS_HTDIGEST_FILE' in os.environ:
    with open(os.environ['KLAUS_HTDIGEST_FILE']) as file:
        application = make_app(
            os.environ['KLAUS_REPOS'].split(),
            os.environ['KLAUS_SITE_NAME'],
            os.environ['KLAUS_GIT_BIN'],
            os.environ['KLAUS_CLONE_URLS'].split(),
            os.environ.get('KLAUS_USE_SMARTHTTP'),
            file,
        )
else:
    application = make_app(
        os.environ['KLAUS_REPOS'].split(),
        os.environ['KLAUS_SITE_NAME'],
        os.environ['KLAUS_GIT_BIN'],
        os.environ['KLAUS_CLONE_URLS'].split(),
        os.environ.get('KLAUS_USE_SMARTHTTP'),
        None,
    )
Ejemplo n.º 23
0
def test_htdigest_file_without_smarthttp_or_require_browser_auth():
    with pytest.raises(ValueError):
        klaus.make_app([], None, htdigest_file=object())
Ejemplo n.º 24
0
            _.inner_app = make_app(
                [os.path.join(repos_root, x) for x in os.listdir(repos_root)],
                *args, **kwargs
            )
            _.should_reload = False
        return _.inner_app(environ, start_response)

    # Background thread that polls the directory for changes
    poller_thread = threading.Thread(target=(lambda: poll_for_changes(10, repos_root)))
    poller_thread.daemon = True
    poller_thread.start()

    return app


if 'KLAUS_HTDIGEST_FILE' in os.environ:
    with open(os.environ['KLAUS_HTDIGEST_FILE']) as file:
        application = make_app(
            os.environ['KLAUS_REPOS'],
            os.environ['KLAUS_SITE_NAME'],
            os.environ.get('KLAUS_USE_SMARTHTTP'),
            file,
        )
else:
    application = make_autoreloading_app(
        os.environ['KLAUS_REPOS'],
        os.environ['KLAUS_SITE_NAME'],
        os.environ.get('KLAUS_USE_SMARTHTTP'),
        None,
    )
Ejemplo n.º 25
0
def test_unauthenticated_push_and_require_browser_auth():
    with pytest.raises(ValueError):
        klaus.make_app([], None, use_smarthttp=True, unauthenticated_push=True, require_browser_auth=True)
Ejemplo n.º 26
0
def serve(*args, **kwargs):
    app = klaus.make_app(ALL_TEST_REPOS, TEST_SITE_NAME, *args, **kwargs)
    with serve_app(app):
        yield
Ejemplo n.º 27
0
def test_unauthenticated_push_with_disable_push():
    with pytest.raises(ValueError):
        klaus.make_app([], None, unauthenticated_push=True, disable_push=True)
Ejemplo n.º 28
0
Archivo: utils.py Proyecto: jahir/klaus
def serve(*args, **kwargs):
    app = klaus.make_app(ALL_TEST_REPOS, TEST_SITE_NAME, *args, **kwargs)
    with serve_app(app):
        yield