コード例 #1
0
ファイル: proxy.py プロジェクト: mikulely/radula
    def __info(self, **kwargs):
        """prints metadata for a remote subject key"""
        subject = kwargs.get("subject", None)
        if not subject:
            raise RadulaError("Missing remote subject key to get info for")

        target = kwargs.get("target", None)
        remainder = kwargs.get("remainder", [])

        subject_keys = [k for k in [subject] + [target] + remainder if k]
        actual_keys = []
        info = []
        for subject_key in subject_keys:
            bucket_name, pattern = Radula.split_bucket(subject_key)
            if not pattern:  # is not a key, but a bucket
                info.append({
                    "bucket": subject_key,
                    "info": self.lib.info(subject_key)
                })
            else:
                l = len(actual_keys)
                for key in self.lib.keys(subject_key, long_key=True):
                    actual_keys.append(key)
                if len(actual_keys) == l:
                    raise RadulaError("Key not found: {0}".format(subject_key))

        for subject_key in actual_keys:
            info.append({
                "key": subject_key,
                "info": self.lib.info(subject_key)
            })

        return info
コード例 #2
0
ファイル: proxy.py プロジェクト: mikulely/radula
    def __info(self, **kwargs):
        """prints metadata for a remote subject key"""
        subject = kwargs.get("subject", None)
        if not subject:
            raise RadulaError("Missing remote subject key to get info for")

        target = kwargs.get("target", None)
        remainder = kwargs.get("remainder", [])

        subject_keys = [k for k in [subject] + [target] + remainder if k]
        actual_keys = []
        info = []
        for subject_key in subject_keys:
            bucket_name, pattern = Radula.split_bucket(subject_key)
            if not pattern:  # is not a key, but a bucket
                info.append({
                    "bucket": subject_key,
                    "info": self.lib.info(subject_key)
                })
            else:
                l = len(actual_keys)
                for key in self.lib.keys(subject_key, long_key=True):
                    actual_keys.append(key)
                if len(actual_keys) == l:
                    raise RadulaError("Key not found: {0}".format(subject_key))

        for subject_key in actual_keys:
            info.append({
                "key": subject_key,
                "info": self.lib.info(subject_key)
            })

        return info
コード例 #3
0
def _real_main():
    args = _parse_args()
    if args.version:
        print __version__
        exit()

    command = args.command.replace('-', '_')
    config_check()
    radu = Radula()

    default_log_level = logging.INFO
    if args.verbose:
        log_level = logging.DEBUG
    else:
        log_level = default_log_level
        if args.log_level:
            if not isinstance(args.log_level, int):
                level = getattr(logging, args.log_level)
                if isinstance(log_level, int):
                    log_level = level

    logging.basicConfig(
        level=log_level,
        format='%(asctime)s %(levelname)s:%(name)s: %(message)s')
    logger = logging.getLogger("radula")
    logger.debug("Radula Version: %s", __version__)
    logger.debug("Log Level: %d", log_level)

    if args.command in cmd_acl:
        radu.connect(profile=args.profile)
        getattr(radu, command)(**vars(args))
        exit()

    if args.command in cmd_proxy:
        radu = RadulaProxy(profile=args.profile)
        getattr(radu, command)(**vars(args))
        pass

    if args.command in cmd_preconnect:
        getattr(radu, command)(**vars(args))
        pass
コード例 #4
0
ファイル: __init__.py プロジェクト: magicrobotmonkey/radula
def _real_main():
    args = _parse_args()
    if args.version:
        print __version__
        exit()

    command = args.command.replace('-', '_')
    radu = Radula()
    radu.config_check()

    if args.command in cmd_acl:
        radu.connect(profile=args.profile)
        getattr(radu, command)(**vars(args))
        exit()

    if args.command in cmd_usr:
        radu.connect(profile=args.profile)
        getattr(radu, command)(**vars(args))
        exit()

    if args.command in cmd_proxy:
        radu = RadulaProxy(profile=args.profile)
        getattr(radu, command)(**vars(args))
        pass
コード例 #5
0
ファイル: __init__.py プロジェクト: magicrobotmonkey/radula
def _real_main():
    args = _parse_args()
    if args.version:
        print __version__
        exit()

    command = args.command.replace('-', '_')
    radu = Radula()
    radu.config_check()

    if args.command in cmd_acl:
        radu.connect(profile=args.profile)
        getattr(radu, command)(**vars(args))
        exit()

    if args.command in cmd_usr:
        radu.connect(profile=args.profile)
        getattr(radu, command)(**vars(args))
        exit()

    if args.command in cmd_proxy:
        radu = RadulaProxy(profile=args.profile)
        getattr(radu, command)(**vars(args))
        pass
コード例 #6
0
ファイル: __init__.py プロジェクト: mikulely/radula
def _real_main():
    args = _parse_args()
    if args.version:
        print __version__
        exit()

    command = args.command.replace('-', '_')
    config_check()
    radu = Radula()

    log_level = logging.INFO
    if args.log_level:
        if not isinstance(args.log_level, int):
            level = getattr(logging, args.log_level)
            print args.log_level, level, '?'
            if isinstance(log_level, int):
                log_level = level

    logging.basicConfig(
        level=log_level,
        format='%(asctime)s %(levelname)s:%(name)s: %(message)s'
    )
    logger = logging.getLogger("radula")
    logger.info("Log Level: %d", log_level)

    if args.command in cmd_acl:
        radu.connect(profile=args.profile)
        getattr(radu, command)(**vars(args))
        exit()

    if args.command in cmd_usr:
        radu.connect(profile=args.profile)
        getattr(radu, command)(**vars(args))
        exit()

    if args.command in cmd_proxy:
        radu = RadulaProxy(profile=args.profile)
        getattr(radu, command)(**vars(args))
        pass