pysepal.scripts.drive_interface.GDriveInterface#
- class pysepal.scripts.drive_interface.GDriveInterface(sepal_headers=None)[source]#
Google Drive interface with SEPAL credential integration.
This class provides methods to interact with Google Drive using SEPAL credentials or file-based credentials. It supports automatic token refresh and various file operations.
Initialize the Google Drive interface.
- Parameters:
sepal_headers (dict | None) – Optional SEPAL headers dictionary for authentication. If not provided, falls back to file-based credentials.
- Raises:
ValueError – If credentials file not found or no access token available.
Attributes
serviceLazy property that ensures valid credentials and service.
Methods
Initialize the Google Drive interface.
Delete a file from Google Drive.
Download a file from Google Drive.
Download csv file result from GDrive.
Get the Google Drive file ID for a given filename.
Get a list of CSV files from Google Drive.
Get the current state of the task.
Print a list of files from Google Drive to the console.
Refresh credentials synchronously by calling SEPAL API or re-reading file.
- GDriveInterface.__init__(sepal_headers=None)[source]#
Initialize the Google Drive interface.
- Parameters:
sepal_headers (dict | None) – Optional SEPAL headers dictionary for authentication. If not provided, falls back to file-based credentials.
- Raises:
ValueError – If credentials file not found or no access token available.
- GDriveInterface.delete_file(filename)[source]#
Delete a file from Google Drive.
- Parameters:
filename (str) – Name of the file to delete.
- GDriveInterface.download_file(filename, output_file, sepal_client=None)[source]#
Download a file from Google Drive.
- Parameters:
filename (str) – Name of the file to download.
output_file (str or Path) – Path where the file should be saved.
sepal_client – Optional SEPAL client for remote file operations.
- GDriveInterface.download_from_task_file(task_id, tasks_file, task_filename, sepal_client=None)[source]#
Download csv file result from GDrive.
- Parameters:
task_id (str) – id of the task tasked in GEE.
tasks_file (Path) – path file containing all task_id, task_name
task_filename (str) – name of the task file to be downloaded.
- GDriveInterface.get_id(filename)[source]#
Get the Google Drive file ID for a given filename.
- Parameters:
filename (str) – Name of the file to search for.
- Returns:
(success_flag, file_id_or_error_message)
- Return type:
tuple