Skip to content

Commit

Permalink
Fixed operation and formatting errors
Browse files Browse the repository at this point in the history
- Fixed formatting error for printing the commands
that are being run in the container to the report
- Moved the clearing of the cache to be run separate
from creating a report
- Added the temp folder to gitignore

Signed-off-by: Nisha K <[email protected]>
  • Loading branch information
Nisha K committed Nov 8, 2017
1 parent b738515 commit e476294
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
__pycache__
*.pyc
sources
temp
report.txt
tern.log
18 changes: 9 additions & 9 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def print_invoke_list(info_dict, info):
if 'container' in info_dict[info]['invoke'][step]:
report = report + '\tin container:\n'
for snippet in info_dict[info]['invoke'][step]['container']:
report = report + '\t' + snippet
report = report + '\t' + snippet + '\n'
else:
for value in info_dict[info]:
report = report + ' ' + value
Expand Down Expand Up @@ -310,14 +310,14 @@ def print_package_info(command_name, package_name):
report = ''
pkg_list = cmds.command_lib['snippets'][command_name]['packages']
pkg_dict = check_for_unique_package(pkg_list, package_name)
report = report + print_invoke_list(pkg_dict, 'version').format(
package=package_name)
report = report + print_invoke_list(pkg_dict, 'license').format(
package=package_name)
report = report + print_invoke_list(pkg_dict, 'src_url').format(
package=package_name)
report = report + print_invoke_list(pkg_dict, 'deps').format(
package=package_name)
report = report + print_invoke_list(pkg_dict, 'version').format_map(
cmds.FormatAwk(package=package_name))
report = report + print_invoke_list(pkg_dict, 'license').format_map(
cmds.FormatAwk(package=package_name))
report = report + print_invoke_list(pkg_dict, 'src_url').format_map(
cmds.FormatAwk(package=package_name))
report = report + print_invoke_list(pkg_dict, 'deps').format_map(
cmds.FormatAwk(package=package_name))
return report


Expand Down
6 changes: 2 additions & 4 deletions report.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def print_dockerfile_run(report, shell, base_layer_no, pkg_name_list,
instr, shell, pkg_name_list)
if not is_summary:
report = report + retrieved_by_invoke.format(
sha=layer_obj.sha)
sha=layer_obj.sha[:10])
report = report + print_invoke_per_instruction(
run_dict['confirmed'])
pkg_list = common.get_packages_from_snippets(
Expand Down Expand Up @@ -238,9 +238,7 @@ def execute(args):
if args.dockerfile:
# parse the dockerfile
common.load_docker_commands(args.dockerfile)
if args.clear_cache:
logger.debug('Clearing cache...')
common.clear_cache()

# master list of package names so far
master_list = []

Expand Down
6 changes: 5 additions & 1 deletion tern
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import argparse
import logging

import report
from common import clear_cache

# logging
logfile = 'tern.log'
Expand All @@ -17,7 +18,10 @@ logfile = 'tern.log'
def main(args, logger):
'''Execute according to subcommands'''
logger.debug('Starting...')
if args.name == 'report':
if args.clear_cache:
logger.debug('Clearing cache...')
clear_cache()
if hasattr(args, 'name') and args.name == 'report':
logger.debug('Creating Report...')
if args.summary:
logger.debug('Creating a summary of components in Docker image...')
Expand Down

0 comments on commit e476294

Please sign in to comment.