Ejemplo n.º 1
0
    def __init__(self):
        self.system = Antenna()
        ant_list = self.system.get_list()
        self.target = Target()
        target_list = self.target.get_list()

        title = "INP Generator for Orbit ACUs"
        subtitle = "Choose your Antenna"
        # A menu to select our antenna
        selection = SelectionMenu.get_selection(ant_list,
                                                title=title,
                                                subtitle=subtitle)
        if selection == len(ant_list):
            sys.exit()

        sys_name = ant_list[selection]

        subtitle = "Using " + sys_name + ", Choose the target"
        # A menu to select our target
        selection = SelectionMenu.get_selection(target_list,
                                                title=title,
                                                subtitle=subtitle)
        if selection == len(target_list):
            sys.exit()

        target_name = target_list[selection]

        self.system.ready(sys_name)
        self.target.ready(target_name)
        self.target.ready_antenna(self.system.lat, self.system.lon,
                                  self.system.alt)
        self.target.generate_report()

        if self.target.rise_time is None:
            output = "\n\n  " + target_name + " doesn't rise in the next 12 hours...\n\n"
            print(output)
            sys.exit()
        else:
            output = "\n\n " + target_name + " will be up at " + self.target.rise_time + "\n"
            print(output)
            output = " The report ends or " + target_name + " fades at " + self.target.fade_time + "\n\n"
            print(output)
            filename = "/home/scheduler/Desktop/" + sys_name + "_" + target_name + ".orb"
            output = " Saving INP file to " + filename + "\n\n"
            print(output)
            with open(filename, 'w') as f:
                for line in self.target.report:
                    f.write(line)
            sys.exit()
Ejemplo n.º 2
0
def select_emulator_resolution():
    while True:
        selection = SelectionMenu.get_selection(
            [
                'Default - {} x {}: {}dpi'.format(
                    *DEFAULT_RESOLUTION.values()), 'Customize...'
            ],
            title="Select the emulator screen resolution:")
        if selection == 0:
            return DEFAULT_RESOLUTION
        elif selection == 1:
            width = click.prompt('Please enter emulator screen width',
                                 type=int)
            height = click.prompt('Please enter emulator screen height',
                                  type=int)
            density = click.prompt('Please enter emulator screen density',
                                   type=int)
            customized_resolution = {
                'width': width,
                'height': height,
                'density': density
            }
            if click.confirm(
                    "Please confirm your emulator screen resolution - {} x {}: {}dpi."
                    .format(*customized_resolution.values())):
                return customized_resolution
        elif selection == 2:
            sys.exit(1)
Ejemplo n.º 3
0
def update(name, col_search=None, val_search=None):
    try:
        cols = []
        vals = []
        val = 0
        if col_search == None:
            col_search = columns[name][SelectionMenu.get_selection(
                [i for i in columns[name]],
                show_exit_option=False,
                title="Choose column to search",
            )]
        if val_search == None:
            val_search = Screen().input("Enter value to update: ")
        Screen().println(
            'Enter columns, text values must be surrounded by "\'"')
        Screen().println("Empty lines will be ignored")
        for i in range(1, len(columns[name])):
            col = columns[name][i]
            val = Screen().input(f"{(col)}: ")
            if bool(val and not val.isspace()):
                cols.append(col)
                vals.append(val)
        ens = db.update(name, cols, vals, col_search, val_search)
        if isinstance(ens, Exception):
            Screen().input(f"Derror: {ens}")
            return
        else:
            Screen().input(f"Updated { ens } items")
    except Exception as e:
        Screen().input("\n".join(
            [f"CError: {e}", "Press any key to continue..."]))
Ejemplo n.º 4
0
def process_data(name, data, page, nested=None):
    if isinstance(data, Exception):
        Screen().input(f"DError: {data}")
        return
    subtitle = "".join(f"{i} " for i in columns[name])
    arr = [f" Page {page - 1}", f" Page {page + 1}"]
    for en in data:
        arr.append(" ".join(map(str, en)))
    sel = SelectionMenu.get_selection(arr, subtitle)
    if sel in range(2, len(arr)):
        subtitle = ""
        for i in range(len(columns[name])):
            subtitle += f"{columns[name][i]}: {data[sel - 2][i]}; "
        menu = ConsoleMenu("Item actions", subtitle)
        if name == "Seller" and nested == None:
            menu.append_item(
                FunctionItem("Find products", find_products,
                             [data[sel - 2][0], 1]))
        elif name == "Product" and nested == None:
            menu.append_item(
                FunctionItem("Find sellers", find_sellers,
                             [data[sel - 2][0], 1]))
        menu.append_item(
            FunctionItem("Edit", update,
                         [name, columns[name][0], data[sel - 2][0]]))
        menu.append_item(
            FunctionItem("Delete", delete,
                         [name, columns[name][0], data[sel - 2][0]]))
        menu.show()
    elif sel < 2:
        return sel + 1
