Пример #1
0


#
# Verify Lender ID has valid format and pull lender history.
#

if options.kiva_id is None:
    if 'GATEWAY_INTERFACE' not in environ:
        kiva_id = environ["USER"]
    else:
        exit(3)
else:
    kiva_id = options.kiva_id

lender.check_lender_id(kiva_id)
my_countries, not_loaned = lender.read_lender_csv(kiva_id,private,verbose,display)

#
# Check for loans in countries we haven't hit yet.
#

loans_found = loan.find_new_loans(not_loaned,loan_count,verbose)

if newonly:
        print "Searched all new countries."
        exit(0)

if len(loans_found) < loan_count:
    print "Found %s loans for new countries. Looking for less used countries." % len(loans_found)
    loans_found = loan.find_old_loans(loans_found,my_countries,loan_count,verbose)
Пример #2
0
    verbose = 'verbose' in arg_list
    display = 'display' in arg_list
    newonly = 'newonly' in arg_list
    rss = 'rss' in arg_list
    private = 'private' in arg_list
    set_cookie = 'private' not in arg_list

    kiva_id = cgi.escape(form.getfirst('lender', 'empty')).strip('"\'')
    if kiva_id == 'empty':
            try:
                    cookie = Cookie.SimpleCookie(os.environ["HTTP_COOKIE"])
                    kiva_id = cookie["lender"].value
            except:
                    print
    if not lender.check_lender_id(kiva_id):
        print
        print "Lender ID is invalid."
        exit(1)

    if set_cookie:
        expiration = datetime.datetime.now() + datetime.timedelta(days=60)
        print 'Set-Cookie: lender=' + kiva_id + "; expires=" + expiration.strftime("%a, %d-%b-%Y %H:%M:%S PST")
    print

    loan_count = form.getfirst('count','1')
    if not loan_count.isdigit() and int(loan_count) <= 0:
        loan_count = '1'
    loan_count = int(loan_count)

    print '<p>Hello %s!</p>' % kiva_id