Ejemplo n.º 1
0
def append_cacheinfo_to_list(belong, path):
    info = []
    info.append('Belong:%s' % belong)
    info.append('Path:%s' % path)
    if os.path.isdir(path):
        info.append('Type:directory')
        info.append('Size:%s' % common.confirm_filesize_unit(common.get_dir_size(path)))
    else:
        info.append('Type:file')
        info.append('Size:%s' % common.confirm_filesize_unit(os.path.getsize(path)))

    return info
Ejemplo n.º 2
0
def append_cacheinfo_to_list(belong, path):
    info = []
    info.append('Belong:%s' % belong)
    info.append('Path:%s' % path)
    if os.path.isdir(path):
        info.append('Type:directory')
        info.append('Size:%s' % common.confirm_filesize_unit(common.get_dir_size(path)))
    else:
        info.append('Type:file')
        info.append('Size:%s' % common.confirm_filesize_unit(os.path.getsize(path)))

    return info
Ejemplo n.º 3
0
def interface_remove_file_system(system, fp):
        if os.path.exists(fp):
            filepath = fp.encode("UTF-8")
            info = []
            if os.path.isdir(filepath):
                info.append('Path:%s' % filepath)
                info.append('Size:%s' % common.confirm_filesize_unit(common.get_dir_size(filepath)))
                shutil.rmtree(filepath)
                system.subpage_data_signal(info)
            else:
                info.append('Path:%s' % filepath)
                info.append('Size:%s' % common.confirm_filesize_unit(os.path.getsize(filepath)))
                os.remove(filepath)
                system.subpage_data_signal(info)
        else:
            system.subpage_error_signal('Non-existent:%s' % filepath)
Ejemplo n.º 4
0
def interface_remove_file_system(system, fp):
        filepath = fp.encode("UTF-8")
        if os.path.exists(fp):
            info = []
            if os.path.isdir(filepath):
                info.append('Path:%s' % filepath)
                info.append('Size:%s' % common.confirm_filesize_unit(common.get_dir_size(filepath)))
                shutil.rmtree(filepath)
                system.subpage_data_signal(info)
            else:
                info.append('Path:%s' % filepath)
                info.append('Size:%s' % common.confirm_filesize_unit(os.path.getsize(filepath)))
                os.remove(filepath)
                system.subpage_data_signal(info)
        else:
            system.subpage_error_signal('Non-existent:%s' % filepath)
Ejemplo n.º 5
0
 def get_softwarecenter_cache(self, homedir):
     centercachelist = []
     if homedir:
         softwarecenter_cache = '%s/.cache/software-center/' % homedir
     else:
         softwarecenter_cache = os.path.expanduser('~/.cache/software-center/')
     full_path = softwarecenter_cache
     if os.path.exists(full_path):
         for one in os.listdir(full_path):
             tmp_path = full_path + one
             if os.path.isdir(tmp_path):
                 size = get_dir_size(tmp_path)
                 centercachelist.append('%s<2_2>%s' % (tmp_path, confirm_filesize_unit(size)))
             else:
                 centercachelist.append('%s<2_2>%s' % (tmp_path, confirm_filesize_unit(os.path.getsize(tmp_path))))
     return centercachelist
Ejemplo n.º 6
0
 def get_softwarecenter_cache(self, homedir):
     centercachelist = []
     if homedir:
         softwarecenter_cache = '%s/.cache/software-center/' % homedir
     else:
         softwarecenter_cache = os.path.expanduser(
             '~/.cache/software-center/')
     full_path = softwarecenter_cache
     if os.path.exists(full_path):
         for one in os.listdir(full_path):
             tmp_path = full_path + one
             if os.path.isdir(tmp_path):
                 size = get_dir_size(tmp_path)
                 centercachelist.append(
                     '%s<2_2>%s' % (tmp_path, confirm_filesize_unit(size)))
             else:
                 centercachelist.append(
                     '%s<2_2>%s' %
                     (tmp_path,
                      confirm_filesize_unit(os.path.getsize(tmp_path))))
     return centercachelist
Ejemplo n.º 7
0
    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'])
