[Git][NTPsec/ntpsec][master] 4 commits: configure: improve mesage about missing libsodium

Gary E. Miller gitlab at mg.gitlab.com
Thu Jan 19 01:51:17 UTC 2017


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


Commits:
572b99b5 by Gary E. Miller at 2017-01-18T17:35:20-08:00
configure: improve mesage about missing libsodium

- - - - -
8ffb279f by Gary E. Miller at 2017-01-18T17:36:51-08:00
configure: pep8 compliance

- - - - -
437b91eb by Gary E. Miller at 2017-01-18T17:38:35-08:00
configure: pyflakes fixes

- - - - -
0bda4777 by Gary E. Miller at 2017-01-18T17:50:57-08:00
temp-log: pep8 compliance

- - - - -


3 changed files:

- contrib/temp-log.py
- wafhelpers/asciidoc.py
- wafhelpers/check_sodium.py


Changes:

=====================================
contrib/temp-log.py
=====================================
--- a/contrib/temp-log.py
+++ b/contrib/temp-log.py
@@ -1,11 +1,19 @@
 #!/usr/bin/env python
-# temp-log.py: A script that will be run eventually as a daemon to log temperature of a system
+# temp-log.py: A script that will be run eventually as a daemon
+#              to log temperature of a system
 # Usage:
 # temp-log.py [-h] [-V] [-s] [-m]
 # Writes logs to /var/log/ntpstats
 # Requires root to run
 
-import sys, re, time, subprocess, os, logging, logging.handlers
+import logging
+import logging.handlers
+import os
+import re
+import subprocess
+import sys
+import time
+
 
 class CpuTemp:
     "Sensors on the CPU Core"
@@ -13,8 +21,9 @@ class CpuTemp:
         # pattern that matches the string that has the cpu temp
         self._pattern = re.compile('^\s+temp\d+_input:\s+([\d\.]+).*$')
         # Find the sensors binary and stores the path
-        self._sensors_path = subprocess.check_output(["which", "sensors"], universal_newlines=False).replace('\n', '')
-        if self._sensors_path == None:
+        self._sensors_path = subprocess.check_output(
+            ["which", "sensors"], universal_newlines=False).replace('\n', '')
+        if self._sensors_path is None:
             raise Exception("Unable to find sensors binary")
 
     def get_data(self):
@@ -36,9 +45,11 @@ class CpuTemp:
     def _record_temp(self):
         "Call the external command 'sensors -u' and get the data"
         # grab the data from the "sensors -u" command
-        output = subprocess.check_output([self._sensors_path, "-u"], universal_newlines=True)
+        output = subprocess.check_output([self._sensors_path, "-u"],
+                                         universal_newlines=True)
         self.sensors_output = output.split('\n')
 
+
 class SmartCtl:
     "Sensor on the Hard Drive"
     def __init__(self, device):
@@ -51,7 +62,8 @@ class SmartCtl:
 
     def get_data(self):
         "Collects the data and return the output as an array"
-        _output = subprocess.check_output(["smartctl", "-a", self._device], universal_newlines=True)
+        _output = subprocess.check_output(["smartctl", "-a", self._device],
+                                          universal_newlines=True)
         _lines = _output.split('\n')
         for line in _lines:
             match = self._pat.match(line)
@@ -60,6 +72,7 @@ class SmartCtl:
                 temp = match.group(1)
                 return ('%d SMART %s' % (now, temp))
 
+
 class ZoneTemp:
     "Sensors on the CPU Zones"
     def __init__(self):
@@ -74,7 +87,8 @@ class ZoneTemp:
         _zone = 0
         _data = []
         for zone in self.zone_directories:
-            _zone_data = open(os.path.join(os.path.join(self._base_dir, zone), 'temp'))
+            _zone_data = open(os.path.join(os.path.join(self._base_dir, zone),
+                                           'temp'))
             for line in _zone_data:
                 temp = float(line) / 1000
                 _now = int(time.time())
@@ -86,18 +100,26 @@ class ZoneTemp:
 # Global vars
 version = 1.0
 # Create objects
-cpu  = CpuTemp()
+cpu = CpuTemp()
 zone = ZoneTemp()
-hdd  = SmartCtl('/dev/sda')
+hdd = SmartCtl('/dev/sda')
+
 
 def logging_setup(fileName, levelName, logLevel):
     "Create logging object with midnight rotation"