def select_scan():

    global lightsheetPackages, lightsheetScanPaths, displayNames

    scanIndex = SelectionMenu.get_selection(displayNames)

    if scanIndex >= len(displayNames):
        return None

    scanName = displayNames[scanIndex]
    scan = lightsheetPackages[scanIndex]
    attribs = scan.get_filled_attr_dict()

    # TODO: Open the scan and spawn the GUI showing the metadata and thumbnail

    analysisList = ['3D Density Map', 'Stroke Volume', 'Vessel Diameter']

    scanMenu = ConsoleMenu(scanName, exit_option_text="Close Scan")
    viewAttribsItem = FunctionItem("View Metadata", show_scan_metadata,
                                   [attribs])
    viewMaxProjItem = FunctionItem("View Max-Proj", show_scan_maxproj,
                                   [attribs['maxProjPath'], attribs['name']])
    #selectAnalysisPackageItem = FunctionItem("View Analysis", select_existing_analysis, [analysisList])
    #createNewAnalysisPackageItem = FunctionItem("Import Analysis", perform_new_analysis, [analysisList])
    downloadScanItem = FunctionItem("Download Copy", download_scan,
                                    [scan.get_uniqueID()])
    scanMenu.append_item(viewAttribsItem)
    scanMenu.append_item(viewMaxProjItem)
    #scanMenu.append_item(selectAnalysisPackageItem)
    #scanMenu.append_item(createNewAnalysisPackageItem)
    scanMenu.append_item(downloadScanItem)
    scanMenu.show()
Ejemplo n.º 6
0
def autodetect_codec(path):
    if re.search("h.264", path, re.IGNORECASE) != None and (
            re.search("blu", path, re.IGNORECASE) != None
            or re.search("web", path, re.IGNORECASE) == None):
        return 'h.264 Remux'
    elif re.search("h.265", path, re.IGNORECASE) != None and (
            re.search("blu", path, re.IGNORECASE) != None
            or re.search("web", path, re.IGNORECASE) == None):
        return 'x264'
    elif re.search("x265", path, re.IGNORECASE) != None:
        return 'x265'
    elif re.search("x264", path, re.IGNORECASE) != None:
        return 'x264'
    elif re.search("VC-1 Remux", path, re.IGNORECASE) != None:
        return 'VC-1 Remux'
    elif re.search("MPEG2 Remux", path, re.IGNORECASE) != None:
        return 'MPEG2 Remux'

    upstring = f"{os.path.basename(path)}\nWhat is the codec of the Upload?"
    print(upstring)

    options = [
        "x264", "h.264 Remux", "x265", "h.265 Remux", "VC-1 Remux"
        "MPEG2 Remux"
    ]

    if sys.platform != "win32":
        menu = TerminalMenu(options)
        menu_entry_index = menu.show()
    else:
        menu_entry_index = SelectionMenu.get_selection(options)
    value = options[menu_entry_index]
    return value
Ejemplo n.º 7
0
    def action_write(args):
        i = 0
        data = []

        encoded_file = os.path.expanduser(args.write)

        while True:
            env_list = []
            if data:
                for osenv in data:
                    env = next(iter(osenv)).split("_")[0]
                    env_list.append("Delete {0} environment.".format(env))

            selection_list = ["Add a new OpenStack Environment"]
            selection_list.extend(env_list)
            selection_list.append(
                "Encode and write file {file}.".format(file=encoded_file))
            selection = SelectionMenu.get_selection(selection_list)

            i = len(env_list)

            if selection == 0:
                osenv = input(
                    "Input environment name for configuration and press [ENTER]: "
                )
                data.append(json.loads(OSEnvController.add_tenant(name=osenv)))
                #i += 1
            elif selection > 0 and selection <= i:
                if not input(
                        "Are you sure? (y/n): ").lower().strip()[:1] == "y":
                    break
                data.pop(selection - 1)
            elif selection == len(env_list) + 1:
                print("Encrypt and write file...")
                crypto = FileEncryption()
                crypto.encrypt_configfile(data=json.dumps(data),
                                          output_file=encoded_file)
                #crypto.encrypt_configfile(data=json.dumps(data), output_file=args.edit, key=userkey)

                if not os.path.isfile(encoded_file):
                    print("{0} file not found.".format(encoded_file))
                    break

                try:
                    os.chmod(encoded_file, 0o600)
                except OSError as e:
                    print(
                        "Couldn't change file permissions to 0600. Please change it, otherwise you are not able to read this file. [{0}]"
                        .format(e))

                print("File {file} written ...".format(file=encoded_file))
                print("Finish")
                return True

            elif selection == len(env_list) + 2:
                print("Program termination ...")
                # break
                # print(json.dumps(data))
                sys.exit()
