From b0b411c3c03ddcee067d574f2a758f35266ad0c1 Mon Sep 17 00:00:00 2001 From: John Hensley Date: Wed, 1 Apr 2020 13:48:11 -0400 Subject: [PATCH] Add source detail to create-dev-data output As sources are being added, include the count in the output, to give a better idea of progress. --- securedrop/create-dev-data.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/securedrop/create-dev-data.py b/securedrop/create-dev-data.py index f04bdb8d7ff..140641e49c2 100755 --- a/securedrop/create-dev-data.py +++ b/securedrop/create-dev-data.py @@ -58,10 +58,12 @@ def main(staging=False): # Add test sources and submissions num_sources = int(os.getenv('NUM_SOURCES', 2)) - for i in range(num_sources): + for i in range(1, num_sources + 1): if i == 0: # For the first source, the journalist who replied will be deleted - create_source_and_submissions(journalist_who_replied=journalist_tobe_deleted) + create_source_and_submissions( + i, num_sources, journalist_who_replied=journalist_tobe_deleted + ) continue create_source_and_submissions() # Now let us delete one journalist @@ -89,8 +91,9 @@ def add_test_user(username, password, otp_secret, is_admin=False, db.session.rollback() -def create_source_and_submissions(num_submissions=2, num_replies=2, - journalist_who_replied=None): +def create_source_and_submissions( + source_index, source_count, num_submissions=2, num_replies=2, journalist_who_replied=None +): # Store source in database codename = current_app.crypto_util.genrandomid() filesystem_id = current_app.crypto_util.hash_codename(codename) @@ -137,9 +140,13 @@ def create_source_and_submissions(num_submissions=2, num_replies=2, db.session.commit() - print("Test source (codename: '{}', journalist designation '{}') " - "added with {} submissions and {} replies".format( - codename, journalist_designation, num_submissions, num_replies)) + print( + "Test source {}/{} (codename: '{}', journalist designation '{}') " + "added with {} submissions and {} replies".format( + source_index, source_count, codename, journalist_designation, + num_submissions, num_replies + ) + ) if __name__ == "__main__": # pragma: no cover