From 14d4da8c97f572d40f3a856c7189f733901705ed Mon Sep 17 00:00:00 2001
From: Karim Ahmed <karim.ahmed@xfel.eu>
Date: Mon, 4 Nov 2019 14:20:16 +0100
Subject: [PATCH] avoid only empty str updated value and small fix for
 rng_pulse_agipd

---
 cal_tools/cal_tools/agipdlib.py | 2 +-
 webservice/update_config.py     | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/cal_tools/cal_tools/agipdlib.py b/cal_tools/cal_tools/agipdlib.py
index b7a482f51..227e873b3 100644
--- a/cal_tools/cal_tools/agipdlib.py
+++ b/cal_tools/cal_tools/agipdlib.py
@@ -1177,7 +1177,7 @@ class AgipdCorrections:
         # Check if 1st pulse idx was out of valid range.
         # If that is the case only calibrate the last step pulse.
         if self.pulses_lst[0] >= last_pulse:
-            first_pulse = self.pulses_lst[0] - pulse_step
+            first_pulse = last_pulse - pulse_step
         else:
             first_pulse = self.pulses_lst[0]
 
diff --git a/webservice/update_config.py b/webservice/update_config.py
index e70548aa4..d1972e6e6 100644
--- a/webservice/update_config.py
+++ b/webservice/update_config.py
@@ -80,9 +80,13 @@ for key, value in args.items():
 
         if 'no-' in key and isinstance(value, bool):
             if key not in bool_keys:
-                new_conf[task][instrument][detector][key.replace('no-','')] = False
+                new_conf[task][instrument][detector][key.replace('no-','')] = False  #noqa
             # avoid saving the "no-"key into the updated config
             continue
+        # Assure adding an empty string for new empty
+        # str. updates (e.g. calfile)
+        if isinstance(key, str) and (value == '' or value == ' '):
+            value = '""'
 
         new_conf[task][instrument][detector][key] = value
 
-- 
GitLab