Exemple #1
0
def log_file(request, build):
    data_dir = request.app.app.data_dir
    filename = os.path.join(data_dir, build, 'log.txt')
    levelno = request.values.get('levelno', default=logging.INFO, type=int)
    thread = request.values.get('thread')
    logger = request.values.get('name')
    def records():
        with open(filename) as f:
            for number, line in enumerate(f):
                if not line.strip():
                    continue
                try:
                    record = json.loads(line)
                except Exception:
                    record = {
                        'parsing_error': traceback.format_exc(),
                        'line_number': number + 1
                    }
                else:
                    if logger and not record['name'].startswith(logger):
                        continue
                    if record['levelno'] < levelno:
                        continue
                    if thread and thread != (record['process_name'] +
                                             '/' + record['thread_name']):
                        continue
                    record['created_time'] = time.gmtime(record['created'])
                    record['created_string'] = time.strftime(
                        '%Y-%m-%d %H:%M:%S',
                        record['created_time']
                    )
                yield record
    return render(request, records(), 'log_file',
                  build=build, records=records(), levelno=levelno)
Exemple #2
0
def log_list(request):
    data_dir = request.app.app.data_dir
    entries = [
        dirname
        for dirname in os.listdir(data_dir)
        if os.path.isdir(os.path.join(data_dir, dirname))
    ]
    entries.sort(key=lambda n: n.rsplit('.', 1)[-1], reverse=True)
    return render(request, entries, 'log_list', builds=entries)
Exemple #3
0
def home(request):
    return render(request, {'pi': 3.14}, 'home', pi=3.14)
Exemple #4
0
def home(request):
    """The list of deployed branches."""
    deployments = request.app.app.deployments
    return render(request, deployments, 'home', deployments=deployments)