Ejemplo n.º 1
0
    def get_data_upload_instance(self, config_path, server_url):
        """Get instance of the DataUpload class."""
        config = ClientConfig(path=config_path)
        server_url = server_url or config.default_url

        if not server_url:
            raise self.Error("No default URL is configured. "
                             "Enter server URL as a CLI argument!")

        api_url = DataUpload.get_api_url(server_url)
        ows_url = DataUpload.get_ows_url(server_url)
        access_token = config.get_site_config(ows_url).get("token")

        if not access_token:
            raise self.Error("No access token configured for %s!" % ows_url)

        return DataUpload(api_url, token=access_token)
Ejemplo n.º 2
0
 def execute(self, config_path):
     config = ClientConfig(path=config_path)
     if exists(config.path):
         remove(config.path)
         sys.stdout.write(f"Deleted configuration file: {config.path}\n")
     else:
         sys.stdout.write(
             f"WARNING: No configuration file found (attempted to delete {config.path})\n"
         )
Ejemplo n.º 3
0
 def execute(self, config_path):
     config = ClientConfig(path=config_path)
     config.default_url = None
     config.save()
Ejemplo n.º 4
0
 def execute(self, config_path, server_url):
     config = ClientConfig(path=config_path)
     config.default_url = server_url
     config.save()
Ejemplo n.º 5
0
 def execute(self, config_path, server_url):
     config = ClientConfig(path=config_path)
     config.set_site_config(server_url)
     config.save()
Ejemplo n.º 6
0
 def execute(self, config_path, server_url, token):
     if token is None:
         token = input("Enter access token: ")
     config = ClientConfig(path=config_path)
     config.set_site_config(server_url, token=token)
     config.save()
Ejemplo n.º 7
0
 def execute(self, config_path):
     config = ClientConfig(path=config_path)
     config.init()
     config.save()
Ejemplo n.º 8
0
 def execute(self, config_path):
     config = ClientConfig(path=config_path)
     if not exists(config.path):
         raise self.Error("Configuration file %s does not exist!" %
                          config.path)
     sys.stdout.write(str(config))