mirror of https://github.com/apache/lucene.git
ReleaseWizard - Upgrade 'consolemenu' dependency to v0.7.1 (#11855)
Ported from https://github.com/apache/solr/pull/1020 Also pin python versions in requirements.txt to avoid unexpected incompatibilties in the future Co-authored-by: Jan Høydahl <janhoy@users.noreply.github.com>
This commit is contained in:
parent
d62fb5309e
commit
5f1c726807
|
@ -63,7 +63,6 @@ except:
|
||||||
import scriptutil
|
import scriptutil
|
||||||
from consolemenu import ConsoleMenu
|
from consolemenu import ConsoleMenu
|
||||||
from consolemenu.items import FunctionItem, SubmenuItem, ExitItem
|
from consolemenu.items import FunctionItem, SubmenuItem, ExitItem
|
||||||
from consolemenu.screen import Screen
|
|
||||||
from scriptutil import BranchType, Version, download, run
|
from scriptutil import BranchType, Version, download, run
|
||||||
|
|
||||||
# Lucene-to-Java version mapping
|
# Lucene-to-Java version mapping
|
||||||
|
@ -654,8 +653,8 @@ class TodoGroup(SecretYamlObject):
|
||||||
return "%s%s (%d/%d)" % (prefix, self.title, self.num_done(), self.num_applies())
|
return "%s%s (%d/%d)" % (prefix, self.title, self.num_done(), self.num_applies())
|
||||||
|
|
||||||
def get_submenu(self):
|
def get_submenu(self):
|
||||||
menu = UpdatableConsoleMenu(title=self.title, subtitle=self.get_subtitle, prologue_text=self.get_description(),
|
menu = ConsoleMenu(title=self.title, subtitle=self.get_subtitle, prologue_text=self.get_description(),
|
||||||
screen=MyScreen())
|
clear_screen=False)
|
||||||
menu.exit_item = CustomExitItem("Return")
|
menu.exit_item = CustomExitItem("Return")
|
||||||
for todo in self.get_todos():
|
for todo in self.get_todos():
|
||||||
if todo.applies(state.release_type):
|
if todo.applies(state.release_type):
|
||||||
|
@ -663,7 +662,7 @@ class TodoGroup(SecretYamlObject):
|
||||||
return menu
|
return menu
|
||||||
|
|
||||||
def get_menu_item(self):
|
def get_menu_item(self):
|
||||||
item = UpdatableSubmenuItem(self.get_title, self.get_submenu())
|
item = SubmenuItem(self.get_title, self.get_submenu())
|
||||||
return item
|
return item
|
||||||
|
|
||||||
def get_todos(self):
|
def get_todos(self):
|
||||||
|
@ -820,7 +819,7 @@ class Todo(SecretYamlObject):
|
||||||
print("ERROR while executing todo %s (%s)" % (self.get_title(), e))
|
print("ERROR while executing todo %s (%s)" % (self.get_title(), e))
|
||||||
|
|
||||||
def get_menu_item(self):
|
def get_menu_item(self):
|
||||||
return UpdatableFunctionItem(self.get_title, self.display_and_confirm)
|
return FunctionItem(self.get_title, self.display_and_confirm)
|
||||||
|
|
||||||
def clone(self):
|
def clone(self):
|
||||||
clone = Todo(self.id, self.title, description=self.description)
|
clone = Todo(self.id, self.title, description=self.description)
|
||||||
|
@ -1234,104 +1233,6 @@ def pause(fun=None):
|
||||||
input("\nPress ENTER to continue...")
|
input("\nPress ENTER to continue...")
|
||||||
|
|
||||||
|
|
||||||
# Custom classes for ConsoleMenu, to make menu texts dynamic
|
|
||||||
# Needed until https://github.com/aegirhall/console-menu/pull/25 is released
|
|
||||||
# See https://pypi.org/project/console-menu/ for other docs
|
|
||||||
|
|
||||||
class UpdatableConsoleMenu(ConsoleMenu):
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return "%s: %s. %d items" % (self.get_title(), self.get_subtitle(), len(self.items))
|
|
||||||
|
|
||||||
def draw(self):
|
|
||||||
"""
|
|
||||||
Refreshes the screen and redraws the menu. Should be called whenever something changes that needs to be redrawn.
|
|
||||||
"""
|
|
||||||
self.screen.printf(self.formatter.format(title=self.get_title(), subtitle=self.get_subtitle(), items=self.items,
|
|
||||||
prologue_text=self.get_prologue_text(), epilogue_text=self.get_epilogue_text()))
|
|
||||||
|
|
||||||
# Getters to get text in case method reference
|
|
||||||
def get_title(self):
|
|
||||||
return self.title() if callable(self.title) else self.title
|
|
||||||
|
|
||||||
def get_subtitle(self):
|
|
||||||
return self.subtitle() if callable(self.subtitle) else self.subtitle
|
|
||||||
|
|
||||||
def get_prologue_text(self):
|
|
||||||
return self.prologue_text() if callable(self.prologue_text) else self.prologue_text
|
|
||||||
|
|
||||||
def get_epilogue_text(self):
|
|
||||||
return self.epilogue_text() if callable(self.epilogue_text) else self.epilogue_text
|
|
||||||
|
|
||||||
|
|
||||||
class UpdatableSubmenuItem(SubmenuItem):
|
|
||||||
def __init__(self, text, submenu, menu=None, should_exit=False):
|
|
||||||
"""
|
|
||||||
:ivar ConsoleMenu self.submenu: The submenu to be opened when this item is selected
|
|
||||||
"""
|
|
||||||
super(UpdatableSubmenuItem, self).__init__(text=text, menu=menu, should_exit=should_exit, submenu=submenu)
|
|
||||||
|
|
||||||
if menu:
|
|
||||||
self.get_submenu().parent = menu
|
|
||||||
|
|
||||||
def show(self, index):
|
|
||||||
return "%2d - %s" % (index + 1, self.get_text())
|
|
||||||
|
|
||||||
# Getters to get text in case method reference
|
|
||||||
def get_text(self):
|
|
||||||
return self.text() if callable(self.text) else self.text
|
|
||||||
|
|
||||||
def set_menu(self, menu):
|
|
||||||
"""
|
|
||||||
Sets the menu of this item.
|
|
||||||
Should be used instead of directly accessing the menu attribute for this class.
|
|
||||||
|
|
||||||
:param ConsoleMenu menu: the menu
|
|
||||||
"""
|
|
||||||
self.menu = menu
|
|
||||||
self.get_submenu().parent = menu
|
|
||||||
|
|
||||||
def action(self):
|
|
||||||
"""
|
|
||||||
This class overrides this method
|
|
||||||
"""
|
|
||||||
self.get_submenu().start()
|
|
||||||
|
|
||||||
def clean_up(self):
|
|
||||||
"""
|
|
||||||
This class overrides this method
|
|
||||||
"""
|
|
||||||
self.get_submenu().join()
|
|
||||||
self.menu.clear_screen()
|
|
||||||
self.menu.resume()
|
|
||||||
|
|
||||||
def get_return(self):
|
|
||||||
"""
|
|
||||||
:return: The returned value in the submenu
|
|
||||||
"""
|
|
||||||
return self.get_submenu().returned_value
|
|
||||||
|
|
||||||
def get_submenu(self):
|
|
||||||
"""
|
|
||||||
We unwrap the submenu variable in case it is a reference to a method that returns a submenu
|
|
||||||
"""
|
|
||||||
return self.submenu if not callable(self.submenu) else self.submenu()
|
|
||||||
|
|
||||||
|
|
||||||
class UpdatableFunctionItem(FunctionItem):
|
|
||||||
def show(self, index):
|
|
||||||
return "%2d - %s" % (index + 1, self.get_text())
|
|
||||||
|
|
||||||
# Getters to get text in case method reference
|
|
||||||
def get_text(self):
|
|
||||||
return self.text() if callable(self.text) else self.text
|
|
||||||
|
|
||||||
|
|
||||||
class MyScreen(Screen):
|
|
||||||
def clear(self):
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
class CustomExitItem(ExitItem):
|
class CustomExitItem(ExitItem):
|
||||||
def show(self, index):
|
def show(self, index):
|
||||||
return super(CustomExitItem, self).show(index)
|
return super(CustomExitItem, self).show(index)
|
||||||
|
@ -1346,6 +1247,13 @@ def main():
|
||||||
global templates
|
global templates
|
||||||
|
|
||||||
print("Lucene releaseWizard v%s" % getScriptVersion())
|
print("Lucene releaseWizard v%s" % getScriptVersion())
|
||||||
|
|
||||||
|
try:
|
||||||
|
ConsoleMenu(clear_screen=True)
|
||||||
|
except Exception as e:
|
||||||
|
sys.exit("You need to install 'consolemenu' package version 0.7.1 for the Wizard to function. Please run 'pip "
|
||||||
|
"install -r requirements.txt'")
|
||||||
|
|
||||||
c = parse_config()
|
c = parse_config()
|
||||||
|
|
||||||
if c.dry:
|
if c.dry:
|
||||||
|
@ -1402,18 +1310,18 @@ def main():
|
||||||
lucene_news_file = os.path.join(state.get_website_git_folder(), 'content', 'core', 'core_news',
|
lucene_news_file = os.path.join(state.get_website_git_folder(), 'content', 'core', 'core_news',
|
||||||
"%s-%s-available.md" % (state.get_release_date_iso(), state.release_version.replace(".", "-")))
|
"%s-%s-available.md" % (state.get_release_date_iso(), state.release_version.replace(".", "-")))
|
||||||
|
|
||||||
main_menu = UpdatableConsoleMenu(title="Lucene ReleaseWizard",
|
main_menu = ConsoleMenu(title="Lucene ReleaseWizard",
|
||||||
subtitle=get_releasing_text,
|
subtitle=get_releasing_text,
|
||||||
prologue_text="Welcome to the release wizard. From here you can manage the process including creating new RCs. "
|
prologue_text="Welcome to the release wizard. From here you can manage the process including creating new RCs. "
|
||||||
"All changes are persisted, so you can exit any time and continue later. Make sure to read the Help section.",
|
"All changes are persisted, so you can exit any time and continue later. Make sure to read the Help section.",
|
||||||
epilogue_text="® 2022 The Lucene project. Licensed under the Apache License 2.0\nScript version v%s)" % getScriptVersion(),
|
epilogue_text="® 2022 The Lucene project. Licensed under the Apache License 2.0\nScript version v%s)" % getScriptVersion(),
|
||||||
screen=MyScreen())
|
clear_screen=False)
|
||||||
|
|
||||||
todo_menu = UpdatableConsoleMenu(title=get_releasing_text,
|
todo_menu = ConsoleMenu(title=get_releasing_text,
|
||||||
subtitle=get_subtitle,
|
subtitle=get_subtitle,
|
||||||
prologue_text=None,
|
prologue_text=None,
|
||||||
epilogue_text=None,
|
epilogue_text=None,
|
||||||
screen=MyScreen())
|
clear_screen=False)
|
||||||
todo_menu.exit_item = CustomExitItem("Return")
|
todo_menu.exit_item = CustomExitItem("Return")
|
||||||
|
|
||||||
for todo_group in state.todo_groups:
|
for todo_group in state.todo_groups:
|
||||||
|
@ -1422,14 +1330,14 @@ def main():
|
||||||
menu_item.set_menu(todo_menu)
|
menu_item.set_menu(todo_menu)
|
||||||
todo_menu.append_item(menu_item)
|
todo_menu.append_item(menu_item)
|
||||||
|
|
||||||
main_menu.append_item(UpdatableSubmenuItem(get_todo_menuitem_title, todo_menu, menu=main_menu))
|
main_menu.append_item(SubmenuItem(get_todo_menuitem_title, todo_menu, menu=main_menu))
|
||||||
main_menu.append_item(UpdatableFunctionItem(get_start_new_rc_menu_title, start_new_rc))
|
main_menu.append_item(FunctionItem(get_start_new_rc_menu_title, start_new_rc))
|
||||||
main_menu.append_item(UpdatableFunctionItem('Clear and restart current RC', state.clear_rc))
|
main_menu.append_item(FunctionItem('Clear and restart current RC', state.clear_rc))
|
||||||
main_menu.append_item(UpdatableFunctionItem("Clear all state, restart the %s release" % state.release_version, reset_state))
|
main_menu.append_item(FunctionItem("Clear all state, restart the %s release" % state.release_version, reset_state))
|
||||||
main_menu.append_item(UpdatableFunctionItem('Start release for a different version', release_other_version))
|
main_menu.append_item(FunctionItem('Start release for a different version', release_other_version))
|
||||||
main_menu.append_item(UpdatableFunctionItem('Generate Asciidoc guide for this release', generate_asciidoc))
|
main_menu.append_item(FunctionItem('Generate Asciidoc guide for this release', generate_asciidoc))
|
||||||
# main_menu.append_item(UpdatableFunctionItem('Dump YAML', dump_yaml))
|
# main_menu.append_item(FunctionItem('Dump YAML', dump_yaml))
|
||||||
main_menu.append_item(UpdatableFunctionItem('Help', help))
|
main_menu.append_item(FunctionItem('Help', help))
|
||||||
|
|
||||||
main_menu.show()
|
main_menu.show()
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
six>=1.11.0
|
six~=1.16.0
|
||||||
Jinja2>=2.10.1
|
Jinja2~=3.1.1
|
||||||
PyYAML>=5.1
|
PyYAML~=6.0
|
||||||
holidays>=0.9.10
|
holidays~=0.16
|
||||||
ics>=0.4
|
ics~=0.7.2
|
||||||
console-menu>=0.5.1
|
console-menu~=0.7.1
|
||||||
PyGithub
|
PyGithub~=1.56
|
||||||
jira
|
jira~=3.4.1
|
Loading…
Reference in New Issue