epson_connect package

Submodules

epson_connect.authenticate module

exception epson_connect.authenticate.ApiError[source]

Bases: RuntimeError

General error raised for any API errors after authentication has succeeded. This can include bad requests, server errors, etc.

class epson_connect.authenticate.AuthCtx(base_url, printer_email, client_id, client_secret)[source]

Bases: object

Authentication context for the printer API.

This class manages authentication to the API by obtaining and refreshing access tokens as required.

property default_headers

Default headers for the API requests.

This includes the current access token for authentication.

Returns:

Dictionary of default headers.

property device_id

Get the device (printer) ID from the current session.

Returns:

Device ID (subject_id from the authentication response).

send(method, path, data=None, json=None, headers=None, auth=None)[source]

Send a request to the API.

Parameters:
  • method – HTTP method (e.g., GET, POST).

  • path – API path.

  • data – Data payload for the request.

  • json – JSON payload for the request.

  • headers – HTTP headers.

  • auth – Authentication object.

Return type:

dict

Returns:

Dictionary containing the response.

exception epson_connect.authenticate.AuthenticationError[source]

Bases: RuntimeError

Error raised when there are authentication specific exceptions. This can include failed authentication attempts, invalid tokens, etc.

epson_connect.client module

class epson_connect.client.Client(base_url='', printer_email='', client_id='', client_secret='')[source]

Bases: object

Client for the Epson Connect API.

This class provides a higher-level interface to interact with the Epson Connect services, including authentication, printer management, and scanning operations.

EC_BASE_URL = 'https://api.epsonconnect.com'
deauthenticate()[source]

De-authenticate from the Epson Connect API.

This method ends the current session and invalidates the access token.

property printer

Get the Printer interface for the current session.

Returns:

An instance of the Printer class.

property scanner

Get the Scanner interface for the current session.

Returns:

An instance of the Scanner class.

exception epson_connect.client.ClientError[source]

Bases: ValueError

Error raised for client-specific exceptions.

This includes cases like missing credentials, misconfigured environment, etc.

epson_connect.printer module

class epson_connect.printer.Printer(auth_ctx)[source]

Bases: object

Printer class for managing print jobs in the Epson Connect API.

This class provides methods to handle printing, including file uploads, print job creation, fetching printer capabilities, and more.

VALID_EXTENSIONS = {'bmp', 'doc', 'docx', 'gif', 'jpeg', 'jpg', 'pdf', 'png', 'ppt', 'pptx', 'tiff', 'xls', 'xlsx'}
VALID_OPERATORS = {'operator', 'user'}
cancel_print(job_id, operated_by='user')[source]

Cancel print.

capabilities(mode)[source]

Fetch the device print capabilities based on the given mode.

Parameters:

mode – The mode for which to fetch capabilities.

Returns:

Dictionary containing device capabilities.

property device_id

Retrieve the device ID associated with the current session.

Returns:

Device ID.

execute_print(job_id)[source]

Execute print job.

info()[source]

Get device information.

job_info(job_id)[source]

Get print job information.

notification(callback_uri, enabled=True)[source]

Configure notifications for the print job status change.

Parameters:
  • callback_uri – URI to which notifications should be sent.

  • enabled – Whether or not to enable notifications. Defaults to True.

Returns:

Response from the API.

print(file_path, settings=None)[source]

Print file.

Return type:

str

Returns:

Job ID for print job.

print_setting(settings)[source]

Create a print job.

Return type:

dict

upload_file(upload_uri, file_path, print_mode)[source]

Upload file to be printed.

Return type:

None

exception epson_connect.printer.PrinterError[source]

Bases: ValueError

Error raised for printer-specific exceptions.

This includes cases like invalid file extensions, unsupported print modes, and other printer-related issues.

epson_connect.printer_settings module

exception epson_connect.printer_settings.PrintSettingError[source]

Bases: ValueError

Error raised for printer setting-specific exceptions.

This includes cases like invalid values, missing required settings, or mismatched configurations.

epson_connect.printer_settings.merge_with_default_settings(settings=None)[source]

Merge the given settings with default printer settings.

This function will set defaults for any missing settings from the input. It also generates a random job name if one is not provided.

Parameters:

settings – Dictionary containing printer settings.

Returns:

Dictionary containing the merged settings.

epson_connect.printer_settings.validate_settings(settings)[source]

Validate all parts of a settings object.

This function checks if the provided settings are valid and raises an error if they are not. Each setting is validated against pre-defined valid values or constraints.

Parameters:

settings (dict) – Dictionary containing printer settings.

Raises:

PrintSettingError – If any of the settings are invalid.

epson_connect.scanner module

class epson_connect.scanner.Scanner(auth_ctx)[source]

Bases: object

Scanner class for managing scan destinations in the Epson Connect API.

This class provides methods to add, update, list, and remove scan destinations.

VALID_DESTINATION_TYPES = {'mail', 'url'}
add(name, destination, type_='mail')[source]

Register a new scan destination.

Parameters:
  • name – Alias name for the scan destination.

  • destination – The actual destination (email or URL).

  • type – Type of the destination. Defaults to ‘mail’. Can be ‘mail’ or ‘url’.

Returns:

Response dictionary containing details of the added destination.

list()[source]

Retrieve a list of scan destinations.

Returns:

A list of registered scan destinations.

remove(id_)[source]

Remove a scan destination.

Parameters:

id – ID of the scan destination to be removed.

update(id_, name=None, destination=None, type_=None)[source]

Update an existing scan destination.

Parameters:
  • id – ID of the scan destination to be updated.

  • name – New alias name for the scan destination.

  • destination – The new destination (email or URL).

  • type – New type of the destination. Can be ‘mail’ or ‘url’.

Returns:

Response dictionary containing details of the updated destination.

exception epson_connect.scanner.ScannerError[source]

Bases: ValueError

Error raised for scanner-specific exceptions.

This includes cases like invalid destination type, name or destination length issues, etc.

Module contents