Example #1
0
    def authenticate(self):
        try:
            configuration = Configuration()
            if os.name != 'nt':
                permissions = os.stat(self.config).st_mode
                if (permissions & 4) or (permissions & 32):
                    print(
                        'Warning: Your Kaggle API key is readable by other users on '
                        +
                        'this system! To fix this, you can run \'chmod 600 {}\''
                        .format(self.config))
            with open(self.config, 'r') as f:
                config_data = json.load(f)

            self.copy_config_value(self.CONFIG_NAME_PROXY, config_data)
            self.copy_config_value(self.CONFIG_NAME_PATH, config_data)
            self.copy_config_value(self.CONFIG_NAME_COMPETITION, config_data)
            self.copy_config_value(self.CONFIG_NAME_USER, config_data)

            configuration.username = config_data[self.CONFIG_NAME_USER]
            configuration.password = config_data[self.CONFIG_NAME_KEY]
            if self.CONFIG_NAME_PROXY in config_data:
                configuration.proxy = config_data[self.CONFIG_NAME_PROXY]
            self.api_client = ApiClient(configuration)

        except Exception as error:
            if 'Proxy' in type(error).__name__:
                sys.exit('The specified proxy ' +
                         config_data[self.CONFIG_NAME_PROXY] +
                         ' is not valid, please check your proxy settings')
            else:
                sys.exit(
                    'Unauthorized: you must download an API key from ' +
                    'https://www.kaggle.com/<username>/account\nThen put ' +
                    self.config_file + ' in the folder ' + self.config_path)
  def authenticate(self):
    try:
      configuration = Configuration()
      if os.name != 'nt':
        permissions = os.stat(self.config).st_mode
        if (permissions & 4) or (permissions & 32):
          print('Warning: Your Kaggle API key is readable by other users on ' +
                'this system! To fix this, you can run \'chmod 600 {}\''.format(
                    self.config))
      with open(self.config, 'r') as f:
        config_data = json.load(f)

      self.copy_config_value(self.CONFIG_NAME_PROXY, config_data)
      self.copy_config_value(self.CONFIG_NAME_PATH, config_data)
      self.copy_config_value(self.CONFIG_NAME_COMPETITION, config_data)
      self.copy_config_value(self.CONFIG_NAME_USER, config_data)

      configuration.username = config_data[self.CONFIG_NAME_USER]
      configuration.password = config_data[self.CONFIG_NAME_KEY]
      if self.CONFIG_NAME_PROXY in config_data:
        configuration.proxy = config_data[self.CONFIG_NAME_PROXY]
      self.api_client = ApiClient(configuration)

    except Exception as error:
      if 'Proxy' in type(error).__name__:
        sys.exit('The specified proxy ' + config_data[self.CONFIG_NAME_PROXY] +
                 ' is not valid, please check your proxy settings')
      else:
        sys.exit('Unauthorized: you must download an API key from ' +
                 'https://www.kaggle.com/<username>/account\nThen put ' +
                 self.config_file + ' in the folder ' + self.config_path)
 def authenticate(self):
   try:
     configuration = Configuration()
     if os.name != 'nt':
       permissions = os.stat(self.config).st_mode
       if (permissions & 4) or (permissions & 32):
         print("Warning: Your Kaggle API key is readable by other users on this system! To fix this, you can run 'chmod 600 {}'".format(self.config))
     with open(self.config, 'r') as f:
       configData = json.load(f)
     configuration.username = configData['username']
     configuration.password = configData['key']
     self.api_client.configuration = configuration
   except: 
     sys.exit('Unauthorized: you must download an API key from https://www.kaggle.com/<username>/account\nThen put ' + self.configFile + ' in the folder ' + self.configPath)
Example #4
0
    def __init__(self, config, *, context, **kwargs):
        super(Application, self).__init__(config,
                                          debug=config.debug,
                                          context=context,
                                          **kwargs)

        main_html = pathlib.Path(__file__).parent / 'templates' / 'main.html'
        self.main_html = main_html.read_text(encoding='utf-8')

        configuration = Configuration()
        configuration.username = self.context.config.kaggle.user
        configuration.password = self.context.config.kaggle.key
        self.api_client = ApiClient(configuration)

        self.kaggle_api = NoAuthKaggleApi(self.api_client)
Example #5
0
 def authenticate(self):
     try:
         configuration = Configuration()
         if os.name != 'nt':
             permissions = os.stat(self.config).st_mode
             if (permissions & 4) or (permissions & 32):
                 print(
                     "Warning: Your Kaggle API key is readable by other users on this system! To fix this, you can run 'chmod 600 {}'"
                     .format(self.config))
         with open(self.config, 'r') as f:
             configData = json.load(f)
         configuration.username = configData['username']
         configuration.password = configData['key']
         self.api_client.configuration = configuration
     except:
         sys.exit(
             'Unauthorized: you must download an API key from https://www.kaggle.com/<username>/account\nThen put '
             + self.configFile + ' in the folder ' + self.configPath)
Example #6
0
    def __init__(self,
                 configuration=None,
                 header_name=None,
                 header_value=None,
                 cookie=None):
        if configuration is None:
            configuration = Configuration()
        self.configuration = configuration

        self.pool = ThreadPool()
        self.rest_client = rest.RESTClientObject(configuration)
        self.default_headers = {}
        if header_name is not None:
            self.default_headers[header_name] = header_value
        self.cookie = cookie
        # Set default User-Agent.
        self.user_agent = 'Swagger-Codegen/1/python'
Example #7
0
    def __init__(self,
                 configuration=None,
                 header_name=None,
                 header_value=None,
                 cookie=None):
        if configuration is None:
            configuration = Configuration()
        self.configuration = configuration

        self.pool = ThreadPool()

        # if configuration.username:
        #     proxy = requests.get("http://192.168.31.11:5010/get").content
        #     proxy = f'http://{proxy.decode()}'
        #     configuration.proxy = proxy
        # print('proxy', configuration.proxy)
        print(1)
        self.rest_client = rest.RESTClientObject(configuration)
        self.default_headers = {}
        if header_name is not None:
            self.default_headers[header_name] = header_value
        self.cookie = cookie
        # Set default User-Agent.
        self.user_agent = 'Swagger-Codegen/1/python'