<s> from kitt . interfaces import IDroneDApplication , implements <EOL> from droned . applications import ApplicationPlugin <EOL> from droned . models . app import AppVersion <EOL> from droned . models . event import Event <EOL> from kitt . decorators import debugCall , safe <EOL> from droned . logging import err <EOL> try : import rpm <EOL> except : rpm = None <EOL> class RPMApplication ( ApplicationPlugin ) : <EOL> """<STR_LIT>""" <EOL> SEARCH_DELAY = <NUM_LIT> <EOL> implements ( IDroneDApplication ) <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> Event ( '<STR_LIT>' ) . subscribe ( self . _check_version ) <EOL> @ safe ( None ) <EOL> def _check_version ( self , occurrence ) : <EOL> ai = occurrence . instance <EOL> if ai . app . name == self . name : <EOL> return self . _updateVersion ( None , ai . label ) <EOL> def _updateVersion ( self , result , label ) : <EOL> thisInst = self . getInstance ( label ) <EOL> try : <EOL> ts = rpm . TransactionSet ( ) <EOL> mi = ts . dbMatch ( '<STR_LIT:name>' , self . name ) <EOL> for h in mi : <EOL> if not h : break <EOL> version = AppVersion . makeVersion ( self . name , h [ '<STR_LIT:version>' ] ) <EOL> if version > thisInst . appversion : <EOL> thisInst . version = version <EOL> except : <EOL> err ( '<STR_LIT>' ) <EOL> return result <EOL> def startInstance ( self , label ) : <EOL> """<STR_LIT>""" <EOL> d = ApplicationPlugin . startInstance ( self , label ) <EOL> d . addCallback ( self . _updateVersion , label ) <EOL> return d <EOL> if rpm : __all__ = [ '<STR_LIT>' ] </s>
