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