mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +00:00
backups: Minor styling fixes
- Ran yapf Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
5e38b169b9
commit
2e112d751c
@ -44,8 +44,7 @@ def parse_arguments():
|
|||||||
required=True)
|
required=True)
|
||||||
mount.add_argument('--ssh-keyfile', help='Path of private ssh key',
|
mount.add_argument('--ssh-keyfile', help='Path of private ssh key',
|
||||||
default=None, required=False)
|
default=None, required=False)
|
||||||
umount = subparsers.add_parser('umount',
|
umount = subparsers.add_parser('umount', help='unmount an ssh filesystem')
|
||||||
help='unmount an ssh filesystem')
|
|
||||||
umount.add_argument('--mountpoint', help='Mountpoint to unmount',
|
umount.add_argument('--mountpoint', help='Mountpoint to unmount',
|
||||||
required=True)
|
required=True)
|
||||||
is_mounted = subparsers.add_parser(
|
is_mounted = subparsers.add_parser(
|
||||||
@ -68,9 +67,10 @@ def subcommand_mount(arguments):
|
|||||||
kwargs = {}
|
kwargs = {}
|
||||||
# the shell would expand ~/ to the local home directory
|
# the shell would expand ~/ to the local home directory
|
||||||
remote_path = remote_path.replace('~/', '').replace('~', '')
|
remote_path = remote_path.replace('~/', '').replace('~', '')
|
||||||
cmd = ['sshfs', remote_path, arguments.mountpoint, '-o',
|
cmd = [
|
||||||
'UserKnownHostsFile=/dev/null', '-o',
|
'sshfs', remote_path, arguments.mountpoint, '-o',
|
||||||
'StrictHostKeyChecking=no']
|
'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no'
|
||||||
|
]
|
||||||
if arguments.ssh_keyfile:
|
if arguments.ssh_keyfile:
|
||||||
cmd += ['-o', 'IdentityFile=' + arguments.ssh_keyfile]
|
cmd += ['-o', 'IdentityFile=' + arguments.ssh_keyfile]
|
||||||
else:
|
else:
|
||||||
@ -79,6 +79,7 @@ def subcommand_mount(arguments):
|
|||||||
raise ValueError('mount requires either a password or ssh_keyfile')
|
raise ValueError('mount requires either a password or ssh_keyfile')
|
||||||
cmd += ['-o', 'password_stdin']
|
cmd += ['-o', 'password_stdin']
|
||||||
kwargs['input'] = password.encode()
|
kwargs['input'] = password.encode()
|
||||||
|
|
||||||
subprocess.run(cmd, check=True, timeout=TIMEOUT, **kwargs)
|
subprocess.run(cmd, check=True, timeout=TIMEOUT, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@ -91,11 +92,11 @@ def validate_mountpoint(mountpoint):
|
|||||||
"""Check that the folder is empty, and create it if it doesn't exist"""
|
"""Check that the folder is empty, and create it if it doesn't exist"""
|
||||||
if os.path.exists(mountpoint):
|
if os.path.exists(mountpoint):
|
||||||
if _is_mounted(mountpoint):
|
if _is_mounted(mountpoint):
|
||||||
raise AlreadyMountedError('Mountpoint %s already mounted' %
|
raise AlreadyMountedError(
|
||||||
mountpoint)
|
'Mountpoint %s already mounted' % mountpoint)
|
||||||
if os.listdir(mountpoint) or not os.path.isdir(mountpoint):
|
if os.listdir(mountpoint) or not os.path.isdir(mountpoint):
|
||||||
raise ValueError('Mountpoint %s is not an empty directory' %
|
raise ValueError(
|
||||||
mountpoint)
|
'Mountpoint %s is not an empty directory' % mountpoint)
|
||||||
else:
|
else:
|
||||||
os.makedirs(mountpoint)
|
os.makedirs(mountpoint)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user