Example #1
0
    def message(self, *args, **opts):
        if len(args) < 2:
            raise ArgumentError("Invalid number of arguments")

        return self.make_message(name=args[0],
                                 cmd=" ".join(args[1:]),
                                 start=opts.get('start', False))
Example #2
0
    def message(self, *args, **opts):
        if len(args) > 1:
            raise ArgumentError("message invalid")

        if len(args) == 1:
            return self.make_message(name=args[0])
        else:
            return self.make_message()
Example #3
0
    def message(self, *args, **opts):
        if len(args) > 1:
            raise ArgumentError("Invalid number of arguments")

        if len(args) == 1:
            return self.make_message(name=args[0], **opts)

        return self.make_message(**opts)
Example #4
0
 def message(self, *args, **opts):
     if len(args) < 1:
         raise ArgumentError("Invalid number of arguments")
     options = {'name': args[0]}
     if len(args) > 1:
         options['nb'] = int(args[1])
     options.update(opts)
     return self.make_message(**options)
Example #5
0
    def validate(self, props):
        super(Signal, self).validate(props)

        if 'childpid' in props and 'pid' not in props:
            raise ArgumentError('cannot specify childpid without pid')

        try:
            props['signum'] = to_signum(props['signum'])
        except ValueError:
            raise MessageError('signal invalid')
Example #6
0
    def message(self, *args, **opts):
        if len(args) < 3:
            raise ArgumentError("Invalid number of arguments")

        args = list(args)
        watcher_name = args.pop(0)
        if len(args) % 2 != 0:
            raise ArgumentError("List of key/values is invalid")

        options = {}
        while len(args) > 0:
            kv, args = args[:2], args[2:]
            kvl = kv[0].lower()
            options[kvl] = convert_option(kvl, kv[1])

        if opts.get('waiting', False):
            return self.make_message(name=watcher_name,
                                     waiting=True,
                                     options=options)
        else:
            return self.make_message(name=watcher_name, options=options)
Example #7
0
    def message(self, *args, **opts):
        if len(args) < 1 or len(args) > 2:
            raise ArgumentError("Invalid number of arguments")

        props = {}
        props['name'] = args[0]
        if len(args) > 1:
            props['pid'] = args[1]
        if opts['signum'] is not None:
            props['signum'] = opts['signum']
        if opts['graceful_timeout'] is not None:
            props['graceful_timeout'] = opts['graceful_timeout']
        return self.make_message(**props)
Example #8
0
    def message(self, *args, **opts):
        if len(args) > 2:
            raise ArgumentError("message invalid")

        extended = opts.get("extended", False)
        if len(args) == 2:
            return self.make_message(name=args[0],
                                     process=int(args[1]),
                                     extended=extended)
        elif len(args) == 1:
            return self.make_message(name=args[0], extended=extended)
        else:
            return self.make_message(extended=extended)
Example #9
0
    def message(self, *args, **opts):
        largs = len(args)
        if largs < 2 or largs > 3:
            raise ArgumentError("Invalid number of arguments")

        props = {
            'name': args[0],
            'children': opts.get("children", False),
            'recursive': opts.get("recursive", False),
            'signum': args[-1],
        }
        if len(args) == 3:
            props['pid'] = int(args[1])
        return self.make_message(**props)
Example #10
0
    def message(self, *args, **opts):
        if len(args) > 1:
            raise ArgumentError("invalid number of arguments")

        graceful = not opts.get("terminate", False)
        waiting = opts.get("waiting", False)
        sequential = opts.get("sequential", False)
        if len(args) == 1:
            return self.make_message(name=args[0],
                                     graceful=graceful,
                                     waiting=waiting,
                                     sequential=sequential)
        else:
            return self.make_message(graceful=graceful,
                                     waiting=waiting,
                                     sequential=sequential)
Example #11
0
    def message(self, *args, **opts):

        if len(args) < 1:
            raise ArgumentError("number of arguments invalid")

        return self.make_message(name=args[0])
Example #12
0
 def message(self, *args, **opts):
     if len(args) > 0:
         raise ArgumentError("Invalid number of arguments")
     return self.make_message()
Example #13
0
    def message(self, *args, **opts):
        if len(args) < 2:
            raise ArgumentError("Invalid number of arguments")

        return self.make_message(name=args[0], keys=args[1:])