p2obt.backend.upload#

p2obt.backend.upload.add_template(connection: ApiConnection, ob_id: int, ob: Dict, template_kind: str) None[source]#

Adds template to an (.obx)-file on the p2.

Parameters:
  • connection (p2api.p2api.ApiConnection) – The P2 python api connection.

  • ob_id (int) – The id that specifies the ob on p2.

  • ob (dict)

  • template_kind (str)

p2obt.backend.upload.apply_mapping(content: Dict, mapping: Dict) None[source]#

Applies mapping to make template serializable.

p2obt.backend.upload.create_ob(connection: ApiConnection, container_id: int, header: Dict) int[source]#

Creates an OB on p2.

Parameters:
  • connection (p2api.p2api.ApiConnection) – The P2 python api connection.

  • container_id (int) – The id that specifies the container on p2.

  • header (Dict) – The header of the OB.

p2obt.backend.upload.create_remote_container(connection: ApiConnection, name: str, container_id: int, container_type: str = 'concatenation') int[source]#

Creates a container on p2.

Parameters:
  • connection (p2api.p2api.ApiConnection) – The P2 python api connection.

  • name (str) – The container’s name.

  • container_id (int) – The id that specifies the container on p2.

  • type (str) – Container type. Either “folder”, “concatenation” or “group”. Default is “concatenation”. service mode (SM) or “im” for imaging mode (IM).

Returns:

container_id – The created container’s id.

Return type:

int

p2obt.backend.upload.get_remote_run(connection: ApiConnection, run_id: str) int | None[source]#

Gets the run that corresponds to the period, proposal and the number and returns its runId.

Parameters:
  • connection (p2api.p2api.ApiConnection) – The P2 python api connection.

  • run_id (str) – The id that specifies the run on p2.

Returns:

run_id – The run’s id that can be used to access and modify it with the p2api. If not found return “None”.

Return type:

int, optional

p2obt.backend.upload.login(user_name: str | None = None, store_password: bool | None = False, remove_password: bool | None = False, server: str | None = 'demo')[source]#

Login to the p2 API with the given username. Return the API connection. :param username: The p2 user name. :type username: str, optional :param server: Either “demo”, “production” for paranal or “production_lasilla” for la

silla.

Parameters:
  • store_password (bool, optional) – If ‘True’ the password will be stored in the keyring.

  • remove_password (bool, optional) – If ‘True’ the password will be removed from the keyring.

p2obt.backend.upload.remote_container_exists(connection: ApiConnection, container_id: int) bool[source]#

Checks if the container with this id exists on p2.

Parameters:
  • connection (p2api.p2api.ApiConnection) – The p2ui python api.

  • container_id (int) – The id that specifies the container on p2.

Returns:

container_exists – ‘True’ if container exists, otherwise ‘False’.

Return type:

bool

p2obt.backend.upload.upload_ob(connection: ApiConnection, ob: Dict, container_id: int | None = None) None[source]#
Parameters:
  • connection (p2api.p2api.ApiConnection) – The P2 python api connection.

  • ob (dict)

  • container_id (int) – The id that specifies the container on p2.