summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorTaniadz <tdziubenko@ukr.net>2017-09-12 16:24:44 +0300
committerTaniadz <tdziubenko@ukr.net>2017-09-12 16:24:44 +0300
commit5404d4108b510765150c2ac54098cd26ec18a683 (patch)
treed215273429579c10be2d5c213b09e7ce5d17dfeb /scripts
parentecdbe7b6fb64ae7d27d9147aa2c4a55b3a491735 (diff)
downloadvyos-1x-5404d4108b510765150c2ac54098cd26ec18a683.tar.gz
vyos-1x-5404d4108b510765150c2ac54098cd26ec18a683.zip
Add debug mode to the build-command-templates script with content printing
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build-command-templates24
1 files changed, 15 insertions, 9 deletions
diff --git a/scripts/build-command-templates b/scripts/build-command-templates
index ccd87829b..0bac920fb 100755
--- a/scripts/build-command-templates
+++ b/scripts/build-command-templates
@@ -25,6 +25,7 @@ import os
import getopt
import copy
import functools
+import pprint
from lxml import etree as ET
@@ -42,12 +43,14 @@ output_dir = sys.argv[3]
debug = False
-opts, args = getopt.getopt(sys.argv[4:], '', ['debug='])
-
-for opt, arg in opts:
- if opt == '--debug':
- if arg == "1":
- debug = True
+try:
+ opts, args = getopt.getopt(sys.argv[4:], '', ['debug=', ])
+ for opt, arg in opts:
+ if opt == '--debug':
+ if arg == "1":
+ debug = True
+except getopt.GetoptError as err:
+ pass
## Load and validate the inputs
@@ -145,10 +148,10 @@ def make_node_def(props):
if "owner" in props:
node_def += "end: sudo sh -c \"{0}\"\n".format(props["owner"])
-
+ if debug:
+ print("The content of node_def:", node_def)
return node_def
-
def process_node(n, tmpl_dir):
# Avoid mangling the path from the outer call
my_tmpl_dir = copy.copy(tmpl_dir)
@@ -161,8 +164,9 @@ def process_node(n, tmpl_dir):
node_type = n.tag
my_tmpl_dir.append(name)
+
if debug:
- print("Make dir for the node:", n)
+ print("Name of the node: {};\n Created directory: ".format(name), end="")
os.makedirs(make_path(my_tmpl_dir), exist_ok=True)
props = get_properties(props_elem)
@@ -185,6 +189,8 @@ def process_node(n, tmpl_dir):
process_node(inner_n, my_tmpl_dir)
if node_type == "tagNode":
my_tmpl_dir.append("node.tag")
+ if debug:
+ print("Created path for the tagNode:", end="")
os.makedirs(make_path(my_tmpl_dir), exist_ok=True)
inner_nodes = children.iterfind("*")
for inner_n in inner_nodes: