(self)
| 1615 | return Commands(**fields) |
| 1616 | |
| 1617 | def run(self): # pylint: disable=inconsistent-return-statements # TODO |
| 1618 | root = self.get_root_folder() |
| 1619 | |
| 1620 | if self.commands_text: |
| 1621 | print(self.get_commands_text()) |
| 1622 | if self.env: |
| 1623 | for key in self.env: |
| 1624 | val = self.jinjaify(self.env[key]) |
| 1625 | os.environ[key] = val |
| 1626 | if is_windows(): |
| 1627 | print("\n SET %s=%s" % (key, val)) |
| 1628 | else: |
| 1629 | print("\n export %s=%s" % (key, val)) |
| 1630 | print(abbreviate_homedir("\n cd %s" % root)) |
| 1631 | commands = ensure_list(self.commands) |
| 1632 | for cmd in commands: |
| 1633 | for line in cmd.display_cmd(): |
| 1634 | print(" %s" % line) |
| 1635 | print() |
| 1636 | confirm_each = (not self.confirm_each_command is False) and len(commands) > 1 |
| 1637 | if not self.enable_execute is False: |
| 1638 | if self.run_text: |
| 1639 | print("\n%s\n" % self.get_run_text()) |
| 1640 | if confirm_each: |
| 1641 | print("You will get prompted before running each individual command.") |
| 1642 | else: |
| 1643 | print( |
| 1644 | "You will not be prompted for each command but will see the output of each. If one command fails the execution will stop.") |
| 1645 | success = True |
| 1646 | if ask_yes_no("Do you want me to run these commands now?"): |
| 1647 | if self.remove_files: |
| 1648 | for _f in ensure_list(self.get_remove_files()): |
| 1649 | f = os.path.join(root, _f) |
| 1650 | if os.path.exists(f): |
| 1651 | filefolder = "File" if os.path.isfile(f) else "Folder" |
| 1652 | if ask_yes_no("%s %s already exists. Shall I remove it now?" % (filefolder, f)) and not dry_run: |
| 1653 | if os.path.isdir(f): |
| 1654 | shutil.rmtree(f) |
| 1655 | else: |
| 1656 | os.remove(f) |
| 1657 | index = 0 |
| 1658 | log_folder = self.logs_prefix if len(commands) > 1 else None |
| 1659 | for cmd in commands: |
| 1660 | index += 1 |
| 1661 | if len(commands) > 1: |
| 1662 | log_prefix = "%02d_" % index |
| 1663 | else: |
| 1664 | log_prefix = self.logs_prefix if self.logs_prefix else '' |
| 1665 | if not log_prefix[-1:] == '_': |
| 1666 | log_prefix += "_" |
| 1667 | cwd = root |
| 1668 | if cmd.cwd: |
| 1669 | cwd = os.path.join(root, cmd.cwd) |
| 1670 | folder_prefix = '' |
| 1671 | if cmd.cwd: |
| 1672 | folder_prefix = cmd.cwd + "_" |
| 1673 | if confirm_each and cmd.comment: |
| 1674 | print("# %s\n" % cmd.get_comment()) |
nothing calls this directly
no test coverage detected