예제 #1
0
def status_refresher_data():
    try:
        w_status = wpa_cli.connection_status()
    except:
        return ["wpa_cli fail".center(o.cols)]
    #Getting data
    state = w_status['wpa_state']
    ip = w_status['ip_address'] if 'ip_address' in w_status else 'None'
    ap = w_status['ssid'] if 'ssid' in w_status else 'None'

    #Formatting strings for screen width
    if len(ap) > o.cols:  #AP doesn't fit on the screen
        ap = ellipsize(ap, o.cols)
    if o.cols >= len(ap) + len("SSID: "):
        ap = "SSID: " + ap
    ip_max_len = 15  #3x4 digits + 3 dots
    if o.cols >= ip_max_len + 4:  #disambiguation fits on the screen
        ip = "IP: " + ip
    data = [ap.center(o.cols), ip.center(o.cols)]

    #Formatting strings for screen height
    #Additional state info
    if o.rows > 2:
        data.append(("St: " + state).center(o.cols))
    #Button usage tips - we could have 3 rows by now, can we add at least two more?
    if o.rows >= 5:
        empty_rows = o.rows - 5  #ip, ap, state and two rows we'll add
        for i in range(empty_rows):
            data.append("")  #Padding
        data.append("ENTER: more info".center(o.cols))
        data.append("RIGHT: rescan".center(o.cols))

    return data
예제 #2
0
def select_channel():
    global config
    contents = []
    channels = amixer_get_channels()
    for channel in channels:
        contents.append([ellipsize(channel, o.cols), channel])
    channel = Listbox(contents, i, o, "Channel selection listbox").activate()
    if channel is None:
        return False
    config["channel"] = channel
    write_config(config, config_path)
예제 #3
0
파일: main.py 프로젝트: CRImier/pyLCI
def select_channel():
    global config
    contents = []
    channels = amixer_get_channels()
    for channel in channels:
        contents.append([ellipsize(channel, o.cols), channel])
    channel = Listbox(contents, i, o, "Channel selection listbox").activate()
    if channel is None:
        return False
    config["channel"] = channel
    write_config(config, config_path)
예제 #4
0
파일: main.py 프로젝트: CRImier/pyLCI
def show_devices():
    menu_contents = []
    try:
        usb_devices = lsusb.lsusb()
    except OSError:
        Printer(["Do you have", "lsusb?"], i, o, 2)
        return False
    for bus, dev, vid_pid, name in usb_devices:   
        ell_name = ellipsize(name, o.cols)
        menu_contents.append([["{}{},{}".format(bus, dev, vid_pid), ell_name], lambda x=name: Printer(x, i, o, skippable=True)])
    Menu(menu_contents, i, o, entry_height=2).activate()
예제 #5
0
def select_card():
    #TODO get a list of all cards
    global config
    contents = []
    cards = []
    for card in cards:
        contents.append([ellipsize(card["name"], o.cols), card["id"]])
    card_id = Listbox(contents, i, o, "Card selection listbox").activate()
    if card_id is None:
        return False
    config["card"] = card_id
    write_config(config, config_path)
예제 #6
0
def show_devices():
    menu_contents = []
    try:
        usb_devices = lsusb.lsusb()
    except OSError:
        Printer(["Do you have", "lsusb?"], i, o, 2)
        return False
    for bus, dev, vid_pid, name in usb_devices:
        ell_name = ellipsize(name, o.cols)
        menu_contents.append([["{}{},{}".format(bus, dev, vid_pid), ell_name],
                              lambda x=name: Printer(x, i, o, skippable=True)])
    Menu(menu_contents, i, o, entry_height=2).activate()
예제 #7
0
파일: main.py 프로젝트: CRImier/pyLCI
def select_card():
    #TODO get a list of all cards
    global config
    contents = []
    cards = [] 
    for card in cards:
        contents.append([ellipsize(card["name"], o.cols), card["id"]])
    card_id = Listbox(contents, i, o, "Card selection listbox").activate()
    if card_id is None:
        return False
    config["card"] = card_id
    write_config(config, config_path)
예제 #8
0
파일: main.py 프로젝트: hpagseddy/ZPUI
def callback():
    menu_contents = []
    try:
        usb_devices = lsusb.lsusb()
    except OSError:
        PrettyPrinter("Do you have lsusb?", i, o, 2)
        return False
    for bus, dev, vid_pid, name in usb_devices:
        name = name if name else "[Unknown]"
        ell_name = ellipsize(name, o.cols)
        info = "{}\n{}".format(vid_pid, name)
        menu_contents.append(
            [["D{},B{},{}".format(bus, dev, vid_pid), ell_name],
             lambda x=info: PrettyPrinter(x, i, o, skippable=True)])
    Menu(menu_contents, i, o, entry_height=2).activate()
예제 #9
0
파일: main.py 프로젝트: hpagseddy/ZPUI
def status_refresher_data():
    try:
        w_status = wpa_cli.connection_status()
    except:
        return ["wpa_cli fail".center(o.cols)]
    # This function is written for character displays
    # so, if you're wondering why there are magic numbers and weird formatting,
    # this is why =)
    #Getting data
    state = w_status['wpa_state']
    ip = w_status.get('ip_address', 'None')
    ap = w_status.get('ssid', 'None')

    #Formatting strings for screen width
    if len(ap) > o.cols:  #AP doesn't fit on the screen
        ap = ellipsize(ap, o.cols)
    if o.cols >= len(ap) + len("SSID: "):
        ap = "SSID: " + ap
    ip_max_len = 15  #3x4 digits + 3 dots
    if o.cols >= ip_max_len + 4:  #disambiguation fits on the screen
        ip = "IP: " + ip
    data = [ap.center(o.cols), ip.center(o.cols)]

    #Formatting strings for screen height
    #Additional state info
    if o.rows > 2:
        data.append(("St: " + state).center(o.cols))
    #Button usage tips - we could have 3 rows by now, can we add at least 3 more?
    if o.rows >= 6:
        empty_rows = o.rows - 6  #ip, ap, state and two rows we'll add
        for i in range(empty_rows):
            data.append("")  #Padding
        data.append("ENTER: more info".center(o.cols))
        data.append("UP: reconnect".center(o.cols))
        data.append("RIGHT: rescan".center(o.cols))

    return data
예제 #10
0
 def test_ellipsize(self):
     """Tests ellipsize"""
     text = "ooooooo"
     assert (ellipsize(text, 5) == "oo...")
     assert (ellipsize(text, 16) == text)
예제 #11
0
 def get_contents():
     return [[ellipsize("File: {}".format(file_path), o.cols), change_file],
             ["Interval: {}".format(interval), change_interval],
             ["Start", start_lecture]]