-    logFormat = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+    logFormat = logging.Formatter(
+        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
     # Create logger for cpuTemp
     tempLogger = logging.getLogger(levelName)
     tempLogger.setLevel(logLevel)
     # Create file handler
-    _file = logging.handlers.TimedRotatingFileHandler(fileName, when='midnight', interval=1, backupCount=5, encoding=None, delay=False, utc=False)
+    _file = logging.handlers.TimedRotatingFileHandler(fileName,
+                                                      when='midnight',
+                                                      interval=1,
+                                                      backupCount=5,
+                                                      encoding=None,
+                                                      delay=False,
+                                                      utc=False)
     _file.setLevel(logLevel)
     # Create the formatter and add it to the handler
     _file.setFormatter(logFormat)
@@ -106,6 +128,7 @@ def logging_setup(fileName, levelName, logLevel):
     # Logging rotate
     return tempLogger
 
+
 def log_data(logger, data):
     "Write data to the log"
     if type(data) in (tuple, list):
@@ -114,12 +137,16 @@ def log_data(logger, data):
     else:
         logger.info(data)
 
+
 def log_with_multiple_files():
     "Write the logs to individual files depending on sensor"
     # Create logger instances
-    zoneLogger = logging_setup('/var/log/ntpstats/zoneTemp.log', 'zone_levelname', logging.INFO)
-    cpuLogger  = logging_setup('/var/log/ntpstats/cpuTemp.log', 'cpu_levelname', logging.INFO)
-    hddLogger  = logging_setup('/var/log/ntpstats/hddTemp.log', 'hdd_levelname', logging.INFO)
+    zoneLogger = logging_setup('/var/log/ntpstats/zoneTemp.log',
+                               'zone_levelname', logging.INFO)
+    cpuLogger = logging_setup('/var/log/ntpstats/cpuTemp.log',
+                              'cpu_levelname', logging.INFO)
+    hddLogger = logging_setup('/var/log/ntpstats/hddTemp.log',
+                              'hdd_levelname', logging.INFO)
 
     # Write data to their respective logs forever
     while True:
@@ -129,12 +156,16 @@ def log_with_multiple_files():
         # Sleep 15 seconds
         time.sleep(15)
 
+
 def log_with_one_file():
     "Write all temperature readings to one file"
     # Create the logger instance
-    zoneLogger = logging_setup('/var/log/ntpstats/temp.log', 'zone_levelname', logging.INFO)
-    cpuLogger  = logging_setup('/var/log/ntpstats/temp.log', 'cpu_levelname', logging.INFO)
-    hddLogger  = logging_setup('/var/log/ntpstats/temp.log', 'hdd_levelname', logging.INFO)
+    zoneLogger = logging_setup('/var/log/ntpstats/temp.log',
+                               'zone_levelname', logging.INFO)
+    cpuLogger = logging_setup('/var/log/ntpstats/temp.log',
+                              'cpu_levelname', logging.INFO)
+    hddLogger = logging_setup('/var/log/ntpstats/temp.log',
+                              'hdd_levelname', logging.INFO)
 
     # Write data to their respective logs forever
     while True:
@@ -144,9 +175,11 @@ def log_with_one_file():
         # Sleep 15 seconds
         time.sleep(15)
 
+
 def help_text():
     "Help message"
-    print("temp-log.py [-f filepath] [-h] [-s [-r {hour|day|week|month|year}] [-m] [-V]")
+    print("temp-log.py [-f filepath] [-h] "
+          "[-s [-r {hour|day|week|month|year}] [-m] [-V]")
     print("-h\tPrints this help message")
     print("-s\tWrites all data to a single log file")
     print("-m\tWrites data for each sensor type to their own log file")


=====================================
wafhelpers/asciidoc.py
=====================================
--- a/wafhelpers/asciidoc.py
+++ b/wafhelpers/asciidoc.py
@@ -33,6 +33,5 @@ def run_a2x(self, node):
     n_file = node.path_from(self.bld.bldnode)
     out = "%s.%s" % (n_file.replace("-man.txt.man-tmp", ""), self.section)
     out_n = self.bld.path.find_or_declare(out)
-    # FIXME: pyflakes says tsk never used...
-    tsk = self.create_task('a2x', node, out_n)
+    self.create_task('a2x', node, out_n)
     self.bld.install_files("${PREFIX}/man/man%s/" % self.section, out_n)


=====================================
wafhelpers/check_sodium.py
=====================================
--- a/wafhelpers/check_sodium.py
+++ b/wafhelpers/check_sodium.py
@@ -1,7 +1,6 @@
-import sys
-from waflib.Logs import pprint
+
 
 def check_sodium(ctx):
-    ctx.check_cc(header_name="sodium.h", mandatory=True)
+    ctx.check_cc(header_name="sodium.h", mandatory=True,
+                 errmsg="No\nFatal Error: Your system is missing libsodium")
     ctx.check_cc(lib="sodium", comment="Sodium crypto library", mandatory=True)
-



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/60e3783ad6d0083af86b83a801ba76945f9bb0e6...0bda47772a09c85fd593e1253e0a6bd0695c0274
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170119/fe295b4c/attachment.html>


More information about the vc mailing list