|
@@ -141,29 +141,41 @@ class DockerImage:
|
|
|
|
|
|
class FuseMount:
|
|
class FuseMount:
|
|
|
|
|
|
- def __init__(self, cmd, path, cd=False):
|
|
+ def __init__(self, mount_arg_patterns, mount_point_path, cd=False):
|
|
- self._mount_arg_patterns = cmd
|
|
+ self._mount_arg_patterns = mount_arg_patterns
|
|
- self._mount_path = path
|
|
+ self._mount_point_path = mount_point_path
|
|
self._cd = cd
|
|
self._cd = cd
|
|
|
|
|
|
def __enter__(self):
|
|
def __enter__(self):
|
|
import shlex
|
|
import shlex
|
|
- mount_args = [a.format(mp=shlex.quote(self._mount_path))
|
|
+ mount_args = [a.format(mp=shlex.quote(self._mount_point_path))
|
|
for a in self._mount_arg_patterns]
|
|
for a in self._mount_arg_patterns]
|
|
sys.stderr.write('{}\n'.format(shlex_join(mount_args)))
|
|
sys.stderr.write('{}\n'.format(shlex_join(mount_args)))
|
|
subprocess.check_call(mount_args)
|
|
subprocess.check_call(mount_args)
|
|
if self._cd:
|
|
if self._cd:
|
|
self._previous_work_dir_path = os.getcwd()
|
|
self._previous_work_dir_path = os.getcwd()
|
|
- os.chdir(self._mount_path)
|
|
+ os.chdir(self._mount_point_path)
|
|
- return self._mount_path
|
|
+ return self._mount_point_path
|
|
|
|
|
|
def __exit__(self, exc_type, exc_value, traceback):
|
|
def __exit__(self, exc_type, exc_value, traceback):
|
|
- umount_args = ['fusermount', '-u', '-z', self._mount_path]
|
|
+ umount_args = ['fusermount', '-u', '-z', self._mount_point_path]
|
|
sys.stderr.write('{}\n'.format(shlex_join(umount_args)))
|
|
sys.stderr.write('{}\n'.format(shlex_join(umount_args)))
|
|
subprocess.check_call(umount_args)
|
|
subprocess.check_call(umount_args)
|
|
if self._cd:
|
|
if self._cd:
|
|
os.chdir(self._previous_work_dir_path)
|
|
os.chdir(self._previous_work_dir_path)
|
|
|
|
|
|
|
|
+class EncFSMount(FuseMount):
|
|
|
|
+
|
|
|
|
+ def __init__(self, root_dir_path, mount_point_path, cd=False, extpass=None):
|
|
|
|
+ mount_arg_patterns = ['encfs', root_dir_path, mount_point_path]
|
|
|
|
+ if extpass:
|
|
|
|
+ mount_arg_patterns.extend(['--extpass', shlex_join(extpass)])
|
|
|
|
+ super().__init__(
|
|
|
|
+ mount_arg_patterns=mount_arg_patterns,
|
|
|
|
+ mount_point_path=mount_point_path,
|
|
|
|
+ cd=cd,
|
|
|
|
+ )
|
|
|
|
+
|
|
class StdoutTee:
|
|
class StdoutTee:
|
|
|
|
|
|
def __init__(self, sink):
|
|
def __init__(self, sink):
|
|
@@ -245,6 +257,7 @@ def os_read_non_blocking(fd, buffer_size_bytes=8*1024, timeout_seconds=0.1):
|
|
|
|
|
|
def shlex_join(params):
|
|
def shlex_join(params):
|
|
import shlex
|
|
import shlex
|
|
|
|
+ assert isinstance(params, list) or isinstance(params, tuple), params
|
|
return ' '.join(shlex.quote(p) for p in params)
|
|
return ' '.join(shlex.quote(p) for p in params)
|
|
|
|
|
|
def timestamp_now_utc():
|
|
def timestamp_now_utc():
|