Example #1
0
def guests(request, hotel):
    context = {}
    context["hotel"] = hotel
    context["reserves"] = Reserve.objects.all()
    now = datetime.now() - timedelta(days=30)
    context["now"] = now.strftime("%Y-%m-%d")
    print(now.strftime("%Y-%m-%d"))

    return render(request, "guests.html", context)
Example #2
0
def linkacc():
    card_type = str(request.form['card_type'])
    card_number = str(request.form['card_number'])
    cvv_number = str(request.form['cvv_number'])
    month_year = str(request.form['month'])
    x = month_year.split("-")
    now = datetime.datetime.now()
    date = now.strftime("%Y-%m")
    current = date.split("-")
    if x[0] > current[0] or (x[0] == current[0] and (x[1] >= current[1])):
        query1 = "select user_id from thomaspay.users where username='******'user'] + "'"
        print(query1)
        cursor.execute(query1)
        uid = cursor.fetchall()
        print(uid[0][0])
        print(type(card_number), type(card_type), type(cvv_number), type(x[0]),
              type(x[1]), type(uid[0][0]))

        query = "insert into thomaspay.account(user_id, card_name, cardnumber, cvv, month, year) values(%s, %s, %s, %s, %s, %s)"
        val = (int(uid[0][0]), card_type, card_number, cvv_number, x[1], x[0])
        print(query)
        cursor.execute(query, val)
        db.commit()
        message = "Card  Details Entered !!!!!!!!!!!!!!!!!!!!"
    else:
        message = "Card Expired !!!!!!!!!!!!!!!!"
    return render_template('linkaccount.html', message=message)
Example #3
0
def quickpayamount():
    beneficiaries = getBeneficiaries()
    accounts = getAccounts()
    now = datetime.datetime.now()
    date = now.strftime("%Y-%m-%d")
    beneficiary = str(request.form['beneficiary'])
    amount = request.form['amount']
    if re.search(r"""^^(?!-).*[0-9]+(\.[0-9]{1,2})?$""", amount):
        print("Valid amount entered!")
    else:
        message = "Invalid ammount entered..!"
        return render_template('quickpay.html',
                               message=message,
                               beneficiaries=beneficiaries,
                               accounts=accounts)
    query0 = "select thomaspay.users.user_id, thomaspay.wallet.balance from thomaspay.wallet, thomaspay.users where thomaspay.users.user_id = thomaspay.wallet.user_id " \
             "and thomaspay.users.username='******'user'] + "'"
    cursor.execute(query0)
    data = cursor.fetchall()
    uid = data[0][0]
    balance = data[0][1]
    print(uid)
    amount = int(amount)
    print(amount)
    print(date, beneficiary, amount)
    if balance >= amount:
        query11 = "select nickname from thomaspay.beneficiary where beneficiary_id = %s and user_id = %s"
        val11 = (int(beneficiary), int(uid))
        cursor.execute(query11, val11)
        nickname = cursor.fetchall()
        print(nickname[0][0])
        query1 = "insert into thomaspay.transactions(user_id, transaction_type, amount, transaction_date, sendto, receivedfrom) " \
                "values(%s, %s, %s, %s, %s, %s)"
        val1 = (int(uid), 'Debit', float(amount), date, nickname[0][0], 'null')
        val2 = (beneficiary, 'Credit', float(amount), date, 'null',
                session['user'])
        cursor.execute(query1, val1)
        cursor.execute(query1, val2)
        query2 = "UPDATE thomaspay.wallet SET balance = balance - %s WHERE user_id = %s and balance >= %s"
        val3 = (float(amount), int(uid), float(amount))
        cursor.execute(query2, val3)
        query3 = "UPDATE thomaspay.wallet SET balance = balance + %s WHERE user_id = %s and balance >= %s"
        val4 = (float(amount), int(beneficiary), float(amount))
        cursor.execute(query3, val4)
        db.commit()
        message = "Successfully transferred $" + str(
            amount) + " to " + nickname[0][0] + " ."
    else:
        message = "Insufficient balance..."
    return render_template('quickpay.html',
                           message=message,
                           beneficiaries=beneficiaries,
                           accounts=accounts)
