Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from print to logging on scramble script #409

Merged
merged 3 commits into from
Jul 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/meshapi/management/commands/scramble_members.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from argparse import ArgumentParser
from datetime import date, timedelta
from random import randint, randrange
Expand Down Expand Up @@ -34,11 +35,11 @@ def add_arguments(self, parser: ArgumentParser) -> None:

@transaction.atomic
def handle(self, *args: Any, **options: Any) -> None:
print("Scrambling database with fake information")
logging.info("Scrambling database with fake information")
fake = Faker()
if not options["skip_members"]:
members = Member.objects.all()
print("Scrambling members...")
logging.info("Scrambling members...")
for member in members:
member.name = fake.name()
member.primary_email_address = f"{member.name.replace(' ', '').lower()}@gmail.com"
Expand All @@ -51,7 +52,7 @@ def handle(self, *args: Any, **options: Any) -> None:
member.save()

if not options["skip_installs"]:
print("Scrambling installs...")
logging.info("Scrambling installs...")
installs = Install.objects.all()
for install in installs:
install.unit = randrange(100)
Expand All @@ -61,9 +62,9 @@ def handle(self, *args: Any, **options: Any) -> None:
)
install.save()

print("Scrambling all other notes and dates")
logging.info("Scrambling all other notes and dates")

print("Scrambling buildings...")
logging.info("Scrambling buildings...")
buildings = Building.objects.all()
for building in buildings:
building.notes = fake.text()
Expand All @@ -80,7 +81,7 @@ def handle(self, *args: Any, **options: Any) -> None:

building.save()

print("Scrambling devices...")
logging.info("Scrambling devices...")
devices = Device.objects.all()
for device in devices:
device.notes = fake.text()
Expand All @@ -89,7 +90,7 @@ def handle(self, *args: Any, **options: Any) -> None:
)
device.save()

print("Scrambling links...")
logging.info("Scrambling links...")
links = Link.objects.all()
for link in links:
link.notes = fake.text()
Expand All @@ -98,7 +99,7 @@ def handle(self, *args: Any, **options: Any) -> None:
)
link.save()

print("Scrambling nodes...")
logging.info("Scrambling nodes...")
nodes = Node.objects.all()
for node in nodes:
node.notes = fake.text()
Expand All @@ -107,7 +108,7 @@ def handle(self, *args: Any, **options: Any) -> None:
)
node.save()

print("Done")
logging.info("Done")

@staticmethod
def fuzz_dates(
Expand Down
Loading