diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/omny_general_tools.py b/csaxs_bec/bec_ipython_client/plugins/omny/omny_general_tools.py index 78e9892..74b03af 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/omny_general_tools.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny_general_tools.py @@ -329,8 +329,12 @@ class TomoIDManager: """Registers a tomography measurement in the OMNY sample database and returns its assigned tomo ID. - Falls back to tomo ID 0 for non-production accounts (e.g. test - accounts like "gac-x01dc") which the server rejects. + Non-production accounts (e.g. test accounts like "gac-x01dc") register + against the test server (TEST_OMNY_URL) instead of production, so + testing still gets a real, incrementing tomo ID -- matching the + counter the samples-folder PDF upload reads from on that same test + host -- accepting that the eaccount recorded in that test database + won't be a real e-account. Usage: id_manager = TomoIDManager() @@ -346,6 +350,7 @@ class TomoIDManager: """ OMNY_URL = "https://v1p0zyg2w9n2k9c1.myfritz.net/samples/newmeasurement.php" + TEST_OMNY_URL = "https://omny-test.psi.ch/samples/newmeasurement.php" TMP_FILE = "~/currsamplesnr.txt" FALLBACK_TOMO_ID = 0 @@ -366,18 +371,23 @@ class TomoIDManager: ) -> int: """Register a new measurement and return the assigned tomo ID. - Returns FALLBACK_TOMO_ID (0) if the account is not a real e-account - or if the server cannot be reached / returns an unusable response. + Registers against OMNY_URL (production) for a real e-account, or + TEST_OMNY_URL (test server) otherwise. Returns FALLBACK_TOMO_ID (0) + only if the server actually can't be reached / returns an unusable + response. """ - if not self._is_valid_eaccount(eaccount): + if self._is_valid_eaccount(eaccount): + omny_url = self.OMNY_URL + else: + omny_url = self.TEST_OMNY_URL logger.warning( - f"Account '{eaccount}' is not a valid e-account; " - f"skipping OMNY registration, using tomo ID {self.FALLBACK_TOMO_ID}." + f"Account '{eaccount}' is not a valid e-account; registering " + f"against the test server ({self.TEST_OMNY_URL}) instead of " + "production -- the eaccount recorded there won't be real." ) - return self.FALLBACK_TOMO_ID url = ( - f"{self.OMNY_URL}" + f"{omny_url}" f"?sample={sample_name}" f"&date={date}" f"&eaccount={eaccount}" @@ -392,7 +402,7 @@ class TomoIDManager: result = subprocess.run(f"wget -q -O {tmp_file} '{url}'", shell=True, timeout=30) if result.returncode != 0: raise OMNYToolsError( - f"wget failed (exit code {result.returncode}) fetching tomo ID from {self.OMNY_URL}" + f"wget failed (exit code {result.returncode}) fetching tomo ID from {omny_url}" ) with open(tmp_file) as f: content = f.read().strip()