<s> """<STR_LIT>""" <EOL> import base64 <EOL> import datetime <EOL> import logging <EOL> from google . appengine import runtime <EOL> from google . appengine . ext import db <EOL> from google . appengine . ext import deferred <EOL> from google . appengine . runtime import apiproxy_errors <EOL> from simian . mac import common <EOL> from simian . mac import models <EOL> from simian . mac . common import util <EOL> from simian . mac . munki import plist as plist_module <EOL> CLIENT_ID_FIELDS = { <EOL> '<STR_LIT>' : str , '<STR_LIT>' : str , '<STR_LIT>' : str , '<STR_LIT>' : str , <EOL> '<STR_LIT>' : str , '<STR_LIT>' : str , '<STR_LIT>' : str , '<STR_LIT>' : str , <EOL> '<STR_LIT>' : str , '<STR_LIT>' : str , '<STR_LIT>' : bool , <EOL> '<STR_LIT>' : str , '<STR_LIT>' : float , '<STR_LIT>' : int , <EOL> '<STR_LIT>' : int , '<STR_LIT>' : bool , '<STR_LIT>' : str , <EOL> '<STR_LIT>' : bool , <EOL> } <EOL> CONNECTION_DATETIMES_LIMIT = <NUM_LIT:10> <EOL> CONNECTION_DATES_LIMIT = <NUM_LIT:30> <EOL> DATASTORE_NOWRITE_DELAY = <NUM_LIT> <EOL> PANIC_MODE_PREFIX = '<STR_LIT>' <EOL> PANIC_MODE_NO_PACKAGES = '<STR_LIT>' <EOL> PANIC_MODES = [ PANIC_MODE_NO_PACKAGES ] <EOL> FLASH_PLUGIN_NAME = '<STR_LIT>' <EOL> FLASH_PLUGIN_DEBUG_NAME = '<STR_LIT>' <EOL> APPLESUS_PKGS_TO_INSTALL_FORMAT = '<STR_LIT>' <EOL> DUPE_SERIAL_NUMBER_EXCEPTIONS = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , None ] <EOL> class Error ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class ComputerNotFoundError ( Error ) : <EOL> """<STR_LIT>""" <EOL> class ManifestNotFoundError ( Error ) : <EOL> """<STR_LIT>""" <EOL> class ManifestDisabledError ( Error ) : <EOL> """<STR_LIT>""" <EOL> def _SaveFirstConnection ( client_id , computer ) : <EOL> """<STR_LIT>""" <EOL> e = models . FirstClientConnection ( key_name = client_id [ '<STR_LIT>' ] ) <EOL> e . computer = computer <EOL> e . owner = client_id [ '<STR_LIT>' ] <EOL> e . hostname = client_id [ '<STR_LIT>' ] <EOL> e . office = client_id [ '<STR_LIT>' ] <EOL> e . site = client_id [ '<STR_LIT>' ] <EOL> e . put ( ) <EOL> if computer . serial not in DUPE_SERIAL_NUMBER_EXCEPTIONS : <EOL> for dupe in models . Computer . AllActive ( ) . filter ( '<STR_LIT>' , computer . serial ) : <EOL> if dupe . uuid == computer . uuid : <EOL> continue <EOL> if dupe . preflight_datetime < computer . preflight_datetime : <EOL> dupe . active = False <EOL> dupe . put ( update_active = False ) <EOL> def LogClientConnection ( <EOL> event , client_id , user_settings = None , pkgs_to_install = None , <EOL> apple_updates_to_install = None , ip_address = None , report_feedback = None , <EOL> computer = None , delay = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if delay : <EOL> now_str = datetime . datetime . utcnow ( ) . strftime ( '<STR_LIT>' ) <EOL> deferred_name = '<STR_LIT>' % ( client_id [ '<STR_LIT>' ] , now_str ) <EOL> deferred . defer ( <EOL> LogClientConnection , event , client_id , user_settings = user_settings , <EOL> pkgs_to_install = pkgs_to_install , ip_address = ip_address , <EOL> apple_updates_to_install = apple_updates_to_install , <EOL> report_feedback = report_feedback , _name = deferred_name , _countdown = delay ) <EOL> return <EOL> if not client_id [ '<STR_LIT>' ] : <EOL> logging . warning ( '<STR_LIT>' ) <EOL> return <EOL> def __UpdateComputerEntity ( <EOL> event , _client_id , _user_settings , _pkgs_to_install , <EOL> _apple_updates_to_install , _ip_address , _report_feedback , c = None ) : <EOL> """<STR_LIT>""" <EOL> now = datetime . datetime . utcnow ( ) <EOL> is_new_client = False <EOL> if c is None : <EOL> c = models . Computer . get_by_key_name ( _client_id [ '<STR_LIT>' ] ) <EOL> if c is None : <EOL> c = models . Computer ( key_name = _client_id [ '<STR_LIT>' ] ) <EOL> is_new_client = True <EOL> c . uuid = _client_id [ '<STR_LIT>' ] <EOL> c . hostname = _client_id [ '<STR_LIT>' ] <EOL> c . serial = _client_id [ '<STR_LIT>' ] <EOL> c . owner = _client_id [ '<STR_LIT>' ] <EOL> c . track = _client_id [ '<STR_LIT>' ] <EOL> c . site = _client_id [ '<STR_LIT>' ] <EOL> c . office = _client_id [ '<STR_LIT>' ] <EOL> c . config_track = _client_id [ '<STR_LIT>' ] <EOL> c . client_version = _client_id [ '<STR_LIT>' ] <EOL> c . os_version = _client_id [ '<STR_LIT>' ] <EOL> c . uptime = _client_id [ '<STR_LIT>' ] <EOL> c . root_disk_free = _client_id [ '<STR_LIT>' ] <EOL> c . user_disk_free = _client_id [ '<STR_LIT>' ] <EOL> c . runtype = _client_id [ '<STR_LIT>' ] <EOL> c . ip_address = _ip_address <EOL> last_notified_datetime = _client_id [ '<STR_LIT>' ] <EOL> if last_notified_datetime : <EOL> try : <EOL> last_notified_datetime = datetime . datetime . strptime ( <EOL> last_notified_datetime , '<STR_LIT>' ) <EOL> c . last_notified_datetime = last_notified_datetime <EOL> except ValueError : <EOL> logging . warning ( <EOL> '<STR_LIT>' , last_notified_datetime ) <EOL> if event == '<STR_LIT>' : <EOL> c . preflight_datetime = now <EOL> if _client_id [ '<STR_LIT>' ] == True : <EOL> c . last_on_corp_preflight_datetime = now <EOL> if not _report_feedback or not _report_feedback . get ( '<STR_LIT>' ) : <EOL> if c . preflight_count_since_postflight is not None : <EOL> c . preflight_count_since_postflight += <NUM_LIT:1> <EOL> else : <EOL> c . preflight_count_since_postflight = <NUM_LIT:1> <EOL> elif event == '<STR_LIT>' : <EOL> c . preflight_count_since_postflight = <NUM_LIT:0> <EOL> c . postflight_datetime = now <EOL> if _pkgs_to_install : <EOL> c . pkgs_to_install = _pkgs_to_install <EOL> c . all_pkgs_installed = False <EOL> else : <EOL> c . pkgs_to_install = [ ] <EOL> c . all_pkgs_installed = True <EOL> if not pkgs_to_install and not _apple_updates_to_install : <EOL> c . all_apple_updates_installed = True <EOL> else : <EOL> c . all_apple_updates_installed = False <EOL> for update in _apple_updates_to_install : <EOL> c . pkgs_to_install . append ( APPLESUS_PKGS_TO_INSTALL_FORMAT % update ) <EOL> if len ( c . connection_datetimes ) == CONNECTION_DATETIMES_LIMIT : <EOL> c . connection_datetimes . pop ( <NUM_LIT:0> ) <EOL> c . connection_datetimes . append ( now ) <EOL> if _client_id [ '<STR_LIT>' ] == True : <EOL> c . connections_on_corp = ( c . connections_on_corp or <NUM_LIT:0> ) + <NUM_LIT:1> <EOL> elif _client_id [ '<STR_LIT>' ] == False : <EOL> c . connections_off_corp = ( c . connections_off_corp or <NUM_LIT:0> ) + <NUM_LIT:1> <EOL> now_date = datetime . datetime . combine ( now , datetime . time ( ) ) <EOL> if now_date not in c . connection_dates : <EOL> if len ( c . connection_dates ) == CONNECTION_DATES_LIMIT : <EOL> c . connection_dates . pop ( <NUM_LIT:0> ) <EOL> c . connection_dates . append ( now_date ) <EOL> else : <EOL> logging . warning ( '<STR_LIT>' , event ) <EOL> c . put ( ) <EOL> if is_new_client : <EOL> deferred . defer ( <EOL> _SaveFirstConnection , client_id = _client_id , computer = c , <EOL> _countdown = <NUM_LIT> , _queue = '<STR_LIT>' ) <EOL> try : <EOL> db . run_in_transaction ( <EOL> __UpdateComputerEntity , <EOL> event , client_id , user_settings , pkgs_to_install , <EOL> apple_updates_to_install , ip_address , report_feedback , c = computer ) <EOL> except ( db . Error , apiproxy_errors . Error , runtime . DeadlineExceededError ) as e : <EOL> logging . warning ( <EOL> '<STR_LIT>' , e . __class__ . __name__ , str ( e ) ) <EOL> LogClientConnection ( <EOL> event , client_id , user_settings , pkgs_to_install , <EOL> apple_updates_to_install , ip_address , report_feedback , <EOL> delay = DATASTORE_NOWRITE_DELAY ) <EOL> def WriteClientLog ( model , uuid , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' in kwargs : <EOL> del kwargs [ '<STR_LIT>' ] <EOL> uuid = common . SanitizeUUID ( uuid ) <EOL> if '<STR_LIT>' not in kwargs : <EOL> kwargs [ '<STR_LIT>' ] = models . Computer . get_by_key_name ( uuid ) <EOL> l = model ( uuid = uuid , ** kwargs ) <EOL> try : <EOL> l . put ( ) <EOL> except ( db . Error , apiproxy_errors . Error , runtime . DeadlineExceededError ) : <EOL> logging . warning ( '<STR_LIT>' ) <EOL> now_str = datetime . datetime . utcnow ( ) . strftime ( '<STR_LIT>' ) <EOL> deferred_name = '<STR_LIT>' % ( uuid , now_str ) <EOL> deferred . defer ( <EOL> WriteClientLog , model , uuid , <EOL> _name = deferred_name , _countdown = <NUM_LIT:5> , ** kwargs ) <EOL> return kwargs [ '<STR_LIT>' ] <EOL> def WriteBrokenClient ( uuid , reason , details ) : <EOL> """<STR_LIT>""" <EOL> facts = { } <EOL> lines = details . splitlines ( ) <EOL> for line in lines : <EOL> try : <EOL> ( key , unused_sep , value ) = line . split ( '<STR_LIT:U+0020>' , <NUM_LIT:2> ) <EOL> except ValueError : <EOL> continue <EOL> value = value . strip ( ) <EOL> facts [ key ] = value <EOL> uuid = common . SanitizeUUID ( uuid ) <EOL> bc = models . ComputerClientBroken . get_or_insert ( uuid ) <EOL> bc . broken_datetimes . append ( datetime . datetime . utcnow ( ) ) <EOL> bc . reason = reason <EOL> bc . details = details <EOL> bc . fixed = False <EOL> bc . hostname = facts . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> bc . owner = facts . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> bc . serial = facts . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> bc . uuid = uuid <EOL> bc . put ( ) <EOL> def WriteComputerMSULog ( uuid , details ) : <EOL> """<STR_LIT>""" <EOL> uuid = common . SanitizeUUID ( uuid ) <EOL> key = '<STR_LIT>' % ( uuid , details [ '<STR_LIT:source>' ] , details [ '<STR_LIT>' ] ) <EOL> c = models . ComputerMSULog ( key_name = key ) <EOL> c . uuid = uuid <EOL> c . event = details [ '<STR_LIT>' ] <EOL> c . source = details [ '<STR_LIT:source>' ] <EOL> c . user = details [ '<STR_LIT:user>' ] <EOL> c . desc = details [ '<STR_LIT>' ] <EOL> try : <EOL> mtime = util . Datetime . utcfromtimestamp ( details . get ( '<STR_LIT:time>' , None ) ) <EOL> except ValueError , e : <EOL> logging . warning ( '<STR_LIT>' % str ( e ) ) <EOL> mtime = datetime . datetime . utcnow ( ) <EOL> except util . EpochExtremeFutureValueError , e : <EOL> logging . warning ( '<STR_LIT>' % str ( e ) ) <EOL> mtime = datetime . datetime . utcnow ( ) <EOL> except util . EpochValueError : <EOL> mtime = datetime . datetime . utcnow ( ) <EOL> if c . mtime is None or mtime > c . mtime : <EOL> c . mtime = mtime <EOL> c . put ( ) <EOL> def GetBoolValueFromString ( s ) : <EOL> """<STR_LIT>""" <EOL> if s and s . lower ( ) == '<STR_LIT:true>' or s == '<STR_LIT:1>' : <EOL> return True <EOL> elif s and s . lower ( ) == '<STR_LIT:false>' or s == '<STR_LIT:0>' : <EOL> return False <EOL> else : <EOL> return None <EOL> def KeyValueStringToDict ( s , delimiter = '<STR_LIT:|>' ) : <EOL> """<STR_LIT>""" <EOL> d = { } <EOL> pairs = s . split ( delimiter ) <EOL> for pair in pairs : <EOL> try : <EOL> key , value = pair . split ( '<STR_LIT:=>' , <NUM_LIT:1> ) <EOL> if not value or value == '<STR_LIT:None>' : <EOL> value = None <EOL> d [ key ] = value <EOL> except ValueError : <EOL> logging . debug ( '<STR_LIT>' , pair ) <EOL> return d <EOL> def ParseClientId ( client_id , uuid = None ) : <EOL> """<STR_LIT>""" <EOL> if client_id and client_id . find ( '<STR_LIT:\n>' ) > - <NUM_LIT:1> : <EOL> logging . warning ( <EOL> '<STR_LIT>' , <EOL> base64 . b64encode ( client_id ) ) <EOL> client_id = client_id . replace ( '<STR_LIT:\n>' , '<STR_LIT:_>' ) <EOL> if type ( client_id ) is str : <EOL> try : <EOL> client_id = client_id . decode ( '<STR_LIT:utf-8>' ) <EOL> except UnicodeDecodeError : <EOL> client_id = client_id . decode ( '<STR_LIT:utf-8>' , '<STR_LIT:replace>' ) <EOL> logging . warning ( '<STR_LIT>' , client_id ) <EOL> out = KeyValueStringToDict ( client_id ) <EOL> for field , value_type in CLIENT_ID_FIELDS . iteritems ( ) : <EOL> if field not in out or out [ field ] is None : <EOL> out [ field ] = None <EOL> elif value_type is bool : <EOL> out [ field ] = GetBoolValueFromString ( out [ field ] ) <EOL> elif value_type is str : <EOL> out [ field ] = out [ field ] [ : <NUM_LIT> ] <EOL> else : <EOL> try : <EOL> out [ field ] = value_type ( out [ field ] ) <EOL> except ValueError : <EOL> logging . warning ( <EOL> '<STR_LIT>' , field , out [ field ] ) <EOL> out [ field ] = None <EOL> if out [ '<STR_LIT>' ] not in common . TRACKS : <EOL> if out [ '<STR_LIT>' ] is not None : <EOL> logging . warning ( '<STR_LIT>' , out [ '<STR_LIT>' ] ) <EOL> out [ '<STR_LIT>' ] = common . DEFAULT_TRACK <EOL> if uuid : <EOL> out [ '<STR_LIT>' ] = common . SanitizeUUID ( uuid ) <EOL> return out <EOL> def IsPanicMode ( mode ) : <EOL> """<STR_LIT>""" <EOL> if mode not in PANIC_MODES : <EOL> raise ValueError ( mode ) <EOL> m = models . KeyValueCache . MemcacheWrappedGet ( <EOL> '<STR_LIT>' % ( PANIC_MODE_PREFIX , mode ) ) <EOL> if m : <EOL> return True <EOL> else : <EOL> return False <EOL> def SetPanicMode ( mode , enabled ) : <EOL> """<STR_LIT>""" <EOL> if mode not in PANIC_MODES : <EOL> raise ValueError ( mode ) <EOL> q = models . KeyValueCache . get_by_key_name ( '<STR_LIT>' % ( PANIC_MODE_PREFIX , mode ) ) <EOL> if enabled : <EOL> if not q : <EOL> q = models . KeyValueCache ( key_name = '<STR_LIT>' % ( PANIC_MODE_PREFIX , mode ) ) <EOL> q . text_value = '<STR_LIT:1>' <EOL> q . put ( ) <EOL> else : <EOL> if q : <EOL> q . delete ( ) <EOL> models . KeyValueCache . ResetMemcacheWrap ( '<STR_LIT>' % ( PANIC_MODE_PREFIX , mode ) ) <EOL> def IsPanicModeNoPackages ( ) : <EOL> """<STR_LIT>""" <EOL> return IsPanicMode ( PANIC_MODE_NO_PACKAGES ) <EOL> def SetPanicModeNoPackages ( enabled ) : <EOL> """<STR_LIT>""" <EOL> SetPanicMode ( PANIC_MODE_NO_PACKAGES , enabled ) <EOL> def GetComputerManifest ( uuid = None , client_id = None , packagemap = False ) : <EOL> """<STR_LIT>""" <EOL> if client_id is None and uuid is None : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if client_id is not None : <EOL> if type ( client_id ) is not dict : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> uuid = client_id . get ( '<STR_LIT>' ) <EOL> user_settings = None <EOL> if uuid is not None : <EOL> c = models . Computer . get_by_key_name ( uuid ) <EOL> if not c : <EOL> raise ComputerNotFoundError <EOL> user_settings = c . user_settings <EOL> client_id = { <EOL> '<STR_LIT>' : uuid , <EOL> '<STR_LIT>' : c . owner , <EOL> '<STR_LIT>' : c . hostname , <EOL> '<STR_LIT>' : c . serial , <EOL> '<STR_LIT>' : c . config_track , <EOL> '<STR_LIT>' : c . track , <EOL> '<STR_LIT>' : c . site , <EOL> '<STR_LIT>' : c . office , <EOL> '<STR_LIT>' : c . os_version , <EOL> '<STR_LIT>' : c . client_version , <EOL> '<STR_LIT>' : c . connections_on_corp > c . connections_off_corp , <EOL> '<STR_LIT>' : c . last_notified_datetime , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> manifest_plist_xml = None <EOL> if IsPanicModeNoPackages ( ) : <EOL> manifest_plist_xml = '<STR_LIT>' % ( <EOL> plist_module . PLIST_HEAD , plist_module . PLIST_FOOT ) <EOL> else : <EOL> manifest_name = client_id [ '<STR_LIT>' ] <EOL> m = models . Manifest . MemcacheWrappedGet ( manifest_name ) <EOL> if not m : <EOL> raise ManifestNotFoundError ( manifest_name ) <EOL> elif not m . enabled : <EOL> raise ManifestDisabledError ( manifest_name ) <EOL> manifest_plist_xml = GenerateDynamicManifest ( <EOL> m . plist , client_id , user_settings = user_settings ) <EOL> if not manifest_plist_xml : <EOL> raise ManifestNotFoundError ( manifest_name ) <EOL> if not packagemap : <EOL> return manifest_plist_xml <EOL> manifest_plist = plist_module . MunkiManifestPlist ( manifest_plist_xml ) <EOL> manifest_plist . Parse ( ) <EOL> packages = { } <EOL> query = models . PackageInfo . all ( ) <EOL> for p in query : <EOL> display_name = p . plist . get ( '<STR_LIT>' , None ) or p . plist . get ( '<STR_LIT:name>' ) <EOL> display_name = display_name . strip ( ) <EOL> version = p . plist . get ( '<STR_LIT:version>' , '<STR_LIT>' ) <EOL> packages [ p . name ] = '<STR_LIT>' % ( display_name , version ) <EOL> return { <EOL> '<STR_LIT>' : manifest_plist , <EOL> '<STR_LIT>' : packages , <EOL> } <EOL> def _ModifyList ( l , value ) : <EOL> """<STR_LIT>""" <EOL> if value . startswith ( '<STR_LIT:->' ) : <EOL> try : <EOL> l . remove ( value [ <NUM_LIT:1> : ] ) <EOL> except ValueError : <EOL> pass <EOL> else : <EOL> l . append ( value ) <EOL> def GenerateDynamicManifest ( plist , client_id , user_settings = None ) : <EOL> """<STR_LIT>""" <EOL> manifest = client_id [ '<STR_LIT>' ] <EOL> site_mods = models . SiteManifestModification . MemcacheWrappedGetAllFilter ( <EOL> ( ( '<STR_LIT>' , client_id [ '<STR_LIT>' ] ) , ) ) <EOL> os_version_mods = models . OSVersionManifestModification . MemcacheWrappedGetAllFilter ( <EOL> ( ( '<STR_LIT>' , client_id [ '<STR_LIT>' ] ) , ) ) <EOL> owner_mods = models . OwnerManifestModification . MemcacheWrappedGetAllFilter ( <EOL> ( ( '<STR_LIT>' , client_id [ '<STR_LIT>' ] ) , ) ) <EOL> uuid_mods = models . UuidManifestModification . MemcacheWrappedGetAllFilter ( <EOL> ( ( '<STR_LIT>' , client_id [ '<STR_LIT>' ] ) , ) ) <EOL> tag_mods = [ ] <EOL> if client_id [ '<STR_LIT>' ] : <EOL> computer_key = models . db . Key . from_path ( '<STR_LIT>' , client_id [ '<STR_LIT>' ] ) <EOL> computer_tags = models . Tag . GetAllTagNamesForKey ( computer_key ) <EOL> if computer_tags : <EOL> for tag in computer_tags : <EOL> t = ( ( '<STR_LIT>' , tag ) , ) <EOL> tag_mods . extend ( <EOL> models . TagManifestModification . MemcacheWrappedGetAllFilter ( t ) ) <EOL> def __ApplyModifications ( manifest , mod , plist ) : <EOL> """<STR_LIT>""" <EOL> plist_xml = None <EOL> if type ( plist ) is str : <EOL> plist_xml = plist <EOL> if not mod . enabled : <EOL> return <EOL> elif mod . manifests and manifest not in mod . manifests : <EOL> return <EOL> for install_type in mod . install_types : <EOL> plist_module . UpdateIterable ( <EOL> plist , install_type , mod . value , default = [ ] , op = _ModifyList ) <EOL> if site_mods or owner_mods or os_version_mods or uuid_mods or tag_mods : <EOL> if type ( plist ) is str : <EOL> plist = plist_module . MunkiManifestPlist ( plist ) <EOL> plist . Parse ( ) <EOL> for mod in site_mods : <EOL> __ApplyModifications ( manifest , mod , plist ) <EOL> for mod in os_version_mods : <EOL> __ApplyModifications ( manifest , mod , plist ) <EOL> for mod in owner_mods : <EOL> __ApplyModifications ( manifest , mod , plist ) <EOL> for mod in uuid_mods : <EOL> __ApplyModifications ( manifest , mod , plist ) <EOL> for mod in tag_mods : <EOL> __ApplyModifications ( manifest , mod , plist ) <EOL> if user_settings : <EOL> flash_developer = user_settings . get ( '<STR_LIT>' , False ) <EOL> block_packages = user_settings . get ( '<STR_LIT>' , [ ] ) <EOL> if ( flash_developer or block_packages ) and type ( plist ) is str : <EOL> if type ( plist ) is str : <EOL> plist = plist_module . MunkiManifestPlist ( plist ) <EOL> plist . Parse ( ) <EOL> if flash_developer : <EOL> plist [ common . MANAGED_UPDATES ] . append ( FLASH_PLUGIN_DEBUG_NAME ) <EOL> try : <EOL> plist [ common . MANAGED_UPDATES ] . remove ( FLASH_PLUGIN_NAME ) <EOL> except ValueError : <EOL> pass <EOL> for block_package in block_packages : <EOL> for install_type in common . INSTALL_TYPES : <EOL> if block_package in plist . get ( install_type , [ ] ) : <EOL> plist [ install_type ] . remove ( block_package ) <EOL> if type ( plist ) is str : <EOL> return plist <EOL> else : <EOL> return plist . GetXml ( ) </s>
