Пример #1
0
def show_not_su():
    # Show a message about the wizard not having super user (root or sudo) permissions

    button_dialog(title='Not a super user',
                  text=('''
eth-wizard needs to have super user permissions in order to proceed.

A simple way to give eth-wizard these permissions is to start it with sudo.
'''),
                  buttons=[('Quit', False)]).run()
Пример #2
0
def show_unsupported_platform():
    # Show a message about the current platform not being supported

    button_dialog(title='Platform not supported',
                  text=(HTML('''
eth-wizard has no support for your platform. We only support
the following platforms:

* <b>Ubuntu 20.04</b> (x86_64)
* <b>Windows 10</b> (amd64)
''')),
                  buttons=[('Quit', False)]).run()
Пример #3
0
def main_menu_app(title=MAIN_MENU_TITLE, text=MAIN_MENU_TEXT):
    return button_dialog(title=title, text=text, style=APP_STYLE, buttons=[
        ('Lessons',    'lessons'),
        ('Styles',     'styles'),
        ('About',      'about'),
        ('Quit',       None),
    ])
Пример #4
0
def main(session):

    # Choose option Login/Register

    student_register = button_dialog(
        title='Student Login',
        text='Choose Login to Continue or Get registered ',
        buttons=[
            ('Login', False),
            ('Register', True),
        ],
    ).run()

    if student_register:
        register(session)
    else:
        auth_status, username = stu_auth(session, is_stu=True)

        if auth_status:
            session.student_username = username
            stu_prompt(session)
        else:
            message_dialog(
                title='Authentication Failed',
                text='Invalid Username/Password. Press ENTER to try again.'
            ).run()
            main(session)
Пример #5
0
 def creation_loop(self):
     """Set up the main creation loop."""
     selection = button_dialog(title='Selection',
                               text='What would you like to create?',
                               buttons=[
                                   ('Machine', 'machine'),
                                   ('Mode', 'mode'),
                                   ('Show', 'show'),
                                   ('Cancel', 'cancel'),
                               ],
                               style=self.example_style).run()
     if selection == 'machine':
         self.create_machine_config()
     elif selection == 'mode':
         if self.in_machine_folder():
             self.create_mode()
         else:
             self.show_not_in_machine_folder_dialog()
     elif selection == 'show':
         if self.in_machine_folder():
             self.create_show()
         else:
             self.show_not_in_machine_folder_dialog()
     else:
         sys.exit()
     self.creation_loop()
Пример #6
0
    def cmd_delete(self, items: Iterable, args: str) -> Iterable:
        """Usage: | delete [--yes] |

        Calls the cleanup method on all resources.
        Won't ask for confirmation if --yes is provided.

        WARNING: THIS WILL IMMEDIATELY DELETE ALL INPUT RESOURCES
        """
        for item in items:
            if not isinstance(item, BaseResource):
                raise RuntimeError(
                    f"Item {item} is not a valid resource - deletion failed"
                )
            if args == "--yes":
                confirm_delete = True
            else:
                confirm_delete = button_dialog(
                    title=f"Delete {item.name}",
                    text=f"Really delete {item.name}?",
                    buttons=[("Yes", True), ("No", False), ("Abort", None)],
                ).run()

            if confirm_delete is None:
                break
            elif confirm_delete is True:
                item.cleanup(self.graph)
            yield item
Пример #7
0
    def cmd_delete(self, items: Iterable, args: str) -> Iterable:
        '''Usage: | delete [--yes]

        Calls the cleanup method on all resources.
        Won't ask for confirmation if --yes is provided.

        WARNING: THIS WILL IMMEDIATELY DELETE ALL INPUT RESOURCES
        '''
        for item in items:
            if not isinstance(item, BaseResource):
                raise RuntimeError(
                    f'Item {item} is not a valid resource - deletion failed')
            if args == '--yes':
                confirm_delete = True
            else:
                confirm_delete = button_dialog(
                    title=f'Delete {item.name}',
                    text=f'Really delete {item.name}?',
                    buttons=[('Yes', True), ('No', False), ('Abort', None)],
                ).run()

            if confirm_delete is None:
                break
            elif confirm_delete is True:
                item.cleanup(self.graph)
            yield item
def main():
    result = button_dialog(
        title="Button dialog example",
        text="Are you sure?",
        buttons=[("Yes", True), ("No", False), ("Maybe...", None),],
    ).run()

    print("Result = {}".format(result))
