@@ -130,10 +130,36 @@ def xpra_print(socket_path: str, socket_dir: str, password_file: str, encryption
130130 r = exec_command (command , env = env )
131131 if r == 0 :
132132 write_back ("INFO: forwarding" )
133- else :
134- from xpra .exit_codes import exit_str
135- write_back (f"ERROR: contacting the xpra server: { exit_str (r )!r} " )
136- return r
133+ return 0
134+ from xpra .exit_codes import exit_str
135+ write_back (f"ERROR: contacting the xpra server: { exit_str (r )!r} " )
136+ return cups_backend_exit_status (r )
137+
138+
139+ def cups_backend_exit_status (r : int ) -> int :
140+ CUPS_BACKEND_OK = 0
141+ CUPS_BACKEND_FAILED = 1
142+ CUPS_BACKEND_AUTH_REQUIRED = 2
143+ CUPS_BACKEND_HOLD = 3
144+ CUPS_BACKEND_STOP = 4
145+ # CUPS_BACKEND_CANCEL = 5
146+ CUPS_BACKEND_RETRY = 6
147+ # CUPS_BACKEND_RETRY_CURRENT = 7
148+ from xpra .exit_codes import ExitCode
149+ return {
150+ int (ExitCode .OK ): CUPS_BACKEND_OK ,
151+ int (ExitCode .TIMEOUT ): CUPS_BACKEND_HOLD ,
152+ int (ExitCode .AUTHENTICATION_FAILED ): CUPS_BACKEND_AUTH_REQUIRED ,
153+ int (ExitCode .PASSWORD_REQUIRED ): CUPS_BACKEND_AUTH_REQUIRED ,
154+ int (ExitCode .PASSWORD_FILE_ERROR ): CUPS_BACKEND_AUTH_REQUIRED ,
155+ int (ExitCode .ENCRYPTION ): CUPS_BACKEND_AUTH_REQUIRED ,
156+ int (ExitCode .PACKET_FAILURE ): CUPS_BACKEND_STOP ,
157+ int (ExitCode .INCOMPATIBLE_VERSION ): CUPS_BACKEND_STOP ,
158+ int (ExitCode .UNSUPPORTED ): CUPS_BACKEND_STOP ,
159+ int (ExitCode .INTERNAL_ERROR ): CUPS_BACKEND_STOP ,
160+ int (ExitCode .COMPONENT_MISSING ): CUPS_BACKEND_STOP ,
161+ int (ExitCode .IO_ERROR ): CUPS_BACKEND_RETRY ,
162+ }.get (r , CUPS_BACKEND_FAILED )
137163
138164
139165def do_main (args : list [str ]):
0 commit comments