Пример #1
0
def load_config(config_path, config_str, opts):

    ret = modconf.load_config(config_str, opts, "syndicate", CONFIG_OPTIONS)

    conf_dir = os.path.dirname(config_path)
    extend_paths(ret, conf_dir)

    if ret['debug']:
        Log.set_log_level("DEBUG")

    else:
        Log.set_log_level("WARNING")

    return ret
Пример #2
0
def load_config( config_path, config_str, opts ):
   
   ret = modconf.load_config( config_str, opts, "syndicate", CONFIG_OPTIONS )
         
   conf_dir = os.path.dirname( config_path )
   extend_paths( ret, conf_dir )
   
   if ret['debug']:
      Log.set_log_level( "DEBUG" )

   else:
      Log.set_log_level( "WARNING" )
   
   return ret
Пример #3
0
    def __init__(
        self,
        user_id,
        ms_url,
        password=None,
        user_pkey_pem=None,
        syndicate_public_key_pem=None,
        debug=False,
    ):

        self.config = {}
        self.method_singletons = {}

        no_verify_result = True

        # sanity check...
        if syndicate_public_key_pem is not None:
            try:
                self.config['syndicate_public_key'] = CryptoKey.importKey(
                    syndicate_public_key)
                no_verify_result = False
            except:
                raise Exception("Invalid value for syndicate_public_key_pem")

        # sanity check...
        if user_pkey_pem is not None:
            try:
                self.config['user_pkey'] = CryptoKey.importKey(user_pkey_pem)
                assert self.config['user_pkey'].has_private(
                ), "Not a private key"
            except:
                raise Exception("Invalid value for user_pkey_pem")

        try:
            host, port, no_tls = parse_url(ms_url)
        except:
            raise Exception("Invalid URL '%s'" % ms_url)

        # populate our config
        self.config['syndicate_host'] = host
        self.config['syndicate_port'] = port
        self.config['no_tls'] = no_tls
        self.config['user_id'] = user_id
        self.config['debug'] = debug
        self.config['password'] = password
        self.config['no_verify_result'] = no_verify_result

        Log.set_log_level("DEBUG" if debug else "INFO")
Пример #4
0
 def __init__(self, user_id, ms_url,
                    password=None,
                    user_pkey_pem=None,
                    syndicate_public_key_pem=None,
                    debug=False,
                    ):
    
    self.config = {}
    self.method_singletons = {}
    
    no_verify_result = True
    
    # sanity check...
    if syndicate_public_key_pem is not None:
       try:
          self.config['syndicate_public_key'] = CryptoKey.importKey( syndicate_public_key )
          no_verify_result = False
       except:
          raise Exception("Invalid value for syndicate_public_key_pem")
    
    # sanity check...
    if user_pkey_pem is not None:
       try:
          self.config['user_pkey'] = CryptoKey.importKey( user_pkey_pem )
          assert self.config['user_pkey'].has_private(), "Not a private key"
       except:
          raise Exception("Invalid value for user_pkey_pem")
    
    try:
       host, port, no_tls = parse_url( ms_url )
    except:
       raise Exception("Invalid URL '%s'" % ms_url)
    
    # populate our config 
    self.config['syndicate_host'] = host 
    self.config['syndicate_port'] = port 
    self.config['no_tls'] = no_tls
    self.config['user_id'] = user_id
    self.config['debug'] = debug 
    self.config['password'] = password
    self.config['no_verify_result'] = no_verify_result
    
    Log.set_log_level( "DEBUG" if debug else "INFO" )