Example #4
0
def linkacc():
    try:
        card_type = str(request.form['card_type'])
        card_number = str(request.form['card_number'])
        if re.search(r"""^[0-9]{16}?$""", card_number):
            print("Valid card_number!")
        else:
            message = "Card Number Invalid!"
            return render_template('linkaccount.html', message=message)
        cvv_number = str(request.form['cvv_number'])
        if re.search(r"""^[0-9]{3,4}?$""", cvv_number):
            print("Valid cvv_number!")
        else:
            message = "CVV Invalid!"
            return render_template('linkaccount.html', message=message)
        month_year = str(request.form['month'])
        x = month_year.split("-")
        now = datetime.datetime.now()
        date = now.strftime("%Y-%m")
        current = date.split("-")
        if x[0] > current[0] or (x[0] == current[0] and (x[1] >= current[1])):
            query1 = "select user_id from thomaspay.users where username='******'user'] + "'"
            print(query1)
            CURSOR.execute(query1)
            uid = CURSOR.fetchall()
            print(uid[0][0])
            print(type(card_number), type(card_type), type(cvv_number),
                  type(x[0]), type(x[1]), type(uid[0][0]))

            query = "insert into thomaspay.account(user_id, card_name, cardnumber, cvv, month, year) values(%s, %s, %s, %s, %s, %s)"
            val = (int(uid[0][0]), card_type, card_number, cvv_number, x[1],
                   x[0])
            print(query)
            CURSOR.execute(query, val)
            DB.commit()
            message = "Card  Details Entered !!!!!!!!!!!!!!!!!!!!"
        else:
            message = "Card Expired !!!!!!!!!!!!!!!!"
        return render_template('linkaccount.html', message=message)
    except Exception as e:

        logging.basicConfig(filename='tpay.log',
                            filemode='a',
                            format='%(name)s - %(levelname)s - %(message)s')
        logging.error(
            "---------------------------------------------------------------------------------------"
        )
        logging.error("USER DETAIL: %s", session['user'])
        logging.error(":THOMAS PAY ERROR DETAIL:", exc_info=True)
        result = "Some internal error has occured. if problem continues please contact our help desk associate"
        return render_template('/linkaccount.html', result=result)
Example #5
0
def addmoneytodb():
    money = request.form['money']
    money1 = float(money)

    query = "SELECT card_name,cardnumber FROM thomaspay.account,thomaspay.users " \
            "where thomaspay.users.username='******'user'] + "' and thomaspay.users.user_id = thomaspay.account.user_id"
    print(query)
    cursor.execute(query)
    data = cursor.fetchall()
    if money1 < 0:
        print("i am here")
        message = "Enter valid amount"
        return render_template('addmoney.html', data=data, message=message)
    else:
        print(money1)
        now = datetime.datetime.now()
        date = now.strftime("%Y-%m-%d")
        query0 = "select thomaspay.users.user_id, thomaspay.wallet.balance from thomaspay.wallet, thomaspay.users where thomaspay.users.user_id = thomaspay.wallet.user_id " \
                 "and thomaspay.users.username='******'user'] + "'"
        cursor.execute(query0)
        datas = cursor.fetchall()
        uid = datas[0][0]
        balance = datas[0][1]
        print(query0)
        print(balance)
        currentbalance = float(balance)
        updatedbalance = money1 + currentbalance
        print("updated Balance = " + str(updatedbalance))
        query2 = "UPDATE thomaspay.wallet SET balance = %s WHERE user_id = %s"
        val3 = (int(updatedbalance), int(uid))
        cursor.execute(query2, val3)

        query1 = "insert into thomaspay.transactions(user_id, transaction_type, amount, transaction_date, sendto, receivedfrom) " \
                 "values(%s, %s, %s, %s, %s, %s)"
        val1 = (int(uid), 'Credit', float(money1), date, 'null',
                'Wallet Updated')
        cursor.execute(query1, val1)

        db.commit()
        print('money updated in db')
        message = "Money successfully added to your wallet !!"

    return render_template('addmoney.html', data=data, message=message)
