On 10/2/20 4:19 PM, Jonatan Pålsson wrote:
If the value appears to be an integer, parse it as such.

This allows the following:

     qmp/qom-set -s ~/qmp.sock sensor.temperature 20000

.. where sensor is a tmp105 device, and temperature is an integer
property.

Signed-off-by: Jonatan Pålsson <jonata...@gmail.com>
---
  scripts/qmp/qom-set | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/qmp/qom-set b/scripts/qmp/qom-set
index 240a78187f..61920680eb 100755
--- a/scripts/qmp/qom-set
+++ b/scripts/qmp/qom-set
@@ -56,7 +56,10 @@ if len(args) > 1:
          path, prop = args[0].rsplit('.', 1)
      except:
          usage_error("invalid format for path/property/value")
-    value = args[1]
+    try:
+        value = int(args[1])
+    except:
+        value = args[1]

Please catch the ValueError explicitly.

  else:
      usage_error("not enough arguments")

What happens when you don't convert it to int specifically? Does something break? My understanding was that QOM received everything as a string anyway, and does its own parsing.


Reply via email to