Clone cleaning and configure CI to run tests
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
4161e4cd51
commit
ab7e09d7b6
3 changed files with 30 additions and 10 deletions
3
.pylintrc
Normal file
3
.pylintrc
Normal file
|
@ -0,0 +1,3 @@
|
|||
[MESSAGES CONTROL]
|
||||
disable=consider-using-f-string,
|
||||
invalid-name,
|
12
.woodpecker.yml
Normal file
12
.woodpecker.yml
Normal file
|
@ -0,0 +1,12 @@
|
|||
pipeline:
|
||||
test-pylint:
|
||||
group: test
|
||||
image: pipelinecomponents/pylint
|
||||
commands:
|
||||
- pylint check_livestatus
|
||||
|
||||
test-flake8:
|
||||
group: test
|
||||
image: pipelinecomponents/flake8
|
||||
commands:
|
||||
- flake8 check_livestatus
|
|
@ -14,7 +14,7 @@ DEFAULT_HOST = '127.0.0.1'
|
|||
DEFAULT_PORT = 6557
|
||||
DEFAULT_TIMEOUT = 2
|
||||
|
||||
### MAIN ####
|
||||
# MAIN
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
|
||||
parser.add_argument(
|
||||
|
@ -82,7 +82,9 @@ options = parser.parse_args()
|
|||
|
||||
# Initialize log
|
||||
log = logging.getLogger()
|
||||
logformat = logging.Formatter("%(asctime)s - " + os.path.basename(sys.argv[0]) + " - %(levelname)s - %(message)s")
|
||||
logformat = logging.Formatter(
|
||||
"%(asctime)s - " + os.path.basename(sys.argv[0]) +
|
||||
" - %(levelname)s - %(message)s")
|
||||
|
||||
if options.debug:
|
||||
log.setLevel(logging.DEBUG)
|
||||
|
@ -111,7 +113,8 @@ try:
|
|||
livestatus = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
livestatus.connect((options.host, options.port))
|
||||
else:
|
||||
parser.error('You must provide Livestatus UNIX socket path or host & port')
|
||||
parser.error(
|
||||
'You must provide Livestatus UNIX socket path or host & port')
|
||||
sys.exit(3)
|
||||
livestatus.settimeout(options.timeout)
|
||||
|
||||
|
@ -121,14 +124,16 @@ try:
|
|||
status = None
|
||||
if rawdata:
|
||||
data = json.loads(rawdata)
|
||||
assert isinstance(data, list) and len(data) == 2, "Invalid Livestatus return:\n%s" % data
|
||||
assert isinstance(data, list) and len(data) == 2, \
|
||||
"Invalid Livestatus return:\n%s" % data
|
||||
status = dict(
|
||||
(data[0][idx], value)
|
||||
for idx, value in enumerate(data[1])
|
||||
)
|
||||
except Exception:
|
||||
except Exception: # pylint: disable=broad-except
|
||||
print(
|
||||
'UNKNOWN - Fail to retreive status from Livestatus from %s\n\nException:\n%s' %
|
||||
'UNKNOWN - Fail to retreive status from Livestatus '
|
||||
'from %s\n\nException:\n%s' %
|
||||
(peer, traceback.format_exc())
|
||||
)
|
||||
sys.exit(2)
|
||||
|
|
Loading…
Reference in a new issue