From 5820303883f67c6f26f457912e3231c6b402f29e Mon Sep 17 00:00:00 2001
From: Mario <mario@champ.hep.sci.osaka-u.ac.jp>
Date: Thu, 4 Mar 2021 14:33:47 +0900
Subject: [PATCH] Fixed issue 'labRemote not found'

---
 libDCS/iviscan.py |  29 ++++++++-----
 libDCS/qaqc.py    | 105 +++++++++++++++++++++++++---------------------
 2 files changed, 75 insertions(+), 59 deletions(-)

diff --git a/libDCS/iviscan.py b/libDCS/iviscan.py
index 66b7f00..e684340 100644
--- a/libDCS/iviscan.py
+++ b/libDCS/iviscan.py
@@ -10,9 +10,12 @@ from influxdb import InfluxDBClient, exceptions
 # LR stuff
 LABREMOTE = 1
 try:
-    import _labRemote as labRemote
+    import labRemote
 except:
-    LABREMOTE = 0
+    try:
+        import _labRemote as labRemote
+    except:
+        LABREMOTE = 0
 
 
 
@@ -331,16 +334,20 @@ if __name__ == "__main__":
         sys.path.append(lrLibPath)
 
         try:
-            import _labRemote as labRemote
+            import labRemote
         except:
-            print("Couldn't find the labRemote Python libraries. Make sure to add them to your $PYTHONPATH first by either doing")
-            print()
-            print("     export PYTHONPATH=/path/to/labRemote/build/lib:$PYTHONPATH")
-            print()
-            print("  or writing \"/path/to/labRemote/build/lib\" in \"" + args.equip + "\"")
-            print()
-            print("And make sure also that you have previously built labRemote enabling the Python bindings (cmake3 -DUSE_PYTHON=on)")
-            exit(1)
+            try:
+                import _labRemote as labRemote
+            except:
+                print("Couldn't find the labRemote Python libraries. Make sure to add them to your $PYTHONPATH first by either doing")
+                print()
+                print("     export PYTHONPATH=/path/to/labRemote/build/lib:$PYTHONPATH")
+                print()
+                print("  or writing \"/path/to/labRemote/build/lib\" in \"" + args.equip + "\"")
+                print()
+                print("And make sure also that you have previously built labRemote enabling the Python bindings (cmake3 -DUSE_PYTHON=on)")
+                exit(1)
+
 
 
     uploadToInflux = False
diff --git a/libDCS/qaqc.py b/libDCS/qaqc.py
index b2fe0bf..a8f8844 100644
--- a/libDCS/qaqc.py
+++ b/libDCS/qaqc.py
@@ -46,9 +46,12 @@ dpColumnName = "Dew Point (ch.Carrier in) [C]"
 # LR stuff
 LABREMOTE = 1
 try:
-    import _labRemote as labRemote
+    import labRemote
 except:
-    LABREMOTE = 0
+    try:
+        import _labRemote as labRemote
+    except:
+        LABREMOTE = 0
 
 
 # misc
@@ -92,44 +95,47 @@ def power_on(hw, ps, args):
 
 def power_off(hw, ps, args):
 
-    if (args.force):
-        ps.turnOff()
-        print("[ info ][ps] ps off")     
-        return
-
-
-    t  = getFromInflux(temperatureSink, "select last(" + tColumnName + ") from " + temperatureSink["measurement"])
-    dp = getFromInflux(dewpointSink, "select last(\"" + dpColumnName + "\") from " + dewpointSink["measurement"])
-
-    if t == [] or dp == []:
-        print("[ error ][ps] couldn't find T or DP data in influxDB. The retrieved values are")
-        print("[ info ][ps] T = {}    DP = {}".format(t, dp))
-        print("[ qstn ][ps] turn off the PS anyway?")
-
-        ans = input ("y/n: ")
-        if ans == 'y': 
-            ps.turnOff()
-            print("[ info ][ps] ps off")
-            return
-        else: 
-            print("[ info ][ps] ok!")
-            return
-
-
-
-    t =  t[0][0]["last"]
-    dp = dp[0][0]["last"]
-
-    print("[ info ][ps] T = {:.2f}; dp = {:.2f}".format(t, dp))
-    
-    diff = t - dp
-    if diff < maxDiffBetweenTandDPtoTurnTheHVoff:
-        print("[ warn ][ps] (T - DP) = {:.2f}, which is smaller than {}. Cannot power off the PS in these conditions".format(diff, maxDiffBetweenTandDPtoTurnTheHVoff))
-    else:
-        ps.turnOff()
-        print("[ info ][ps] ps off")
+    ps.turnOff()
+    return 0
 
-    return
+#    if (args.force):
+#        ps.turnOff()
+#        print("[ info ][ps] ps off")     
+#        return
+#
+#
+#    t  = getFromInflux(temperatureSink, "select last(" + tColumnName + ") from " + temperatureSink["measurement"])
+#    dp = getFromInflux(dewpointSink, "select last(\"" + dpColumnName + "\") from " + dewpointSink["measurement"])
+#
+#    if t == [] or dp == []:
+#        print("[ error ][ps] couldn't find T or DP data in influxDB. The retrieved values are")
+#        print("[ info ][ps] T = {}    DP = {}".format(t, dp))
+#        print("[ qstn ][ps] turn off the PS anyway?")
+#
+#        ans = input ("y/n: ")
+#        if ans == 'y': 
+#            ps.turnOff()
+#            print("[ info ][ps] ps off")
+#            return
+#        else: 
+#            print("[ info ][ps] ok!")
+#            return
+#
+#
+#
+#    t =  t[0][0]["last"]
+#    dp = dp[0][0]["last"]
+#
+#    print("[ info ][ps] T = {:.2f}; dp = {:.2f}".format(t, dp))
+#    
+#    diff = t - dp
+#    if diff < maxDiffBetweenTandDPtoTurnTheHVoff:
+#        print("[ warn ][ps] (T - DP) = {:.2f}, which is smaller than {}. Cannot power off the PS in these conditions".format(diff, maxDiffBetweenTandDPtoTurnTheHVoff))
+#    else:
+#        ps.turnOff()
+#        print("[ info ][ps] ps off")
+#
+#    return
 
 def measure(hw, ps, args):
     # Takes data and pushes it to influxdb
@@ -356,16 +362,19 @@ if __name__ == "__main__":
         sys.path.append(lrLibPath)
 
         try:
-            import _labRemote as labRemote
+            import labRemote
         except:
-            print("Couldn't find the labRemote Python libraries. Make sure to add them to your $PYTHONPATH first by either doing")
-            print()
-            print("     export PYTHONPATH=/path/to/labRemote/build/lib:$PYTHONPATH")
-            print()
-            print("  or writing \"/path/to/labRemote/build/lib\" in \"" + args.equip + "\"")
-            print()
-            print("And make sure also that you have previously built labRemote enabling the Python bindings (cmake3 -DUSE_PYTHON=on)")
-            exit(1)
+            try:
+                import _labRemote as labRemote
+            except:
+                print("Couldn't find the labRemote Python libraries. Make sure to add them to your $PYTHONPATH first by either doing")
+                print()
+                print("     export PYTHONPATH=/path/to/labRemote/build/lib:$PYTHONPATH")
+                print()
+                print("  or writing \"/path/to/labRemote/build/lib\" in \"" + args.equip + "\"")
+                print()
+                print("And make sure also that you have previously built labRemote enabling the Python bindings (cmake3 -DUSE_PYTHON=on)")
+                exit(1)
 
 
     # - - - - - - - - - -
-- 
GitLab