Esempio n. 1
0
def cli():
    cli = CommandLineInterface()

    @cli.command
    def inc(x):
        print(int(x) + 1)

    @cli.command
    def add(x, y):
        print(int(x) + int(y))

    return cli
Esempio n. 2
0
# usr/bin/env python3

from cli import CommandLineInterface


if __name__ == "__main__":
    try:
        cli = CommandLineInterface()
        cli.run()
    except KeyboardInterrupt:
        exit(0)
Esempio n. 3
0
        # If thought data dosen't match thought size
        if (actual_thought_data_size != thought_size):
            raise RuntimeError(CThought.ERROR_DATA_INCOMPLETE)

        # Parse thought data
        parsed_thought_data = CThought.parse_thought_data(raw_thought_data)

        # Writing user thought to disk
        self.write_user_thought(datetime_formatted, user_id_number,
                                parsed_thought_data)


from cli import CommandLineInterface

cli = CommandLineInterface()


@cli.command
def run(address, data):
    # Parse server address
    server_ip_str, server_port_str = address.split(":")
    server_port_int = int(server_port_str)

    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    server.bind((server_ip_str, server_port_int))
    server.listen(1000)

    while True:
        # Accept client
Esempio n. 4
0
def start_ui(log_queue, config):
    """ Start the user interface """
    ui = CommandLineInterface(log_queue, config=config)
    curses.wrapper(ui.run)
Esempio n. 5
0
from cli import CommandLineInterface


cli = CommandLineInterface()


@cli.command
def inc(x):
    print(int(x) + 1)


@cli.command
def add(x, y):
    print(int(x) + int(y))


if __name__ == '__main__':
    cli.main()
Esempio n. 6
0
from sys import argv
from time import time, ctime
from os.path import dirname, realpath, join
from cli import CommandLineInterface
from managers import SessionManager, LibraryManager
from factory import Factory
from utils import ppDict

SESSION = '.cascade'
ROOT = dirname(realpath(__file__))
DATA = join(ROOT, '../data')
DEFAULT_CONFIG = join(DATA, 'default.json')
LIB_DATA_FILE = join(DATA, 'libraries.json')

cas = CommandLineInterface()
sesmgr = SessionManager(SESSION, ROOT, DEFAULT_CONFIG)
libmgr = LibraryManager(LIB_DATA_FILE)

for cmd in sesmgr.commands:
    cas.addCommand(*cmd)
for cmd in libmgr.commands:
    cas.addCommand(*cmd)

libmgr.load()
# print(ppDict(libmgr.libraries))

Factory.create(cas)
cas.parse(argv)

if cas.command in sesmgr.handles: