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

Avoid datetime deprecations in releaseWizard.py #751

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
21 changes: 11 additions & 10 deletions hack/release/wizard/releaseWizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from collections import OrderedDict
from datetime import datetime
from datetime import timedelta
from datetime import timezone

try:
import holidays
Expand Down Expand Up @@ -97,7 +98,7 @@ def expand_jinja(text, vars=None):
'state': state,
'gpg_key': state.get_gpg_key(),
'gpg_fingerprint': state.get_gpg_fingerprint(),
'epoch': unix_time_millis(datetime.utcnow()),
'epoch': unix_time_millis(datetime.now(timezone.utc)),
'get_next_version': state.get_next_version(),
'get_next_major_version': state.get_next_major_version(),
'get_next_minor_version': state.get_next_minor_version(),
Expand Down Expand Up @@ -201,7 +202,7 @@ def check_prerequisites(todo=None):
return True


epoch = datetime.utcfromtimestamp(0)
epoch = datetime.fromtimestamp(0, timezone.utc)


def unix_time_millis(dt):
Expand Down Expand Up @@ -295,7 +296,7 @@ def __init__(self, config_path, release_version, script_version):
self.latest_version = None
self.previous_rcs = {}
self.rc_number = 1
self.start_date = unix_time_millis(datetime.utcnow())
self.start_date = unix_time_millis(datetime.now(timezone.utc))
self.script_branch = run("git rev-parse --abbrev-ref HEAD").strip()
self.released_versions = None
try:
Expand Down Expand Up @@ -771,7 +772,7 @@ def get_vars(self):

def set_done(self, is_done):
if is_done:
self.state['done_date'] = unix_time_millis(datetime.utcnow())
self.state['done_date'] = unix_time_millis(datetime.now(timezone.utc))
if self.persist_vars:
for k in self.persist_vars:
self.state[k] = self.get_vars()[k]
Expand Down Expand Up @@ -966,21 +967,21 @@ def expand_multiline(cmd_txt, indent=0):


def unix_to_datetime(unix_stamp):
return datetime.utcfromtimestamp(unix_stamp / 1000)
return datetime.fromtimestamp(unix_stamp / 1000, timezone.utc)


def generate_asciidoc():
base_filename = os.path.join(state.get_release_folder(),
"solr_operator_release_%s"
% (state.release_version.replace("\.", "_")))
% (state.release_version.replace(".", "_")))

filename_adoc = "%s.adoc" % base_filename
filename_html = "%s.html" % base_filename
fh = open(filename_adoc, "w")

fh.write("= Solr Operator Release %s\n\n" % state.release_version)
fh.write("(_Generated by releaseWizard.py %s at %s_)\n\n"
% (getScriptVersion(), datetime.utcnow().strftime("%Y-%m-%d %H:%M UTC")))
% (getScriptVersion(), datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M UTC")))
fh.write(":numbered:\n\n")
fh.write("%s\n\n" % template('help'))
for group in state.todo_groups:
Expand Down Expand Up @@ -1895,17 +1896,17 @@ def create_ical(todo):
return True


today = datetime.utcnow().date()
today = datetime.now(timezone.utc).date()
sundays = {(today + timedelta(days=x)): 'Sunday' for x in range(10) if (today + timedelta(days=x)).weekday() == 6}
y = datetime.utcnow().year
y = datetime.now(timezone.utc).year
years = [y, y+1]
non_working = holidays.CA(years=years) + holidays.US(years=years) + holidays.UK(years=years) \
+ holidays.DE(years=years) + holidays.NO(years=years) + holidays.IND(years=years) + holidays.RU(years=years)


def vote_close_72h_date():
# Voting open at least 72 hours according to ASF policy
return datetime.utcnow() + timedelta(hours=73)
return datetime.now(timezone.utc) + timedelta(hours=73)


def vote_close_72h_holidays():
Expand Down
Loading