Beispiel #1
0
def save_solution():
    '''Save solution to file'''

    cli(CLEAR)
    write_log(['solve.log', s_moves])
    print('Saving solution to solve.log...')
    s_moves.clear()
    time.sleep(1)
    display()
Beispiel #2
0
def test_mult_solver():
    '''Test random generated cubes'''

    t_start = time.perf_counter()

    count = 10000
    cli(CLEAR)

    with multiprocessing.Pool() as pool:
        len_moves = pool.map(solver_call, range(count))

    t_end = time.perf_counter()

    print_perf_test(t_start, t_end, count, len_moves)
Beispiel #3
0
def install_db_dep():
    """
        Install Dependencies and Setup Database
    """
    cmd = "GRANT ALL PRIVILEGES ON *.* TO 'carely_admin'@'localhost' IDENTIFIED BY 'carely_admin';"
    cli("echo 'Installing Dependencies'")
    cli("pip3 install -r requirements.txt")
    cli('sudo mysql -u root -e "' + cmd + '"')
    cli("sudo mysql -u root -p < Data/Query/skeleton.sql")
Beispiel #4
0
def test_solver():
    '''Test random generated cubes'''

    t_start = time.process_time()

    count = 0
    len_moves = []
    cli(CLEAR)

    print('Solving: ', end='', flush=True)

    for count in range(1, 10001):
        print(count, end='', flush=True)
        len_moves.append(solver_call(None))
        print('\033[' + str(len("%i" % count)) + 'D', end='', flush=True)

    cli(CLEAR)
    t_end = time.process_time()

    print_perf_test(t_start, t_end, count, len_moves)
Beispiel #5
0
def display():
    '''Display cube'''

    cli(CLEAR)
    print('                ' + set_color(pieces[18]) + '  ' +
          set_color(pieces[19]) + '  ' + set_color(pieces[20]) + '        ' +
          '[SR] Shift right    [SL] Shift left')
    print('                ' + set_color(pieces[21]) + '  ' +
          set_color(pieces[22]) + '  ' + set_color(pieces[23]) + '        ' +
          '[SU] Shift up       [SD] Shift down')
    print('                ' + set_color(pieces[24]) + '  ' +
          set_color(pieces[25]) + '  ' + set_color(pieces[26]) + '        ' +
          '[RR] Rotate right   [RL] Rotate left')
    print('\r')
    print('         ' + L_ARROW + '[ 9]  ' + set_color(pieces[9]) + '  ' +
          set_color(pieces[10]) + '  ' + set_color(pieces[11]) + '  [10]' +
          R_ARROW + '')
    print('                ' + set_color(pieces[12]) + '  ' +
          set_color(pieces[13]) + '  ' + set_color(pieces[14]))
    print('         ' + L_ARROW + '[11]  ' + set_color(pieces[15]) + '  ' +
          set_color(pieces[16]) + '  ' + set_color(pieces[17]) + '  [12]' +
          R_ARROW + '')
    print('\r')
    print('                ' + '▲     ▲')
    print('               ' + '[5]   [7]')
    print('\r')
    print(
        set_color(pieces[36]) + '  ' + set_color(pieces[37]) + '  ' +
        set_color(pieces[38]) + '   ' + L_ARROW + '[1]  ' +
        set_color(pieces[0]) + '  ' + set_color(pieces[1]) + '  ' +
        set_color(pieces[2]) + '  [2]' + R_ARROW + '  ' +
        set_color(pieces[45]) + '  ' + set_color(pieces[46]) + '  ' +
        set_color(pieces[47]))

    print(
        set_color(pieces[39]) + '  ' + set_color(pieces[40]) + '  ' +
        set_color(pieces[41]) + '         ' + set_color(pieces[3]) + '  ' +
        set_color(pieces[4]) + '  ' + set_color(pieces[5]) + '        ' +
        set_color(pieces[48]) + '  ' + set_color(pieces[49]) + '  ' +
        set_color(pieces[50]))

    print(
        set_color(pieces[42]) + '  ' + set_color(pieces[43]) + '  ' +
        set_color(pieces[44]) + '   ' + L_ARROW + '[3]  ' +
        set_color(pieces[6]) + '  ' + set_color(pieces[7]) + '  ' +
        set_color(pieces[8]) + '  [4]' + R_ARROW + '  ' +
        set_color(pieces[51]) + '  ' + set_color(pieces[52]) + '  ' +
        set_color(pieces[53]))
    print('\r')
    print('               ' + '[6]   [8]')
    print('                ' + '▼     ▼')
    print('\r')
    print('                ' + set_color(pieces[27]) + '  ' +
          set_color(pieces[28]) + '  ' + set_color(pieces[29]) + '        ' +
          '[U]ndo last move    [S]ave moves')
    print('                ' + set_color(pieces[30]) + '  ' +
          set_color(pieces[31]) + '  ' + set_color(pieces[32]) + '        ' +
          '[M]ix the cube      [E]xit and save moves')
    print('                ' + set_color(pieces[33]) + '  ' +
          set_color(pieces[34]) + '  ' + set_color(pieces[35]) + '        ' +
          '[R]eset the cube    [Q]uit without saving')
    print('\r')
Beispiel #6
0
                    action="store_true",
                    help="Input of User Id for further function use")
# Here constant is stored in case no argument is passed
parser.add_argument("-r",
                    "--registration",
                    action="store_true",
                    help="To register new Carely User.")
parser.add_argument("-b",
                    "--booking",
                    action="store_true",
                    help="To Book Appointment")
parser.add_argument(
    "-v",
    "--view",
    const=True,
    nargs="?",
    help="to view records of Booking, Caretaker,Elderly,etc.",
)
arg = parser.parse_args()
print(arg)
if arg.registration:
    cli("python Main/Registration.py")
elif arg.view:
    if arg.id == False:
        cond = ""
    else:
        cond = " --id '" + arg.id + "'"
    cli("python Main/View.py --view" + cond)
elif arg.booking:
    cli("python Main/Booking.py")
Beispiel #7
0
from Utility.Utility import verify_user, invalid_user, chgdir
from argparse import ArgumentParser as ap
from os import system as cli

chgdir()
miscellaneous = "Miscellaneous Python file to Update Carely user records and confirm Booking status and Verify Carely Users "
parser = ap(description=miscellaneous)
parser.add_argument("-u",
                    "--update",
                    action="store_true",
                    help="To Book Appointment")
parser.add_argument("-v",
                    "--verification",
                    action="store_true",
                    help="To register new Carely User.")
args = parser.parse()

uid = input("Enter a Valid Carely Id")
if uid[:2] not in ["el,ct"]:
    invalid_user()
db = "Caretaker" if uid[:2] else "Elderly"
if verify_user(uid, db, "id"):
    if arg.update:
        cli("python Miscellaneous/Update.py -i '" + uid + "'")
    if arg.verification:
        cli("python Miscellaneous/Verification.py -i '" + uid + "'")
Beispiel #8
0
def load_data():
    # to load data from .csv to database using certain format
    # used command to export data out of mysql : sudo mysql -u root -e "use carelydb;select* from Caretaker;" | sed 's/\t/,/g' > Data/Sample_CSV/Caretaker.csv
    cli("sudo mysql -u root -p < Data/Query/load_cs_db.sql")