Ejemplo n.º 8
0
def select_emulator():
    """Displayes an interactive menu to select a released emulator binary.

    Returns a ImuInfo object with the choice or None if the user aborts.    """
    emu_infos = [x for x in get_emus_info() if "linux" in x.urls]
    display = ["EMU {} {}".format(emu_info.channel, emu_info.version) for emu_info in emu_infos]
    selection = SelectionMenu.get_selection(display, title="Select the emulator you wish to use:")
    return emu_infos[selection] if selection < len(emu_infos) else None
Ejemplo n.º 9
0
def show_LibrMenu():
    libr_list = [
        "Add item", "Update item", "Archive a item", "Check borrowed items"
    ]
    selection_lib = SelectionMenu.get_selection(
        libr_list, "Digital Library Service - Librarian Functions",
        "Please select function:")
    return selection_lib
Ejemplo n.º 10
0
def show_UserMenu():
    user_list = [
        "List all contents", "Serch for contents", "Borrow an item",
        "Return item"
    ]
    selection_usr = SelectionMenu.get_selection(
        user_list, "Digital Library Service - User Functions",
        "Please select function:")
    return selection_usr
def select_image():
    img_infos = get_images_info()
    display = [
        "{} {} {} {}".format(img_info.tag, img_info.api, img_info.letter,
                             img_info.abi) for img_info in img_infos
    ]
    selection = SelectionMenu.get_selection(
        display, title='Select the system image you wish to use:')
    return img_infos[selection] if selection < len(img_infos) else None
def select_emulator():
    emu_infos = [x for x in get_emus_info() if 'linux' in x.urls]
    display = [
        "EMU {} {}".format(emu_info.channel, emu_info.version)
        for emu_info in emu_infos
    ]
    selection = SelectionMenu.get_selection(
        display, title='Select the emulator you wish to use:')
    return emu_infos[selection] if selection < len(emu_infos) else None
Ejemplo n.º 13
0
def select_image(arm):
    """Displayes an interactive menu to select a released system image.

    Returns a SysImgInfo object with the choice or None if the user aborts.    """
    img_infos = get_images_info(arm)
    display = [
        "{} {} {} ({})".format(img_info.api, img_info.letter, img_info.tag, img_info.abi) for img_info in img_infos
    ]
    selection = SelectionMenu.get_selection(display, title="Select the system image you wish to use:")
    return img_infos[selection] if selection < len(img_infos) else None
Ejemplo n.º 14
0
def desired_prorerty_submenu(desired_properties: List[DesiredProperty]):
    selected = SelectionMenu.get_selection(DESIRED_PROPERTY_OPTIONS.keys())
    if selected == DESIRED_PROPERTY_OPTIONS["POI"]:
        new_property = poi_type_selection_handler()
    elif selected == DESIRED_PROPERTY_OPTIONS["Rent"]:
        new_property = rent_handler()
    elif selected == DESIRED_PROPERTY_OPTIONS["Proximity to work"]:
        new_property = proximity_handler()
    elif selected == DESIRED_PROPERTY_OPTIONS["Safety Level"]:
        new_property = safety_handler()
    else:
        return
    desired_properties.append(new_property)
