Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
help="for debug print.",
)
group.add_argument(
"--quiet",
dest=loglevel_dest,
action="store_const",
const=QUIET_LOG_LEVEL,
default=logbook.INFO,
help="suppress execution log messages.",
)
group = parser.add_argument_group("Ping Options")
group.add_argument(
"--timestamp",
choices=TimestampFormat.LIST,
default=TimestampFormat.NONE,
help="""[Only for LINUX]
{}: no timestamps.
{}: add timestamps with UNIX epoch time format.
{}: add timestamps with ISO time format.
""".format(
TimestampFormat.NONE, TimestampFormat.EPOCH, TimestampFormat.DATETIME
),
)
group.add_argument(
"-c",
"--count",
type=int,
help="""Stop after sending the count.
see also ping(8) [-c count] option description.
""",
)
raise TypeError("not supported type to convert: {}".format(type(obj)))
def _serialize_datetime(obj):
if isinstance(obj, datetime):
return obj.isoformat()
if isinstance(obj, TIMESTAMP_TYPES):
return obj
raise TypeError("not supported type to convert: {}".format(type(obj)))
timestamp_serialize_map = {
TimestampFormat.NONE: None,
TimestampFormat.EPOCH: _serialize_epoch,
TimestampFormat.DATETIME: _serialize_datetime,
}
def dumps_dict(obj, timestamp_format, indent=0):
serialize_func = timestamp_serialize_map[timestamp_format]
if indent <= 0:
return json.dumps(obj, default=serialize_func)
return json.dumps(obj, indent=indent, default=serialize_func)
def main():
options = parse_option()