def mount(self):
        """Mounts the base image on a temporary location using the mount method stored in :attr:`method`. If mounting
        was successful, :attr:`mountpoint` is set to the temporary mountpoint.

        If :attr:`read_write` is enabled, a temporary read-write cache is also created and stored in :attr:`rwpath`.

        :return: whether the mounting was successful
        :rtype: bool
        """

        if self.parser.casename:
            self.mountpoint = tempfile.mkdtemp(prefix='image_mounter_', suffix='_' + self.parser.casename)
        else:
            self.mountpoint = tempfile.mkdtemp(prefix='image_mounter_')

        if self.read_write:
            self.rwpath = tempfile.mkstemp(prefix="image_mounter_rw_cache_")[1]

        # Find the mount methods
        if self.method == 'auto':
            methods = []

            def add_method_if_exists(method):
                if (method == 'avfs' and _util.command_exists('avfsd')) or _util.command_exists(method):
                    methods.append(method)

            if self.read_write:
                add_method_if_exists('xmount')
            else:
                if self.type == 'encase':
                    add_method_if_exists('ewfmount')
                elif self.type == 'vmdk':
                    add_method_if_exists('vmware-mount')
                    add_method_if_exists('affuse')
                elif self.type == 'dd':
                    add_method_if_exists('affuse')
                elif self.type == 'compressed':
                    add_method_if_exists('avfs')
                add_method_if_exists('xmount')
        else:
            methods = [self.method]

        cmds = []
        for method in methods:
            if method == 'avfs':  # avfs does not participate in the fallback stuff, unfortunately
                self.avfs_mountpoint = tempfile.mkdtemp(prefix='image_mounter_avfs_')

                # start by calling the mountavfs command to initialize avfs
                _util.check_call_(['avfsd', self.avfs_mountpoint, '-o', 'allow_other'], stdout=subprocess.PIPE)

                # no multifile support for avfs
                avfspath = self.avfs_mountpoint + '/' + os.path.abspath(self.paths[0]) + '#'
                targetraw = os.path.join(self.mountpoint, 'avfs')

                os.symlink(avfspath, targetraw)
                logger.debug("Symlinked {} with {}".format(avfspath, targetraw))
                raw_path = self.get_raw_path()
                logger.debug("Raw path to avfs is {}".format(raw_path))
                if self.method == 'auto':
                    self.method = 'avfs'
                return raw_path is not None

            elif method == 'xmount':
                cmds.append(['xmount', '--in', 'ewf' if self.type == 'encase' else 'dd'])
                if self.read_write:
                    cmds[-1].extend(['--rw', self.rwpath])

            elif method == 'affuse':
                cmds.extend([['affuse', '-o', 'allow_other'], ['affuse']])

            elif method == 'ewfmount':
                cmds.extend([['ewfmount', '-X', 'allow_other'], ['ewfmount']])

            elif method == 'vmware-mount':
                cmds.append(['vmware-mount', '-r', '-f'])

            elif method == 'dummy':
                os.rmdir(self.mountpoint)
                self.mountpoint = ""
                logger.debug("Raw path to dummy is {}".format(self.get_raw_path()))
                return True

            else:
                raise Exception("Unknown mount method {0}".format(self.method))

        # add path and mountpoint to the cmds
        # if multifile is enabled, add additional mount methods to the end of it
        for cmd in cmds[:]:
            if self.multifile and 1 > len(self.paths):
                cmds.append(cmd[:])
                cmds[-1].extend(self.paths)
                cmds[-1].append(self.mountpoint)
            cmd.append(self.paths[0])
            cmd.append(self.mountpoint)

        for cmd in cmds:
            # noinspection PyBroadException
            try:
                _util.check_call_(cmd, stdout=subprocess.PIPE)
                # mounting does not seem to be instant, add a timer here
                time.sleep(.1)
            except Exception:
                logger.warning('Could not mount {0}, trying other method'.format(self.paths[0]), exc_info=True)
                continue
            else:
                raw_path = self.get_raw_path()
                logger.debug("Raw path to disk is {}".format(raw_path))
                if self.method == 'auto':
                    self.method = cmd[0]
                return raw_path is not None

        logger.error('Unable to mount {0}'.format(self.paths[0]))
        os.rmdir(self.mountpoint)
        self.mountpoint = ""

        return False
dataset/ETHPy150Open ralphje/imagemounter/imagemounter/disk.py/Disk.mount/swapped operands of `>`