from odoo import _ # *** # This file is used to define commonly used constants # *** # Returned when a general error occurs GENERAL_ERROR = -100 # Returned when a resource is not found NOT_FOUND = -101 # -- SSH # Returned when an SSH connection error occurs SSH_CONNECTION_ERROR = 503 # -- Command: -200 > -299 # Returned when trying to execute another instance of a command on the same server # and this command doesn't allow parallel run ANOTHER_COMMAND_RUNNING = -201 # Returned when no runner is found for command action NO_COMMAND_RUNNER_FOUND = -202 # Returned when the command failed to execute due to a python code execution error PYTHON_COMMAND_ERROR = -203 # Returned when the command failed to execute because the condition was not met PLAN_LINE_CONDITION_CHECK_FAILED = -205 # Returned when the command timed out COMMAND_TIMED_OUT = -206 COMMAND_TIMED_OUT_MESSAGE = _("Command timed out and was terminated") # Returned when the command is not compatible with the server COMMAND_NOT_COMPATIBLE_WITH_SERVER = -207 # Returned when the command was stopped by user COMMAND_STOPPED = -208 # -- Plan: -300 > -399 # Returned when trying to execute another instance of a flightplan on the same server # and this flightplan doesn't allow parallel run ANOTHER_PLAN_RUNNING = -301 # Returned when trying to start plan without lines PLAN_IS_EMPTY = -302 # Returned when a plan tries to parse a command log record which doesn't have # a valid plan reference in it PLAN_NOT_ASSIGNED = -303 # Returned when a plan tries to parse a command log record which doesn't have # a valid plan line reference in it PLAN_LINE_NOT_ASSIGNED = -304 # Returned when any of the commands in the plan is not compatible with the server PLAN_NOT_COMPATIBLE_WITH_SERVER = -306 # Returned when the flight plan was stopped by user PLAN_STOPPED = -308 # -- File: -400 > -499 # Returned when the file could not be created on the server FILE_CREATION_FAILED = -400 # Returned when the file could not be uploaded to the server FILE_UPLOAD_FAILED = -401 # Returned when the file could not be downloaded from the server FILE_DOWNLOAD_FAILED = -402 # -- Jet: -500 > -599 # Returned when the jet action is not found JET_ACTION_NOT_FOUND = -501 # Returned when the jet template is not found JET_TEMPLATE_NOT_FOUND = -502 # Returned when the jet is not found JET_NOT_FOUND = -503 # Returned when a jet state error occurs JET_STATE_ERROR = -504 # Returned when the jet action is not available JET_ACTION_NOT_AVAILABLE = -505 # Returned when the jet dependencies are not satisfied JET_DEPENDENCIES_NOT_SATISFIED = -506 # Returned when the waypoint template is not found or not set WAYPOINT_TEMPLATE_NOT_FOUND = -507 # Returned when waypoint creation fails (e.g. template not for jet, jet busy) WAYPOINT_CREATE_FAILED = -508 # -- Default values # Default Python code used in Python code command DEFAULT_PYTHON_CODE = _( """# Please refer to the 'Help' tab and documentation for more information. # # You can return command result in the 'result' variable which is a dictionary: # result = {"exit_code": 0, "message": "Some message"} # default value is {"exit_code": 0, "message": None} """ # noqa: E501 ) # Default Python code help displayed in the "Help" tab DEFAULT_PYTHON_CODE_HELP = _( """
Each Python code command returns the result value which is a dictionary.
There are two keys in the dictionary:
exit_code: Integer. Exit code of the command. "0" means success, any other value means failure. Default value is "0".message: String. Message to be logged. Default value is "None".custom_values dictionary that contains custom values provided to the command or flight plan.
Custom values can be modified, thus can be used to pass data between commands in a flight plan.
Please keep in mind that custom values are persistent only between commands in a flight plan and are not saved to the database.
server_name = server.name
build_name = custom_values.get("build_name")
if build_name:
result = {"exit_code": 0, "message": "Build name for " + server_name + " is " + build_name}
else:
result = {"exit_code": 0, "message": "No build name provided for " + server_name}
custom_values["build_name"] = "New build name"
Various fields may use Python code or Python expressions. The following variables can be used:
""" # noqa: E501 )