Ejemplo n.º 15
0
def get_imdb_info(path):

    details = guessit(path)
    title = details['title']
    if 'year' in details:
        title = "{} {}".format(title, details['year'])
    results = IMDb().search_movie(title)
    if len(results) == 0:
        bhdlogger.warn("Unable to find imdb")
        id = input("Please Enter imdb id: ")
        id = re.sub("https://www.imdb.com/title/", "", id)
        id = re.sub("tt", "", id)
        id = re.sub("/", "", id)
        results = IMDb().get_movie(id)
    bhdlogger.debug(results)
    if isinstance(results, list) != True:
        return results

    counter = 0
    accept = 'No'
    bhdlogger.warn("Searching for movie/TV Show on IMDB\n")
    while accept != "Yes":
        if counter == 6:
            id = input("Pleases Enter imdb id: ")
            id = re.sub("https://www.imdb.com/title/", "", id)
            id = re.sub("tt", "", id)
            id = re.sub("/", "", id)
            results = IMDb().get_movie(id)
            return results
        title = results[counter]['title']
        year = str(results[counter]['year'])
        t = f"{title}  {{ Movie Released-{year}}}"
        print(t)
        options = ["Yes", "No"]
        if sys.platform != "win32":
            menu = TerminalMenu(options)
            menu_entry_index = menu.show()
        else:
            menu_entry_index = SelectionMenu.get_selection(options)
        accept = options[menu_entry_index]
        if accept == "No":
            counter = counter + 1

    if accept == "No":
        id = input("Please Enter imdb id")
        id = re.sub("https://www.imdb.com/title/", "", id)
        id = re.sub("tt", "", id)
        id = re.sub("/", "", id)
        results = IMDb().get_movie(id)
        return results
    return results[counter]
def createMenu(options: list):
    """
    Creates a selection menu based on a list

    Args:
        options (list): A list of all the different options for the menu

    Returns:
        int: The integer index of the selected value.
    """

    selection = SelectionMenu.get_selection(options)

    return selection
Ejemplo n.º 17
0
    def getSelection(self):
        # Eğer Kullanıcı sayısı 0 ise dur
        if len(self._rows) == 0:
            log.write("Kullanıcı olmadığı için program durduruldu.", "error")
            exit()

        # Kullanıcı seçimi yaptır
        users_data = self._rows
        if self.opt_user == False:
            user_ids = self.ids()
            selection_list = ["Tüm Kullanıcılar"] + self.get('name')
            selection = SelectionMenu.get_selection(selection_list, title="EBABOT - HARİCİ CANLI DERS", subtitle="Lütfen işlem yapılacak kullanıcı seçimi yapın.", show_exit_option=False)
            if selection != 0:
                users_data = [self.find(user_ids[selection-1])]

        log.write("{} kullanıcı alındı.".format(len(users_data)), "header")

        return users_data
Ejemplo n.º 18
0
def delete(name, col_search=None, val_search=None):
    try:
        if col_search == None:
            col_search = columns[name][SelectionMenu.get_selection(
                [i for i in columns[name]],
                show_exit_option=False,
                title="Choose column to search",
            )]
        if val_search == None:
            val_search = Screen().input("Enter value to delete: ")
        ens = db.delete(name, col_search, val_search)
        if isinstance(ens, Exception):
            Screen().input(f"Derror: { ens }")
            return
        else:
            Screen().input(f"Deleted { ens } items")
    except Exception as e:
        Screen().input("\n".join(
            [f"CError: {e}", "Press any key to continue..."]))
Ejemplo n.º 19
0
def find_like(name):
    try:
        page = 1
        per_page = 15
        col = columns[name][SelectionMenu.get_selection(
            [i for i in columns[name]],
            show_exit_option=False,
            title="Choose column to search",
        )]
        val = Screen().input("Enter search: ")
        while True:
            data = db.find_like(name, col, val, (page - 1) * per_page,
                                per_page)
            proc = process_data(name, data, page)
            if proc == 1 and page > 1:
                page -= 1
            elif proc == 2:
                page += 1
            else:
                break
    except Exception as e:
        Screen().input("\n".join(
            [f"CError: {e}", "Press any key to continue..."]))
Ejemplo n.º 20
0
def autodetect_media_source(path):

    MEDIA_SOURCES = ['Blu-ray', 'HD-DVD', 'HDTV', 'WEB']
    if re.search("HDTV", path, re.IGNORECASE) != None:
        return 'HDTV'
    elif re.search("WEB", path, re.IGNORECASE) != None:
        return 'WEB'
    elif re.search("Blu-ray", path, re.IGNORECASE) != None or re.search(
            "Bluray", path, re.IGNORECASE) != None:
        return 'Blu-ray'
    elif re.search("HD-DVD", path, re.IGNORECASE) != None or re.search(
            "HDDVD", path, re.IGNORECASE) != None:
        return 'HD-DVD'
    elif re.search("DVD", path, re.IGNORECASE) != None:
        return 'DVD'
    upstring = f"{os.path.basename(path)}\nWhat is the Source of the Upload?"
    print(upstring)
    if sys.platform != "win32":
        menu = TerminalMenu(MEDIA_SOURCES)
        menu_entry_index = menu.show()
    else:
        menu_entry_index = SelectionMenu.get_selection(MEDIA_SOURCES)
    value = MEDIA_SOURCES[menu_entry_index]
    return value
