Exemplo 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
Exemplo 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
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
 def get_large_files(self, size, path, sesdaemon):
     objlg = diskanalyse.DiskAnalyse()
     finalsize = size * 1024 * 1024
     largefile_list = objlg.hundred_large_files(finalsize, path)
     for one in largefile_list:
         sesdaemon.data_transmit_by_large(common.confirm_filesize_unit(one[0]), one[1])
     sesdaemon.large_transmit_complete()
Exemplo 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
Exemplo n.º 7
0
 def adjust_the_list(self, size, path):
     final_str = []
     tmp_list = self.hundred_large_files(size, path)
     if tmp_list:
         for tmp in tmp_list:
             tmp[0] = common.confirm_filesize_unit(tmp[0])
             final_str.append('<2_2>'.join(tmp))
     return final_str
Exemplo n.º 8
0
 def adjust_the_list(self, size, path):
     final_str = []
     tmp_list = self.hundred_large_files(size, path)
     if tmp_list:
         for tmp in tmp_list:
             tmp[0] = common.confirm_filesize_unit(tmp[0])
             final_str.append('<2_2>'.join(tmp))
     return final_str
Exemplo n.º 9
0
 def get_spare_packages(self):
     cache = common.get_cache_list()
     spare_packages_list = []
     if cache:
         for pkg in cache:
             if pkg.is_auto_removable and not pkg.name.startswith('linux'):
             #if pkg.is_installed and pkg.name.startswith('linux-headers'):
                 tmp_packages_list = [pkg.name, pkg.installed.summary, common.confirm_filesize_unit(pkg.installed.installed_size)]
                 spare_packages_list.append('<2_2>'.join(tmp_packages_list))
     return spare_packages_list
Exemplo n.º 10
0
 def get_apt_cache(self):
     apt_cache = '/var/cache/apt/archives'
     #aptcachelist = map(lambda filename: '%s/%s<2_2>%s' % (apt_cache, filename, str(os.path.getsize('%s/%s' % (apt_cache, filename)))), filter(lambda filestr: filestr.endswith('deb'), os.listdir(apt_cache)))
     aptcachelist = [
         '%s/%s<2_2>%s' % (apt_cache, filename,
                           confirm_filesize_unit(
                               os.path.getsize('%s/%s' %
                                               (apt_cache, filename))))
         for filename in os.listdir(apt_cache) if filename.endswith('deb')
     ]
     return aptcachelist
Exemplo n.º 11
0
 def get_unneed_packages(self):
     cache = common.get_cache_list()
     unneed_packages_list = []
     if cache:
         for pkg in cache:
             if pkg.is_auto_removable and not pkg.name.startswith('linux'):
                 unneed_packages_list.append(
                     'Name:' + pkg.name + ';' + 'Summary:' +
                     pkg.installed.summary + ';' + 'Size:' +
                     common.confirm_filesize_unit(
                         pkg.installed.installed_size))
     return unneed_packages_list
Exemplo n.º 12
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
Exemplo n.º 13
0
 def clean_cache(self, sysdaemon):
     totalsize = 0
     self.get_cache(None)
     for key in self.cache_dic.keys():
         for f in self.cache_dic[key]:
             totalsize += common.get_size(f)
             if os.path.isdir(f):
                 sysdaemon.info_for_mainpage_clean(f)
                 shutil.rmtree(f)
             else:
                 sysdaemon.info_for_mainpage_clean(f)
                 os.remove(f)
     size_str = common.confirm_filesize_unit(totalsize)
     sysdaemon.mainpage_clean(size_str)
Exemplo n.º 14
0
 def get_spare_packages(self):
     cache = common.get_cache_list()
     spare_packages_list = []
     if cache:
         for pkg in cache:
             if pkg.is_auto_removable and not pkg.name.startswith('linux'):
                 #if pkg.is_installed and pkg.name.startswith('linux-headers'):
                 tmp_packages_list = [
                     pkg.name, pkg.installed.summary,
                     common.confirm_filesize_unit(
                         pkg.installed.installed_size)
                 ]
                 spare_packages_list.append('<2_2>'.join(tmp_packages_list))
     return spare_packages_list
