示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#6
0
文件: utils.py 项目: 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)
示例#7
0
文件: utils.py 项目: 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)
示例#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)
示例#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,
    )
示例#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)
示例#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
示例#12
0
def test_unauthenticated_push_with_disable_push():
    with pytest.raises(ValueError):
        klaus.make_app([], None, unauthenticated_push=True, disable_push=True)
示例#13
0
def test_unauthenticated_push_without_use_smarthttp():
    with pytest.raises(ValueError):
        klaus.make_app([], None, unauthenticated_push=True)
示例#14
0
文件: wsgi.py 项目: 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)
示例#15
0
def test_htdigest_file_without_smarthttp_or_require_browser_auth():
    with pytest.raises(ValueError):
        klaus.make_app([], None, htdigest_file=object())
示例#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)
示例#17
0
文件: wsgi.py 项目: 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,
    )
示例#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)
示例#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'),
)
示例#20
0
def test_unauthenticated_push_without_use_smarthttp():
    with pytest.raises(ValueError):
        klaus.make_app([], None, unauthenticated_push=True)
示例#21
0
文件: wsgi.py 项目: momodel/klaus
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")
示例#22
0
文件: wsgi.py 项目: 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,
    )
示例#23
0
def test_htdigest_file_without_smarthttp_or_require_browser_auth():
    with pytest.raises(ValueError):
        klaus.make_app([], None, htdigest_file=object())
示例#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,
    )
示例#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)
示例#26
0
def serve(*args, **kwargs):
    app = klaus.make_app(ALL_TEST_REPOS, TEST_SITE_NAME, *args, **kwargs)
    with serve_app(app):
        yield
示例#27
0
def test_unauthenticated_push_with_disable_push():
    with pytest.raises(ValueError):
        klaus.make_app([], None, unauthenticated_push=True, disable_push=True)
示例#28
0
文件: utils.py 项目: jahir/klaus
def serve(*args, **kwargs):
    app = klaus.make_app(ALL_TEST_REPOS, TEST_SITE_NAME, *args, **kwargs)
    with serve_app(app):
        yield