Ejemplo n.º 21
0
def perform_new_analysis(analysisList):

    selection = SelectionMenu.get_selection(analysisList)
    print("Starting new " + str(selection) + " analysis!")
Ejemplo n.º 22
0
        if args.upload:
            print("Upload Mode\n")
            upload_emp(path, args)
            keepgoing = input("Continue Uploading?: ")
        if args.update:
            print("Update Template Mode\n")
            update_template(path, args)
            keepgoing = input("Update Another Template?: ")

    #batchmode
    while keepgoing == "Yes" or keepgoing == "yes" or keepgoing == "Y" or keepgoing == "y" or keepgoing == "YES":
        if sys.platform != "win32":
            menu = TerminalMenu(choices)
            menu_entry_index = menu.show()
        else:
            menu_entry_index = SelectionMenu.get_selection(choices)

        if menu_entry_index >= (len(choices)):
            continue
        try:
            path = choices[int(menu_entry_index)]

        except:
            bhdlogger.warn("Please Enter a Valid Value")
            continue
        path = os.path.join(args.media, path)
        #crete basename for some modes
        basename = os.path.basename(path)
        if os.path.isfile(basename):
            basename = os.path.splitext(basename)[:-1]
        if args.prepare:
Ejemplo n.º 23
0
            playlist = []

            with open(os.path.join(root, filename), 'r') as f:
                for line in f:
                    line = line.strip()
                    if line != '':
                        playlist.append(line)

            playlists[name] = playlist

    # selecting the playlists
    playlist_names = natsorted(playlists.keys())
    selected = []

    while True:
        sel = SelectionMenu.get_selection(playlist_names, "Select a playlist:")

        if sel > len(playlist_names) - 1:
            break

        selected.append(playlist_names[sel])

    print('Selected: ' + ', '.join(selected))
    sample_limit = int(input("Enter sample total size limit: "))

    # subset composition calculation
    a_total = 0.0
    for sel in selected:
        a_total += len(playlists[sel])

    s_nums = []
Ejemplo n.º 24
0
def select_existing_analysis(analysisList):

    selection = SelectionMenu.get_selection(analysisList)
    print("Getting " + str(selection) + "!")
Ejemplo n.º 25
0
    def action_edit(args):
        encoded_file = os.path.expanduser(args.edit)

        # Check if file exists
        if not os.path.isfile(encoded_file):
            print("{0} file not found.".format(encoded_file))
            sys.exit(1)

        # check permissions 0600
        st = os.stat(encoded_file)
        if oct(st.st_mode) > OSEnvController.FILE_PERMISSION:
            print("File {0} has the wrong permissions. \"0600\" are required.".
                  format(encoded_file))
            sys.exit(1)

        # read from file
        userkey = None
        try:
            userkey = getpass.getpass(
                prompt="Input master key and press [ENTER]: ")
            if userkey is not None and len(userkey) != 44:
                print("Wrong key length {length}, encryption process aborted!".
                      format(length=len(userkey)))
                sys.exit(1)
        except Exception as error:
            print("ERROR key", error)
            return None

        crypto = FileEncryption()
        json_data = crypto.decrypt_configfile(input_file=encoded_file,
                                              key=userkey)
        data = json.loads(json_data)

        while True:
            # print("List of available environments:\n")
            env_list = []
            if data:
                for osenv in data:
                    env = next(iter(osenv)).split("_")[0]
                    env_list.append("Delete {0} environment.".format(env))

            # Create menu
            selection_list = ["Add a new OpenStack Environment"]
            selection_list.extend(env_list)
            selection_list.append(
                "Encode and write file {file}.".format(file=encoded_file))
            selection_list.append("Show data array")
            selection = SelectionMenu.get_selection(selection_list)

            i = len(env_list)

            if selection == 0:
                # add new one
                osenv = input(
                    "Input environment name for configuration and press [ENTER]: "
                )
                data.append(json.loads(OSEnvController.add_tenant(name=osenv)))
            elif selection > 0 and selection <= i:
                if not input(
                        "Are you sure? (y/n): ").lower().strip()[:1] == "y":
                    break
                data.pop(selection - 1)
            elif selection == len(env_list) + 1:
                print("Encrypt and write file...")
                crypto.encrypt_configfile(data=json.dumps(data),
                                          output_file=args.edit,
                                          key=userkey)
                sys.exit(0)
            elif selection == len(env_list) + 2:
                print("Show data ...")
                pprint(data)
                pprint(env_list)
                input("Press Enter to continue...")
            elif selection == len(env_list) + 3:
                print("Program termination ...")
                sys.exit(0)