Пример #9
0
def aszarr(path, verbose, remap, flip, host, output):
    """
    Convert arbitrary dataset into Zarr dataset format.

    If OUTPUT is not specified, it will default to 'SOURCE.zarr'
    \f

    Args:
        path (str): path to the original dataset
        verbose (str, optional): how verbose should the logger behave
        output (str, optional): path to the destination
    """
    # we know this is annoying, silence it
    logging.getLogger("tifffile").setLevel(logging.ERROR)

    # convert verbose level
    verbose = 2 if verbose > 2 else verbose
    level = {0: "WARNING", 1: "INFO", 2: "DEBUG"}.get(verbose)
    coloredlogs.install(level=level,
                        fmt="%(asctime)s %(levelname)s %(message)s",
                        datefmt="%H:%M:%S")

    # ensure we does not have ambiguous input
    src_path = os.path.abspath(path)

    logger.info("loading source dataset")
    show_trace = logger.getEffectiveLevel() <= logging.DEBUG
    ds = open_dataset(src_path, show_trace=show_trace)
    ds = _remap_and_flip(ds, remap, flip)

    # generate the output
    if output is None:
        parent, dname = os.path.split(src_path)
        dst_path = os.path.join(parent, f"{dname}.zarr")
    else:
        dst_path = output
    logger.info(f'converted dataset will save to "{dst_path}"')

    dump, overwrite = True, False
    if os.path.exists(dst_path):
        # output already exists, ask user what's next
        dump, overwrite = button_dialog(
            title="Zarr dataset exists",
            text="What should we do?",
            buttons=[
                ("Skip", (False, None)),
                ("Update", (True, False)),
                ("Overwrite", (True, True)),
            ],
        ).run()
    else:
        dump, overwrite = True, False

    if dump:
        with get_client(address=host):
            ZarrDataset.dump(dst_path, ds, overwrite=overwrite)

    logger.info("complete zarr dataset conversion")
Пример #10
0
def choose_action():
    """
    Select which action to perform
    """
    return button_dialog(
        title='Options',
        text='What do you want to do?',
        buttons=[('Create', 0), ('Modify', 1), ('Delete', 2), ('Exit', 3)],
    )
Пример #11
0
def custom_temperature_dialog() -> button_dialog:
    return button_dialog(
        title="Min and Max Temperature values",
        text=
        "Do you want to set custom min and max temperature values or infer them from the images? You must enter "
        "both a min and max.",
        buttons=[
            ('Infer', False),
            ('Custom', True),
        ]).run()
Пример #12
0
def ask_large(n: int) -> bool:
    return button_dialog(
        title=f'High result count ({n})',
        text=
        f'You are trying to get {n} points, can this be correct? It could take long to load and execute...',
        buttons=[
            ('YES', True),
            ('No (edit)', False),
        ],
    ).run()
Пример #13
0
Файл: run.py Проект: wxnacy/et
def create_dialog():
    return button_dialog(
        title='Button dialog example',
        text='Are you sure?',
        buttons=[
            ('Yes', True),
            ('No', False),
            ('Maybe...', None),
        ],
    ).run()
Пример #14
0
def main(src_dir, dst_dir, dry_run, downsamples, chunk):
    """
    Convert Micro-Manager dataset to BigDataViewer complient XML/HDF5 format.
    \f

    Args:
        src_path (str): path to the MM dataset
        dst_path (str, optional): where to save the BDV dataset
        dry_run (bool, optinal): save XML only
        downsamples (tuple of int, optional): downsample ratio along (X, Y, Z) axis
        chunk (tuple of int, optional): chunk size
    """
    ds_src = open_dataset(src_dir, show_trace=True)

    if dst_dir is None:
        dst_dir = f"{src_dir}_bdv"

    if os.path.exists(dst_dir):
        dump = button_dialog(
            title="BDV dataset exists",
            text="What should we do?",
            buttons=[("Cancel", False), ("Overwrite", True)],
        ).run()
        if dump:
            # we have to unlink first
            logger.warning("remove previous dataset dump")
            rmtree(dst_dir)
    else:
        dump = True

    if dump:
        # NOTE we should already deal with FileExistError
        os.mkdir(dst_dir)

        # ensure downsamples is wrapped
        if isinstance(downsamples[0], int):
            downsamples = [downsamples]
        # reverse downsampling ratio
        downsamples = [tuple(reversed(s)) for s in downsamples]

        # reverse chunk size
        chunk = tuple(reversed(chunk))

        logger.info("convert to zarr dataset")
        try:
            BigDataViewerDataset.dump(
                dst_dir,
                ds_src,
                pyramid=downsamples,
                chunks=chunk,
                dry_run=dry_run,
            )
        except InvalidChunkSizeError as err:
            logger.error(str(err))
Пример #15
0
def menu() -> Any:
    result = button_dialog(
        title='Exemple de boîte de dialogue',
        text='Veuillez répondre à la question suivante:\nContinuer le programme?',
        buttons=[
            ('Oui', True),
            ('Non', False),
            ('Euh...', None)
        ]
    )
    return result
