def test_ensure_files_with_a_dot_prefix_should_not_be_erased(tmpdir): tmpdir = str(tmpdir) some_time_ago = time.time() - 60 * SECONDS old_fnames = 'old1.ts old2.ts old3.ts .should_not_be_erased.ts'.split() config = load_config() ignores = get_ignore_patterns(config) create_old_files(tmpdir, old_fnames, some_time_ago) clean(tmpdir, 50 * SECONDS, ignores) time.sleep(0.01) # sleep because clean runs in another thread assert os.listdir(tmpdir) == ['.should_not_be_erased.ts']
def __init__(self): self.config = helpers.load_config() self.sig_sent = False helpers.setup_logging(self.config, "master process") logging.debug('HLS CLIENT Started') self.destination = self.config.get('hlsclient', 'destination') # ignore all comma separated wildcard names for `clean` call self.clean_maxage = self.config.getint('hlsclient', 'clean_maxage') lock_expiration = self.config.getint('lock', 'expiration') assert self.clean_maxage > lock_expiration self.ignores = helpers.get_ignore_patterns(self.config) # Setup process group, so we can kill the childs os.setpgrp()
def test_should_not_erase_files_with_ops_prefix(tmpdir): tmpdir = str(tmpdir) some_time_ago = time.time() - 60 * SECONDS config = load_config() ignores = get_ignore_patterns(config) old_dir1 = os.path.join(tmpdir, 'need_to_be_erased') old_dir2 = os.path.join(tmpdir, 'opsdir1') os.makedirs(old_dir1) os.makedirs(old_dir2) create_old_files(tmpdir, ['ops_acesso_simultaneo.ts', 'ops_rsrs.ts'], some_time_ago) os.utime(old_dir1, (some_time_ago, some_time_ago)) os.utime(old_dir2, (some_time_ago, some_time_ago)) clean(tmpdir, 50 * SECONDS, ignores) time.sleep(0.01) # sleep because clean runs in another thread assert sorted(os.listdir(tmpdir)) == sorted(['ops_acesso_simultaneo.ts', 'ops_rsrs.ts', 'opsdir1'])
def test_should_not_erase_files_with_ops_prefix(tmpdir): tmpdir = str(tmpdir) some_time_ago = time.time() - 60 * SECONDS config = load_config() ignores = get_ignore_patterns(config) old_dir1 = os.path.join(tmpdir, 'need_to_be_erased') old_dir2 = os.path.join(tmpdir, 'opsdir1') os.makedirs(old_dir1) os.makedirs(old_dir2) create_old_files(tmpdir, ['ops_acesso_simultaneo.ts', 'ops_rsrs.ts'], some_time_ago) os.utime(old_dir1, (some_time_ago, some_time_ago)) os.utime(old_dir2, (some_time_ago, some_time_ago)) clean(tmpdir, 50 * SECONDS, ignores) time.sleep(0.01) # sleep because clean runs in another thread assert sorted(os.listdir(tmpdir)) == sorted( ['ops_acesso_simultaneo.ts', 'ops_rsrs.ts', 'opsdir1'])