예제 #1
0
def main():
    gitrootdir = subprocess.check_output(
        ("git", "rev-parse", "--show-toplevel")).strip().decode("UTF-8")
    assert os.path.abspath(os.curdir) == gitrootdir, \
        "Please run the checks in the git root directory: %s " % gitrootdir
    if len(sys.argv) > 1:
        # if called with commandline parameters, we assume
        # they are the names of the checks you want to run

        # This is how the tests work
        checks_to_run = []
        for checkname in sys.argv[1:]:
            newchecks = list(filter(lambda c: c.__name__ == checkname, CHECKS))
            if len(newchecks) == 1:
                checks_to_run += newchecks
            else:
                print("Check '%s' not found, aborting" % checkname)
                sys.exit(2)

    else:
        checks_to_run = CHECKS

    errors = checks.check(checks_to_run)

    if len(errors) > 0:
        for error in errors:
            print(u"%s, %s" % (error.changedFile.filename, error.errormessage))
        print("COMMIT FAILED, solve the problems and try again")
        sys.exit(1)
예제 #2
0
 def main():
     try:
        users_info = open_json(sys.argv[1])
        venues_info = open_json(sys.argv[2])
         users_key = ["name", "wont_eat", "drinks"]
        venues_key = ["name", "food", "drinks"]
         users_check = checks.check(users_info, users_key, sys.argv[1])
예제 #3
0
def passChange(username, oldPassword, newPassword):
    if oldPassword == newPassword:return checks.message(False, "The new password can't be the\nsame as the old password")
    check = checks.check(username, newPassword, True)
    if check.accepted:
        if utility.checkIfCorrect(username, oldPassword):setPassword(username, newPassword)
        else:return checks.message(False, "Either the username or\nthe password is incorrect")
    return check
예제 #4
0
def addToIndex(username, password):
    result = checks.check(username, password, False)
    # print(result)
    if result.accepted:
        password = encrypt(password)
        with open("data.txt", "a") as f:
            f.write(f"{username}-{password}\n")
    return result
예제 #5
0
def main():
    print(
        "Hi, I'm a submission checker. I will perform some checks to ensure that you're submitting your files correctly."
    )
    print(
        "  (note: these checks are not guaranteed to be comprehensive; please read the spec carefully)"
    )
    print()

    num_errors = check("files are in the correct location",
                       check_file_locations)
    if num_errors:
        exit(1)

    num_errors += check(".sql files don't have SQLite commands",
                        check_sqlite_commands_queries)
    num_errors += check(".sql files include comments", check_query_comments)
    if num_errors > 0:
        exit(1)
예제 #6
0
        CallbackQueryHandler(FeedbackHandler.correction_feedback))

    for handler in group0_handlers:
        dp.add_handler(handler, group=0)

    # for handler in group1_handlers:
    #     dp.add_handler(handler, group=1)

    # setup periodic stats
    for cron_job in crons:
        cron = cron_job["func"]
        interval = cron_job["interval"]
        first = cron_job["first"]
        updater.job_queue.run_repeating(cron, interval=interval, first=first)

    dp.add_error_handler(error_callback)
    print("All handlers initiated.")

    updater.start_polling()
    print("Bot started")

    # Run the bot until you press Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT. This should be used most of the time, since
    # start_polling() is non-blocking and will stop the bot gracefully.
    updater.idle()


if __name__ == '__main__':
    check()
    main()
예제 #7
0
import sys
import json
from pprint import pprint
import checks
import utils
 def open_json(payload):
     with open(payload) as json_file:
            return json.load(json_file)
 def main():
     try:
        users_info = open_json(sys.argv[1])
        venues_info = open_json(sys.argv[2])
         users_key = ["name", "wont_eat", "drinks"]
        venues_key = ["name", "food", "drinks"]
         users_check = checks.check(users_info, users_key, sys.argv[1])
        venues_check = checks.check(venues_info, venues_key, sys.argv[2])
         if users_check and venues_check:
            utils.test(users_info, venues_info)
        else:
            print("KO")
     except Exception as e:
        print("\nOops! An error occurred {}\n".format(e))
 if __name__ == "__main__":
    main()