<s> import webapp2 , jinja2 , os , hashlib , logging , urllib <EOL> import json <EOL> import datetime <EOL> from model import Document <EOL> from google . appengine . api import mail <EOL> from secrets import ADMIN_EMAIL <EOL> from blockchain import auto_consolidate <EOL> class ConsolidationCron ( webapp2 . RequestHandler ) : <EOL> def get ( self ) : <EOL> archiveable = Document . get_archiveable ( ) <EOL> processed = False <EOL> for d in archiveable : <EOL> res = d . archive ( ) <EOL> self . response . write ( "<STR_LIT>" % ( d . digest , res ) ) <EOL> processed = True <EOL> if processed : <EOL> self . response . write ( "<STR_LIT>" ) <EOL> auto_consolidate ( ) <EOL> else : <EOL> self . response . write ( "<STR_LIT>" ) <EOL> class ConfirmationCron ( webapp2 . RequestHandler ) : <EOL> def get ( self ) : <EOL> actionable = Document . get_actionable ( ) <EOL> for d in actionable : <EOL> ret = d . blockchain_certify ( ) <EOL> sender_address = "<STR_LIT>" <EOL> subject = "<STR_LIT>" % ( ret [ '<STR_LIT:success>' ] , d . digest ) <EOL> body = subject + "<STR_LIT>" % ( ret [ '<STR_LIT:message>' ] ) <EOL> mail . send_mail ( sender_address , ADMIN_EMAIL , subject , body ) <EOL> class PaymentCheckerCron ( webapp2 . RequestHandler ) : <EOL> def get ( self ) : <EOL> digest = self . request . get ( '<STR_LIT:d>' ) <EOL> d = Document . get_doc ( digest ) <EOL> if d and d . pending and d . has_balance ( ) : <EOL> d . received_payment ( ) <EOL> self . response . write ( "<STR_LIT>" % ( d . digest , d . payment_address ) ) </s>