Example #6
0
def main():
    # Defining the start of the program
    now = datetime.now()
    dateNow = str(now.strftime("%Y%m%d_%Hh%Mm%Ss"))
    loggingFileName = "logfile_" + dateNow + ".log"
    logging.basicConfig(level=logging.DEBUG,
                        filename="log" + "/" + loggingFileName)
    logging.info("Starting at : " + str(dateNow))
    functions.initFolders(initFoldersList)  # generated_html, log, json, abc

    # list of folders to process
    logging.info("That is " + str(
        len([
            name for name in os.listdir(FOLDER_TXTS_FROM_JSON_OR_XML)
            if os.path.isfile(name)
        ])) + " files in folder " + FOLDER_TXTS_FROM_JSON_OR_XML)
    dirsToProcessInJsonFolder = os.listdir(FOLDER_JSON)
    #functions.processJsonToTxt(dirsToProcessInJsonFolder)
    functions.processTxtToDayFiles(FOLDER_TXTS_FROM_JSON_OR_XML)
    exit()
    functions.createTxtFilesFromFolders(dirsToProcessInJsonFolder)
Example #7
0
def quickpayamount():
    try:
        beneficiaries = getBeneficiaries()
        accounts = getAccounts()
        now = datetime.datetime.now()
        date = now.strftime("%Y-%m-%d")
        beneficiary = str(request.form['beneficiary'])
        amount = request.form['amount']
        if re.search(r"""^^(?!-).*[0-9]+(\.[0-9]{1,2})?$""", amount):
            print("Valid amount entered!")
        else:
            message = "Invalid ammount entered..!"
            return render_template('quickpay.html',
                                   message=message,
                                   beneficiaries=beneficiaries,
                                   accounts=accounts)
        query0 = "select thomaspay.users.user_id, thomaspay.wallet.balance from thomaspay.wallet, thomaspay.users where thomaspay.users.user_id = thomaspay.wallet.user_id " \
                 "and thomaspay.users.username='******'user'] + "'"
        CURSOR.execute(query0)
        data = CURSOR.fetchall()
        uid = data[0][0]
        balance = data[0][1]
        print(uid)
        amount = int(amount)
        print(amount)
        print(date, beneficiary, amount)
        if balance >= amount:
            query11 = "select nickname from thomaspay.beneficiary where beneficiary_id = %s and user_id = %s"
            val11 = (int(beneficiary), int(uid))
            CURSOR.execute(query11, val11)
            nickname = CURSOR.fetchall()
            print(nickname[0][0])
            query1 = "insert into thomaspay.transactions(user_id, transaction_type, amount, transaction_date, sendto, receivedfrom) " \
                    "values(%s, %s, %s, %s, %s, %s)"
            val1 = (int(uid), 'Debit', float(amount), date, nickname[0][0],
                    'null')
            val2 = (beneficiary, 'Credit', float(amount), date, 'null',
                    session['user'])
            CURSOR.execute(query1, val1)
            CURSOR.execute(query1, val2)
            query2 = "UPDATE thomaspay.wallet SET balance = balance - %s WHERE user_id = %s and balance >= %s"
            val3 = (float(amount), int(uid), float(amount))
            CURSOR.execute(query2, val3)
            query3 = "UPDATE thomaspay.wallet SET balance = balance + %s WHERE user_id = %s and balance >= %s"
            val4 = (float(amount), int(beneficiary), float(amount))
            CURSOR.execute(query3, val4)
            DB.commit()
            message = "Successfully transferred $" + str(
                amount) + " to " + nickname[0][0] + " ."
        else:
            message = "Insufficient balance..."
        return render_template('quickpay.html',
                               message=message,
                               beneficiaries=beneficiaries,
                               accounts=accounts)
    except Exception as e:

        logging.basicConfig(filename='tpay.log',
                            filemode='a',
                            format='%(name)s - %(levelname)s - %(message)s')
        logging.error(
            "---------------------------------------------------------------------------------------"
        )
        logging.error("USER DETAIL: %s", session['user'])
        logging.error(":THOMAS PAY ERROR DETAIL:", exc_info=True)
        result = "Some internal error has occured. if problem continues please contact our help desk associate"
        return render_template('/quickpay.html', result=result)
