示例#1
0
def main(l, outputHandle=None):
    l = l.split(',')
    data = parseArgs(l)
    if data == -1:
        outputHandle.output("Transaction Failure: Invalid Arguments")
        return
    print(data)
    workbook = openpyxl.load_workbook(filename=funcs.FOUT, data_only=False)
    sheet = funcs.fetch_sheet(workbook)
    sheet_data = funcs.parse_sheet(sheet)
    col_data = getColumns(data, sheet_data)
    if col_data == -1:
        outputHandle.output('Transaction Failure: Column not found')
        return
    open_row = funcs.find_open_row(sheet)
    print("DEBUG: ", data)
    funcs.set_sheet_vals(sheet, col_data, data['_name'], open_row)
    workbook.save(funcs.FOUT)
    funcs.cleanup(funcs.FOUT)
    s = 'Columns updated:\n' + '\n'.join(
        [f'{name}: {amt}' for amt, name in data.items() if amt != '_name'])
    if outputHandle == None:
        print(s)
        get.main()
    else:
        outputHandle.output(s)
        get.main(outputHandle)
示例#2
0
def main():
    """main func to be called in weekly get script"""

    select_month = find_month()
    week = find_week(select_month)
    port_count, vip_count = get.main()
    insert_weekly(week, port_count, select_month)
    insert_vip(select_month, vip_count)
    return port_count, vip_count
示例#3
0
def check_if_new():
    global x
    print("LFG")
    x = get.main()
    if x[0] != get_last_game():
        print("new game")
        set_last_game(x[0])
        return True
    else:
        print(":(")
        return False
示例#4
0
async def on_message(message):  # event that happens per any message.

    # each message has a bunch of attributes. Here are a few.
    # check out more by print(dir(message)) for example.
    print(message.author)
    print(message.content.strip().lower())
    print(message.author == 'FlyingPotato#1776')
    print(message.content.strip().lower() == 'get')
    if str(message.author) == 'FlyingPotato#1776' and message.content.strip(
    ).lower() == 'get':
        get.main(outputHandle)
        print(
            f"Messaged Processed: {message.channel}: {message.author}: {message.author.name}: {message.content}"
        )
        await message.channel.send(str(outputHandle))
    elif str(message.author) == 'FlyingPotato#1776' and message.content.strip(
    ).lower()[0] in '+-':
        transaction.main(message.content.strip(), outputHandle)
        await message.channel.send(str(outputHandle))
    else:
        if str(message.author) != "MONEY_APP#5784":
            data = parseMsg(message)
            print(f'data: {data}')
            if data == 'auth problem':
                print(f"Unauthorized User: {message.author}")
            elif data['error']:
                cmd_help(data['command'])
                await message.channel.send(str(outputHandle))
            else:
                # bot_print(f'processing: {data["command"]}')
                result = COMMANDS[data['command']](data['arguments'])
                if result == 'ERROR':
                    # bot_print(f'help: {data["command"]}')
                    cmd_help(data['command'])

                print(
                    f"Messaged Processed: {message.channel}: {message.author}: {message.author.name}: {message.content}"
                )
                await message.channel.send(str(outputHandle))
示例#5
0
def output_schedule(find_text):
    kb_schedule = get.main()

    time_form = [
        ["08:20", "09:50"],
        ["10:15", "11:45"],
        ["14:00", "15:30"],
        ["15:55", "17:25"],
    ]

    # time_form_hour = [[],[],[],[]]
    today_hour = time.localtime(time.time()).tm_hour
    today_min = time.localtime(time.time()).tm_min
    today_week = datetime.date.today().weekday() + 1

    today_delta = datetime.timedelta(hours=today_hour, minutes=today_min)

    count = 0
    for t in time_form:
        count += 2
        h1, m1 = t[0].split(":")
        h2, m2 = t[1].split(":")
        print(h1, m1)
        print(h2, m2)
        one_time_delta = datetime.timedelta(hours=int(h1), minutes=int(m1))
        two_time_delta = datetime.timedelta(hours=int(h2), minutes=int(m2))
        if today_delta > one_time_delta and today_delta < two_time_delta:
            find_text = "{0},{1}".format(str(today_week), str(count))
            kb, time_schedule = get.find_schedule(find_text, kb_schedule)
            kb = "{0}\n{1}\n{2}".format(kb[0][0], kb[0][1], time_schedule)
            print(kb)
            return kb

    count == 9
    return_text = "{0}\n{1}\n{2}".format(
        "O(∩_∩)O休息哟", "好好好玩",
        str(today_hour) + ":" + str(today_min))
    return return_text
