Skip to content

Functions

src.utils.adobe.try_photoshop(func) -> Callable

Decorator to handle trying to run a Photoshop action but allowing exceptions to fail silently.

Parameters:

Name Type Description Default
func

Function being wrapped.

required

Returns:

Type Description
Callable

The wrapped function.

Source code in src\utils\adobe.py
def try_photoshop(func) -> Callable:
    """Decorator to handle trying to run a Photoshop action but allowing exceptions to fail silently.

    Args:
        func: Function being wrapped.

    Returns:
        The wrapped function.
    """
    def wrapper(self, *args, **kwargs):
        try:
            result = func(self, *args, **kwargs)
            return result
        except PS_EXCEPTIONS:
            return
    return wrapper

src.utils.adobe.get_photoshop_error_message(err: Exception) -> str

Gets a user-facing error message based on a given Photoshop access exception.

Parameters:

Name Type Description Default
err Exception

Exception object containing the reason an action failed.

required

Returns:

Type Description
str

Proper user response for this exception.

Source code in src\utils\adobe.py
def get_photoshop_error_message(err: Exception) -> str:
    """Gets a user-facing error message based on a given Photoshop access exception.

    Args:
        err: Exception object containing the reason an action failed.

    Returns:
        Proper user response for this exception.
    """
    return (
        "Photoshop is currently busy, close any dialogs and stop any actions.\n"
    ) if 'busy' in str(err).lower() else (
        "Photoshop does not appear to be installed on your system.\n"
        "Please close Proxyshop and install a fresh copy of Photoshop,\n"
        "if Photoshop is installed, view the FAQ for troubleshooting.\n"
    )

src.utils.adobe.get_com_error(signed_int: int) -> str

Check for an error message for both the signed and unsigned version of a COMError code (HRESULT).

Parameters:

Name Type Description Default
signed_int int

Signed integer representing a COMError exception.

required

Returns:

Type Description
str

The string error message associated with this COMError code.

Source code in src\utils\adobe.py
def get_com_error(signed_int: int) -> str:
    """Check for an error message for both the signed and unsigned version of a COMError code (HRESULT).

    Args:
        signed_int: Signed integer representing a COMError exception.

    Returns:
        The string error message associated with this COMError code.
    """
    try:
        err = FormatMessage(signed_int)
    except Exception as e:
        try:
            unsigned_int = c_uint32(signed_int).value
            err = FormatMessage(unsigned_int) or e.args[2]
        except Exception as e:
            err = e.args[2]
    return err