Пример #16
0
def menu():
  return button_dialog(
    title='Menu',
    text='',
    buttons=[
        ('Close Menu', False),
        ('Save', 1),
        ("Save As",3),
        ('Quit',2)
    ],
  )
def main():
    result = button_dialog(
        title='Button dialog example',
        text='Are you sure?',
        buttons=[
            ('Yes', True),
            ('No', False),
            ('Maybe...', None),
        ],
    )

    print('Result = {}'.format(result))
def main():
    result = button_dialog(
        title='Button dialog example',
        text='Are you sure?',
        buttons=[
            ('Yes', True),
            ('No', False),
            ('Maybe...', None),
        ],
    )

    print('Result = {}'.format(result))
Пример #19
0
def prompt_bool(
    for_attr: Optional[str] = None,
    prompt_msg: Optional[str] = None,
    dialog_title: str = "===",
) -> bool:

    m: str = create_prompt_string(bool, for_attr, prompt_msg)
    return button_dialog(
        title=dialog_title,
        text=m,
        buttons=[("True", True), ("False", False)],
        style=STYLE,
    ).run()
Пример #20
0
def quit_prompt():
    """
    Generic function to display a confirmation screen shown if
    user decides to cancel any operation.
    """
    result = button_dialog(
        title='Are you sure you want to exit?',
        text='Do you want to confirm?',
        buttons=[
            ('Yes', True),
            ('No', False),
        ],
    )
    return result
Пример #21
0
def show_whats_next(network, public_keys):
    # Show what's next including wait time

    beaconcha_in_url = BEACONCHA_IN_URLS[network]

    button_dialog(title='Installation completed',
                  text=(f'''
You just completed all the steps needed to become an active validator on
the {network.capitalize()} Ethereum network. You created {len(public_keys)} validator(s)
that will soon be activated.

You can monitor your activation period and all the details about your
validator(s) on the beaconcha.in website at the following URL:

{beaconcha_in_url}

If you have any question or if you need additional support, make sure
to get in touch with the ethstaker community on:

* Discord: discord.io/ethstaker
* Reddit: reddit.com/r/ethstaker
'''),
                  buttons=[('Quit', False)]).run()
Пример #22
0
def attention(msg, title=None):
    prefix = "Attention!"
    if title:
        _title = prefix + f' - {title}'
    else:
        _title = prefix

    buttons = [("Continue", True), ("Exit", False)]

    message = f"{msg}\n\nPress continue."

    btn_dialog = button_dialog(title=_title, text=message, buttons=buttons).run()

    return btn_dialog
Пример #23
0
def create(path):
    """
    Create action
    """
    create_type = button_dialog(
        title='Create',
        text='What do you want to create?',
        buttons=[('Zone', 0), ('Sector', 1), ('Exit', 3)],
    )

    if create_type == ZONE:
        create_zone(path)
    if create_type == SECTOR:
        create_sector(path)
    if create_type == EXIT:
        return
Пример #24
0
def prompt_ask_another(
    for_attr: Optional[str] = None,
    prompt_msg: Optional[str] = None,
    dialog_title: str = "===",
) -> bool:
    m = prompt_msg
    if m is None:
        assert (for_attr is not None
                ), "Expected 'for_attr'; an attribute name to prompt for!"
        m = f"Add another item to '{for_attr}'?"
    return button_dialog(
        title=dialog_title,
        text=m,
        buttons=[("Yes", True), ("No", False)],
        style=STYLE,
    ).run()
Пример #25
0
def delete(path):
    """
    Delete action
    """
    delete_type = button_dialog(
        title='Delete',
        text='What do you want to delete?',
        buttons=[('Zone', 0), ('Sector', 1), ('Exit', 3)],
    )

    if delete_type == ZONE:
        delete_zone(path)
    if delete_type == SECTOR:
        delete_sector(path)
    if delete_type == EXIT:
        return
 def execute_manual_step(self, message, default_error=""):
     # """Pauses test execution until user sets the keyword status.
     #
     # User can press either `PASS` or `FAIL` button. In the latter case execution
     # fails and an additional dialog is opened for defining the error message.
     #
     # `message` is the instruction shown in the initial dialog and
     # `default_error` is the default value shown in the possible error message
     # dialog.
     # """
     result = button_dialog(
         title="Did the test succeed?",
         text=message,
         buttons=[("Pass", "PASS"), ("Fail", "FAIL")],
     )
     if result == 'FAIL':
         # zzz
         pass
 def execute_manual_step(self, message, default_error=""):
     # """Pauses test execution until user sets the keyword status.
     #
     # User can press either `PASS` or `FAIL` button. In the latter case execution
     # fails and an additional dialog is opened for defining the error message.
     #
     # `message` is the instruction shown in the initial dialog and
     # `default_error` is the default value shown in the possible error message
     # dialog.
     # """
     result = button_dialog(
         title="Did the test succeed?",
         text=message,
         buttons=[("Pass", "PASS"), ("Fail", "FAIL")],
     )
     if result == 'FAIL':
         # zzz
         pass
