Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • perun/perun-proxyidp/perun-proxy-utils
1 result
Select Git revision
Show changes
Commits on Source (3)
# [2.5.0](https://gitlab.ics.muni.cz/perun/perun-proxyidp/perun-proxy-utils/compare/v2.4.0...v2.5.0) (2024-02-05)
### Features
* arguments handling with argparse ([4f068a9](https://gitlab.ics.muni.cz/perun/perun-proxyidp/perun-proxy-utils/commit/4f068a9652a119a8ad54e52c5e82938b754d4086))
# [2.4.0](https://gitlab.ics.muni.cz/perun/perun-proxyidp/perun-proxy-utils/compare/v2.3.0...v2.4.0) (2024-02-01)
......
......@@ -35,21 +35,31 @@ run_probes
Script removes all logs from test accounts from SimpleSAMLphp logs.
Params:
For usage instructions, run:
- 1 - The file name
```sh
separate_ssp_logs.py --help
```
### separate_oidc_logs
Script removes all logs from test accounts from mitreID logs.
For usage instructions, run:
```sh
separate_oidc_logs.py --help
```
### metadata_expiration
This script checks whether there are some metadata close to expiration date.
Params:
For usage instructions, run:
- 1 - url to a page which prints a time when expires the metadata closest to expiration
```sh
metadata_expiration.py --help
```
### print_docker_versions
......
import sys
import argparse
from urllib.request import urlopen
from bs4 import BeautifulSoup
def get_args():
"""
Supports the command-line arguments listed below.
"""
parser = argparse.ArgumentParser(
description="This script checks whether there are some metadata close to expiration date."
)
parser.add_argument(
"url",
help="url to a page which prints a time when expires the metadata closest to expiration",
)
return parser.parse_args()
def main():
url = sys.argv[1]
url = get_args().url
html = urlopen(url).read()
closest_expiration = BeautifulSoup(html, "html.parser")
......
......@@ -30,7 +30,7 @@ from __future__ import print_function
from __future__ import division
import sys
import time
import optparse
import argparse
import re
import os
import numbers
......@@ -49,15 +49,13 @@ import bson.son as son
# thanks to http://stackoverflow.com/a/1229667/72987
#
def optional_arg(arg_default):
def func(option, opt_str, value, parser):
if parser.rargs and not parser.rargs[0].startswith("-"):
val = parser.rargs[0]
parser.rargs.pop(0)
else:
val = arg_default
setattr(parser.values, option.dest, val)
class CustomAction(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
if values is None:
values = arg_default
setattr(namespace, self.dest, values)
return func
return CustomAction
def performance_data(perf_data, params):
......@@ -129,32 +127,32 @@ def split_host_port(string):
return (host, port)
def main():
p = optparse.OptionParser(
def get_args():
p = argparse.ArgumentParser(
conflict_handler="resolve",
description="This Nagios plugin checks the health of mongodb.",
)
p.add_option(
p.add_argument(
"-H",
"--host",
action="store",
type="string",
type=str,
dest="host",
default="127.0.0.1",
help="The hostname you want to connect to",
)
p.add_option(
p.add_argument(
"-h",
"--host-to-check",
action="store",
type="string",
type=str,
dest="host_to_check",
default=None,
help="The hostname you want to check (if this is different from the host you "
"are connecting)",
)
p.add_option(
p.add_argument(
"--rdns-lookup",
action="store_true",
dest="rdns_lookup",
......@@ -162,43 +160,43 @@ def main():
help="RDNS(PTR) lookup on given host/host-to-check, to convert ip-address "
"to fqdn",
)
p.add_option(
p.add_argument(
"-P",
"--port",
action="store",
type="int",
type=int,
dest="port",
default=27017,
help="The port mongodb is running on",
)
p.add_option(
p.add_argument(
"--port-to-check",
action="store",
type="int",
type=int,
dest="port_to_check",
default=None,
help="The port you want to check (if this is different from the port you "
"are connecting)",
)
p.add_option(
p.add_argument(
"-u",
"--user",
action="store",
type="string",
type=str,
dest="user",
default=None,
help="The username you want to login as",
)
p.add_option(
p.add_argument(
"-p",
"--pass",
action="store",
type="string",
type=str,
dest="passwd",
default=None,
help="The password you want to use for that user",
)
p.add_option(
p.add_argument(
"-W",
"--warning",
action="store",
......@@ -206,7 +204,7 @@ def main():
default=None,
help="The warning threshold you want to set",
)
p.add_option(
p.add_argument(
"-C",
"--critical",
action="store",
......@@ -214,11 +212,10 @@ def main():
default=None,
help="The critical threshold you want to set",
)
p.add_option(
p.add_argument(
"-A",
"--action",
action="store",
type="choice",
dest="action",
default="connect",
help="The action you want to take",
......@@ -261,14 +258,14 @@ def main():
"replset_quorum",
],
)
p.add_option(
p.add_argument(
"--max-lag",
action="store_true",
dest="max_lag",
default=False,
help="Get max replication lag (for replication_lag action only)",
)
p.add_option(
p.add_argument(
"--mapped-memory",
action="store_true",
dest="mapped_memory",
......@@ -276,7 +273,7 @@ def main():
help="Get mapped memory instead of resident (if resident memory can not be "
"read)",
)
p.add_option(
p.add_argument(
"-D",
"--perf-data",
action="store_true",
......@@ -284,7 +281,7 @@ def main():
default=False,
help="Enable output of Nagios performance data",
)
p.add_option(
p.add_argument(
"-d",
"--database",
action="store",
......@@ -292,32 +289,34 @@ def main():
default="admin",
help="Specify the database to check",
)
p.add_option(
p.add_argument(
"--all-databases",
action="store_true",
dest="all_databases",
default=False,
help="Check all databases (action database_size)",
)
p.add_option(
p.add_argument(
"-t",
"--tls",
dest="tls",
default=False,
action="callback",
callback=optional_arg(True),
action=optional_arg(True),
nargs="?",
const=True,
help="Connect using tls",
)
p.add_option(
p.add_argument(
"-r",
"--replicaset",
dest="replicaset",
default=None,
action="callback",
callback=optional_arg(True),
action=optional_arg(True),
nargs="?",
const=True,
help="Connect to replicaset",
)
p.add_option(
p.add_argument(
"-q",
"--querytype",
action="store",
......@@ -326,7 +325,7 @@ def main():
help="The query type to check [query|insert|update|delete|getmore|command] "
"from queries_per_second",
)
p.add_option(
p.add_argument(
"-c",
"--collection",
action="store",
......@@ -334,68 +333,72 @@ def main():
default="admin",
help="Specify the collection to check",
)
p.add_option(
p.add_argument(
"-T",
"--time",
action="store",
type="int",
type=int,
dest="sample_time",
default=1,
help="Time used to sample number of pages faults",
)
p.add_option(
p.add_argument(
"-a",
"--authdb",
action="store",
type="string",
type=str,
dest="authdb",
default="admin",
help="The database you want to authenticate against",
)
p.add_option(
p.add_argument(
"--insecure",
action="store_true",
dest="insecure",
default=False,
help="Don't verify TLS certificates",
)
p.add_option(
p.add_argument(
"--tls-ca-file",
action="store",
type="string",
type=str,
dest="tls_ca_file",
default=None,
help="Path to Certificate Authority file for TLS",
)
p.add_option(
p.add_argument(
"-f",
"--tls-cert-key-file",
action="store",
type="string",
type=str,
dest="tls_cert_key_file",
default=None,
help="Path to PEM encoded key and cert for client authentication",
)
p.add_option(
p.add_argument(
"-m",
"--auth-mechanism",
action="store",
type="choice",
dest="auth_mechanism",
default=None,
help="Auth mechanism used for auth with mongodb",
choices=["MONGODB-X509", "SCRAM-SHA-256", "SCRAM-SHA-1"],
)
p.add_option(
p.add_argument(
"--disable-retry-writes",
dest="retry_writes_disabled",
default=False,
action="callback",
callback=optional_arg(True),
action=optional_arg(True),
nargs="?",
const=True,
help="Disable retryWrites feature",
)
options, arguments = p.parse_args()
return p.parse_args()
def main():
options = get_args()
host = options.host
host_to_check = options.host_to_check if options.host_to_check else options.host
rdns_lookup = options.rdns_lookup
......
......@@ -5,14 +5,22 @@ import shutil
import re
import sys
from os import mkdir, path, rename, remove, system
import argparse
def main():
if len(sys.argv) <= 1:
print("One argument is expected!")
sys.exit(-1)
def get_args():
"""
Supports the command-line arguments listed below.
"""
parser = argparse.ArgumentParser(
description="Script removes all logs from test accounts from mitreID logs."
)
parser.add_argument("filename", help="The file name of log file")
return parser.parse_args()
absolute_file_name = sys.argv[1]
def main():
absolute_file_name = get_args().filename
if not path.exists(absolute_file_name):
print("File with name " + absolute_file_name + " doesn't exists!")
......
......@@ -5,14 +5,22 @@ import shutil
import re
import sys
from os import mkdir, path, rename, remove, system
import argparse
def main():
if len(sys.argv) <= 1:
print("One argument is expected!")
sys.exit(-1)
def get_args():
"""
Supports the command-line arguments listed below.
"""
parser = argparse.ArgumentParser(
description="Script removes all logs from test accounts from SimpleSAMLphp logs."
)
parser.add_argument("filename", help="The file name of log file")
return parser.parse_args()
absolute_file_name = sys.argv[1]
def main():
absolute_file_name = get_args().filename
if not path.exists(absolute_file_name):
print("File with name " + absolute_file_name + " doesn't exists!")
......
[metadata]
version = 2.4.0
version = 2.5.0
license_files = LICENSE
long_description = file: README.md
long_description_content_type = text/markdown
......