"""
This is the file in which all constants relative to the Condor-IPP
framework are defined for the Camera stage. 

It defines the following constants:
- REQUIREMENTS: The Condor requirements to run Cam jobs
- EMAIL_BODY_MULTIPLE_CAM_ENTRIES: The e-mail body when there is more
  than one cam entry for one chip (Note: it seems it was useful when
  chiptool has a bug but it seems to be fixed now (see svn log for
  revision 32520))
- EMAIL_BODY_REVERT_FAILURE: The e-mail body which is sent when revert
  has failed
"""
from ipp.exceptions.UninstantiableIppException import UninstantiableIppException
from ipp.constants.Globals import Globals as GlobalConstants

class Camera:
    """
    Class where all cam stage constants are defined
    """
    def __init__(self):
        raise UninstantiableIppException()

    # Change it according to new needs
    REQUIREMENTS = GlobalConstants.REQUIREMENTS

    # Body of the e-mail which is sent when there is more than one cam
    # entry for one chip (Note: it seems it was useful when chiptool
    # has a bug but it seems to be fixed now (see svn log for revision
    # 32520)).
    # It is expected to valuate this expression with 3 parameters:
    # - #1: label (str)
    # - #2: exposure name (str)
    # - #3: cam_id (int)
    EMAIL_BODY_MULTIPLE_CAM_ENTRIES = """Hi,

this is an e-mail generated by the ippdor subsystem.

There is more than one entry for the camera stage for 
label %s / exposure %s.

I will only process the entry with cam_id = %d and I strongly
suggest to delete the other entries in the camRun table.

Thanks,
"""
    # Body of the e-mail which is sent when revert has failed. It is
    # expected to valuate this expression with 3 parameters:
    # - #1: exposure name (str)
    # - #2: label (str)
    # - #3: exposure name (str)
    EMAIL_BODY_REVERT_FAILURE = """Hi,

this is an e-mail generated by the ippdor subsystem.

exposure %s has a fault at camera stage (after 3 revert attempts).

You could identify where the problem comes from by running the query:

SELECT exp_name, rawExp.exp_id, chipRun.chip_id, camRun.cam_id, camRun.state, camProcessedExp.fault, camProcessedExp.quality, camProcessedExp.path_base FROM camRun JOIN camProcessedExp USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) WHERE camRun.label = '%s' AND exp_name='%s';

Thanks,
"""