Пример #28
0
def main(ds_src_dir, ds_dst_dir, client=None):
    logger.info("loading source dataset")
    ds_src = open_dataset(ds_src_dir)

    pprint(ds_src.metadata)

    logger.info("dump dataset info")
    for key, value in TiledDatasetIterator(ds_src,
                                           return_key=True,
                                           return_format="both"):
        print(key)
        print(value)
        print()

    with pd.option_context("display.max_rows", None):
        print(">> tile_coords")
        print(ds_src.tile_coords)
        print()
        print(">> inventory")
        print(ds_src.inventory)
        print()

    if os.path.exists(ds_dst_dir):
        dump = button_dialog(
            title="BDV dataset exists",
            text="What should we do?",
            buttons=[
                ("Skip", False),
                ("Overwrite", True),
            ],
        ).run()
        if dump:
            # we have to unlink first
            logger.warning("remove previous dataset dump")
            rmtree(ds_dst_dir)
    else:
        dump = True

    if dump:
        logger.info("convert to zarr dataset")
        BigDataViewerDataset.dump(ds_dst_dir,
                                  ds_src,
                                  pyramid=[(1, 1, 1), (2, 4, 4)],
                                  chunks=(16, 128, 128))
Пример #29
0
def prompt_resume(step):
    # Show prompt for user to resume from a previous step

    result = button_dialog(title='Previous installation found',
                           text=(HTML(f'''
It seems like you already started the wizard previously.

You were at following step: <b>{step.display_name}</b>

Would you like to resume at this step or restart the full setup from the
beginning?
''')),
                           buttons=[
                               ('Resume', 1),
                               ('Restart', 2),
                               ('Quit', False),
                           ]).run()

    return result
Пример #30
0
def main():
    setup_method = radiolist_dialog(
        values=[
            (0, 'Quick Setup (recommended)'),  # automatic setup
            (1, 'Ultra Setup (no questions)'),  # automatic setup, file mode
            (2, 'Manual (not recommended)')  # classic setup
        ],
        title='Welcome to JMK OS',
        text='How would you like to setup JMK OS?')
    if setup_method == 0:
        # UINFO variables
        new_password = ""
        new_2_password = ""
        pass_loop = True
        new_username = ""

        # ask for username and password
        new_username = input_dialog(title='Welcome to JMK OS',
                                    text='Please type a username to continue:')
        while pass_loop:
            new_password = input_dialog(title='Welcome to JMK OS',
                                        text='Please type a password:'******'Welcome to JMK OS',
                                          text='Confirm the password:'******'JMK OS 2.0',
                    text='Invalid passwords given.',
                    buttons=[('Retype', True)],
                )

    elif setup_method == 1:
        os.system('cls' if os.name == 'nt' else 'clear')
    elif setup_method == 2:
        os.system('cls' if os.name == 'nt' else 'clear')
    else:
        os.system('cls' if os.name == 'nt' else 'clear')
        print("Error loading JMK Setup. You must reinstall JMK OS.")
Пример #31
0
def show_welcome():
    # Show a welcome message about this wizard

    result = button_dialog(title='Welcome to eth-wizard!',
                           text=('''
This setup assistant is meant to guide anyone through the different steps
to become a fully functional validator on the Ethereum network. It will
install and configure all the software needed to become a validator. It
will test your installation. It will help you avoid the common pitfalls. It
will help you maintain and keep your setup updated.

If you have any question or if you need additional support, make sure
to get in touch with the ethstaker community on:

* Discord: discord.io/ethstaker
* Reddit: reddit.com/r/ethstaker
'''),
                           buttons=[('Start', True), ('Quit', False)]).run()

    return result
Пример #32
0
def main():
    if len(sys.argv) == 1:
        command_index = button_dialog(
            title="iOS Debug",
            text="Select an action:",
            buttons=[(command.name[0].upper() + command.name[1:], index)
                     for index, command in enumerate(commands)],
        ).run()

    else:
        command = sys.argv[1]
        command_names = [command.name for command in commands]
        try:
            command_index = command_names.index(command)
        except ValueError:
            print("Command not found.")
            print("Options:\n")
            _ = [print(name) for name in command_names]

    commands[command_index].execute()
    logger.delete_old_log_file()