diff --git a/.travis.yml b/.travis.yml index 3ce431aa..de340f6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,14 +17,16 @@ addons: mariadb: 10.3 before_install: -- wget https://github.com/DiamondLightSource/ispyb-database/releases/download/v1.8.0/ispyb-database-1.8.0.tar.gz -- tar xvfz ispyb-database-1.8.0.tar.gz +- wget https://github.com/DiamondLightSource/ispyb-database/releases/download/v1.9.1/ispyb-database-1.9.1.tar.gz +- tar xvfz ispyb-database-1.9.1.tar.gz - mysql_upgrade -u root - mysql -u root -e "CREATE DATABASE ispybtest; SET GLOBAL log_bin_trust_function_creators=ON;" - mysql -u root -D ispybtest < schema/tables.sql - mysql -u root -D ispybtest < schema/lookups.sql - mysql -u root -D ispybtest < schema/data.sql - mysql -u root -D ispybtest < schema/routines.sql +- mysql -u root -D ispybtest < grants/ispyb_processing.sql +- mysql -u root -e "CREATE USER ispyb_api@'localhost' IDENTIFIED BY 'password_1234'; GRANT ispyb_processing to ispyb_api@'localhost'; SET DEFAULT ROLE ispyb_processing FOR ispyb_api@'localhost';" before_script: - cp conf/config.example.cfg conf/config.cfg diff --git a/conf/config.example.cfg b/conf/config.example.cfg index 1faf15a4..c3c76870 100644 --- a/conf/config.example.cfg +++ b/conf/config.example.cfg @@ -1,7 +1,7 @@ # Copy this to config.cfg and modify it for your environment [ispyb_mariadb_sp] -user = root -pw = +user = ispyb_api +pw = password_1234 host = localhost port = 3306 db = ispybtest diff --git a/ispyb/sp/mxprocessing.py b/ispyb/sp/mxprocessing.py index 87a5e406..93753c3c 100644 --- a/ispyb/sp/mxprocessing.py +++ b/ispyb/sp/mxprocessing.py @@ -276,6 +276,21 @@ def upsert_program_attachment(self, values): procname="upsert_processing_program_attachment_v2", args=values ) + def upsert_program_message( + self, id=None, program_id=None, severity=None, message=None, description=None + ): + """Store new or update existing program message params. + + :param severity: ERROR,WARNING or INFO + :param message: The message - max 200 characters + :param description: A more detailed description of the message + :return: The program_message_id. + """ + return self.get_connection().call_sp_write( + procname="upsert_processing_program_message", + args=[id, program_id, severity, message, description], + ) + def upsert_processing(self, values): return self.get_connection().call_sp_write( procname="upsert_processing", args=values diff --git a/tests/test_mxprocessing.py b/tests/test_mxprocessing.py index d9bd67fb..6f1f8c40 100644 --- a/tests/test_mxprocessing.py +++ b/tests/test_mxprocessing.py @@ -181,6 +181,18 @@ def test_processing2(testdb): assert pa2[0]["filePath"] == params["file_path"] assert pa2[0]["fileType"] == params["file_type"] + pmid = mxprocessing.upsert_program_message( + id=None, + program_id=programid, + severity="WARNING", + message="Missing images", + description="Images # 3, 14-27, 29, 37, 42, 59-63, 97, 118, 121 missing from data collection directory", + ) + assert pmid is not None + + pmid2 = mxprocessing.upsert_program_message(id=pmid, severity="ERROR") + assert pmid == pmid2 + params = mxprocessing.get_integration_params() params["datacollectionid"] = 993677 params["start_image_no"] = 1