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
overwrite timezone configuration with env #981
Conversation
Pull Request Test Coverage Report for Build 3393
💛 - Coveralls |
Codecov Report
@@ Coverage Diff @@
## master #981 +/- ##
==========================================
+ Coverage 73.12% 73.34% +0.22%
==========================================
Files 112 112
Lines 4788 4764 -24
Branches 612 609 -3
==========================================
- Hits 3501 3494 -7
+ Misses 1062 1045 -17
Partials 225 225
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, minor changes requested.
Also:
- squash the two commits together and add
Fixes #982
in the commit log - you may want to update the commit log text to indicate you are adding a new functionality
general question: when will be the new reporting - telemetry available? this was used quite heavily by our internal QA team and they have to do some manual reporting now after switched to 6.10. any preview branch available? |
It will be ready when our resources allow it. Just yesterday we've merged the first iteration of the status matrix and it will become available in the next version that will be released.
We've had #657 opened since December and we dropped legacy reports after March 1st. The specs for the new Telemetry have been published since then. I don't see any feedback from you wrt features or information what and how is used so there isn't really anything we can do at this point. Feel free to open a new issue to discuss use-cases and features which are not in the current telemetry spec so we don't pollute this pull request with off-topic comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, see the review comment b/c the current piece of code can be improved a bit more.
About commit log message overwrite with env value
- overwrite what ?
When somebody sees this commit they will have no idea what it is.
A more descriptive Overwrite timezone settings via env
or Use ENV variables to control timezone settings
, etc will be better.
tcms/settings/common.py
Outdated
@@ -208,11 +208,12 @@ | |||
] | |||
|
|||
# If you set this to False, Django will not use timezone-aware datetimes. | |||
USE_TZ = False | |||
USE_TZ = True if os.environ.get('KIWI_USE_TZ') == str(True) else False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is your intention here? Do you want to use timezone only when $KIWI_USE_TZ
is set to the string "True" or any other non-empty string ?
Depending on what behaviour you want you either need a comment to document that or use a simpler boolean condition (e.g. using ==
will return bool and you can also compare strings directly, can use .lower()
for convenience).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intention is to use timezone ONLY when env KIWI_USE_TZ is set to True. non-empty string , e.g. bool('False'), will resolve to true
in python. prefer not using .lower()
to follow Django settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment has been updated. re-check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.environ.get('KIWI_USE_TZ', 'False').lower() == 'true'
evaluates as boolean and allows the user to specify any capitalization variant of "True". If you don't want to allow variations then os.environ.get('KIWI_USE_TZ') == 'True'
is still simpler than the if expression you have currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if KIWI_USE_TZ is set to False or any non-empty string, os.envuse iron.get('KIWI_USE_TZ')
will resolve to True, this is why I use str(True)
in the code to make sure only "True" is taken as authentic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if KIWI_USE_TZ is set to False or any non-empty string, os.envuse iron.get('KIWI_USE_TZ') will resolve to True
This is simply not True. os.environ.get
returns a string, it isn't automatically resolved as boolean. This is why you compare the result with ==
to another string and the result of the equality comparison operator is boolean:
>>> use_tz = os.environ.get('KIWI_USE_TZ')
>>> use_tz
'False'
>>> type(use_tz)
<type 'str'>
>>> use_tz.lower() == 'true'
False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see an update. This should become:
USE_TZ = os.environ.get('KIWI_USE_TZ', 'False').lower() == 'true'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh. please re-check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment about the conditional statement. Everything else looks good.
tcms/settings/common.py
Outdated
@@ -208,11 +208,12 @@ | |||
] | |||
|
|||
# If you set this to False, Django will not use timezone-aware datetimes. | |||
USE_TZ = False | |||
USE_TZ = True if os.environ.get('KIWI_USE_TZ') == str(True) else False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.environ.get('KIWI_USE_TZ', 'False').lower() == 'true'
evaluates as boolean and allows the user to specify any capitalization variant of "True". If you don't want to allow variations then os.environ.get('KIWI_USE_TZ') == 'True'
is still simpler than the if expression you have currently.
link to issue #982