From 9f231010240cc9b367866a02f71a63632f178ff0 Mon Sep 17 00:00:00 2001 From: David Becvarik Date: Thu, 4 Jun 2015 15:35:05 +0200 Subject: [PATCH 1/9] implementig submodule commands --- ctf_cli/application.py | 27 +++++++++++ ctf_cli/arguments_parser.py | 91 ++++++++++++++++++++++++++++--------- ctf_cli/cli_runner.py | 10 +++- ctf_cli/config.py | 9 +++- 4 files changed, 112 insertions(+), 25 deletions(-) diff --git a/ctf_cli/application.py b/ctf_cli/application.py index 3e6518a..b8d08af 100644 --- a/ctf_cli/application.py +++ b/ctf_cli/application.py @@ -127,6 +127,33 @@ def init(self): f.write(sample_ctl_ctf_config) check_call("git add %s" % ctf_conf_file, shell=True) + def add_remote(self): + if 'feature' in self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_TYPE): + self.add_remote_feature() + else: + self.add_remote_step() + + def add_remote_feature(self): + project = self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_PROJECT) + if project is None: + path = "tests/features/common-remote" + else: + path = "tests/features/" + project + self.add_submodule(path) + + def add_remote_step(self): + project = self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_PROJECT) + if project is None: + path = "tests/steps/common-remote" + else: + path = "tests/steps/" + project + self.add_submodule(path) + + def add_submodule(self, path): + url = self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_URL) + print (url) + check_call('git submodule add %s %s' % (url, path), shell=True) + def run(self): """ The main application execution method diff --git a/ctf_cli/arguments_parser.py b/ctf_cli/arguments_parser.py index 4738085..6a1a095 100644 --- a/ctf_cli/arguments_parser.py +++ b/ctf_cli/arguments_parser.py @@ -25,53 +25,83 @@ class ArgumentsParser(object): def __init__(self, args=None): """ parse arguments """ self.parser = argparse.ArgumentParser(description='CLI for running Containers Testing Framework') + self.subparsers = self.parser.add_subparsers(dest="cli_action") self.add_args() + self.add_remote_subparser() + self.add_init_subparser() + self.add_run_subparser() + self.add_update_subparser() self.args = self.parser.parse_args(args) - def add_args(self): - self.parser.add_argument( - dest='cli_action', - choices=['init', 'run', 'update'], - default=['init', 'run'], - nargs='?', - help="Action to perform (default - init and run)" - ) - self.parser.add_argument( - "-v", - "--verbose", - default=False, - action="store_true", - help="Output is more verbose (recommended)" - ) - self.parser.add_argument( + def add_remote_add_subparser(self, subparser): + subparser.add_argument( + dest='remote_type', + choices=['steps', 'features'], + ) + + subparser.add_argument( + dest='url', + help='module url' + ) + + subparser.add_argument( + "--project", + dest='project', + help="name of test project") + + def add_remote_remove_subparser(self, subparser): + subparser.add_argument( + dest='remote_type', + choices=['steps', 'features'], + ) + + subparser.add_argument( + dest='url', + help='module url' + ) + + subparser.add_argument( + "--project", + dest='project', + help="name of test project") + + def add_remote_subparser(self): + remote_subparser=self.subparsers.add_parser('remote', help='addidng/removing test suites') + remote_oper_subparser=remote_subparser.add_subparsers(dest='remote_action') + self.add_remote_add_subparser(remote_oper_subparser.add_parser('add', help='add remote repository')) + self.add_remote_remove_subparser(remote_oper_subparser.add_parser('remove', help='remove remote repository')) + + def add_run_subparser(self): + run_subparser=self.subparsers.add_parser('run', help="run test suite - default") + run_subparser.add_argument( "-c", "--cli-config", default=None, dest='cli_config_path', help="Path to CLI configuration file (By default use only CLI arguments and default values)" ) - self.parser.add_argument( + run_subparser.add_argument( "-t", "--tests-config", default=None, dest='tests_config_path', help="Path to tests configuration file. By default it will be searched for in test/ dir" ) - self.parser.add_argument( + run_subparser.add_argument( "-f", "--dockerfile", default=None, dest='dockerfile', help="Path to Dockerfile to use. If not passed, will be searched for in the current directory" ) - self.parser.add_argument( + run_subparser.add_argument( "-i", "--image", default=None, dest='image', help="Image to use for testing. If not passed, the image will be built from the Dockerfile." ) - self.parser.add_argument( + run_subparser.add_argument( "-j", "--junit", default=None, @@ -79,8 +109,27 @@ def add_args(self): help="Junit folder to store results. If not passed junit reports will not be generated" ) + def add_update_subparser(self): + update_subparser=self.subparsers.add_parser('update', help="update suites") + + def add_init_subparser(self): + init_subparser=self.subparsers.add_parser('init', help="update suites") + + def add_args(self): + self.parser.add_argument( + "-v", + "--verbose", + default=False, + action="store_true", + help="Output is more verbose (recommended)" + ) + + def __getattr__(self, name): try: return getattr(self.args, name) except AttributeError: - return object.__getattribute__(self, name) + try: + return object.__getattribute__(self, name) + except AttributeError: + return None diff --git a/ctf_cli/cli_runner.py b/ctf_cli/cli_runner.py index a663b62..592c3db 100644 --- a/ctf_cli/cli_runner.py +++ b/ctf_cli/cli_runner.py @@ -35,9 +35,7 @@ def run(): try: # add application-wide debug log LoggerHelper.add_debug_log_file(os.getcwd()) - args = ArgumentsParser(sys.argv[1:]) - if args.verbose is True: LoggerHelper.add_stream_handler(logger, logging.Formatter('%(levelname)s:\t%(message)s'), @@ -54,6 +52,14 @@ def run(): app.run() if 'update' in args.cli_action: app.update() + if 'remote' in args.cli_action: + if 'add' in args.remote_action: + app.add_remote() + if 'remove' in args.remote_action: + app.remove_remote() + if 'list' in args.remote_action: + app.list_remotes() + except KeyboardInterrupt: logger.info('Interrupted by user') except CTFCliError as e: diff --git a/ctf_cli/config.py b/ctf_cli/config.py index 6720a5d..652c67c 100644 --- a/ctf_cli/config.py +++ b/ctf_cli/config.py @@ -38,6 +38,9 @@ class CTFCliConfig(object): CONFIG_IMAGE = 'Image' CONFIG_JUNIT = 'Junit' CONFIG_EXEC_TYPE = 'ExecType' + CONFIG_REMOTE_TYPE = 'remote_type' + CONFIG_REMOTE_URL = 'url' + CONFIG_REMOTE_PROJECT = 'project' ANSIBLE_SECTION_NAME = 'ansible' CONFIG_ANSIBLE_HOST = 'Host' @@ -99,8 +102,10 @@ def _add_commandline_arguments(self, cli_conf): self.CONFIG_IMAGE: cli_conf.image, self.CONFIG_JUNIT: cli_conf.junit, self.CONFIG_EXEC_TYPE: 'ansible', + self.CONFIG_REMOTE_TYPE: cli_conf.remote_type, + self.CONFIG_REMOTE_URL: cli_conf.url, + self.CONFIG_REMOTE_PROJECT: cli_conf.project, }} - self.config_parser_read_dict(self._config, cli_settings) def __getattr__(self, name): @@ -133,4 +138,4 @@ def config_parser_read_dict(config_parser_obj, dictionary): # go through all key: value in the section for option, value in six.iteritems(conf): if config_parser_obj.has_option(section, option) is False: - config_parser_obj.set(section, option, value) \ No newline at end of file + config_parser_obj.set(section, option, value) From 9ac150bd640f179173dd30be9f1a87fcec00b0c8 Mon Sep 17 00:00:00 2001 From: David Becvarik Date: Fri, 19 Jun 2015 10:01:39 +0200 Subject: [PATCH 2/9] added submodule list command --- ctf_cli/application.py | 4 +++- ctf_cli/arguments_parser.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ctf_cli/application.py b/ctf_cli/application.py index b8d08af..c27f027 100644 --- a/ctf_cli/application.py +++ b/ctf_cli/application.py @@ -149,9 +149,11 @@ def add_remote_step(self): path = "tests/steps/" + project self.add_submodule(path) + def list_remotes(self): + check_call("git submodule foreach 'git config --get remote.origin.url'", shell=True) + def add_submodule(self, path): url = self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_URL) - print (url) check_call('git submodule add %s %s' % (url, path), shell=True) def run(self): diff --git a/ctf_cli/arguments_parser.py b/ctf_cli/arguments_parser.py index 6a1a095..48bd035 100644 --- a/ctf_cli/arguments_parser.py +++ b/ctf_cli/arguments_parser.py @@ -70,6 +70,7 @@ def add_remote_subparser(self): remote_oper_subparser=remote_subparser.add_subparsers(dest='remote_action') self.add_remote_add_subparser(remote_oper_subparser.add_parser('add', help='add remote repository')) self.add_remote_remove_subparser(remote_oper_subparser.add_parser('remove', help='remove remote repository')) + remote_oper_subparser.add_parser('list', help='list remote repositories') def add_run_subparser(self): run_subparser=self.subparsers.add_parser('run', help="run test suite - default") From 07ed8d7f9164a2b65f467b45cf86572e00b3943d Mon Sep 17 00:00:00 2001 From: David Becvarik Date: Fri, 19 Jun 2015 10:06:50 +0200 Subject: [PATCH 3/9] fixing unused variables errors --- ctf_cli/arguments_parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ctf_cli/arguments_parser.py b/ctf_cli/arguments_parser.py index 48bd035..60a2781 100644 --- a/ctf_cli/arguments_parser.py +++ b/ctf_cli/arguments_parser.py @@ -111,10 +111,10 @@ def add_run_subparser(self): ) def add_update_subparser(self): - update_subparser=self.subparsers.add_parser('update', help="update suites") + self.subparsers.add_parser('update', help="update suites") def add_init_subparser(self): - init_subparser=self.subparsers.add_parser('init', help="update suites") + self.subparsers.add_parser('init', help="update suites") def add_args(self): self.parser.add_argument( From 1a21a41b825d13e31ab79396e615ad7930d26cc1 Mon Sep 17 00:00:00 2001 From: David Becvarik Date: Fri, 19 Jun 2015 10:10:38 +0200 Subject: [PATCH 4/9] do not checkout common steps and features by default - its not needed when containers are not tested --- ctf_cli/application.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/ctf_cli/application.py b/ctf_cli/application.py index c27f027..077a9d0 100644 --- a/ctf_cli/application.py +++ b/ctf_cli/application.py @@ -100,22 +100,6 @@ def init(self): f.write(common_steps_py_content) check_call("git add %s" % steps_py_file, shell=True) - # Add common-features and common-steps as submodules - # TODO: make this generic when a different type of container is specified - common_features_dir = os.path.join(features_dir, "common-features") - if os.path.exists(common_features_dir): - logger.info("Directory tests/features/common-features already exists") - else: - logger.info("Adding tests/features/common-features as a submodule") - check_call('git submodule add https://github.com/Containers-Testing-Framework/common-features.git tests/features/common-features', shell=True) - - common_steps_dir = os.path.join(steps_dir, "common_steps") - if os.path.exists(common_steps_dir): - logger.info("Directory tests/steps/common_steps already exists") - else: - logger.info("Adding tests/steps/common_steps as a submodule") - check_call('git submodule add https://github.com/Containers-Testing-Framework/common-steps.git tests/steps/common_steps', shell=True) - # Copy sample configuration ctf_conf_file = os.path.join(self._execution_dir_path, "ctf.conf") if os.path.exists(ctf_conf_file): From 34cad1b0c9cfd3a7f1f291b6e5418695182bd312 Mon Sep 17 00:00:00 2001 From: David Becvarik Date: Fri, 19 Jun 2015 10:37:07 +0200 Subject: [PATCH 5/9] implemented remove command for submodules --- ctf_cli/application.py | 7 +++++++ ctf_cli/arguments_parser.py | 13 +------------ ctf_cli/config.py | 2 ++ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/ctf_cli/application.py b/ctf_cli/application.py index 077a9d0..a3c2188 100644 --- a/ctf_cli/application.py +++ b/ctf_cli/application.py @@ -17,6 +17,7 @@ # along with this program. If not, see . import os +import shutil import sys from subprocess import check_call, CalledProcessError @@ -140,6 +141,12 @@ def add_submodule(self, path): url = self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_URL) check_call('git submodule add %s %s' % (url, path), shell=True) + def remove_remote(self): + name = self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_NAME) + check_call('git submodule deinit -f %s' %name, shell=True) + check_call('git config -f .gitmodules --remove-section "submodule.%s"' %name, shell=True) + shutil.rmtree(name) + def run(self): """ The main application execution method diff --git a/ctf_cli/arguments_parser.py b/ctf_cli/arguments_parser.py index 60a2781..edcbe1b 100644 --- a/ctf_cli/arguments_parser.py +++ b/ctf_cli/arguments_parser.py @@ -51,20 +51,9 @@ def add_remote_add_subparser(self, subparser): def add_remote_remove_subparser(self, subparser): subparser.add_argument( - dest='remote_type', - choices=['steps', 'features'], - ) - - subparser.add_argument( - dest='url', - help='module url' + dest='name' ) - subparser.add_argument( - "--project", - dest='project', - help="name of test project") - def add_remote_subparser(self): remote_subparser=self.subparsers.add_parser('remote', help='addidng/removing test suites') remote_oper_subparser=remote_subparser.add_subparsers(dest='remote_action') diff --git a/ctf_cli/config.py b/ctf_cli/config.py index 652c67c..0ad2273 100644 --- a/ctf_cli/config.py +++ b/ctf_cli/config.py @@ -41,6 +41,7 @@ class CTFCliConfig(object): CONFIG_REMOTE_TYPE = 'remote_type' CONFIG_REMOTE_URL = 'url' CONFIG_REMOTE_PROJECT = 'project' + CONFIG_REMOTE_NAME = 'name' ANSIBLE_SECTION_NAME = 'ansible' CONFIG_ANSIBLE_HOST = 'Host' @@ -105,6 +106,7 @@ def _add_commandline_arguments(self, cli_conf): self.CONFIG_REMOTE_TYPE: cli_conf.remote_type, self.CONFIG_REMOTE_URL: cli_conf.url, self.CONFIG_REMOTE_PROJECT: cli_conf.project, + self.CONFIG_REMOTE_NAME: cli_conf.name, }} self.config_parser_read_dict(self._config, cli_settings) From 243aa378acd0fd10f56b47f720ae5cb3c72464fe Mon Sep 17 00:00:00 2001 From: David Becvarik Date: Mon, 22 Jun 2015 08:31:37 +0200 Subject: [PATCH 6/9] changed update command to update or remotes had to remove sanity check(probably is better to move it to some subcommand), because there should not been some features/steps defined in time it is run --- circle.yml | 3 ++- ctf_cli/application.py | 22 ++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/circle.yml b/circle.yml index 6d5f208..41a46a9 100644 --- a/circle.yml +++ b/circle.yml @@ -15,6 +15,7 @@ test: override: - mkdir test_dir - cd test_dir && COVERAGE_FILE=../.coverage.init coverage run ../ctf-cli.py init + - cd test_dir && COVAREGE_FILE=../.coverage.remote_add coverage run ../ctf-cli.py remote add features https://github.com/Containers-Testing-Framework/common-features.git - cd test_dir && COVERAGE_FILE=../.coverage.update coverage run ../ctf-cli.py update - cd test_dir && COVERAGE_FILE=../.coverage.run coverage run ../ctf-cli.py run - COVERAGE_FILE=.coverage.tests nosetests @@ -23,4 +24,4 @@ test: notify: webhooks: - - url: https://webhooks.gitter.im/e/92b168ffacdc38a6facd \ No newline at end of file + - url: https://webhooks.gitter.im/e/92b168ffacdc38a6facd diff --git a/ctf_cli/application.py b/ctf_cli/application.py index a3c2188..b3bc099 100644 --- a/ctf_cli/application.py +++ b/ctf_cli/application.py @@ -101,6 +101,13 @@ def init(self): f.write(common_steps_py_content) check_call("git add %s" % steps_py_file, shell=True) + common_steps_dir = os.path.join(steps_dir, "common_steps") + if os.path.exists(common_steps_dir): + logger.info("Directory tests/steps/common_steps already exists") + else: + logger.info("Adding tests/steps/common_steps as a submodule") + check_call('git submodule add https://github.com/Containers-Testing-Framework/common-steps.git tests/steps/common_steps', shell=True) + # Copy sample configuration ctf_conf_file = os.path.join(self._execution_dir_path, "ctf.conf") if os.path.exists(ctf_conf_file): @@ -183,15 +190,6 @@ def update(self): """ Update app submodules """ - logger.info("Updating Containers Testing Framework common steps and features") - - common_steps_dir = os.path.join(self._execution_dir_path, "tests", "steps", "common_steps") - common_features_dir = os.path.join(self._execution_dir_path, "tests", "features", "common-features") - for directory in [common_steps_dir, common_features_dir]: - logger.info("Updating %s", directory) - check_call("git fetch origin", shell=True, cwd=directory) - check_call("git checkout origin/master", shell=True, cwd=directory) - - # Check that steps are not contradicting with each other - logger.info("Checking project steps sanity") - check_call("behave tests -d", shell=True) + logger.info("Updating remote test and feautres") + + check_call("git submodule foreach git pull --rebase", shell=True) From 48b4a872ccda89f2fac98033eeeaea35360da252 Mon Sep 17 00:00:00 2001 From: David Becvarik Date: Mon, 22 Jun 2015 09:43:49 +0200 Subject: [PATCH 7/9] updating docs --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 54981da..9d86228 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,6 @@ You can implement any of the methods that are typically used with Behave inside 1. Clone repositories ``` git clone https://github.com/Containers-Testing-Framework/ctf-cli.git -git clone https://github.com/Containers-Testing-Framework/common-steps.git -git clone https://github.com/Containers-Testing-Framework/common-features.git ``` 1. Optional: clone an example repository ``` @@ -90,10 +88,14 @@ cd ctf-cli cp ctf.conf.sample ctf.conf cp tests.conf.sample tests.conf ``` -1. Change to project directory and run tests +1. Change to project directory and get common features ``` cd example-project-postgresql -../ctf-cli/ctf-cli.py +../ctf-cli/ctf-cli.py remote add features https://github.com/Containers-Testing-Framework/common-features.git +``` +1. Run tests +``` +../ctf-cli/ctf-cli.py run ``` ## CLI tool From e754e529866b9d04b61f51394b0e981b35b4aa63 Mon Sep 17 00:00:00 2001 From: David Becvarik Date: Mon, 22 Jun 2015 12:57:07 +0200 Subject: [PATCH 8/9] make submodule dir repo name and removed common steps form downloading by default --- circle.yml | 1 + ctf_cli/application.py | 14 ++++---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/circle.yml b/circle.yml index 41a46a9..c19bbcb 100644 --- a/circle.yml +++ b/circle.yml @@ -15,6 +15,7 @@ test: override: - mkdir test_dir - cd test_dir && COVERAGE_FILE=../.coverage.init coverage run ../ctf-cli.py init + - cd test_dir && COVAREGE_FILE=../.coverage.remote_add coverage run ../ctf-cli.py remote add steps https://github.com/Containers-Testing-Framework/common-steps.git - cd test_dir && COVAREGE_FILE=../.coverage.remote_add coverage run ../ctf-cli.py remote add features https://github.com/Containers-Testing-Framework/common-features.git - cd test_dir && COVERAGE_FILE=../.coverage.update coverage run ../ctf-cli.py update - cd test_dir && COVERAGE_FILE=../.coverage.run coverage run ../ctf-cli.py run diff --git a/ctf_cli/application.py b/ctf_cli/application.py index b3bc099..139f9ee 100644 --- a/ctf_cli/application.py +++ b/ctf_cli/application.py @@ -100,13 +100,6 @@ def init(self): with open(steps_py_file, "w") as f: f.write(common_steps_py_content) check_call("git add %s" % steps_py_file, shell=True) - - common_steps_dir = os.path.join(steps_dir, "common_steps") - if os.path.exists(common_steps_dir): - logger.info("Directory tests/steps/common_steps already exists") - else: - logger.info("Adding tests/steps/common_steps as a submodule") - check_call('git submodule add https://github.com/Containers-Testing-Framework/common-steps.git tests/steps/common_steps', shell=True) # Copy sample configuration ctf_conf_file = os.path.join(self._execution_dir_path, "ctf.conf") @@ -128,7 +121,7 @@ def add_remote(self): def add_remote_feature(self): project = self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_PROJECT) if project is None: - path = "tests/features/common-remote" + path = "tests/features/" else: path = "tests/features/" + project self.add_submodule(path) @@ -136,7 +129,7 @@ def add_remote_feature(self): def add_remote_step(self): project = self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_PROJECT) if project is None: - path = "tests/steps/common-remote" + path = "tests/steps/" else: path = "tests/steps/" + project self.add_submodule(path) @@ -146,7 +139,8 @@ def list_remotes(self): def add_submodule(self, path): url = self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_URL) - check_call('git submodule add %s %s' % (url, path), shell=True) + dirname = os.path.splitext(os.path.basename(url))[0] + check_call('git submodule add %s %s' % (url, path + "/" + dirname), shell=True) def remove_remote(self): name = self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_NAME) From c06ea3079c478fdaec511f4bfe3b5b9a2ce746ef Mon Sep 17 00:00:00 2001 From: David Becvarik Date: Mon, 22 Jun 2015 13:17:12 +0200 Subject: [PATCH 9/9] change - to _ in repositories name for python import to work --- ctf_cli/application.py | 2 +- ctf_cli/behave.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ctf_cli/application.py b/ctf_cli/application.py index 139f9ee..e41aae7 100644 --- a/ctf_cli/application.py +++ b/ctf_cli/application.py @@ -139,7 +139,7 @@ def list_remotes(self): def add_submodule(self, path): url = self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME, CTFCliConfig.CONFIG_REMOTE_URL) - dirname = os.path.splitext(os.path.basename(url))[0] + dirname = os.path.splitext(os.path.basename(url))[0].replace('-', '_') check_call('git submodule add %s %s' % (url, path + "/" + dirname), shell=True) def remove_remote(self): diff --git a/ctf_cli/behave.py b/ctf_cli/behave.py index b37e6af..22fc5c3 100644 --- a/ctf_cli/behave.py +++ b/ctf_cli/behave.py @@ -272,7 +272,7 @@ def _write_environment_py(self): """ project_env_py = glob.glob(os.path.join(self._working_dir, '*environment.py')) if project_env_py: - module_name = os.path.basename(project_env_py[0]).replace('.py', '') + module_name = os.path.basename(project_env_py[0]).replace('.py', '').replace('-', '_') import_statement = 'from {0} import *\n'.format(module_name) import_statement += 'import {0}'.format(module_name) else: