Univention Bugzilla – Attachment 9453 Details for
Bug 46553
two+ Python syntax errors in UCR conffiles
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
ucs-lint - should be added to ucslint
ucr-lint (text/plain), 1.72 KB, created by
Philipp Hahn
on 2018-03-08 16:03:24 CET
(
hide
)
Description:
ucs-lint - should be added to ucslint
Filename:
MIME Type:
Creator:
Philipp Hahn
Created:
2018-03-08 16:03:24 CET
Size:
1.72 KB
patch
obsolete
>#!/usr/bin/python >""" >Check UCR templates for Python errors >""" > >from __future__ import print_function >from os import walk >from os.path import join >from sys import argv, stderr >from errno import ENOENT >from subprocess import Popen, PIPE >from logging import StreamHandler, Formatter, getLogger, INFO >try: > import colorlog >except ImportError: > colorlog = None >import re > >EXECUTE_TOKEN = re.compile('@!@(.+?)@!@', re.MULTILINE | re.DOTALL) >HEADER = '''\ ># -*- coding: utf-8 -*- >import univention.config_registry >configRegistry = univention.config_registry.ConfigRegistry() >configRegistry.load() ># for compatibility >baseConfig = configRegistry >''' > >if colorlog: > handler = colorlog.StreamHandler(stderr) > handler.setFormatter(colorlog.ColoredFormatter('%(log_color)s%(levelname)s:%(message)s')) >else: > handler = StreamHandler(stderr) > handler.setFormatter(Formatter('%(levelname)s:%(message)s')) > >log = getLogger(__name__) >log.addHandler(handler) >log.setLevel(INFO) > >try: > root, = argv[1:] >except ValueError: > root = '.' > >for (dirpath, dirnames, filenames) in walk(root): > if 'conffiles' not in dirpath: > continue > for filename in filenames: > pathname = join(dirpath, filename) > log.debug('Processing %s ...', pathname) > try: > with open(pathname, 'r') as stream: > text = stream.read() > except EnvironmentError as ex: > if ex.errno == ENOENT: > log.warn('ERROR: %s: %s', pathname, ex) > else: > log.fatal('ERROR: %s: %s', pathname, ex) > > continue > > for match in EXECUTE_TOKEN.findall(text): > log.debug('Found match') > proc = Popen(('pyflakes',), stdin=PIPE) > proc.stdin.write(HEADER) > proc.stdin.write(match) > proc.stdin.close() > rv = proc.wait() > if rv: > log.fatal('FAIL: %s', pathname) > else: > log.info('OK: %s', pathname)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 46553
: 9453 |
10257