Exemplo n.º 1
0
  def run(self):
    common.print_verbose("Running " + self.name + " action")

    with open(self.actions_file_location) as f:
      actions_file_contents = f.read()
      for stage in yaml.load(actions_file_contents, Loader=yaml.SafeLoader).items():
        for an_action in stage[1]:
          common.stop_if_failed(*self.action_for(an_action).run())
    f.closed
    return 0, ""
Exemplo n.º 2
0
    def run(self):
        super().run()

        with open(self.actions_file_location) as f:
            actions_file_contents = f.read()
            for stage in yaml.load(actions_file_contents,
                                   Loader=yaml.SafeLoader).items():
                if stage[0] == 'default':
                    for an_action in stage[1]:
                        common.stop_if_failed(
                            *self.action_for(an_action).run())
        f.closed
        return 0, ""
Exemplo n.º 3
0
    def test_stop_if_failed(self):
        orig_exit = sys.exit
        sys.exit = MagicMock()
        # continue when there are no failures
        common.stop_if_failed()  # assume success
        common.stop_if_failed(common.SUCCESS)
        common.stop_if_failed(common.SUCCESS, "abcd")

        # exit if failed
        common.stop_if_failed(common.FAILED, "error string")
        sys.exit.assert_called_with(common.FAILED)
        sys.exit = orig_exit
Exemplo n.º 4
0
def run(log_level="info",
        meta_model_name="power_daps/python3",
        actions_to_run=["default"]):
    common.set_log_level(log_level)
    meta_model = MetaModel(meta_model_name)
    common.set_meta_model(meta_model_name)

    valid_actions = meta_model.actions()
    valid_actions += actions.local_actions()
    valid_action_names = [common.action_name(va) for va in valid_actions]

    common.print_verbose('Actions to run ' + str(actions_to_run))
    common.print_verbose('Valid actions ' + str(valid_action_names))

    for action_to_run in actions_to_run:
        if action_to_run not in valid_action_names:
            common.print_error("Action '" + action_to_run + "' not found.")
            continue
        for valid_action in valid_actions:
            valid_action_name = common.action_name(valid_action)
            if valid_action_name == action_to_run:
                common.stop_if_failed(*valid_action.run())
Exemplo n.º 5
0
    def install(self, dep_name, dep_version="latest", details={}):
        package_name = dep_name
        if not dep_version == "latest":
            package_name = dep_name + "==" + str(dep_version)

        status = self.is_already_installed(dep_name, dep_version)
        if status == PipInstaller.NOT_INSTALLED:
            common.print_verbose(dep_name + " not installed. Installing.")
            command_to_run = [which('pip3'), '-q', 'install', package_name]
            exit_code, output = common.run_command(command_to_run)
            common.stop_if_failed(exit_code, output)

        elif status == PipInstaller.OLDER_VERSION_INSTALLED:
            common.print_verbose(dep_name +
                                 " is already installed. Upgrading to " +
                                 dep_version + " version.")

            command_to_run = [
                which('pip3'), '-q', 'install', '--upgrade', package_name
            ]
            exit_code, output = common.run_command(command_to_run)
            common.stop_if_failed(exit_code, output)

        elif status == PipInstaller.NEWER_VERSION_INSTALLED:
            common.print_verbose("Newer version of " + dep_name +
                                 " installed. Uninstalling and installing " +
                                 dep_version + " version.")

            command_to_run = [which('pip3'), '-q', 'uninstall', package_name]
            exit_code, output = common.run_command(command_to_run)
            common.stop_if_failed(exit_code, output)

            command_to_run = [which('pip3'), '-q', 'install', package_name]
            exit_code, output = common.run_command(command_to_run)
            common.stop_if_failed(exit_code, output)
        else:
            common.print_verbose(dep_name + ", " + dep_version +
                                 " is already installed. Doing nothing.")
Exemplo n.º 6
0
 def run(self):
     common.print_verbose("Running " + self.name + " action")
     common.stop_if_failed(*common.run_command(["/bin/rm", "-rf", "dist"]))
     return common.run_command(["npx", "webpack-cli"])
Exemplo n.º 7
0
 def install(self, dep_name, dep_version, details):
     exit_code, output = common.run_command(self.command_base + [dep_name])
     common.stop_if_failed(exit_code, output)
Exemplo n.º 8
0
  def delete_dir_named(self, dir_name):
    common.print_verbose("Found " + str(len(self.dirs_named(dir_name))) + " dirs named " + dir_name)

    for d in self.dirs_named(dir_name):
      common.print_verbose("Deleting dir " + d)
      common.stop_if_failed(*common.run_command(["/bin/rm", "-rf", d]))