Ejemplo n.º 1
0
Archivo: fuse.py Proyecto: zzed/cbdfs
    def add_option(self, *opts, **attrs):
        if 'mountopt' in attrs:
            if opts or 'subopt' in attrs:
                raise OptParseError(
                  "having options or specifying the `subopt' attribute conflicts with `mountopt' attribute")
            opts = ('-o',)
            attrs['subopt'] = attrs.pop('mountopt')
            if not 'dest' in attrs:
                attrs['dest'] = attrs['subopt']

        SubbedOptParse.add_option(self, *opts, **attrs)
Ejemplo n.º 2
0
    def add_option(self, *opts, **attrs):
        if 'mountopt' in attrs:
            if opts or 'subopt' in attrs:
                raise OptParseError(
                  "having options or specifying the `subopt' attribute conflicts with `mountopt' attribute")
            opts = ('-o',)
            attrs['subopt'] = attrs.pop('mountopt')
            if not 'dest' in attrs:
                attrs['dest'] = attrs['subopt']

        SubbedOptParse.add_option(self, *opts, **attrs)
Ejemplo n.º 3
0
Archivo: fuse.py Proyecto: zzed/cbdfs
 def parse_args(self, args=None, values=None):
     o, a = SubbedOptParse.parse_args(self, args, values)
     if a and self.fetch_mp:
         self.fuse_args.mountpoint = a.pop()
     return o, a
Ejemplo n.º 4
0
Archivo: fuse.py Proyecto: zzed/cbdfs
 def print_version(self, file=sys.stderr):
     SubbedOptParse.print_version(self, file)
     self.fuse_args.setmod('showversion')
Ejemplo n.º 5
0
Archivo: fuse.py Proyecto: zzed/cbdfs
 def print_help(self, file=sys.stderr):
     SubbedOptParse.print_help(self, file)
     print >> file
     self.fuse_args.setmod('showhelp')
Ejemplo n.º 6
0
Archivo: fuse.py Proyecto: zzed/cbdfs
 def error(self, msg):
     SubbedOptParse.error(self, msg)
     raise OptParseError, msg
Ejemplo n.º 7
0
Archivo: fuse.py Proyecto: zzed/cbdfs
    def __init__(self, *args, **kw):

        self.mountopts = []

        self.fuse_args = \
            'fuse_args' in kw and kw.pop('fuse_args') or FuseArgs()
        dsd = 'dash_s_do' in kw and kw.pop('dash_s_do') or 'whine'
        if 'fetch_mp' in kw:
            self.fetch_mp = bool(kw.pop('fetch_mp'))
        else:
            self.fetch_mp = True
        if 'standard_mods' in kw:
            smods = bool(kw.pop('standard_mods'))
        else:
            smods = True
        if 'fuse' in kw:
            self.fuse = kw.pop('fuse')
        if not 'formatter' in kw:
            kw['formatter'] = FuseFormatter()
        doh = 'dash_o_handler' in kw and kw.pop('dash_o_handler')

        SubbedOptParse.__init__(self, *args, **kw)

        if doh:
            self.add_option(doh)
        else:
            self.add_option('-o', action='store_hive',
                            subopts_hive=self.fuse_args, help="mount options",
                            metavar="opt,[opt...]")

        if smods:
            self.add_option('-f', action='callback',
                            callback=lambda *a: self.fuse_args.setmod('foreground'),
                            help=SUPPRESS_HELP)
            self.add_option('-d', action='callback',
                            callback=lambda *a: self.fuse_args.add('debug'),
                            help=SUPPRESS_HELP)

        if dsd == 'whine':
            def dsdcb(option, opt_str, value, parser):
                raise RuntimeError, """

! If you want the "-s" option to work, pass
!
!   dash_s_do='setsingle'
!
! to the Fuse constructor. See docstring of the FuseOptParse class for an
! explanation why is it not set by default.
"""

        elif dsd == 'setsingle':
            def dsdcb(option, opt_str, value, parser):
                self.fuse.multithreaded = False

        elif dsd == 'undef':
            dsdcb = None
        else:
            raise ArgumentError, "key `dash_s_do': uninterpreted value " + str(dsd)

        if dsdcb:
            self.add_option('-s', action='callback', callback=dsdcb,
                            help=SUPPRESS_HELP)
Ejemplo n.º 8
0
 def parse_args(self, args=None, values=None):
     o, a = SubbedOptParse.parse_args(self, args, values)
     if a and self.fetch_mp:
         self.fuse_args.mountpoint = os.path.realpath(a.pop())
     return o, a
Ejemplo n.º 9
0
 def print_version(self, file=sys.stderr):
     SubbedOptParse.print_version(self, file)
     self.fuse_args.setmod('showversion')
Ejemplo n.º 10
0
 def print_help(self, file=sys.stderr):
     SubbedOptParse.print_help(self, file)
     print >> file
     self.fuse_args.setmod('showhelp')
Ejemplo n.º 11
0
 def error(self, msg):
     SubbedOptParse.error(self, msg)
     raise OptParseError, msg
Ejemplo n.º 12
0
    def __init__(self, *args, **kw):

        self.mountopts = []

        self.fuse_args = \
            'fuse_args' in kw and kw.pop('fuse_args') or FuseArgs()
        dsd = 'dash_s_do' in kw and kw.pop('dash_s_do') or 'whine'
        if 'fetch_mp' in kw:
            self.fetch_mp = bool(kw.pop('fetch_mp'))
        else:
            self.fetch_mp = True
        if 'standard_mods' in kw:
            smods = bool(kw.pop('standard_mods'))
        else:
            smods = True
        if 'fuse' in kw:
            self.fuse = kw.pop('fuse')
        if not 'formatter' in kw:
            kw['formatter'] = FuseFormatter()
        doh = 'dash_o_handler' in kw and kw.pop('dash_o_handler')

        SubbedOptParse.__init__(self, *args, **kw)

        if doh:
            self.add_option(doh)
        else:
            self.add_option('-o',
                            action='store_hive',
                            subopts_hive=self.fuse_args,
                            help="mount options",
                            metavar="opt,[opt...]")

        if smods:
            self.add_option(
                '-f',
                action='callback',
                callback=lambda *a: self.fuse_args.setmod('foreground'),
                help=SUPPRESS_HELP)
            self.add_option('-d',
                            action='callback',
                            callback=lambda *a: self.fuse_args.add('debug'),
                            help=SUPPRESS_HELP)

        if dsd == 'whine':

            def dsdcb(option, opt_str, value, parser):
                raise RuntimeError, """

! If you want the "-s" option to work, pass
!
!   dash_s_do='setsingle'
!
! to the Fuse constructor. See docstring of the FuseOptParse class for an
! explanation why is it not set by default.
"""

        elif dsd == 'setsingle':

            def dsdcb(option, opt_str, value, parser):
                self.fuse.multithreaded = False

        elif dsd == 'undef':
            dsdcb = None
        else:
            raise ArgumentError, "key `dash_s_do': uninterpreted value " + str(
                dsd)

        if dsdcb:
            self.add_option('-s',
                            action='callback',
                            callback=dsdcb,
                            help=SUPPRESS_HELP)