I should have been more ashamed of this ljust madness than I was

This commit is contained in:
Stefan Midjich 2017-12-06 12:01:58 +01:00
parent 148d409d3b
commit bec77b9d92
1 changed files with 10 additions and 6 deletions

View File

@ -150,7 +150,7 @@ if args.refresh:
except Exception as e: except Exception as e:
if args.verbose: if args.verbose:
print('Failed to init client:{ip}: {error}'.format( print('Failed to init client:{ip}: {error}'.format(
ip=client_ip.ljust(12), ip=client_ip,
error=str(e) error=str(e)
)) ))
@ -169,7 +169,7 @@ if args.refresh:
if client._new: if client._new:
if args.verbose > 1: if args.verbose > 1:
print('Client:{ip} created'.format( print('Client:{ip} created'.format(
ip=client.ip_address.ljust(13) ip=client.ip_address
)) ))
client.enabled = True client.enabled = True
@ -177,6 +177,10 @@ if args.refresh:
# we enable it and set a new expired date for it. As if it's a new # we enable it and set a new expired date for it. As if it's a new
# (reset) client. # (reset) client.
if not client.enabled: if not client.enabled:
if args.verbose:
print('Client:{ip} enabled'.format(
ip=client.ip_address
))
client.enabled = True client.enabled = True
client.expires = current_time client.expires = current_time
@ -185,7 +189,7 @@ if args.refresh:
if int(packets_val) > client.last_packets: if int(packets_val) > client.last_packets:
if args.verbose > 1: if args.verbose > 1:
print('Client:{ip} updated'.format( print('Client:{ip} updated'.format(
ip=client.ip_address.ljust(13) ip=client.ip_address
)) ))
client.last_packets = packets_val client.last_packets = packets_val
@ -196,7 +200,7 @@ if args.refresh:
# unique clients life-time. # unique clients life-time.
if args.verbose > 1: if args.verbose > 1:
print('Client:{ip} reset'.format( print('Client:{ip} reset'.format(
ip=client.ip_address.ljust(13) ip=client.ip_address
)) ))
client.last_packets = packets_val client.last_packets = packets_val
@ -208,7 +212,7 @@ if args.refresh:
if not client.last_activity and expired: if not client.last_activity and expired:
if args.verbose: if args.verbose:
print('Client:{ip} disabled, no activity logged'.format( print('Client:{ip} disabled, no activity logged'.format(
ip=client.ip_address.ljust(13) ip=client.ip_address
)) ))
client.enabled = False client.enabled = False
@ -223,7 +227,7 @@ if args.refresh:
if args.verbose: if args.verbose:
print('Client:{ip} disabled, no activity since "{last_activity}"'.format( print('Client:{ip} disabled, no activity since "{last_activity}"'.format(
last_activity=client.last_activity, last_activity=client.last_activity,
ip=client.ip_address.ljust(13) ip=client.ip_address
)) ))
client.enabled = False client.enabled = False