Added more logging output for --clean

This commit is contained in:
Joshua Sherman 2013-10-25 15:18:39 +00:00
parent 2ea5f2c48e
commit 9fa7e85fa1

8
tmpufw
View file

@ -63,7 +63,9 @@ class tmpufw(object):
self.error('there are no rules to display')
elif args.clean:
# Checks for PID file
if not path.exists(pid_file):
if path.exists(pid_file):
self.error(__file__ + ' is already running')
else:
# Creates the PID file
try:
handle = open(pid_file, 'w')
@ -91,11 +93,11 @@ class tmpufw(object):
# Checks if rule has expired
if current_time < float(timestamp):
handle.write(line)
print(time() + "\tskipped rule: " + rule)
print(str(datetime.fromtimestamp(time())) + "\tskipped rule\t" + rule)
else:
try:
self.ufw_execute('delete ' + rule)
print(time() + "\tdeleted rule: " + rule)
print(str(datetime.fromtimestamp(time())) + "\tdeleted rule\t" + rule)
except CalledProcessError as error:
self.ufw_error(error)