예제 #1
0
파일: pstor.py 프로젝트: rrader/pstor
def umount(remote_dir):
    if not mounted(remote_dir):
        print "<Not mounted>"
        return

    try:
        sh.fusermount('-u', remote_dir)
    except sh.ErrorReturnCode, e:
        print "Error. Can't unmount %s: %s" % (remote_dir, e.message)
예제 #2
0
def try_unmount(mount_point, user=False):
    sh.sync()
    try:
        sh.mountpoint(mount_point, '-q')
        if user:
            sh.fusermount('-quz', mount_point, _fg=True)
        else:
            sh.sudo.umount(mount_point, '-R', '-l', _fg=True)
    except sh.ErrorReturnCode:
        pass
예제 #3
0
    def fuse(self):
        from studip.fs_driver import FUSEView
        from fuse import FUSE
        import sh

        view = self.database.list_views(full=True)[0]
        fuse_ops = FUSEView(self.sync_dir, self.config, self.database, view)
        path = os.path.realpath(os.path.expanduser("~/studip-fuse"))
        try:
            os.makedirs(path, exist_ok=True)
            sh.fusermount("-u", path)
        except:
            pass
        FUSE(fuse_ops, path, nothreads=True, foreground=True)
예제 #4
0
    def teardown(self):
        try:
            if OS_NAME == 'Darwin':
                sh.umount("HttpFs")
                sh.umount(self.http_directory)
            else:
                sh.fusermount("-uz", self.http_directory)
        except Exception:
            pass

        try:
            if OS_NAME == 'Darwin':
                sh.umount("HttpFs")
                sh.umount(self.https_directory)
            else:
                sh.fusermount("-uz", self.https_directory)
        except Exception:
            pass
예제 #5
0
파일: init.py 프로젝트: rrader/pstor
def init(**args):
    if os.path.isdir(".pstor"):
        raise exceptions.PstorException("Already initialized.")
    else:
        password = args['pass']
        if not password and not args['exists']:
            password = getpass.getpass()

        os.mkdir(".pstor")
        os.mkdir(".pstor/remotes")
        os.mkdir(".pstor/encrypted")
        os.mkdir("files")

        cwd = os.getcwd()
        if not args['exists']:
            sh.encfs(os.path.join(cwd,'.pstor/encrypted'),
                     os.path.join(cwd,'files'),
                     paranoia=True, extpass="******" % password)
            sleep(1)
            sh.fusermount('-u', 'files')

        # sh.cp(sh.glob(os.path.join(cwd,'.pstor/data/*')), cwd, symbolic_link=True, recursive=True)

        print "Now you can add remote for this pstore with\n $ pstor remote --add"