| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
import os |
| 9 |
import shutil |
| 10 |
import time |
| 11 |
|
| 12 |
from rsyncfns import FROMDIR, TODIR, checkit, rsync_getgroups, test_fail |
| 13 |
|
| 14 |
|
| 15 |
groups = rsync_getgroups() |
| 16 |
if not groups: |
| 17 |
test_fail("Can't get groups") |
| 18 |
|
| 19 |
FROMDIR.mkdir(parents=True, exist_ok=True) |
| 20 |
for g in groups: |
| 21 |
fname = FROMDIR / f'foo-{g}' |
| 22 |
fname.write_text(time.ctime() + '\n') |
| 23 |
chgrp = shutil.which('chgrp') |
| 24 |
if chgrp is None: |
| 25 |
test_fail("chgrp not found in PATH") |
| 26 |
|
| 27 |
try: |
| 28 |
os.chown(fname, -1, int(g)) |
| 29 |
except (ValueError, PermissionError): |
| 30 |
|
| 31 |
import subprocess |
| 32 |
proc = subprocess.run([chgrp, g, str(fname)]) |
| 33 |
if proc.returncode != 0: |
| 34 |
test_fail("Can't chgrp") |
| 35 |
|
| 36 |
time.sleep(2) |
| 37 |
|
| 38 |
checkit(['-rtgpvvv', f'{FROMDIR}/', f'{TODIR}/'], FROMDIR, TODIR) |