Exemplo n.º 1
0
#!/usr/bin/env python3
from blessings import Terminal
t = Terminal()
print(t.clear())
print(t.bold('Hi there!'))
print(t.move_down)
print(t.bold_red_on_bright_green('It hurts my eyes!'))
print(t.move_down + t.bold_underline_black_on_yellow(
    'Look! a 1997 web page! No, the font would have to be blinking'))
print(t.move_down)
print(" Terminal width: ", t.width)
print(" Terminal height: ", t.height)
print(t.move_down + "A one-liner way to show terminal width and height",
      t.reverse, t.width, "by", t.height, " ")
with t.location(20, t.height - 1):
    print(t.reverse + t.blink('This is at thebottom and printed in REVERSE. '))
Exemplo n.º 2
0
REQUIRED_KEYS = ['time_ms', 'code', 'result', 'exec', 'pid', 'cwd']
INVALID_FORKS = []
VALID_FORKS = []
REPORTS['EXEC_DURATIONS'] = {}
for F in FORKS:
    VALID = True
    for k in REQUIRED_KEYS:
        if not k in F:
            VALID = False
    if not VALID:
        INVALID_FORKS.append(F)
        FORKS.remove(F)
    else:
        VALID_FORKS.append(F)

VALID_FORKS_TXT = t.bold_red_on_bright_green('Valid Forks')

print('\n{} {} from {} extrace lines'.format(len(FORKS), VALID_FORKS_TXT,
                                             len(LINES)))
print('{} Invalid Forks'.format(len(INVALID_FORKS)))

REPORTS['UNIQUE_EXECS'] = unique(
    [o['exec'].split(' ')[0] for o in VALID_FORKS])

try:
    REPORTS['TOP_FORK_DURATIONS'] = sorted(VALID_FORKS,
                                           key=lambda F: F['time_ms'],
                                           reverse=True)
except Exception as e:
    print('Unable to sort top fork durations')
    print(VALID_FORKS)
Exemplo n.º 3
0
#!/usr/bin/env python3

from blessings import Terminal

t = Terminal()
print(t.clear())
print(t.bold("Hi there!"))
print(t.move_down)
print(t.bold_red_on_bright_green("It hurts my eyes!"))
print(t.move_down + t.bold_underline_black_on_yellow(
    "Look! A 1997 web page! No, the font would have to be blinking!"))
print(t.move_down)
print(" Terminal width: ", t.width)
print(" Terminal height: ", t.height)
print(t.move_down + "A one-liner way to show terminal width and height",
      t.reverse, t.width, "by", t.height, " ")
with t.location(20, t.height - 1):
    print(t.reverse + t.blink("This is at the bottom and printed in REVERSE."))
Exemplo n.º 4
0
from blessings import Terminal

t = Terminal()

print t.bold("Hi there!")
print t.bold_red_on_bright_green("It hurts my eyes!")

with t.location(0, t.height - 1):
    print "This is at the bottom."
def control_led_by_pot():
    try:
        while True:
            knob_val = adc.read_oneshot(POTI)
            print("Pot value is", hex(knob_val))
            pct_full_scale = min(1.0, knob_val / 0x4fffff)
            print("Pot % is", pct_full_scale)
            dac.write_dac(DAC_A, DEFAULT_LED_BIAS + int(LED_RANGE*pct_full_scale))

    except (KeyboardInterrupt):
        print("\n" * 8 + "User exit.\n")
    return


print(term.clear() + term.bold_red_on_bright_green(' Wavefront ADC/DAC Board with PiGPIO Demo '))
host = input('Raspberry Pi hostname (enter for localhost):')
hostName = host if host else 'localhost'
print(term.blue('Connecting to'), term.bold(hostName))

pi = io.pi(host)

if not pi.connected:
    print(term.white_on_red("Could not connect to PiGPIO target " + hostName + "!"))
    sys.exit(-1)

print(term.dim('...connection established'))
adc = ADS1256(pi=pi)
# calibrate
adc.cal_self()
dac = DAC8552(pi=pi)
from blessings import Terminal
from time import sleep

t = Terminal()

# TText formatting
print(t.bold('This text is bold'))
print(t.underline('This text is underline'))

# text color and highlight
print(t.red('Some red text'))
print(t.red_on_yellow('Text red on yellow'))

# compund formatting
print(t.bold_red_on_bright_green('Bold text red on bright green'))

# Normal text
print('Normal Text')


# Positioning Text
def position(x, y):
    with t.location(x, y):
        print(f'Text controlled by location ({x}, {y})')


for i in range(10):
    position(10 + i, t.height - i)

with t.fullscreen():
    # callable formats
Exemplo n.º 7
0
from blessings import Terminal
import time

t = Terminal()

print(t.bold("Hello world!"))
print(t.bold_red_on_bright_green("hurt my eyes!"))

with t.location(0, t.height-1):
    print("bottom!!!")

buffer = ""
for i in range(10):
    time.sleep(1)
    buffer += "#"
    with t.location(5, 10):
        print("[{: <10}]".format(buffer))
Exemplo n.º 8
0
import sys
import time

from blessings import Terminal

t = Terminal()

print t.bold('Hi there!')
print t.bold_red_on_bright_green('It hurts my eyes!')

with t.location(0, t.height - 1):
    print 'This is at the bottom.'

print t.move_down + 'hi'

inp = None
while inp != 'q':
    inp = t.getch()
    if inp:
        print 'hi:' +  inp