示例#6
0
文件: app.py 项目: nettlless/meme-api
def home():
    return jsonify(get.main())
示例#7
0
文件: app.py 项目: nettlless/meme-api
def getWithUpvotes(subreddits, limit, upvotes):
    return jsonify(get.main(limit=limit, subs=subreddits, upvotes=upvotes))
示例#8
0
文件: app.py 项目: nettlless/meme-api
def getFromSubs(subreddits, limit):
    return jsonify(get.main(limit=limit, subs=subreddits))
示例#9
0
文件: app.py 项目: nettlless/meme-api
def getMore(limit):
    return jsonify(get.main(limit=limit, subs=config.subreddits))
示例#10
0
@contextlib.contextmanager
def working_directory(path):
    prev_cwd = os.getcwd()
    os.chdir(path)
    yield
    os.chdir(prev_cwd)


# Get files
#with working_directory('./static/pixiv'):
#    posts = glob.glob('*.png') + glob.glob('*.jpg')
dbsession = scoped_session(db.Session())
if db.isempty():
    print("downloading")
    get.main()
    with working_directory('./static/pixiv'):
        ids = glob.glob('*.json')
    print(str(ids))
    ids = map(lambda x: x.split('.')[0], ids)
    for id in ids:
        db.addpixiv(id)
print(db.session.query(db.Posts).all())
#posts = map(addition, numbers)


@app.route('/')
def hello_world():
    return render_template("hello.html",
                           posts=map(lambda x: x.file_name,
                                     db.session.query(db.Posts).all()))
示例#11
0
def callModule(tokList, lineNo):
    #this function will be incharge of analyzing the token list, and calling the relative call_module

    #incase the line is a comment, that is it starts with a hash, no processing needed
    if(tokList[0][0] == '#'):
        return

    #the command to execute will be the first word, hence, look up the commands
    command = tokList[0]

    #if else ladder of the commands
    if command == "get":
        tokListLists = preprocess(tokList, lineNo)

        if tokListLists == -1: #identifier not found
            return -1

        for tokenList in tokListLists:
            status = get.main(tokenList, lineNo)
            if(status == -1):
                return status
    
    
    elif command == "help":
        status = help.main(tokList, lineNo)
        return status


    elif command == "view":
        tokListLists = preprocess(tokList, lineNo)

        if tokListLists == -1: #identifier not found
            return -1

        for tokenList in tokListLists:
            status = view.main(tokenList, lineNo)
            if(status == -1):
                return status


    elif command == "let":
        status = let.main(tokList, lineNo, varTable, listTable)

        #if status is -1, error has occoured, or else, add variable to the table
        if status != -1:
            varTable[status[0]] = status[1]

        return status
    

    elif command == "list":
        status = listCmd.main(tokList, lineNo, varTable, listTable)

        #if status is -1, error has occoured, or else, add list to the table
        if status != -1:
            listTable[status[0]] = status[1]
        
        return status

    elif command == "freevar":
        #this block of code is to remove all the variables that user wants to delete

        varToDelete = tokList[1:]

        #error checking to ensure all the variables do infact exist
        flag=1
        for var in varToDelete:
            if var in varTable:
                continue
            else:
                print("Error on line " + str(lineNo) + " no variable: " + var + " found")
                flag=0

        if(flag==0):
            #if flag is 0, the command is incorrect
            return -1
        
        #now to go about and deleting all the variables from the varTable

        for var in varToDelete:
            del varTable[var]
    
    elif command == "freelist":
        #this block of code is to remove all the lists that the user wants to delete

        listsToDelete = tokList[1:]

        #error checking to ensure all the lists do infact exist
        flag=1
        for list_ in listsToDelete:
            if list_ in listTable:
                continue
            else:
                print("Error on line " + str(lineNo) + " no list: " + list_ + " found")
                flag=0

        if(flag==0):
            #if flag is 0, the command is incorrect
            return -1
        
        #now to go about and deleting all the variables from the varTable

        for list_ in listsToDelete:
            del listTable[list_]
    
    elif command == "mem":
        status = mem.main(tokList, lineNo, varTable, listTable)

        #if an error is there in the command
        if(status == -1):
            return status


    else:
        print("Unkown command: " + command + " on line no: " + str(lineNo))
        return -1