def list_cleanerml_files(local_only=False): """List CleanerML files""" cleanerdirs = (bleachbit.personal_cleaners_dir, ) if bleachbit.local_cleaners_dir: # If the application is installed, locale_cleaners_dir is None cleanerdirs = (bleachbit.local_cleaners_dir, ) if not local_only and bleachbit.system_cleaners_dir: cleanerdirs += (bleachbit.system_cleaners_dir, ) for pathname in listdir(cleanerdirs): if not pathname.lower().endswith('.xml'): continue import stat st = os.stat(pathname) if sys.platform != 'win32' and stat.S_IMODE(st[stat.ST_MODE]) & 2: logger.warning("ignoring cleaner because it is world writable: %s", pathname) continue yield pathname
def list_cleanerml_files(local_only=False): """List CleanerML files""" cleanerdirs = (bleachbit.personal_cleaners_dir, ) if bleachbit.local_cleaners_dir: # If the application is installed, local_cleaners_dir is None 응용프로그램이 설치된 경우, local_cleaner_dir은 없다. cleanerdirs = (bleachbit.local_cleaners_dir, ) # 지역 클리너 디렉토리가 있는경우 cleanerdirs에 저장 if not local_only and bleachbit.system_cleaners_dir: cleanerdirs += (bleachbit.system_cleaners_dir, ) # local_only가 false고 시스템 클리너 디렉토리가 으면 cleanerdirs에 저장 for pathname in listdir(cleanerdirs): if not pathname.lower().endswith('.xml'): # 클리너디렉토리에 있는 파일의 전체경로를 반복하여 소문자로바꾸고 .xml로 끝나는지 확인 continue # false면 continue import stat # stat모듈을 불러온다 st = os.stat(pathname) # 해당 경로의 내용을 추출하여 st에 저장 if sys.platform != 'win32' and stat.S_IMODE(st[stat.ST_MODE]) & 2: logger.warning("ignoring cleaner because it is world writable: %s", pathname) continue yield pathname # 경로 반환
def create_pot(): """Create a .pot for translation using gettext""" f = open('../po/cleanerml.pot', 'w') for pathname in listdir('../cleaners'): if not pathname.lower().endswith(".xml"): continue strings = [] try: CleanerML(pathname, lambda newstr, translators=None: strings.append( [newstr, translators])) except: logger.exception(_("Error reading cleaner: %s"), pathname) continue for (string, translators) in strings: f.write(pot_fragment(string, pathname, translators)) f.close()
def list_cleanerml_files(local_only=False): """List CleanerML files""" cleanerdirs = (bleachbit.personal_cleaners_dir, ) if bleachbit.local_cleaners_dir: # If the application is installed, locale_cleaners_dir is None cleanerdirs = (bleachbit.local_cleaners_dir, ) if not local_only and bleachbit.system_cleaners_dir: cleanerdirs += (bleachbit.system_cleaners_dir, ) for pathname in listdir(cleanerdirs): if not pathname.lower().endswith('.xml'): continue import stat st = os.stat(pathname) if sys.platform != 'win32' and stat.S_IMODE(st[stat.ST_MODE]) & 2: # TRANSLATORS: When BleachBit detects the file permissions are # insecure, it will not load the cleaner as if it did not exist. logger.warning( _("Ignoring cleaner because it is world writable: %s"), pathname) continue yield pathname
def create_pot(): """Create a .pot for translation using gettext""" f = open('../po/cleanerml.pot', 'w') for pathname in listdir('../cleaners'): if not pathname.lower().endswith(".xml"): continue strings = [] try: CleanerML(pathname, lambda newstr, translators=None: strings.append([newstr, translators])) except: logger.exception('error reading: %s', pathname) continue for (string, translators) in strings: f.write(pot_fragment(string, pathname, translators)) f.close()
def create_pot(): """Create a .pot for translation using gettext gettext를 이용해 번역할 .pot파일 생성""" f = open('../po/cleanerml.pot', 'w') # po/cleanerml.pot을 연다. for pathname in listdir('../cleaners'): # /cleaners경로에있는 파일들의 경로 반복 if not pathname.lower().endswith(".xml"): #경로를 소문자로바꾸고 .xml로 끝나는지 확인해서 false면 continue continue strings = [] try: CleanerML(pathname, lambda newstr, translators=None: strings.append([newstr, translators])) except: logger.exception('error reading: %s', pathname) # 에러발생메세지 출력 continue for (string, translators) in strings: f.write(pot_fragment(string, pathname, translators)) f.close()
def test_wipe_sub(n_bytes, mkfs_cmd): """Test FileUtilities.wipe_path""" if 'nt' == os.name: print 'WARNING: test_wipe() not supported on Windows' return filename = create_disk_image(n_bytes) print 'created disk image %s' % filename # format filesystem format_filesystem(filename, mkfs_cmd) # mount mountpoint = tempfile.mkdtemp(prefix='bleachbit-wipe-mountpoint') mount_filesystem(filename, mountpoint) # baseline free disk space print 'df for clean filesystem' print run_external(['df', mountpoint])[1] # make dirty make_dirty(mountpoint) # verify dirtiness unmount_filesystem(mountpoint) assert(verify_cleanliness(filename) == 11) mount_filesystem(filename, mountpoint) # standard delete print 'info: standard delete' delete_counter = 0 for secretfile in listdir(mountpoint): if not 'secret' in secretfile: # skip lost+found continue delete(secretfile, shred=False) delete_counter += 1 print 'debug: deleted %d files' % delete_counter # check print 'df for empty, dirty filesystem' print run_external(['df', mountpoint])[1] # verify dirtiness unmount_filesystem(mountpoint) assert(verify_cleanliness(filename) == 11) mount_filesystem(filename, mountpoint) expected_free_space = free_space(mountpoint) # measure effectiveness of multiple wipes for i in range(1, 10): print '*' * 30 print '* pass %d *' % i print '*' * 30 # remount if i > 1: mount_filesystem(filename, mountpoint)\ # really wipe print 'wiping %s' % mountpoint for w in wipe_path(mountpoint): pass # verify cleaning process freed all space it allocated actual_free_space = free_space(mountpoint) if not expected_free_space == actual_free_space: print 'expecting %d free space but got %d' % \ (expected_free_space, actual_free_space) import pdb pdb.set_trace() # unmount unmount_filesystem(mountpoint) # verify cleanliness cleanliness = verify_cleanliness(filename) assert(cleanliness < 2) # remove temporary delete(filename) delete(mountpoint)
def test_wipe_sub(n_bytes, mkfs_cmd): """Test FileUtilities.wipe_path""" filename = create_disk_image(n_bytes) print('created disk image %s' % filename) # format filesystem format_filesystem(filename, mkfs_cmd) # mount mountpoint = tempfile.mkdtemp(prefix='bleachbit-wipe-mountpoint') mount_filesystem(filename, mountpoint) # baseline free disk space print('df for clean filesystem') print(run_external(['df', mountpoint])[1]) # make dirty make_dirty(mountpoint) # verify dirtiness unmount_filesystem(mountpoint) assert (verify_cleanliness(filename) == 11) mount_filesystem(filename, mountpoint) # standard delete logger.info('standard delete') delete_counter = 0 for secretfile in listdir(mountpoint): if 'secret' not in secretfile: # skip lost+found continue delete(secretfile, shred=False) delete_counter += 1 logger.debug('deleted %d files', delete_counter) # check print('df for empty, dirty filesystem') print(run_external(['df', mountpoint])[1]) # verify dirtiness unmount_filesystem(mountpoint) assert (verify_cleanliness(filename) == 11) mount_filesystem(filename, mountpoint) expected_free_space = free_space(mountpoint) # measure effectiveness of multiple wipes for i in range(1, 10): print('*' * 30) print('* pass %d *' % i) print('*' * 30) # remount if i > 1: mount_filesystem(filename, mountpoint)\ # really wipe print('wiping %s' % mountpoint) for w in wipe_path(mountpoint): pass # verify cleaning process freed all space it allocated actual_free_space = free_space(mountpoint) if not expected_free_space == actual_free_space: print('expecting %d free space but got %d' % (expected_free_space, actual_free_space)) import pdb pdb.set_trace() # unmount unmount_filesystem(mountpoint) # verify cleanliness cleanliness = verify_cleanliness(filename) assert (cleanliness < 2) # remove temporary delete(filename) delete(mountpoint)
def test_wipe_sub(n_bytes, mkfs_cmd): """Test FileUtilities.wipe_path""" if 'nt' == os.name: print 'WARNING: test_wipe() not supported on Windows' return filename = create_disk_image(n_bytes) print 'created disk image %s' % filename # format filesystem format_filesystem(filename, mkfs_cmd) # mount mountpoint = tempfile.mkdtemp('bleachbit-wipe-mountpoint') mount_filesystem(filename, mountpoint) # baseline free disk space print 'df for clean filesystem' print run_external(['df', mountpoint])[1] # make dirty make_dirty(mountpoint) # verify dirtiness unmount_filesystem(mountpoint) assert (verify_cleanliness(filename) == 11) mount_filesystem(filename, mountpoint) # standard delete print 'info: standard delete' delete_counter = 0 for secretfile in listdir(mountpoint): if not 'secret' in secretfile: # skip lost+found continue delete(secretfile, shred=False) delete_counter += 1 print 'debug: deleted %d files' % delete_counter # check print 'df for empty, dirty filesystem' print run_external(['df', mountpoint])[1] # verify dirtiness unmount_filesystem(mountpoint) assert (verify_cleanliness(filename) == 11) mount_filesystem(filename, mountpoint) expected_free_space = free_space(mountpoint) # measure effectiveness of multiple wipes for i in range(1, 10): print '*' * 30 print '* pass %d *' % i print '*' * 30 # remount if i > 1: mount_filesystem(filename, mountpoint)\ # really wipe print 'wiping %s' % mountpoint for w in wipe_path(mountpoint): pass # verify cleaning process freed all space it allocated actual_free_space = free_space(mountpoint) if not expected_free_space == actual_free_space: print 'expecting %d free space but got %d' % \ (expected_free_space, actual_free_space) import pdb pdb.set_trace() # unmount unmount_filesystem(mountpoint) # verify cleanliness cleanliness = verify_cleanliness(filename) assert (cleanliness < 2) # remove temporary delete(filename) delete(mountpoint)