Ejemplo n.º 8
0
    def get_all_cache_crufts(self, mode_list, flag, sesdaemon):
        homedir = common.return_homedir_sesdaemon()

        if 'apt' in mode_list:
            aptpath = "/var/cache/apt/archives"
            temp_apt_list = self.objc.scan_apt_cache(aptpath)
            for one in temp_apt_list:
                sesdaemon.data_transmit_by_cache('apt', one, 'False', '%s' % common.confirm_filesize_unit(os.path.getsize(one)))

        if 'software-center' in mode_list:
            softwarecenterpath = "%s/.cache/software-center" % homedir
            temp_softwarecenter_list = self.objc.public_scan_cache(softwarecenterpath)
            for one in temp_softwarecenter_list:
                if os.path.isdir(one):
                    sesdaemon.data_transmit_by_cache('software-center', one, 'True', common.confirm_filesize_unit(common.get_dir_size(one)))
                else:
                    sesdaemon.data_transmit_by_cache('software-center', one, 'False', common.confirm_filesize_unit(os.path.getsize(one)))

        if 'thumbnails' in mode_list:
            thumbnailspath = "%s/.cache/thumbnails" % homedir
            temp_thumbnails_list = self.objc.public_scan_cache(thumbnailspath)
            for one in temp_thumbnails_list:
                if os.path.isdir(one):
                    sesdaemon.data_transmit_by_cache('thumbnails', one, 'True', common.confirm_filesize_unit(common.get_dir_size(one)))
                else:
                    sesdaemon.data_transmit_by_cache('thumbnails', one, 'False',common.confirm_filesize_unit(os.path.getsize(one)))
        if 'firefox' in mode_list:
            firefoxpath = "%s/.cache/mozilla/firefox/%s" % (homedir, common.analytical_profiles_file(homedir))
            #sesdaemon.path_transmit_by_cache('firefox', firefoxpath)
            temp_firefox_list = self.objc.firefox_scan_cache(firefoxpath)
            for one in temp_firefox_list:
                if os.path.isdir(one):
                    sesdaemon.data_transmit_by_cache('firefox', one, 'True', common.confirm_filesize_unit(common.get_dir_size(one)))
                else:
                    sedaemon.data_transmit_by_cache('firefox', one, 'False', common.confirm_filesize_unit(os.path.getsize(one)))
        if 'chromium' in mode_list:
            chromiumpath = "%s/.cache/chromium/Default" % homedir
            #sesdaemon.path_transmit_by_cache('chromium', chromiumpath)
            temp_chromium_list = self.objc.public_scan_cache(chromiumpath)
            for one in temp_chromium_list:
                if os.path.isdir(one):
                    sesdaemon.data_transmit_by_cache('chromium', one, 'True', common.confirm_filesize_unit(common.get_dir_size(one)))
                else:
                    sesdaemon.data_transmit_by_cache('chromium', one, 'False',common.confirm_filesize_unit(os.path.getsize(one)))

        sesdaemon.cache_transmit_complete(flag)
Ejemplo n.º 9
0
 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
     time.sleep(1)
     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'])
     time.sleep(1)
     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'])
     time.sleep(1)
     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'])
Ejemplo n.º 10
0
    def get_all_cache_crufts(self, mode_list, flag, sesdaemon):
        homedir = common.return_homedir_sesdaemon()

        if 'apt' in mode_list:
            aptpath = "/var/cache/apt/archives"
            temp_apt_list = self.objc.scan_apt_cache(aptpath)
            for one in temp_apt_list:
                sesdaemon.data_transmit_by_cache('apt', one, 'False', '%s' % common.confirm_filesize_unit(os.path.getsize(one)))

        if 'software-center' in mode_list:
            softwarecenterpath = "%s/.cache/software-center" % homedir
            temp_softwarecenter_list = self.objc.public_scan_cache(softwarecenterpath)
            for one in temp_softwarecenter_list:
                if os.path.isdir(one):
                    sesdaemon.data_transmit_by_cache('software-center', one, 'True', common.confirm_filesize_unit(common.get_dir_size(one)))
                else:
                    sesdaemon.data_transmit_by_cache('software-center', one, 'False', common.confirm_filesize_unit(os.path.getsize(one)))

        if 'thumbnails' in mode_list:
            thumbnailspath = "%s/.cache/thumbnails" % homedir
            temp_thumbnails_list = self.objc.public_scan_cache(thumbnailspath)
            for one in temp_thumbnails_list:
                if os.path.isdir(one):
                    sesdaemon.data_transmit_by_cache('thumbnails', one, 'True', common.confirm_filesize_unit(common.get_dir_size(one)))
                else:
                    sesdaemon.data_transmit_by_cache('thumbnails', one, 'False',common.confirm_filesize_unit(os.path.getsize(one)))
        if 'firefox' in mode_list:
            firefoxpath = "%s/.cache/mozilla/firefox/%s" % (homedir, common.analytical_profiles_file(homedir))
            #sesdaemon.path_transmit_by_cache('firefox', firefoxpath)
            temp_firefox_list = self.objc.firefox_scan_cache(firefoxpath)
            for one in temp_firefox_list:
                if os.path.isdir(one):
                    sesdaemon.data_transmit_by_cache('firefox', one, 'True', common.confirm_filesize_unit(common.get_dir_size(one)))
                else:
                    sedaemon.data_transmit_by_cache('firefox', one, 'False', common.confirm_filesize_unit(os.path.getsize(one)))
        if 'chromium' in mode_list:
            chromiumpath = "%s/.cache/chromium/Default" % homedir
            #sesdaemon.path_transmit_by_cache('chromium', chromiumpath)
            temp_chromium_list = self.objc.public_scan_cache(chromiumpath)
            for one in temp_chromium_list:
                if os.path.isdir(one):
                    sesdaemon.data_transmit_by_cache('chromium', one, 'True', common.confirm_filesize_unit(common.get_dir_size(one)))
                else:
                    sesdaemon.data_transmit_by_cache('chromium', one, 'False',common.confirm_filesize_unit(os.path.getsize(one)))

        sesdaemon.cache_transmit_complete(flag)