nvchecker-notify: accept and pass --tries and --failures to nvchecker

This commit is contained in:
Štěpán Němec 2023-10-03 17:20:32 +02:00
parent b8c0e8a6b3
commit 4f79058cbd
1 changed files with 9 additions and 0 deletions

View File

@ -26,6 +26,11 @@ def get_args():
parser.add_argument('-k', '--keyfile', parser.add_argument('-k', '--keyfile',
metavar='FILE', type=str, metavar='FILE', type=str,
help='use specified keyfile (override the one in configuration file)') help='use specified keyfile (override the one in configuration file)')
parser.add_argument('-t', '--tries', default=1, type=int, metavar='N',
help='try N times when network errors occur')
parser.add_argument('--failures', action='store_true',
help='exit with code 3 if failures / errors happen during checking')
return parser.parse_args() return parser.parse_args()
def main(): def main():
@ -43,6 +48,10 @@ def main():
cmd.extend(['-c', args.file]) cmd.extend(['-c', args.file])
if args.keyfile: if args.keyfile:
cmd.extend(['-k', args.keyfile]) cmd.extend(['-k', args.keyfile])
if args.tries:
cmd.extend(['-t', str(args.tries)])
if args.failures:
cmd.append('--failures')
process = subprocess.Popen(cmd, pass_fds=(wfd,)) process = subprocess.Popen(cmd, pass_fds=(wfd,))
os.close(wfd) os.close(wfd)