Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
Python class for creating list of CheckBox and OptionBox. CheckBox has the feature of being multi choice and OptionBox of simple choice.
Developed and tested in Linux and Python 3.6
pip3 install ebx_checkbox
or from source:
python3 -m pip install [your_path]/ebx_checkbox/
get_CheckList(str_Title, InitialLine, InitialColumn, SizeLimit, Options, ClearLine=True, Options_sets=[]):
Description: Create a list of checkBox and multiple choices, return a list of 1 (check) and 0 (uncheck) for all itens (on same order) of Options parameter
Parameter | Description |
---|---|
str_Title: | Title of the list |
InitialLine: | First line on screen where the list will br printed. |
InitialColumn: | Column on screen where the list will br printed. |
SizeLimit: | Limit (quantity) in lines that will be shown on screen, navigation is by Up and Down arrows. |
Options: | List of itens to be printed. |
ClearLine: | (True or False) Clear entire line before print?. |
Options_sets: | (Optional) List of predefined choices (mark) of 1 (Checked) or 0 (Unchecked). The list must have same len of Options, and set 1 on index that you want show checked. |
Return: List of 1 (check) and 0 (uncheck) for all itens (on same order) of Options parameter. -1 if canceled (Esc)
###Information:
get_OptionList (str_Title, InitialLine, InitialColumn, SizeLimit, Options, ClearLine=True, Options_Index=-1)
Description: Create a list of OptionBox and only one choice, return a list of 1 (check) and 0 (uncheck) for all itens (on same order) of Options parameter
Parameter | Description |
---|---|
str_Title: | Title of the list |
InitialLine: | First line on screen where the list will br printed |
InitialColumn: | Column on screen where the list will br printed |
SizeLimit | Limit (quantity) in lines that will be shown on screen, navigation is by Up and Down arrows |
Options: | List of itens to be printed |
ClearLine: | (True or False) Clear entire line before print? |
Options_Index: | (Optional) Index of predefined choice (mark) of 1 (Checked) or 0 (Unchecked). |
Return: List of 1 (check) and 0 (uncheck) for all itens (on same order) of Options parameter. -1 if canceled (Esc)
Information: ###Information:
import ebx_checklist
obj_Checklist = ebx_checklist.Options()
lst_Hosts = [{'IP': '15.128.89.74', 'DC': u'asia-dc'}, {'IP': '15.128.89.75', 'DC': u'asia-dc'}, {'IP': '15.128.89.76', 'DC': u'asia-dc'},
{'IP': '15.128.89.77', 'DC': u'asia-dc'}, {'IP': '15.128.89.78', 'DC': u'asia-dc'}, {'IP': '15.128.89.79', 'DC': u'asia-dc'},
{'IP': '15.128.89.80', 'DC': u'asia-dc'}, {'IP': '15.128.89.81', 'DC': u'asia-dc'}, {'IP': '15.128.89.88', 'DC': u'asia-dc'},
{'IP': '15.128.89.89', 'DC': u'asia-dc'}, {'IP': '15.128.89.90', 'DC': u'asia-dc'}, {'IP': '15.128.89.91', 'DC': u'asia-dc'},
{'IP': '15.128.89.92', 'DC': u'asia-dc'}, {'IP': '15.128.89.93', 'DC': u'asia-dc'}, {'IP': '15.128.89.94', 'DC': u'asia-dc'},
{'IP': '15.128.89.95', 'DC': u'asia-dc'}, {'IP': '15.128.89.96', 'DC': u'asia-dc'}, {'IP': '15.128.89.97', 'DC': u'asia-dc'},
{'IP': '15.128.89.98', 'DC': u'asia-dc'}, {'IP': '15.128.89.99', 'DC': u'asia-dc'}, {'IP': '15.128.89.100', 'DC': u'asia-dc'},
{'IP': '15.128.89.101', 'DC': u'asia-dc'}, {'IP': '15.128.89.102', 'DC': u'asia-dc'}, {'IP': '15.128.89.103', 'DC': u'asia-dc'},
{'IP': '15.130.89.74', 'DC': u'eu-dc'}, {'IP': '15.130.89.75', 'DC': u'eu-dc'}, {'IP': '15.130.89.76', 'DC': u'eu-dc'},
{'IP': '15.130.89.77', 'DC': u'eu-dc'}, {'IP': '15.130.89.78', 'DC': u'eu-dc'}, {'IP': '15.130.89.79', 'DC': u'eu-dc'},
{'IP': '15.130.89.80', 'DC': u'eu-dc'}, {'IP': '15.130.89.81', 'DC': u'eu-dc'}, {'IP': '15.130.89.82', 'DC': u'eu-dc'},
{'IP': '15.130.89.83', 'DC': u'eu-dc'}, {'IP': '15.130.89.84', 'DC': u'eu-dc'}, {'IP': '15.130.89.85', 'DC': u'eu-dc'},
{'IP': '15.130.89.92', 'DC': u'eu-dc'}, {'IP': '15.130.89.93', 'DC': u'eu-dc'}, {'IP': '15.130.89.94', 'DC': u'eu-dc'},
{'IP': '15.130.89.95', 'DC': u'eu-dc'}, {'IP': '15.130.89.96', 'DC': u'eu-dc'}, {'IP': '15.130.89.97', 'DC': u'eu-dc'},
{'IP': '15.130.89.98', 'DC': u'eu-dc'}, {'IP': '15.130.89.99', 'DC': u'eu-dc'}, {'IP': '15.130.89.100', 'DC': u'eu-dc'},
{'IP': '15.130.89.101', 'DC': u'eu-dc'}, {'IP': '15.130.89.102', 'DC': u'eu-dc'}, {'IP': '15.130.89.103', 'DC': u'eu-dc'},
{'IP': '15.135.51.19', 'DC': u'america-dc'}, {'IP': '15.135.51.20', 'DC': u'america-dc'}, {'IP': '15.135.51.21', 'DC': u'america-dc'},
{'IP': '15.135.51.22', 'DC': u'america-dc'}, {'IP': '15.135.51.23', 'DC': u'america-dc'}, {'IP': '15.135.51.24', 'DC': u'america-dc'},
{'IP': '15.135.187.74', 'DC': u'america-dc'}, {'IP': '15.135.187.75', 'DC': u'america-dc'}, {'IP': '15.135.187.76', 'DC': u'america-dc'},
{'IP': '15.135.187.77', 'DC': u'america-dc'}, {'IP': '15.135.187.78', 'DC': u'america-dc'}, {'IP': '15.135.187.79', 'DC': u'america-dc'},
{'IP': '15.135.187.86', 'DC': u'america-dc'}, {'IP': '15.135.187.87', 'DC': u'america-dc'}, {'IP': '15.135.187.88', 'DC': u'america-dc'},
{'IP': '15.135.187.89', 'DC': u'america-dc'}, {'IP': '15.135.187.90', 'DC': u'america-dc'}, {'IP': '15.135.187.91', 'DC': u'america-dc'},
{'IP': '15.135.187.92', 'DC': u'america-dc'}, {'IP': '15.135.187.93', 'DC': u'america-dc'}, {'IP': '15.135.187.94', 'DC': u'america-dc'},
{'IP': '15.135.187.95', 'DC': u'america-dc'}, {'IP': '15.135.187.96', 'DC': u'america-dc'}, {'IP': '15.135.187.97', 'DC': u'america-dc'}]
lst_OptionDCs = [d['DC'] for d in {v['DC']:v for v in lst_Hosts}.values()]
print("\033c")
###################################################################################################################################
lst_DataCentersCheck = obj_Checklist.get_OptionList('DC to restart', 5, 20, 20, lst_OptionDCs, ClearLine=True, Options_Index=-1)
lst_indexes = [index for index in range(len(lst_DataCentersCheck)) if lst_DataCentersCheck[index] == 1]
lst_DataCentersFilter = [lst_OptionDCs[i] for i in lst_indexes]
lst_OptionHosts = [d['DC'] + ' - ' + d['IP'] for d in lst_Hosts if d['DC'] in lst_DataCentersFilter]
lst_HostsCheck = obj_Checklist.get_CheckList('Hosts to restart', 5, 120, 20, lst_OptionHosts, ClearLine=False, Options_sets=[])
lst_tmp_hosts = [d['IP'] for d in lst_Hosts if d['DC'] in lst_DataCentersFilter]
lst_indexes = [index for index in range(len(lst_HostsCheck)) if lst_HostsCheck[index] == 1]
lst_DataCentersFilter = [lst_tmp_hosts[i] for i in lst_indexes]
for host in lst_DataCentersFilter:
print(host)
Call python:
python3 ex_checkbox.py
DC to restart Hosts to restart
( ) - asia-dc [ ] - eu-dc - 15.130.89.74
(O) - eu-dc [ ] - eu-dc - 15.130.89.75
( ) - america-dc [ ] - eu-dc - 15.130.89.76
[X] - eu-dc - 15.130.89.77
[ ] - eu-dc - 15.130.89.78
[X] - eu-dc - 15.130.89.79
[ ] - eu-dc - 15.130.89.80
[X] - eu-dc - 15.130.89.81
[ ] - eu-dc - 15.130.89.82
[ ] - eu-dc - 15.130.89.83
[X] - eu-dc - 15.130.89.84
[ ] - eu-dc - 15.130.89.85
[X] - eu-dc - 15.130.89.92
[ ] - eu-dc - 15.130.89.93
[X] - eu-dc - 15.130.89.94
[ ] - eu-dc - 15.130.89.95
[ ] - eu-dc - 15.130.89.96
[ ] - eu-dc - 15.130.89.97
[ ] - eu-dc - 15.130.89.98
[ ] - eu-dc - 15.130.89.99
=======================================================================================
== Log Changes:
== Date: 2021-05-13
== Author: Fausto Branco
== Version: 1.0.1
== Description: Initial Version
=================================================================================
FAQs
CheckBox and OptionBox to Python
We found that ebx-checkbox demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.