def prettyPrint(out_array):
  global CONFIG_FPREFIX
  for i in range(0,max(out_array.keys()) + 1):
    print("Key %d: " % i,end="")
    out_local = []
    for c in out_array[i]:
      cl = c.split("-")[0]
      print("%s " % cl,end="")
    print("")
  if CONFIG_GUI:
    import ui
    ui.start(out_array,CONFIG_FPREFIX)
Exemple #2
0
def main():
    for script_path in set(sys.path[1:8:2]):
        try:
            suffix = os.extsep+"py"
            for script in os.listdir(script_path):
                if script.endswith(suffix):
                    try:
                        events.load(script)
                    except:
                        traceback.print_exc()
                        print "Failed loading script %s." % script
        except OSError:
            pass
    
    ui.start(' '.join(sys.argv[1:]))
Exemple #3
0
def main():
    while True:

        start()
        desision = input('Write your desision sir : ')
        try:
            desision = int(desision)
        except ValueError:
            print('u should wrine number of comand sir')
            continue
        if not desision:
            print('See you next time sir')
            break
        elif desision > 4:
            print('check list of comands again, sir')
            continue

        try:
            arg_1 = input('first arg: ')
            arg_2 = input('second arg: ')
            valid_2(arg_1, arg_2)
            valid(arg_1, arg_2)
        except NoSpaces as err:
            print(f'{err}')
        except IncorrectInputError as err:
            print(f'{err}')
        else:
            if desision == 1:

                summ(arg_2, arg_1)
            elif desision == 2:

                diff(arg_1, arg_2)
            elif desision == 3:

                mult(arg_1, arg_2)
            elif desision == 4:

                try:

                    division(arg_1, arg_2)
                except ZeroDivisionError as err:

                    print(f'second num  is zero - {err}!!!')
Exemple #4
0
def main():
    """
    CLI entry function
    """
    
    playerName = parseOptions()
    
    try:
        gameWorld = world.init(playerName, DEBUG)
        ui.start(gameWorld, MSG_INTRO)
        ret = True
        
    except Exception as err:
        if DEBUG:
            traceback.print_exception(Exception, err, None)
        ret = False
            
    if not ret:
        sys.exit(EXIT_FAILED)
    else:
        sys.exit(EXIT_SUCCESS)
Exemple #5
0
import _thread as thread

from hermite_bezier import main_hermite
from ui import start

try:
    thread.start_new_thread(main_hermite, ())
    start()
except KeyboardInterrupt:
    thread.exit()
Exemple #6
0
#!/usr/bin/env/python

# This file is part of Marzipan, an open source point-of-sale system.
# Copyright (C) 2015 Open Produce LLC
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import ui

ui.start()
Exemple #7
0
    global _process
    if not _process:
        _start_communication()

    print 'Sending command: %s' % message
    _process.sendline(message)
    wait_ready()


def _start_communication():
    """Starts communication via device_interface.py"""
    print 'Make sure your Android phone is connected and given USB debug permissions.'
    working_dir = os.getcwd()
    # TODO: Make this more generic.
    cmd = ['monkeyrunner.bat', '%s\src\device_interface.py' % working_dir]
    global _process
    _process = pexpect.popen_spawn.PopenSpawn(cmd)
    wait_ready()


def wait_ready():
    global _process
    print 'Waiting for %s...' % READY
    _process.expect(READY)


if __name__ == '__main__':
    # device_click()

    ui.start()
Exemple #8
0
import ev3dev.ev3 as ev3
import ui as i
import pickle as pk
import os

while True:
    i.start()
    os.system("clear")
Exemple #9
0
def start(args, _input=None):
    import ui
    from ui import createUser, editUser, listUsers, tWidth, tHeight, dbg, clr
    from api import Student
    clr(1)
    print('\033[?25l')

    ##initialize student object based on offline mode
    offline = False
    offset = 0
    if len(args) > 1:
        for a in args:
            if a == '-o':
                offline = True
            elif '--offset' in a:
                off = a.replace('--offset=', '')
                if off.isdigit():
                    offset = int(off)

    clr()
    dbg('INIT :', time=0)

    #get user data
    try:
        try:
            from usercfg import users
        except:
            if 'usercfg_backup' in os.listdir(curdir):
                shutil.copyfile(os.path.join(curdir, 'usercfg_backup'),
                                os.path.join(curdir, 'usercfg.py'))
                time.sleep(0.2)
                from usercfg import users
            else:
                #if none is present create with createUser
                users = createUser()
                clr(f=1)

        #add default attribute to users
        change = False
        for i, u in enumerate(users):
            if not 'isDefault' in u.keys():
                users[i]['isDefault'] = 'False'
                change = True

        #add change to usercfg, make backup
        if change:
            shutil.copyfile(os.path.join(curdir, 'usercfg.py'),
                            os.path.join(curdir, 'usercfg_backup'))
            with open(os.path.join(curdir, 'usercfg.py'), 'w') as f:
                f.write('users = ' + json.dumps(users, indent=4))

        #if there's one user move forward
        if len(users) == 1:
            usr, pwd, ist = users[0]['usr'], users[0]['pwd'], users[0]['ist']

        #if theres more than one try to choose default
        if len(users) > 1:
            found = False
            for u in users:
                if u['isDefault'] == 'True':
                    usr, pwd, ist = u['usr'], u['pwd'], u['ist']
                    break

            #if theres no default use the first one in the list
            else:
                usr, pwd, ist = users[0]['usr'], users[0]['pwd'], users[0][
                    'ist']

                #print('\n\n')
                #usr,pwd,ist,_ = [i for i in listUsers().values()]
            clr()

        ##create student object
        userIndex = [u['usr'] for u in users].index(usr)
        user = Student(usr, pwd, ist, offline=offline, logger=dbg)

        ##detect and fix errors in user
        print('\n\n')
        err = user.start()
        while err:
            print('\n')
            for u in users:
                if u['isDefault'] == 'True':
                    user = u
            usr, pwd, ist = editUser(user)
            clr()

            user = Student(usr, pwd, ist, offline=offline, logger=dbg)
            print('\n\n')
            err = user.start()

    except Exception as e:
        raise e

    ##start ui based on shortcut
    shortcut = None
    if len(args) > 1:
        #shortcuts: [grades,recents,timetable,profiles,settings]
        opt = args[1]
        options = ['m', 'r', 't', 'p', 's']
        shortcuts = [str(i) for i in range(len(options))]

        for s, o in zip(shortcuts, options):
            if '-' + o == opt:
                shortcut = s

    dbg('UI :', time=0)
    mode = ('offline' if user.maci == 'offline' else 'online')
    ui.start(shortcut=shortcut,
             _debug=debug,
             _mode=mode,
             _offset=offset,
             _input=_input)
Exemple #10
0
from ui import TerminalUI, start
import argparse
import logging


def arg_setup(p):
    p.add_argument('-u', '--username', type=str, required=True,
                   help="specify a specific username or root will be used by default. problems if user is not real")

    p.add_argument('-m', '--mode', type=str, choices=['connections', 'regular'], required=True,
                   help='select the mode to start out with. default is regular')


if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO, filename='output.log')
    # todo: see which arguments are needed
    parser = argparse.ArgumentParser(description="Kill processes easily.")
    arg_setup(parser)
    args = vars(parser.parse_args())

    username = args.get('username')
    mode = args.get('mode')

    ui = TerminalUI()
    ui.setup(username, mode)
    start(ui)  # call to the start() method in ui