Socket
Socket
Sign inDemoInstall

ebx-checkbox

Package Overview
Dependencies
0
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ebx-checkbox

CheckBox and OptionBox to Python


Maintainers
1

Readme

CheckBox / OptionBox

Python class for creating list of CheckBox and OptionBox. CheckBox has the feature of being multi choice and OptionBox of simple choice.

Prerequisites

Developed and tested in Linux and Python 3.6

Installing

pip3 install ebx_checkbox

or from source:

python3 -m pip install [your_path]/ebx_checkbox/

Functions

get_CheckList

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

ParameterDescription
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:

  • Ctrl + A To check entire list
  • Ctrl + N To uncheck entire list
  • Space to select item
  • Arrows:
    -    Up: Move to the above item
    -    Down: Move to the item below
    -    Esc: Cancel selection and return -1

get_OptionList

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

ParameterDescription
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
SizeLimitLimit (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:

  • Space to select item
  • Arrows:
    -    Up: Move to the above item
    -    Down: Move to the item below
    -    Esc: Cancel selection and return -1

Examples of use

ex_checkbox.py:

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

Versioning

=======================================================================================
== Log Changes: 
== Date:            2021-05-13
== Author:          Fausto Branco
== Version:         1.0.1
== Description:     Initial Version
=================================================================================

License

FAQs


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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc