(
c, local_path, remote_path, permissions=None, user='root', group=None, create_parent_dir=False
)
| 11 | |
| 12 | |
| 13 | def put( |
| 14 | c, local_path, remote_path, permissions=None, user='root', group=None, create_parent_dir=False |
| 15 | ): |
| 16 | tmp_path = f'/tmp/fabtmp_{random_string(8)}' |
| 17 | c.put(local_path, tmp_path) |
| 18 | |
| 19 | if create_parent_dir: |
| 20 | dirname = os.path.dirname(remote_path) |
| 21 | c.sudo(f'mkdir -p {dirname}') |
| 22 | set_permission(c, dirname, user=user, group=group) |
| 23 | |
| 24 | if is_dir(c, remote_path): |
| 25 | if not remote_path.endswith('/'): |
| 26 | remote_path += '/' |
| 27 | |
| 28 | filename = os.path.basename(local_path) |
| 29 | remote_path += filename |
| 30 | |
| 31 | c.sudo(f"mv '{tmp_path}' '{remote_path}'") |
| 32 | c.sudo(f"rm -rf '{tmp_path}'") |
| 33 | |
| 34 | set_permission(c, remote_path, permissions=permissions, user=user, group=group) |
| 35 | |
| 36 | |
| 37 | def put_dir( |
no test coverage detected