Exemplo n.º 15
0
 def clean_cache(self, sysdaemon):
     totalsize = 0
     self.get_cache(None)
     for key in self.cache_dic.keys():
         for f in self.cache_dic[key]:
             totalsize += common.get_size(f)
             if os.path.isdir(f):
                 sysdaemon.info_for_mainpage_clean(f)
                 shutil.rmtree(f)
             else:
                 sysdaemon.info_for_mainpage_clean(f)
                 os.remove(f)
     size_str = common.confirm_filesize_unit(totalsize)
     sysdaemon.mainpage_clean(size_str)
Exemplo n.º 16
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)
Exemplo n.º 17
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)
Exemplo n.º 18
0
    def get_oldkernel_packages(self):
        #pkgs = self.cache.packages
        cache = common.get_cache_list()
        oldkernel_list = []
        current_version = '-'.join(os.uname()[2].split('-')[:2])
        if cache:
            for pkg in cache:
                if pkg.is_installed and pkg.name.startswith('linux'):
                    if re.match(self.flag, pkg.name):
                        #version = pkg.installedVersion[:-3]
                        version = pkg.installed.version
                        if apt_pkg.version_compare(version,
                                                   current_version) < 0:
                            #tmp_oldkernel_list = [pkg.name, common.confirm_filesize_unit(pkg.installedSize)]
                            #final_oldkernel_list.append('<2_2>'.join(tmp_oldkernel_list))
                            oldkernel_list.append(
                                'Name:' + pkg.name + ';' + 'Summary:' +
                                pkg.installed.summary + ';' + 'Size:' +
                                common.confirm_filesize_unit(
                                    pkg.installed.installed_size))

        return oldkernel_list
Exemplo n.º 19
0
 def get_apt_cache(self):
     apt_cache = '/var/cache/apt/archives'
     #aptcachelist = map(lambda filename: '%s/%s<2_2>%s' % (apt_cache, filename, str(os.path.getsize('%s/%s' % (apt_cache, filename)))), filter(lambda filestr: filestr.endswith('deb'), os.listdir(apt_cache)))
     aptcachelist = ['%s/%s<2_2>%s' % (apt_cache,filename, confirm_filesize_unit(os.path.getsize('%s/%s' % (apt_cache, filename)))) for filename in os.listdir(apt_cache) if filename.endswith('deb')]
     return aptcachelist
Exemplo n.º 20
0
    def get_oldkernel_packages(self):
        #pkgs = self.cache.packages
        cache = common.get_cache_list()
        oldkernel_list = []
        current_version = '-'.join(os.uname()[2].split('-')[:2])
        if cache:
            for pkg in cache:
                if pkg.is_installed and pkg.name.startswith('linux'):
                    if re.match(self.flag, pkg.name):
                        #version = pkg.installedVersion[:-3]
                        version = pkg.installed.version
                        if apt_pkg.version_compare(version, current_version) < 0:
                            #tmp_oldkernel_list = [pkg.name, common.confirm_filesize_unit(pkg.installedSize)]
                            #final_oldkernel_list.append('<2_2>'.join(tmp_oldkernel_list))
                            oldkernel_list.append('Name:' + pkg.name + ';' + 'Summary:' + pkg.installed.summary + ';' + 'Size:' + common.confirm_filesize_unit(pkg.installed.installed_size))

        return oldkernel_list
Exemplo n.º 21
0
 def get_oldkernel_crufts(self):
     objc = oldkernel.OldKernel()
     pkgobj_list = objc.scan_oldkernel_packages()
     crufts_list = ["%s<2_2>%s" % (pkg.name, pkg.installed.summary, common.confirm_filesize_unit(pkg.installed.installed_size))for pkg in pkgobj_list]
     return crufts_list
Exemplo n.º 22
0
 def get_unneed_packages(self):
     cache = common.get_cache_list()
     unneed_packages_list = []
     if cache:
         for pkg in cache:
             if pkg.is_auto_removable and not pkg.name.startswith('linux'):
                 unneed_packages_list.append('Name:' + pkg.name + ';' + 'Summary:' + pkg.installed.summary + ';' + 'Size:' + common.confirm_filesize_unit(pkg.installed.installed_size))
     return unneed_packages_list