Example #8
0
def addmoneytodb():
    try:
        money = request.form['money']
        money1 = float(money)
        if re.search(r"""^^(?!-).*[0-9]+(\.[0-9]{1,2})?$""", money):
            print("Valid Amounnt!")
        else:
            message = "Invalid amount entered!!"
            return render_template('addmoney.html', message=message)

        query = "SELECT card_name,cardnumber FROM thomaspay.account,thomaspay.users " \
                "where thomaspay.users.username='******'user'] + "' and thomaspay.users.user_id = thomaspay.account.user_id"
        print(query)
        CURSOR.execute(query)
        data = CURSOR.fetchall()
        if money1 < 0:
            message1 = "Enter a valid amount"
            return render_template('addmoney.html',
                                   data=data,
                                   message1=message1)
        else:
            print(money1)
            now = datetime.datetime.now()
            date = now.strftime("%Y-%m-%d")
            query0 = "select thomaspay.users.user_id, thomaspay.wallet.balance from thomaspay.wallet, thomaspay.users where thomaspay.users.user_id = thomaspay.wallet.user_id " \
                     "and thomaspay.users.username='******'user'] + "'"
            CURSOR.execute(query0)
            datas = CURSOR.fetchall()
            uid = datas[0][0]
            balance = datas[0][1]
            print(query0)
            print(balance)
            currentbalance = float(balance)
            updatedbalance = money1 + currentbalance
            print("updated Balance = " + str(updatedbalance))
            query2 = "UPDATE thomaspay.wallet SET balance = %s WHERE user_id = %s"
            val3 = (int(updatedbalance), int(uid))
            CURSOR.execute(query2, val3)

            query1 = "insert into thomaspay.transactions(user_id, transaction_type, amount, transaction_date, sendto, receivedfrom) " \
                     "values(%s, %s, %s, %s, %s, %s)"
            val1 = (int(uid), 'Credit', float(money1), date, 'null',
                    'Wallet Updated')
            CURSOR.execute(query1, val1)

            DB.commit()
            print('money updated in db')
            message = "Money successfully added to your wallet !!"

        return render_template('addmoney.html', data=data, message=message)
    except Exception as e:

        logging.basicConfig(filename='tpay.log',
                            filemode='a',
                            format='%(name)s - %(levelname)s - %(message)s')
        logging.error(
            "---------------------------------------------------------------------------------------"
        )
        logging.error("USER DETAIL: %s", session['user'])
        logging.error(":THOMAS PAY ERROR DETAIL:", exc_info=True)
        result = "Some internal error has occured. if problem continues please contact our help desk associate"
        return render_template('/addmoney.html', result=result)
Example #9
0
def dateConvert(value):
    match_re = re.match(".*?(\d+.*)", value)
    if match_re:
        return match_re.group(1)
    else:
        return now.strftime("%Y-%m-%d %H-%M-%S")
Example #10
0
parser.add_argument('--steps', required=True, type=int, help='#adv. steps')
parser.add_argument('--max_norm',
                    required=True,
                    type=float,
                    help='Linf-norm in PGD')
parser.add_argument('--data', required=True, type=str, help='dataset name')
parser.add_argument('--model', required=True, type=str, help='model name')
parser.add_argument('--root', required=True, type=str, help='path to dataset')
parser.add_argument('--model_out', required=True, type=str, help='output path')

opt = parser.parse_args()

from datetime import datetime
now = datetime.now()
log_file = 'checkpoint/%s_adv_%s.log' % (opt.data,
                                         now.strftime("%m-%d-%Y-%H-%M-%S"))
handlers = [logging.FileHandler(log_file), logging.StreamHandler()]
#handlers = [logging.StreamHandler()]
logging.basicConfig(level=logging.INFO,
                    format='%(asctime)s: %(message)s',
                    datefmt='%Y-%m-%d %H:%M:%S',
                    handlers=handlers)

args_dict = opt.__dict__
for key in args_dict.keys():
    logging.info("- {}: {}".format(key, args_dict[key]))

# Data
logging.info('==> Preparing data..')
if opt.data == 'cifar10':
    nclass = 10
from datetime import datetime

import now

H = []
while True:

    n = int(input())
    k = n // 2
    s = n // 3
    m = n // 4
    if (s + k + m) > n:
        print(s + k + m)
    else:
        print(n)
    date = now.strftime("%H:%M:%S")
    # print(now.strftime("%H:%M:%S") - date)