def clean_all_onekey_crufts(self, sysdaemon, mode_list): homedir = return_homedir_sysdaemon() flag_dic = {'history': False, 'cookies': False, 'cache': False} for mode in mode_list: flag_dic['%s' % mode] = True #if flag_dic['cache']: if mode_list[0] in '1': try: objclean = FunctionOfClean() objcache = cacheclean.CacheClean() apt_path = "/var/cache/apt/archives" temp_apt_list = objcache.scan_apt_cache(apt_path) for cachea in temp_apt_list: sysdaemon.status_for_quick_clean('apt', cachea) objclean.clean_the_file(cachea) sysdaemon.status_for_quick_clean('apt', 'end') swcenterpath = '%s/.cache/software-center' % homedir temp_swcenter_list = objcache.public_scan_cache(swcenterpath) for caches in temp_swcenter_list: sysdaemon.status_for_quick_clean('software_center', caches) objclean.clean_the_file(caches) sysdaemon.status_for_quick_clean('software_center', 'end') except Exception, e: sysdaemon.clean_error_onekey('ce') else: sysdaemon.clean_complete_onekey('c')
def get_cache(self, sesdaemon): flag = False totalsize = 0 homedir = '' cache_obj = cacheclean.CacheClean() if sesdaemon: homedir = common.return_homedir_sesdaemon() else: homedir = return_homedir_sysdaemon() self.cache_dic = {'apt':[], 'softwarecenter':[], 'thumbnail':[]} aptpath = "/var/cache/apt/archives" temp_apt_list = cache_obj.scan_apt_cache(aptpath) if sesdaemon: for one in temp_apt_list: self.cache_dic['apt'].append(one) totalsize += common.get_size(one) sesdaemon.check_scan_garbage_process(one) else: for one in temp_apt_list: self.cache_dic['apt'].append(one) softwarecenterpath = "%s/.cache/software-center" % homedir temp_softwarecenter_list = cache_obj.public_scan_cache(softwarecenterpath) if sesdaemon: for one in temp_softwarecenter_list: self.cache_dic['softwarecenter'].append(one) totalsize += common.get_size(one) sesdaemon.check_scan_garbage_process(one) else: for one in temp_softwarecenter_list: self.cache_dic['softwarecenter'].append(one) thumbnailspath = "%s/.cache/thumbnails" % homedir try: temp_thumbnails_list = cache_obj.public_scan_cache(thumbnailspath) except Exception, e: print e
def interface_get_subpage_session(session, mode_dic): homedir = common.return_homedir_sesdaemon() cache = mode_dic.get('Cache', []) if cache: cache_obj = cacheclean.CacheClean() if 'apt' in cache: aptpath = "/var/cache/apt/archives" apt_list = cache_obj.scan_apt_cache(aptpath) for value in apt_list: info = append_cacheinfo_to_list('Cache.apt', value) session.subpage_data_signal(info) #else: #info = [] #info.append('Belong:Cache.apt') #info.append('') #session.subpage_data_signal(info) if 'software-center' in cache: swcenterpath = "%s/.cache/software-center" % homedir swcenter_list = cache_obj.public_scan_cache(swcenterpath) for value in swcenter_list: info = append_cacheinfo_to_list('Cache.software-center', value) session.subpage_data_signal(info) #else: #info = [] #info.append('Belong:Cache-apt') #info.append('') #session.subpage_data_signal(info) if 'thumbnails' in cache: thumbnailspath = "%s/.cache/thumbnails" % homedir thumbnails_list = cache_obj.public_scan_cache(thumbnailspath) for value in thumbnails_list: info = append_cacheinfo_to_list('Cache.thumbnails', value) session.subpage_data_signal(info) #else: #info = [] #info.append('Belong:Cache.thumbnails') #info.append('') #session.subpage_data_signal(info) if 'firefox' in cache: firefoxpath = "%s/.cache/mozilla/firefox/%s" % (homedir, common.analytical_profiles_file(homedir)) firefox_cache_list = cache_obj.firefox_scan_cache(firefoxpath) for value in firefox_cache_list: info = append_cacheinfo_to_list('Cache.firefox', value) session.subpage_data_signal(info) #else: #info = [] #info.append('Belong:Cache.firefox') #info.append('') #session.subpage_data_signal(info) if 'chromium' in cache: chromiumpath = "%s/.cache/chromium/Default" % homedir chromium_cache_list = cache_obj.public_scan_cache(chromiumpath) for value in chromium_cache_list: info = append_cacheinfo_to_list('Cache.chromium', value) session.subpage_data_signal(info) #else: #info = [] #info.append('Belong:Cache.chromium') #info.append('') #session.subpage_data_signal(info) session.subpage_status_signal('Complete:Cache') cookies = mode_dic.get('Cookies', []) if cookies: cache = common.get_cache_list() cookies_obj = cookiesclean.CookiesClean(homedir) if 'firefox' in cookies: if cache['firefox'].is_installed: ffcpath = "%s/.mozilla/firefox/%s/cookies.sqlite" % (homedir, common.analytical_profiles_file(homedir)) if os.path.exists(ffcpath): ffcpam = [ffcpath, 'moz_cookies', 'baseDomain'] firefox_cookies_list = cookies_obj.scan_cookies_records(ffcpam[0], ffcpam[1], ffcpam[2]) for value in firefox_cookies_list: info = [] info.append('Belong:Cookies.firefox') info.append('Content:%s' % value[0]) info.append('Count:%s' % str(value[-1])) session.subpage_data_signal(info) else: info = [] info.append('Belong:Cookies.firefox') info.append('') session.subpage_data_signal(info) else: session.subpage_error_signal('Uninstalled:Firefox') if 'chromium' in cookies: if cache['chromium-browser'].is_installed: chcpath = "%s/.config/chromium/Default/Cookies" % homedir if os.path.exists(chcpath): chcpam = [chcpath, 'cookies', 'host_key'] chromium_cookies_list = cookies_obj.scan_cookies_records(chcpam[0], chcpam[1], chcpam[2]) for value in chromium_cookies_list: info = [] info.append('Belong:Cookies.chromium') info.append('Content:%s' % value[0]) info.append('Count:%s' % str(value[-1])) session.subpage_data_signal(info) else: info = [] info.append('Belong:Cookies.chromium') info.append('') session.subpage_data_signal(info) else: session.subpage_error_signal('Uninstalled:Chromium') session.subpage_status_signal('Complete:Cookies') history = mode_dic.get('History', []) if history: cache = common.get_cache_list() brohistory_obj = historyclean.HistoryClean(homedir) if 'firefox' in history: if cache['firefox'].is_installed: ffhpath = "%s/.mozilla/firefox/%s/places.sqlite" % (homedir, common.analytical_profiles_file(homedir)) if os.path.exists(ffhpath): firefox_history_list = brohistory_obj.scan_firefox_history_records(ffhpath) #for single in firefox_history_list: # info = [] # info.append('Belong:History.firefox') # info.append('Id:%s' % str(single[0])) # info.append('Url:%s' % single[1]) # info.append('Count:%s' % str(single[2])) # session.subpage_data_signal(info) info = [] info.append('Belong:History.firefox') info.append('Count:%s' % str(len(firefox_history_list))) session.subpage_data_signal(info) else: info = [] info.append('Belong:History.firefox') info.append('') session.subpage_data_signal(info) else: session.subpage_error_signal('Uninstalled:Firefox') if 'chromium' in history: chhpath = "%s/.config/chromium/Default/History" % homedir if cache['chromium-browser'].is_installed: run = common.process_pid("chromium-browser") if not run: chromium_history_list = brohistory_obj.scan_chromium_history_records(chhpath) #for single in chromium_history_list: # info = [] # info.append('Belong:History.chromium') # info.append('Id:%s' % str(single[0])) # info.append('Url:%s' % single[1]) # info.append('Count:%s' % str(single[2])) # session.subpage_data_signal(info) info = [] info.append('Belong:History.chromium') info.append('Count:%s' % str(len(chromium_history_list))) session.subpage_data_signal(info) else: session.subpage_error_signal('Working:Chromium') else: session.subpage_error_signal('Uninstalled:Chromium') if 'system' in history: syshistory_obj = systemhistory.SystemHistory() url_list = syshistory_obj.scan_the_xml(homedir) #for value in url_list: # info = [] # info.append('Belong:History.system') #info.append('Count:%s' % len(url_list)) # info.append('Href:%s' % value) # session.subpage_data_signal(info) info = [] info.append('Belong:History.system') info.append('Count:%s' % str(len(url_list))) session.subpage_data_signal(info) session.subpage_status_signal('Complete:History') packages = mode_dic.get('Packages', []) if packages: if 'unneed' in packages: unneed_obj = osslim.OsSlim() unneed_packages_list = unneed_obj.get_unneed_packages() for value in unneed_packages_list: info = value.split(";") info.insert(0, 'Belong:Packages.unneed') session.subpage_data_signal(info) if 'oldkernel' in packages: oldkernel_obj = oldkernel.OldKernel() oldkernel_list = oldkernel_obj.get_oldkernel_packages() for value in oldkernel_list: info = value.split(";") info.insert(0, 'Belong:Packages.oldkernel') session.subpage_data_signal(info) if 'configfile' in packages: configfile_obj = softwareconfigfile.SoftwareConfigfile() configfile_list = configfile_obj.get_configfile_packages() for value in configfile_list: info = value.split(";") info.insert(0, 'Belong:Packages.configfile') session.subpage_data_signal(info) session.subpage_status_signal('Complete:Packages') session.subpage_status_signal('Complete:All')
def get_onekey_crufts(self, sesdaemon, mode_list): homedir = common.return_homedir_sesdaemon() crufts_dic = {} total_dic = {} flag_dic = {'history': False, 'cookies': False, 'cache': False} for mode in mode_list: flag_dic['%s' % mode] = True if flag_dic['history']: historysize = 0 objhg = historyclean.HistoryClean(homedir) filepathf = "%s/.mozilla/firefox/%s/places.sqlite" % (homedir, common.analytical_profiles_file(homedir)) if os.path.exists(filepathf): tempf_list = objhg.scan_firefox_history_records(filepathf) for onef in tempf_list: sesdaemon.display_scan_process(onef[1]) #sesdaemon.display_scan_process_msg(onef[1]) historysize += onef[2] filepathc = "%s/.config/chromium/Default/History" % homedir if os.path.exists(filepathc): run = common.process_pid("chromium-browser") if not run: tempc_list = objhg.scan_chromium_history_records(filepathc) for onec in tempc_list: sesdaemon.display_scan_process(onec[1]) #sesdaemon.display_scan_process_msg(onec[1]) historysize += onec[2] total_dic['history'] = str(historysize) sesdaemon.total_data_transmit('h', total_dic['history']) if flag_dic['cookies']: cookiessize = 0 objcg = cookiesclean.CookiesClean(homedir) filepathff = "%s/.mozilla/firefox/%s/cookies.sqlite" % (homedir, common.analytical_profiles_file(homedir)) if os.path.exists(filepathff): pamf = [filepathff, 'moz_cookies', 'baseDomain'] tempff_list = objcg.scan_cookies_records(pamf[0], pamf[1], pamf[2]) for oneff in tempff_list: sesdaemon.display_scan_process(oneff[0]) #sesdaemon.display_scan_process_msg(oneff[0]) cookiessize += oneff[1] filepathcc = "%s/.config/chromium/Default/Cookies" % homedir if os.path.exists(filepathcc): pamc = [filepathcc, 'cookies', 'host_key'] tempcc_list = objcg.scan_cookies_records(pamc[0], pamc[1], pamc[2]) for onecc in tempcc_list: sesdaemon.display_scan_process(onecc[0]) #sesdaemon.display_scan_process_msg(onecc[0]) cookiessize += onecc[1] total_dic['cookies'] = str(cookiessize) sesdaemon.total_data_transmit('k', total_dic['cookies']) if flag_dic['cache']: cachesize = 0 objcache = cacheclean.CacheClean() apt_path = "/var/cache/apt/archives" temp_apt_list = objcache.scan_apt_cache(apt_path) for oneapt in temp_apt_list: sesdaemon.display_scan_process(oneapt) #sesdaemon.display_scan_process_msg(oneapt) cachesize += os.path.getsize(oneapt) swcenterpath = '%s/.cache/software-center' % homedir temp_swcenter_list = objcache.public_scan_cache(swcenterpath) for oneswcenter in temp_swcenter_list: sesdaemon.display_scan_process(oneswcenter) #sesdaemon.display_scan_process_msg(oneswcenter) if os.path.isdir(oneswcenter): cachesize += common.get_dir_size(oneswcenter) else: cachesize += os.path.getsize(oneswcenter) total_dic['cache'] = common.confirm_filesize_unit(cachesize) sesdaemon.total_data_transmit('c', total_dic['cache'])
def __init__(self): self.objc = cacheclean.CacheClean()