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)
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)
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)
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)
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)
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)
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)
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, )
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)
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
def test_unauthenticated_push_with_disable_push(): with pytest.raises(ValueError): klaus.make_app([], None, unauthenticated_push=True, disable_push=True)
def test_unauthenticated_push_without_use_smarthttp(): with pytest.raises(ValueError): klaus.make_app([], None, unauthenticated_push=True)
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)
def test_htdigest_file_without_smarthttp_or_require_browser_auth(): with pytest.raises(ValueError): klaus.make_app([], None, htdigest_file=object())
# 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)
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, )
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)
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'), )
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")
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, )
_.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, )
def serve(*args, **kwargs): app = klaus.make_app(ALL_TEST_REPOS, TEST_SITE_NAME, *args, **kwargs) with serve_app(app): yield