def is_open(self, quick=False): # Verify that dec_path is mounted off of enc_path mounts = ext('/bin/mount', shell=False) mounted = any(filter(lambda x: 'encfs on %s type fuse.encfs' % self.dec_path in x, mounts)) if mounted and quick: return True if not mounted: print 1, 'Not mounted' return False if not os.path.exists('%s/.encfs6.xml' % self.enc_path): print 2, 'Enc XML not found' return False if not os.path.exists('%s/.encfs6.xml' % self.dec_path): print 3, 'Dec XML not found' return False with open('%s/.encfs6.xml' % self.dec_path, 'rb') as f: if 'EncFS' in f.read(): print 4, 'Dec XML not encrypted' return False from uuid import uuid4 u = str(uuid4()) test_file = os.path.join(self.dec_path, u) ext('touch %s' % test_file) try: if not os.path.exists(os.path.join(self.enc_path, u)): print 5, 'File written to dec not found in enc' return False finally: os.remove(test_file) return True
def docker(self, args, stdin=None): from benome.utils import ext #print ' '.join(args) return ext('docker', list(args), wait=True, shell=False, raw=True, debug=False).strip()
def close(self): result = ext('fusermount', ['-u', self.dec_path], shell=False, raw=True) return result == ''