diff --git a/sncfgtfs/management/commands/update_sncf_gtfs.py b/sncfgtfs/management/commands/update_sncf_gtfs.py index 7adee86..aecfc21 100644 --- a/sncfgtfs/management/commands/update_sncf_gtfs.py +++ b/sncfgtfs/management/commands/update_sncf_gtfs.py @@ -24,6 +24,7 @@ class Command(BaseCommand): } def add_arguments(self, parser): + parser.add_argument('--debug', '-d', action='store_true', help="Activate debug mode") parser.add_argument('--bulk_size', type=int, default=1000, help="Number of objects to create in bulk.") parser.add_argument('--dry-run', action='store_true', help="Do not update the database, only print what would be done.") diff --git a/sncfgtfs/management/commands/update_sncf_gtfs_rt.py b/sncfgtfs/management/commands/update_sncf_gtfs_rt.py index 24d2f79..f78c35f 100644 --- a/sncfgtfs/management/commands/update_sncf_gtfs_rt.py +++ b/sncfgtfs/management/commands/update_sncf_gtfs_rt.py @@ -22,9 +22,9 @@ class Command(BaseCommand): } def add_arguments(self, parser): - pass + parser.add_argument('--debug', '-d', action='store_true', help="Activate debug mode") - def handle(self, *args, **options): + def handle(self, debug=False, *args, **options): for feed_type, feed_url in self.GTFS_RT_FEEDS.items(): self.stdout.write(f"Updating {feed_type} feed...") feed_message = FeedMessage() @@ -32,6 +32,10 @@ class Command(BaseCommand): stop_times_updates = [] + if debug: + with open(f'feed_message-{feed_type}.txt', 'w') as f: + f.write(str(feed_message)) + for entity in feed_message.entity: if entity.HasField("trip_update"): trip_update = entity.trip_update