Example #1
0
def poll_paths():
    request_paths = paths_or_400()
    branch_mode = request.args.get('branch')
    if branch_mode and branch_mode.lower() != 'false':
        poll_paths = [p for p in git.git_branch_files(request_paths[0])]
    else:
        poll_paths = get_path_targets(request_paths[0])
    poll_paths = filter(valid_target, poll_paths)

    full_scan = request.args.get('fullScan', False)
    full_scan = full_scan and full_scan != 'false'

    since = float(int(request.args.get('since')) / 1000)
    response = {
        'changed': {}
    }

    for p in poll_paths:
        mod = os.path.getmtime(p)
        if full_scan or mod > since:
            response['changed'][p] = _results_dict(p)
            response['changed'][p]['modtime'] = mod

    if branch_mode:
        response['delete'] = [i for i in request_paths if i not in poll_paths]
    return jsonify(response)
    def wrapper(*args, **kwargs):
        func_response = func(*args, **kwargs)

        if isinstance(func_response, Response):
            return func_response

        if not isinstance(func_response, tuple):
            return Response(response=util.jsonify(func_response), mimetype='application/json')

        unpack_or_none = lambda resp=None, st_code=HTTP_OK, http_headers=None: (resp, st_code, http_headers)
        response, status, headers = unpack_or_none(*func_response)
        jsonfied_response = Response(response=util.jsonify(response), status=status, mimetype='application/json')

        if headers:
            jsonfied_response.headers.extend(headers)

        return jsonfied_response
Example #3
0
def test_path():
    path = get_path_or_400()
    response = {
        'path': path,
        'exists': os.path.exists(path)
    }
    if response['exists']:
        response['dir'] = os.path.isdir(path)
        if request.args.get('branch'):
            response['targets'] = git.git_branch_files(path)
        else:
            response['targets'] = get_path_targets(path)

        git_branch = git.git_branch(path)
        if git_branch:
            response['branch'] = git_branch
            response['vcs'] = 'git'
            response['name'] = git.git_name()

    return jsonify(response)
Example #4
0
def dumb_route():
    return jsonify({'success': True})