Fixes for building TGZ labelfile and build actions
Change-Id: I62c2a930aa23c1d1d4bdac9d82b3e38370677ff4
Related-PROD: PROD-28199
diff --git a/cfg_checker/helpers/tgz.py b/cfg_checker/helpers/tgz.py
index 631125e..754f0de 100644
--- a/cfg_checker/helpers/tgz.py
+++ b/cfg_checker/helpers/tgz.py
@@ -8,13 +8,17 @@
class TGZFile(object):
basefile = None
+ _labelname = "labelfile"
def __init__(self, _filepath, label=None):
# Check if this filename exists
if not os.path.exists(_filepath):
# If the archive not exists, create it
# simple labelfile for a non-empty archive
- _labelname = "labelfile"
+
+ if not label:
+ label = "MCP Checker TGZ file"
+
with tempfile.TemporaryFile() as _tempfile:
_tempfile.write(label.encode('utf-8'))
_tempfile.flush()
@@ -22,7 +26,7 @@
# create tgz
with tarfile.open(_filepath, "w:gz") as tgz:
_info = tgz.gettarinfo(
- arcname=_labelname,
+ arcname=self._labelname,
fileobj=_tempfile
)
tgz.addfile(_info, fileobj=_tempfile)
@@ -124,9 +128,11 @@
_n.append(f.rsplit('/', 1)[1])
else:
_n.append(f)
- return _n
- else:
- return _names
+ _names = _n
+ # remove label file from output
+ if self._labelname in _names:
+ _names.remove(self._labelname)
+ return _names
def has_file(self, name):
if name in self.list_files():
diff --git a/cfg_checker/modules/packages/repos.py b/cfg_checker/modules/packages/repos.py
index 27c388c..00c438f 100644
--- a/cfg_checker/modules/packages/repos.py
+++ b/cfg_checker/modules/packages/repos.py
@@ -736,12 +736,7 @@
def _build_action(self, url, tags):
for t in tags:
- logger_cli.info(
- "# Building repo info for '{}/{}'".format(
- url,
- t
- )
- )
+ logger_cli.info("# Building repo info for '{}'".format(t))
self.build_repos(url, tag=t)
def get_available_tags(self, tag=None):
@@ -773,20 +768,28 @@
# See if this is a list action
if action == "list":
_all = ReposInfo().list_tags()
- # Print pretty list and exit
- logger_cli.info("# Tags available at '{}':".format(url))
- for t in _all:
- _ri = self._repo_index
- _isparsed = any(
- [k for k, v in _ri.iteritems() if v['props']['tag'] == t]
- )
- if _isparsed:
- logger_cli.info(get_tag_label(t, parsed=True))
- else:
- logger_cli.info(get_tag_label(t))
+ if _all:
+ # Print pretty list and exit
+ logger_cli.info("# Tags available at '{}':".format(url))
+ for t in _all:
+ _ri = self._repo_index
+ _isparsed = any(
+ [k for k, v in _ri.iteritems()
+ if v['props']['tag'] == t]
+ )
+ if _isparsed:
+ logger_cli.info(get_tag_label(t, parsed=True))
+ else:
+ logger_cli.info(get_tag_label(t))
+ else:
+ logger_cli.info("# Not tags parsed yet for '{}':".format(url))
+
# exit
return
+ if action == "build":
+ self._build_action(url, [tag])
+
# Populate action tags
_action_tags = self.get_available_tags(tag)
@@ -802,9 +805,7 @@
)
)
# Execute actions
- if action == "build":
- self._build_action(url, _action_tags)
- elif action == "fetch":
+ if action == "fetch":
for t in _action_tags:
self.fetch_versions(t, descriptions=descriptions, apps=apps)