[Git][NTPsec/ntpsec][master] 6 commits: waf.py: conform to pep8
Gary E. Miller
gitlab at mg.gitlab.com
Tue Jan 3 22:57:08 UTC 2017
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
8af04cf3 by Gary E. Miller at 2017-01-03T14:41:41-08:00
waf.py: conform to pep8
- - - - -
b08a15c1 by Gary E. Miller at 2017-01-03T14:44:49-08:00
util.py: conform to pep8
- - - - -
599b16bf by Gary E. Miller at 2017-01-03T14:46:15-08:00
tool.py: conform to pep8
- - - - -
a0136c71 by Gary E. Miller at 2017-01-03T14:47:03-08:00
test.py: conform to pep8
- - - - -
6f967315 by Gary E. Miller at 2017-01-03T14:48:09-08:00
rtems_trace.py: conform to pep8
- - - - -
adfe834b by Gary E. Miller at 2017-01-03T14:56:27-08:00
refclock.py: conform to pep8
- - - - -
6 changed files:
- wafhelpers/refclock.py
- wafhelpers/rtems_trace.py
- wafhelpers/test.py
- wafhelpers/tool.py
- wafhelpers/util.py
- wafhelpers/waf.py
Changes:
=====================================
wafhelpers/refclock.py
=====================================
--- a/wafhelpers/refclock.py
+++ b/wafhelpers/refclock.py
@@ -8,186 +8,189 @@ from waflib.Logs import pprint
refclock_map = {
- "local": {
- "descr": "Undisciplined Local Clock",
- "define": "CLOCK_LOCAL",
- "file": "local"
- },
-
- "spectracom": {
- "descr": "Spectracom GPS Receivers",
- "define": "CLOCK_SPECTRACOM",
- "file": "spectracom"
- },
-
- "truetime": {
- "descr": "TrueTime GPS/GOES/OMEGA Receivers",
- "define": "CLOCK_TRUETIME",
- "file": "truetime"
- },
-
- "generic": {
- "descr": "Generic Reference Driver (Parse)",
- "define": "CLOCK_GENERIC",
- "require": ["parse"],
- "file": "generic"
- },
-
- "magnavox": {
- "descr": "Magnavox MX4200 and related GPS receivers",
- "define": "CLOCK_MAGNAVOX",
- "require": ["ppsapi"],
- "file": "magnavox"
- },
-
- "arbiter": {
- "descr": "Arbiter 1088A/B GPS Receiver",
- "define": "CLOCK_ARBITER",
- "file": "arbiter"
- },
-
- "modem": {
- "descr": "NIST/USNO/PTB Modem Time Services",
- "define": "CLOCK_MODEM",
- "file": "modem"
- },
-
- "nmea": {
- "descr": "Generic NMEA GPS Receiver",
- "define": "CLOCK_NMEA",
- "file": "nmea"
- },
-
- "pps": {
- "descr": "PPS Clock Discipline",
- "define": "CLOCK_PPS",
- "require": ["ppsapi"],
- "file": "pps"
- },
-
- "hpgps": {
- "descr": "Hewlett Packard 58503A GPS Receiver",
- "define": "CLOCK_HPGPS",
- "file": "hpgps"
- },
-
- "shm": {
- "descr": "Shared Memory Driver",
- "define": "CLOCK_SHM",
- "file": "shm"
- },
-
- "trimble": {
- "descr": "Trimble Navigation GPSes",
- "define": "CLOCK_TRIMBLE",
- "file": "trimble"
- },
-
- "oncore": {
- "descr": "Motorola UT Oncore GPS",
- "define": "CLOCK_ONCORE",
- "require": ["ppsapi"],
- "file": "oncore"
- },
-
- "jupiter": {
- "descr": "Rockwell Jupiter GPS",
- "define": "CLOCK_JUPITER",
- "require": ["ppsapi"],
- "file": "jupiter"
- },
-
- "dumbclock": {
- "descr": "Dumb Clock",
- "define": "CLOCK_DUMBCLOCK",
- "file": "dumbclock"
- },
-
- "jjy": {
- "descr": "JJY Receivers",
- "define": "CLOCK_JJY",
- "file": "jjy"
- },
-
- "zyfer": {
- "descr": "Zyfer GPStarplus Receiver",
- "define": "CLOCK_ZYFER",
- "file": "zyfer"
- },
-
- "neoclock": {
- "descr": "NeoClock4X - DCF77 / TDF serial line",
- "define": "CLOCK_NEOCLOCK",
- "file": "neoclock"
- },
-
- "gpsd": {
- "descr": "GPSD NG client protocol",
- "define": "CLOCK_GPSDJSON",
- "file": "gpsd"
- }
+ "local": {
+ "descr": "Undisciplined Local Clock",
+ "define": "CLOCK_LOCAL",
+ "file": "local"
+ },
+
+ "spectracom": {
+ "descr": "Spectracom GPS Receivers",
+ "define": "CLOCK_SPECTRACOM",
+ "file": "spectracom"
+ },
+
+ "truetime": {
+ "descr": "TrueTime GPS/GOES/OMEGA Receivers",
+ "define": "CLOCK_TRUETIME",
+ "file": "truetime"
+ },
+
+ "generic": {
+ "descr": "Generic Reference Driver (Parse)",
+ "define": "CLOCK_GENERIC",
+ "require": ["parse"],
+ "file": "generic"
+ },
+
+ "magnavox": {
+ "descr": "Magnavox MX4200 and related GPS receivers",
+ "define": "CLOCK_MAGNAVOX",
+ "require": ["ppsapi"],
+ "file": "magnavox"
+ },
+
+ "arbiter": {
+ "descr": "Arbiter 1088A/B GPS Receiver",
+ "define": "CLOCK_ARBITER",
+ "file": "arbiter"
+ },
+
+ "modem": {
+ "descr": "NIST/USNO/PTB Modem Time Services",
+ "define": "CLOCK_MODEM",
+ "file": "modem"
+ },
+
+ "nmea": {
+ "descr": "Generic NMEA GPS Receiver",
+ "define": "CLOCK_NMEA",
+ "file": "nmea"
+ },
+
+ "pps": {
+ "descr": "PPS Clock Discipline",
+ "define": "CLOCK_PPS",
+ "require": ["ppsapi"],
+ "file": "pps"
+ },
+
+ "hpgps": {
+ "descr": "Hewlett Packard 58503A GPS Receiver",
+ "define": "CLOCK_HPGPS",
+ "file": "hpgps"
+ },
+
+ "shm": {
+ "descr": "Shared Memory Driver",
+ "define": "CLOCK_SHM",
+ "file": "shm"
+ },
+
+ "trimble": {
+ "descr": "Trimble Navigation GPSes",
+ "define": "CLOCK_TRIMBLE",
+ "file": "trimble"
+ },
+
+ "oncore": {
+ "descr": "Motorola UT Oncore GPS",
+ "define": "CLOCK_ONCORE",
+ "require": ["ppsapi"],
+ "file": "oncore"
+ },
+
+ "jupiter": {
+ "descr": "Rockwell Jupiter GPS",
+ "define": "CLOCK_JUPITER",
+ "require": ["ppsapi"],
+ "file": "jupiter"
+ },
+
+ "dumbclock": {
+ "descr": "Dumb Clock",
+ "define": "CLOCK_DUMBCLOCK",
+ "file": "dumbclock"
+ },
+
+ "jjy": {
+ "descr": "JJY Receivers",
+ "define": "CLOCK_JJY",
+ "file": "jjy"
+ },
+
+ "zyfer": {
+ "descr": "Zyfer GPStarplus Receiver",
+ "define": "CLOCK_ZYFER",
+ "file": "zyfer"
+ },
+
+ "neoclock": {
+ "descr": "NeoClock4X - DCF77 / TDF serial line",
+ "define": "CLOCK_NEOCLOCK",
+ "file": "neoclock"
+ },
+
+ "gpsd": {
+ "descr": "GPSD NG client protocol",
+ "define": "CLOCK_GPSDJSON",
+ "file": "gpsd"
+ }
}
@conf
def refclock_config(ctx):
- from wafhelpers.refclock import refclock_map
-
- if ctx.options.refclocks == "all":
- ids = refclock_map.keys()
- else:
- # XXX: better error checking
- ids = ctx.options.refclocks.split(",")
-
- ctx.env.REFCLOCK_SOURCE = []
-
- # Remove duplicate IDs while preserving order.
- unique_id = []
- [unique_id.append(x) for x in ids if x not in unique_id]
-
- refclock = False
- for id in unique_id:
- if id not in refclock_map:
- ctx.fatal("'%s' is not a valid Refclock ID" % id)
-
- rc = refclock_map[id]
-
- if rc['define'] == "CLOCK_GENERIC":
- parse_clocks = (
- "CLOCK_COMPUTIME",
- "CLOCK_DCF7000",
- "CLOCK_HOPF6021",
- "CLOCK_MEINBERG",
- "CLOCK_RAWDCF",
- "CLOCK_RCC8000",
- "CLOCK_SCHMID",
- "CLOCK_SEL240X",
- "CLOCK_TRIMTAIP",
- "CLOCK_TRIMTSIP",
- "CLOCK_VARITEXT",
- "CLOCK_WHARTON_400A",
- )
- for subtype in parse_clocks:
- ctx.define(subtype, 1, comment="Enable individual parse clock")
-
- ctx.start_msg("Enabling Refclock %s (%s):" % (rc["descr"], id))
-
- if "require" in rc:
- if "ppsapi" in rc["require"]:
- if not ctx.get_define("HAVE_PPSAPI"):
- ctx.end_msg("No")
- pprint("RED", "Refclock \"%s\" disabled, PPS API has not been detected as working." % rc["descr"])
- continue
-
- ctx.env.REFCLOCK_SOURCE.append((rc["file"], rc["define"]))
- ctx.env["REFCLOCK_%s" % rc["file"].upper()] = True
- ctx.define(rc["define"], 1, comment="Enable '%s' refclock" % rc["descr"])
- ctx.env.REFCLOCK_LIST += [str(id)]
-
- ctx.end_msg("Yes")
-
- refclock = True
-
- if refclock:
- ctx.env.REFCLOCK_ENABLE = True
- ctx.define("REFCLOCK", 1, comment="Enable refclock support")
+ from wafhelpers.refclock import refclock_map
+
+ if ctx.options.refclocks == "all":
+ ids = refclock_map.keys()
+ else:
+ # XXX: better error checking
+ ids = ctx.options.refclocks.split(",")
+
+ ctx.env.REFCLOCK_SOURCE = []
+
+ # Remove duplicate IDs while preserving order.
+ unique_id = []
+ [unique_id.append(x) for x in ids if x not in unique_id]
+
+ refclock = False
+ for id in unique_id:
+ if id not in refclock_map:
+ ctx.fatal("'%s' is not a valid Refclock ID" % id)
+
+ rc = refclock_map[id]
+
+ if rc['define'] == "CLOCK_GENERIC":
+ parse_clocks = (
+ "CLOCK_COMPUTIME",
+ "CLOCK_DCF7000",
+ "CLOCK_HOPF6021",
+ "CLOCK_MEINBERG",
+ "CLOCK_RAWDCF",
+ "CLOCK_RCC8000",
+ "CLOCK_SCHMID",
+ "CLOCK_SEL240X",
+ "CLOCK_TRIMTAIP",
+ "CLOCK_TRIMTSIP",
+ "CLOCK_VARITEXT",
+ "CLOCK_WHARTON_400A",
+ )
+ for subtype in parse_clocks:
+ ctx.define(subtype, 1, comment="Enable individual parse clock")
+
+ ctx.start_msg("Enabling Refclock %s (%s):" % (rc["descr"], id))
+
+ if "require" in rc:
+ if "ppsapi" in rc["require"]:
+ if not ctx.get_define("HAVE_PPSAPI"):
+ ctx.end_msg("No")
+ pprint("RED",
+ "Refclock \"%s\" disabled, PPS API has not "
+ "been detected as working." % rc["descr"])
+ continue
+
+ ctx.env.REFCLOCK_SOURCE.append((rc["file"], rc["define"]))
+ ctx.env["REFCLOCK_%s" % rc["file"].upper()] = True
+ ctx.define(rc["define"], 1,
+ comment="Enable '%s' refclock" % rc["descr"])
+ ctx.env.REFCLOCK_LIST += [str(id)]
+
+ ctx.end_msg("Yes")
+
+ refclock = True
+
+ if refclock:
+ ctx.env.REFCLOCK_ENABLE = True
+ ctx.define("REFCLOCK", 1, comment="Enable refclock support")
=====================================
wafhelpers/rtems_trace.py
=====================================
--- a/wafhelpers/rtems_trace.py
+++ b/wafhelpers/rtems_trace.py
@@ -4,5 +4,6 @@ from waflib.TaskGen import feature, after_method
@feature("rtems_trace")
@after_method('apply_link')
def rtems_trace(self):
- if self.env.RTEMS_TEST_ENABLE:
- self.link_task.env.LINK_CC = self.env.BIN_RTEMS_TLD + self.env.RTEMS_TEST_FLAGS + ['--']
+ if self.env.RTEMS_TEST_ENABLE:
+ self.link_task.env.LINK_CC = self.env.BIN_RTEMS_TLD \
+ + self.env.RTEMS_TEST_FLAGS + ['--']
=====================================
wafhelpers/test.py
=====================================
--- a/wafhelpers/test.py
+++ b/wafhelpers/test.py
@@ -2,39 +2,40 @@ from __future__ import print_function
from waflib.Logs import pprint
+
def test_write_log(ctx):
- file_out = "%s/test.log" % ctx.bldnode.abspath()
+ file_out = "%s/test.log" % ctx.bldnode.abspath()
- log = getattr(ctx, 'utest_results', [])
+ log = getattr(ctx, 'utest_results', [])
- if not log:
- return
+ if not log:
+ return
- with open(file_out, "w") as fp:
- for binary, retval, lines, error in ctx.utest_results:
- fp.write("BINARY : %s\n" % binary)
- fp.write("RETURN VALUE: %s\n" % retval)
- fp.write("\n*** stdout ***\n")
- fp.write(str(lines))
- fp.write("\n*** stderr ***\n")
- fp.write(str(error))
- fp.write("\n\n\n")
+ with open(file_out, "w") as fp:
+ for binary, retval, lines, error in ctx.utest_results:
+ fp.write("BINARY : %s\n" % binary)
+ fp.write("RETURN VALUE: %s\n" % retval)
+ fp.write("\n*** stdout ***\n")
+ fp.write(str(lines))
+ fp.write("\n*** stderr ***\n")
+ fp.write(str(error))
+ fp.write("\n\n\n")
- pprint("BLUE", "Wrote test log to: ", file_out)
+ pprint("BLUE", "Wrote test log to: ", file_out)
def test_print_log(ctx):
- for binary, retval, lines, error in ctx.utest_results:
- pprint("YELLOW", "BINARY :", binary)
- pprint("YELLOW", "RETURN VALUE:", retval)
- print("")
+ for binary, retval, lines, error in ctx.utest_results:
+ pprint("YELLOW", "BINARY :", binary)
+ pprint("YELLOW", "RETURN VALUE:", retval)
+ print("")
- if retval or error:
- pprint("RED", "****** ERROR ******\n")
+ if retval or error:
+ pprint("RED", "****** ERROR ******\n")
- print(error or lines)
+ print(error or lines)
- if (not retval) and (not error):
- pprint("GREEN", "****** LOG ******\n", lines)
+ if (not retval) and (not error):
+ pprint("GREEN", "****** LOG ******\n", lines)
- print("")
+ print("")
=====================================
wafhelpers/tool.py
=====================================
--- a/wafhelpers/tool.py
+++ b/wafhelpers/tool.py
@@ -1,9 +1,14 @@
from waflib.Logs import pprint
+
def check_sanity(ctx, cond, lib):
- define = "HAVE_%s" % lib.upper()
+ define = "HAVE_%s" % lib.upper()
- if cond and (not ctx.get_define(define)):
- pprint("RED", "Warning %s headers detected, binaries do not build/run" % lib)
- elif (not cond) and ctx.get_define(define):
- pprint("RED", "Warning %s headers not detected, binaries build/run" % lib)
+ if cond and (not ctx.get_define(define)):
+ pprint("RED",
+ "Warning %s headers detected, binaries do not build/run"
+ % lib)
+ elif (not cond) and ctx.get_define(define):
+ pprint("RED",
+ "Warning %s headers not detected, binaries build/run"
+ % lib)
=====================================
wafhelpers/util.py
=====================================
--- a/wafhelpers/util.py
+++ b/wafhelpers/util.py
@@ -1,55 +1,59 @@
import re
from waflib.Logs import pprint
+
def msg(str):
- pprint("YELLOW", str)
+ pprint("YELLOW", str)
+
def msg_setting(name, val):
- pprint("NORMAL", " %-30s: " % name, sep="")
- pprint("YELLOW", val)
+ pprint("NORMAL", " %-30s: " % name, sep="")
+ pprint("YELLOW", val)
# Borrowed from waf/docs/book/wscript in the Waf Project.
re_xi = re.compile('''^(include|image)::(.*?.(txt|\\{PIC\\}))\[''', re.M)
+
+
def ascii_doc_scan(self):
- p = self.inputs[0].parent
- node_lst = [self.inputs[0]]
- seen = []
- depnodes = []
-
- while node_lst:
- nd = node_lst.pop(0)
- if nd in seen: continue
- seen.append(nd)
-
- code = nd.read()
- for m in re_xi.finditer(code):
- name = m.group(2)
- if m.group(3) == '{PIC}':
-
- ext = '.eps'
- if self.generator.rule.rfind('A2X') > 0:
- ext = '.png'
-
- k = p.find_resource(name.replace('{PIC}', ext))
- if k:
- depnodes.append(k)
- else:
- k = self.inputs[0].find_resource(name)
- if k:
- depnodes.append(k)
- node_lst.append(k)
- return [depnodes, ()]
+ p = self.inputs[0].parent
+ node_lst = [self.inputs[0]]
+ seen = []
+ depnodes = []
+
+ while node_lst:
+ nd = node_lst.pop(0)
+ if nd in seen:
+ continue
+ seen.append(nd)
+
+ code = nd.read()
+ for m in re_xi.finditer(code):
+ name = m.group(2)
+ if m.group(3) == '{PIC}':
+
+ ext = '.eps'
+ if self.generator.rule.rfind('A2X') > 0:
+ ext = '.png'
+
+ k = p.find_resource(name.replace('{PIC}', ext))
+ if k:
+ depnodes.append(k)
+ else:
+ k = self.inputs[0].find_resource(name)
+ if k:
+ depnodes.append(k)
+ node_lst.append(k)
+ return [depnodes, ()]
def parse_version(config):
- with open("VERSION", "r") as f:
- version_string = f.read().split(" ")[0].strip()
- [major, minor, rev] = version_string.split(".")
- map = {
- # "NTPS" for NTPSec -- this avoids any naming collisions
- "NTPSEC_VERSION_MAJOR" : int(major),
- "NTPSEC_VERSION_MINOR" : int(minor),
- "NTPSEC_VERSION_REV" : int(rev)
- }
-
- config.update(map)
+ with open("VERSION", "r") as f:
+ version_string = f.read().split(" ")[0].strip()
+ [major, minor, rev] = version_string.split(".")
+ # "NTPS" for NTPSec
+ # this avoids any naming collisions
+ map = {"NTPSEC_VERSION_MAJOR": int(major),
+ "NTPSEC_VERSION_MINOR": int(minor),
+ "NTPSEC_VERSION_REV": int(rev)}
+
+ config.update(map)
=====================================
wafhelpers/waf.py
=====================================
--- a/wafhelpers/waf.py
+++ b/wafhelpers/waf.py
@@ -2,71 +2,73 @@ from waflib.Configure import conf
from waflib.TaskGen import feature, before_method
import os
+
@before_method('apply_incpaths')
@feature('bld_include')
def insert_blddir(self):
- bldnode = self.bld.bldnode.parent.abspath()
- self.includes += [bldnode]
+ bldnode = self.bld.bldnode.parent.abspath()
+ self.includes += [bldnode]
+
@before_method('apply_incpaths')
@feature('src_include')
def insert_srcdir(self):
- srcnode = self.bld.srcnode.abspath()
- self.includes += ["%s/include" % srcnode]
+ srcnode = self.bld.srcnode.abspath()
+ self.includes += ["%s/include" % srcnode]
@before_method('apply_incpaths')
@feature('libisc_include')
def insert_libiscdir(self):
- srcnode = self.bld.srcnode.abspath()
- self.includes += ["%s/libisc/include/" % srcnode]
+ srcnode = self.bld.srcnode.abspath()
+ self.includes += ["%s/libisc/include/" % srcnode]
@before_method('apply_incpaths')
@feature('libisc_pthread_include')
def insert_libiscpthreaddir(self):
- srcnode = self.bld.srcnode.abspath()
- self.includes += ["%s/libisc/pthreads/include/" % srcnode]
+ srcnode = self.bld.srcnode.abspath()
+ self.includes += ["%s/libisc/pthreads/include/" % srcnode]
def manpage_subst_fun(task, text):
- return text.replace("include::../docs/", "include::../../../docs/")
+ return text.replace("include::../docs/", "include::../../../docs/")
+
@conf
def manpage(ctx, section, source):
- if ctx.env.MANDIR:
- manprefix = ctx.env.MANDIR
- elif os.path.isdir("/usr/man"):
- manprefix = "/usr/man"
- else:
- manprefix = "/usr/share/man"
- if not manprefix.endswith("/"):
- manprefix += "/"
+ if ctx.env.MANDIR:
+ manprefix = ctx.env.MANDIR
+ elif os.path.isdir("/usr/man"):
+ manprefix = "/usr/man"
+ else:
+ manprefix = "/usr/share/man"
+ if not manprefix.endswith("/"):
+ manprefix += "/"
- #ctx.install_files(manprefix + "man%s/" % section, source.replace("-man.txt", ".%s" % section))
+ # ctx.install_files(manprefix + "man%s/" % section,
+ # source.replace("-man.txt", ".%s" % section))
- if not ctx.env.ENABLE_DOC or ctx.env.DISABLE_MANPAGE:
- return
+ if not ctx.env.ENABLE_DOC or ctx.env.DISABLE_MANPAGE:
+ return
- ctx(
- features = "subst",
- source = source,
- target = source + '.man-tmp',
- subst_fun = manpage_subst_fun
- )
+ ctx(features="subst",
+ source=source,
+ target=source + '.man-tmp',
+ subst_fun=manpage_subst_fun)
- ctx(source=source + '.man-tmp', section=section)
+ ctx(source=source + '.man-tmp', section=section)
@conf
def ntp_test(ctx, **kwargs):
- bldnode = ctx.bldnode.abspath()
- tg = ctx(**kwargs)
+ bldnode = ctx.bldnode.abspath()
+ tg = ctx(**kwargs)
- args = ["%s/tests/%s" % (bldnode, tg.target), "-v"]
+ args = ["%s/tests/%s" % (bldnode, tg.target), "-v"]
- if hasattr(tg, "test_args"):
- args += tg.test_args
+ if hasattr(tg, "test_args"):
+ args += tg.test_args
- tg.ut_exec = args
+ tg.ut_exec = args
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/859c748e05b4664c372815f2f6de8dc039517aec...adfe834b30f71ad2238f4180a1ccce653cd59bc2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170103/dbe94fb3/attachment.html>
More information about the vc
mailing list