Skip to content

BB-2627: Command to retrieve instance statistics from logs.opencraft.com and appservers

IMPORTANT NOTE:

The django.core.management.call_command behavior for optional arguments is broken.

Currently, if you provide a type argument to an argument added via add_arguments that modifies the type of the argument, the call_command method does not respect this and will pass a string representation of that option.

Initially, the valid_date command in instance_statistics_csv.py converted the string input to a date object, but the call_command method did not respect that type conversion, and the string representation was passed through. In order to fix this, the input values are not converted to date objects (by the valid_date method), and are now converted only when they are needed in the handle method. This required converting the default values for those arguments to strings using strftime.

Examine this code to see where the issue is: https://github.com/django/django/blob/stable/2.2.x/django/core/management/__init__.py#L119-L128

Note that on line 125 it only includes required options, and then on line 128, it merges in arg_options with the result of the call to the parse_args method, overwriting any type conversion that occurs in the call to the parse_args method

Merge request reports

Loading