Ejemplo n.º 26
0
def show_MainMenu():
    main_list = ["User functions", "Librarioan functions"]
    selection_main = SelectionMenu.get_selection(main_list,
                                                 "Digital Library Service",
                                                 "Please select your role:")
    return selection_main
Ejemplo n.º 27
0
def main():
    figures = []
    print("Welcome to the Corona Data CLI")
    input("Press any key to select a location...")
    # get list of available locations
    data_response = get_file(csv_urls['confirmed'])

    choices = []
    choices_strings = []

    for row in data_response:

        if row[big_key] != '' and row[lil_key].count(',') == 0:
            choices.append({lil_key: row[lil_key], big_key: row[big_key]})

            if row[lil_key] == '':
                choices_strings.append(row[big_key])

            else:
                choices_strings.append(row[lil_key] + ' - ' + row[big_key])

    # have user choose location
    choices_map = {choices_strings[i]: i for i in range(len(choices))}
    choices_strings.sort()
    index = SelectionMenu.get_selection(choices_strings, title=lil_key)
    if index >= len(choices):
        exit()
    choice = choices[choices_map[choices_strings[index]]]

    # show feedback
    if choice[lil_key] == '':
        print('Building plot for', choice[big_key])

    else:
        print('Building plot for', choice[lil_key], ' - ', choice[big_key])

    # plot the data
    for csv_url in csv_urls:
        if choice[lil_key] == '':
            fig = plt.figure(num=csv_url + ' cases in ' + choice[big_key])
        else:
            fig = plt.figure(num=csv_url + ' cases in ' + choice[lil_key] +
                             ' - ' + choice[big_key])

        if choice[lil_key] == '':
            plot = fig.add_subplot(1,
                                   1,
                                   1,
                                   title=choice[big_key],
                                   xlabel='date',
                                   ylabel='number of cases')

        else:
            plot = fig.add_subplot(1,
                                   1,
                                   1,
                                   title=choice[lil_key] + ' ' +
                                   choice[big_key],
                                   xlabel='date',
                                   ylabel='number of cases')

        the_plot = plot_data(csv_url, plot, choice)
        if the_plot is not None:
            # configure the figure and show the plot
            plot.set_label(csv_url)
            plot.legend()
            fig.show()
        figures.append(fig)

    input("Press any key to continue, plots will be closed...")

    for a_fig in figures:
        plt.close(a_fig)

    figures.clear()
Ejemplo n.º 28
0
def poi_type_selection_handler() -> DesiredProperty:
    selected_poi_value = POI_OPTIONS[SelectionMenu.get_selection(POI_OPTIONS)]
    is_required = is_required_prompt()

    return PointOfInterest(poi_type=POI(selected_poi_value),
                           is_required=is_required)
Ejemplo n.º 29
0
def getSelectionResult(list, title, subtitle=None):
    var = SelectionMenu.get_selection(
        list, title=title, subtitle=subtitle, show_exit_option=False)
    return list[var]
Ejemplo n.º 30
0
                pile.append(a * b)
            elif e == "/":
                pile.append(a / b)
        else:
            if (e == "A"):
                pile.append(number)
            else:
                pile.append(int(e))
    return pile[0]

print("Searching COM ports...")
ports = serial.tools.list_ports.comports()
ports_name = []
for x in ports:
    ports_name.append(x.device)
selectionCOM = SelectionMenu.get_selection(ports_name, "Choose COM port")
if selectionCOM == len(ports_name):
    exit()

bauds = [9600, 19200, 38400, 57600, 115200, 230400]
selectionBAUD = SelectionMenu.get_selection(bauds, "Choose baudrate")
if selectionBAUD == len(bauds):
    exit()
    
try:
    connect = serial.Serial(ports_name[selectionCOM], bauds[selectionBAUD], timeout=TIMEOUT)
except OSError as err:
    print("OS error: {0}".format(err))
    exit()
try:
    connect.write(b"atz\r")