<s> """<STR_LIT>""" <EOL> import datetime <EOL> import time <EOL> import webapp2 <EOL> from google . appengine . ext import blobstore <EOL> from simian import settings <EOL> from simian . auth import gaeserver <EOL> from simian . mac import common <EOL> from simian . mac import models <EOL> from simian . mac . common import gae_util <EOL> from simian . mac . common import mail <EOL> class AuthSessionCleanup ( webapp2 . RequestHandler ) : <EOL> """<STR_LIT>""" <EOL> def get ( self ) : <EOL> """<STR_LIT>""" <EOL> asd = gaeserver . AuthSessionSimianServer ( ) <EOL> expired_sessions_count = asd . ExpireAll ( ) <EOL> class MarkComputersInactive ( webapp2 . RequestHandler ) : <EOL> """<STR_LIT>""" <EOL> def get ( self ) : <EOL> """<STR_LIT>""" <EOL> count = models . Computer . MarkInactive ( ) <EOL> class UpdateAverageInstallDurations ( webapp2 . RequestHandler ) : <EOL> """<STR_LIT>""" <EOL> def get ( self ) : <EOL> """<STR_LIT>""" <EOL> pkgs , unused_dt = models . ReportsCache . GetInstallCounts ( ) <EOL> for p in models . PackageInfo . all ( ) : <EOL> if not p . plist : <EOL> continue <EOL> if p . munki_name not in pkgs : <EOL> continue <EOL> elif not pkgs [ p . munki_name ] . get ( '<STR_LIT>' , None ) : <EOL> continue <EOL> lock = '<STR_LIT>' % p . filename <EOL> if not gae_util . ObtainLock ( lock , timeout = <NUM_LIT> ) : <EOL> continue <EOL> old_desc = p . plist [ '<STR_LIT:description>' ] <EOL> avg_duration_text = models . PackageInfo . AVG_DURATION_TEXT % ( <EOL> pkgs [ p . munki_name ] [ '<STR_LIT>' ] , <EOL> pkgs [ p . munki_name ] [ '<STR_LIT>' ] ) <EOL> p . description = '<STR_LIT>' % ( p . description , avg_duration_text ) <EOL> if p . plist [ '<STR_LIT:description>' ] != old_desc : <EOL> p . put ( ) <EOL> gae_util . ReleaseLock ( lock ) <EOL> delay = <NUM_LIT:0> <EOL> for track in common . TRACKS : <EOL> delay += <NUM_LIT:5> <EOL> models . Catalog . Generate ( track , delay = delay ) <EOL> class VerifyPackages ( webapp2 . RequestHandler ) : <EOL> """<STR_LIT>""" <EOL> def get ( self ) : <EOL> """<STR_LIT>""" <EOL> for p in models . PackageInfo . all ( ) : <EOL> if p . blobstore_key and blobstore . BlobInfo . get ( p . blobstore_key ) : <EOL> continue <EOL> elif p . mtime < ( datetime . datetime . utcnow ( ) - datetime . timedelta ( days = <NUM_LIT:7> ) ) : <EOL> subject = '<STR_LIT>' % p . filename <EOL> body = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( <EOL> settings . SERVER_HOSTNAME , p . filename ) ) <EOL> mail . SendMail ( [ settings . EMAIL_ADMIN_LIST ] , subject , body ) <EOL> for b in blobstore . BlobInfo . all ( ) : <EOL> key = b . key ( ) <EOL> max_attempts = <NUM_LIT:5> <EOL> for i in xrange ( <NUM_LIT:1> , max_attempts + <NUM_LIT:1> ) : <EOL> p = models . PackageInfo . all ( ) . filter ( '<STR_LIT>' , key ) . get ( ) <EOL> if p : <EOL> break <EOL> elif i == max_attempts : <EOL> if not b . filename and not b . size : <EOL> b . delete ( ) <EOL> break <EOL> subject = '<STR_LIT>' % b . filename <EOL> body = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( b . filename , key ) ) <EOL> mail . SendMail ( [ settings . EMAIL_ADMIN_LIST ] , subject , body ) <EOL> break <EOL> time . sleep ( <NUM_LIT:1> ) </s>
