Skip to content

Commit

Permalink
Not a Django management command
Browse files Browse the repository at this point in the history
  • Loading branch information
hancush committed Jul 17, 2024
1 parent c1c6e9a commit 875ae76
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pupa/cli/commands/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,34 +75,34 @@ def handle(self, args, other):
stale_objects = list(self.get_stale_objects(args.window))
num_stale_objects = len(stale_objects)

self.stdout.write(
sys.stdout.write(
f"{num_stale_objects} objects in your database have not been seen "
f"in {args.window} days."
)

if args.report:
for obj in stale_objects:
self.stdout.write(str(obj))
sys.stdout.write(str(obj))
else:
if num_stale_objects > args.max:
self.stderr.write(
sys.stderr.write(
f"{num_stale_objects} exceeds the failsafe limit of {args.max}. "
"Run this command with a larger --max value to proceed."
)
sys.exit()

if args.yes:
self.stdout.write("Proceeding to deletion because you specified --yes.")
sys.stdout.write("Proceeding to deletion because you specified --yes.")

else:
self.stdout.write(
sys.stdout.write(
f"Permanently delete {num_stale_objects} objects? [Y/n]"
)
response = input()

if args.yes or response.lower() == "y":
for obj in stale_objects:
self.stdout.write(f"Deleting {obj}...")
sys.stdout.write(f"Deleting {obj}...")
obj.delete()

self.stdout.write(f"Removed {num_stale_objects} from your database.")
sys.stdout.write(f"Removed {num_stale_objects} from your database.")

0 comments on commit 875ae76

Please sign in to comment.