[Git][NTPsec/ntpsec][master] ntpviz: Add Python 2.6 compatibily fix.

Gary E. Miller gitlab at mg.gitlab.com
Tue Sep 26 20:58:08 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
085df0eb by Gary E. Miller at 2017-09-26T13:56:40-07:00
ntpviz: Add Python 2.6 compatibily fix.

Python 2.6 does not understand a comma in format().

More 2.6  issues to fix.

- - - - -


1 changed file:

- ntpclients/ntpviz


Changes:

=====================================
ntpclients/ntpviz
=====================================
--- a/ntpclients/ntpviz
+++ b/ntpclients/ntpviz
@@ -105,6 +105,12 @@ except ImportError as e:
     sys.stderr.write("%s\n" % e)
     sys.exit(1)
 
+# check Python version
+Python26 = False
+if ((3 > sys.version_info[0]) and (7 > sys.version_info[1])):
+    # running under Python version before 2.7
+    Python26 = True
+
 
 # overload ArgumentParser
 class MyArgumentParser(argparse.ArgumentParser):
@@ -292,11 +298,15 @@ class VizStats(ntp.statfiles.NTPStats):
             v *= self.multiplier
             self.percs[k] = round(v, 4)
             if 'ppm' == self.unit and 0.020 > abs(self.percs[k]):
-                self.percs_f[k] = format(v, ",.4f")
+                fmt = ".4f"
             else:
-                self.percs_f[k] = format(v, ",.3f")
+                fmt = ".3f"
+            if not Python26:
+                # Python 2.6 does not undertand the comma format option
+                fmt = "," + fmt
+            self.percs_f[k] = format(v, fmt)
 
-        # dan't scale skewness and kurtosis
+        # don't scale skewness and kurtosis
         self.percs["skew"] = sts.skewness
         self.percs["kurt"] = sts.kurtosis
         if '°C' == units:



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/085df0eb0cd4c211c55c463db849b735bea2d36d

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/085df0eb0cd4c211c55c463db849b735bea2d36d
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170926/58c06c97/attachment.html>


More information about the vc mailing list