<s> import frappe , json <EOL> from frappe . desk . doctype . desktop_icon . desktop_icon import sync_from_app , get_user_copy <EOL> import frappe . defaults <EOL> def execute ( ) : <EOL> frappe . reload_doc ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> frappe . db . sql ( '<STR_LIT>' ) <EOL> modules_list = [ ] <EOL> for app in frappe . get_installed_apps ( ) : <EOL> modules_list += sync_from_app ( app ) <EOL> hidden_modules = frappe . db . get_global ( '<STR_LIT>' ) <EOL> if hidden_modules : <EOL> for m in json . loads ( hidden_modules ) : <EOL> try : <EOL> desktop_icon = frappe . get_doc ( '<STR_LIT>' , { '<STR_LIT>' : m , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : app } ) <EOL> desktop_icon . db_set ( '<STR_LIT>' , <NUM_LIT:1> ) <EOL> except frappe . DoesNotExistError : <EOL> pass <EOL> for user in frappe . get_all ( '<STR_LIT>' , filters = { '<STR_LIT>' : '<STR_LIT>' } ) : <EOL> user_list = frappe . defaults . get_user_default ( '<STR_LIT>' , user = user . name ) <EOL> if user_list : <EOL> user_list = json . loads ( user_list ) <EOL> for i , module_name in enumerate ( user_list ) : <EOL> try : <EOL> desktop_icon = get_user_copy ( module_name , user = user . name ) <EOL> desktop_icon . db_set ( '<STR_LIT>' , i ) <EOL> except frappe . DoesNotExistError : <EOL> pass <EOL> for module_name in list ( set ( [ m [ '<STR_LIT>' ] for m in modules_list ] ) - set ( user_list ) ) : <EOL> try : <EOL> desktop_icon = get_user_copy ( module_name , user = user . name ) <EOL> desktop_icon . db_set ( '<STR_LIT>' , <NUM_LIT:1> ) <EOL> except frappe . DoesNotExistError : <EOL> pass </s>