Exemplo n.º 23
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'])
Exemplo n.º 24
0
class MainPage():
    def __init__(self):
        pass

    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
        if sesdaemon:
            for one in temp_thumbnails_list:
                self.cache_dic['thumbnail'].append(one)
                totalsize += common.get_size(one)
                sesdaemon.check_scan_garbage_process(one)
        else:
            for one in temp_thumbnails_list:
                self.cache_dic['thumbnail'].append(one)
        if sesdaemon:
            for key in self.cache_dic.keys():
                if self.cache_dic[key]:
                    flag = True
                    break
            if flag:
                sesdaemon.scan_complete('True')
            else:
                sesdaemon.scan_complete('False')
            size_str = common.confirm_filesize_unit(totalsize)
            sesdaemon.check_scan_complete(size_str)
        else:
            pass
Exemplo n.º 25
0
    def get_all_package_crufts(self, mode_list, sesdaemon):
        if 'unneed' in mode_list:
            upkg_obj = osslim.OsSlim()
            temp_unneed_list = upkg_obj.scan_spare_packages()
            for upkg in temp_unneed_list:
                sesdaemon.data_transmit_by_package('unneed', upkg.name, upkg.installed.summary, common.confirm_filesize_unit(upkg.installed.installed_size))
        
        if 'oldkernel' in mode_list:
            opkg_obj = oldkernel.OldKernel()
            temp_oldkernel_list = opkg_obj.scan_oldkernel_packages()
            for opkg in temp_oldkernel_list:
                sesdaemon.data_transmit_by_package('oldkernel', opkg.name, opkg.installed.summary, common.confirm_filesize_unit(opkg.installed.installed_size))

        if 'configfile' in mode_list:
            spkg_obj = softwareconfigfile.SoftwareConfigfile()
            temp_configfile_list = spkg_obj.scan_configfile_packages()
            for spkg in temp_configfile_list:
                sesdaemon.data_transmit_by_package('configfile', spkg.name, '', '')
        sesdaemon.package_transmit_complete()
Exemplo n.º 26
0
    def get_all_package_crufts(self, mode_list, sesdaemon):
        if 'unneed' in mode_list:
            upkg_obj = osslim.OsSlim()
            temp_unneed_list = upkg_obj.scan_spare_packages()
            for upkg in temp_unneed_list:
                sesdaemon.data_transmit_by_package('unneed', upkg.name, upkg.installed.summary, common.confirm_filesize_unit(upkg.installed.installed_size))
        
        if 'oldkernel' in mode_list:
            opkg_obj = oldkernel.OldKernel()
            temp_oldkernel_list = opkg_obj.scan_oldkernel_packages()
            for opkg in temp_oldkernel_list:
                sesdaemon.data_transmit_by_package('oldkernel', opkg.name, opkg.installed.summary, common.confirm_filesize_unit(opkg.installed.installed_size))

        if 'configfile' in mode_list:
            spkg_obj = softwareconfigfile.SoftwareConfigfile()
            temp_configfile_list = spkg_obj.scan_configfile_packages()
            for spkg in temp_configfile_list:
                sesdaemon.data_transmit_by_package('configfile', spkg.name, '', '')
        sesdaemon.package_transmit_complete()
Exemplo n.º 27
0
 def get_oldkernel_crufts(self):
     objc = oldkernel.OldKernel()
     pkgobj_list = objc.scan_oldkernel_packages()
     crufts_list = ["%s<2_2>%s" % (pkg.name, pkg.installed.summary, common.confirm_filesize_unit(pkg.installed.installed_size))for pkg in pkgobj_list]
     return crufts_list
Exemplo n.º 28
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'])
Exemplo n.º 29
0
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:
            try:
                pkg = cache['chromium-browser']
            except KeyError:
                pass
            else:
                if pkg.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
            try:
                pkg = cache['chromium-browser']
            except KeyError:
                pass
            else:
                if pkg.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 'bash' in history:
            path = os.path.join(homedir, ".bash_history")
            size = 0
            if os.path.exists(path):
                size = common.confirm_filesize_unit(os.path.getsize(path))
                info = []
                info.append('Belong:History.bash')
                info.append('Size:%s' % str(size))
                info.append('Path:%s' % path)
                session.subpage_data_signal(info)
            else:
                pass
            

        if 'X11' in history:
            x11_list = [os.path.join(homedir, x) for x in os.listdir(homedir) if x.startswith(".xsession-errors")]
            for value in x11_list:
                info = append_cacheinfo_to_list('History.X11', value)
                session.subpage_data_signal(info)

        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')