Skip to content

Commit

Permalink
Merge pull request #1254 from esm-tools/fix/esm_master_destination_ca…
Browse files Browse the repository at this point in the history
…n_be_nested2

use pushd and popd, instead of cd <dir> and cd -
  • Loading branch information
mandresm authored Dec 12, 2024
2 parents f01c000 + a4381d5 commit c513be5
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 25 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 6.43.4
current_version = 6.43.5
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@
test_suite="tests",
tests_require=test_requirements,
url="https://github.com/esm-tools/esm_tools",
version="6.43.4",
version="6.43.5",
zip_safe=False,
)
2 changes: 1 addition & 1 deletion src/esm_archiving/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

__author__ = """Paul Gierz"""
__email__ = "[email protected]"
__version__ = "6.43.4"
__version__ = "6.43.5"

from .esm_archiving import (archive_mistral, check_tar_lists,
delete_original_data, determine_datestamp_location,
Expand Down
2 changes: 1 addition & 1 deletion src/esm_calendar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

__author__ = """Dirk Barbi"""
__email__ = "[email protected]"
__version__ = "6.43.4"
__version__ = "6.43.5"

from .esm_calendar import *
2 changes: 1 addition & 1 deletion src/esm_cleanup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = """Dirk Barbi"""
__email__ = "[email protected]"
__version__ = "6.43.4"
__version__ = "6.43.5"
2 changes: 1 addition & 1 deletion src/esm_database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = """Dirk Barbi"""
__email__ = "[email protected]"
__version__ = "6.43.4"
__version__ = "6.43.5"
2 changes: 1 addition & 1 deletion src/esm_environment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

__author__ = """Dirk Barbi"""
__email__ = "[email protected]"
__version__ = "6.43.4"
__version__ = "6.43.5"

from .esm_environment import *
2 changes: 1 addition & 1 deletion src/esm_master/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = """Dirk Barbi"""
__email__ = "[email protected]"
__version__ = "6.43.4"
__version__ = "6.43.5"


from . import database
4 changes: 2 additions & 2 deletions src/esm_master/software_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ def get_command_list(self, setup_info, vcs, general):
if isinstance(commands, str):
commands = [commands]
if not todo == "get":
commands.insert(0, "cd " + self.destination)
commands.append(f"cd -")
commands.insert(0, "pushd " + self.destination)
commands.append("popd")
if todo == "get":
if self.coupling_changes:
commands = []
Expand Down
12 changes: 12 additions & 0 deletions src/esm_master/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ def generate_task_script(self):
def execute(self, ignore_errors=False):
# Calculate the number of get commands for this esm_master operation
self.num_of_get_commands()
# Initialize the dirstack for imitating pushd popd
dirstack = []
# Loop through the commands
for command in self.command_list:
repo = self.get_repo_properties_from_command(command)
Expand Down Expand Up @@ -481,6 +483,16 @@ def execute(self, ignore_errors=False):
command_spl = shlex.split(command)
if "cd" == command_spl[0]:
os.chdir(command_spl[1])
elif "pushd" == command_spl[0]:
# Emulates pushd (MA): yes it is horrible, but I don't
# have time to rewrite esm_master right now
dirstack.append(os.getcwd())
os.chdir(command_spl[1])
elif "popd" == command_spl[0]:
# Emulates popd (MA): yes it is horrible, but I don't
# have time to rewrite esm_master right now
target_dir = target_dir = dirstack.pop(-1)
os.chdir(target_dir)
else:
subprocess.run(
command_spl,
Expand Down
2 changes: 1 addition & 1 deletion src/esm_motd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

__author__ = """Dirk Barbi"""
__email__ = "[email protected]"
__version__ = "6.43.4"
__version__ = "6.43.5"

from .esm_motd import *
2 changes: 1 addition & 1 deletion src/esm_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = """Dirk Barbi"""
__email__ = "[email protected]"
__version__ = "6.43.4"
__version__ = "6.43.5"


from .dict_to_yaml import *
Expand Down
2 changes: 1 addition & 1 deletion src/esm_plugin_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

__author__ = """Dirk Barbi, Paul Gierz, Sebastian Wahl"""
__email__ = "[email protected]"
__version__ = "6.43.4"
__version__ = "6.43.5"

from .esm_plugin_manager import *
2 changes: 1 addition & 1 deletion src/esm_profile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

__author__ = """Dirk Barbi"""
__email__ = "[email protected]"
__version__ = "6.43.4"
__version__ = "6.43.5"

from .esm_profile import *
2 changes: 1 addition & 1 deletion src/esm_runscripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = """Dirk Barbi"""
__email__ = "[email protected]"
__version__ = "6.43.4"
__version__ = "6.43.5"

from .batch_system import *
from .chunky_parts import *
Expand Down
2 changes: 1 addition & 1 deletion src/esm_tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = """Miguel Andres-Martinez"""
__email__ = "[email protected]"
__version__ = "6.43.4"
__version__ = "6.43.5"

from .initialization import *
from .read_shipped_data import *
Expand Down
18 changes: 11 additions & 7 deletions src/esm_tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ def comp_test(info):
user_info = info["user"]
this_computer = info["this_computer"]

# Set the regex format for check compilations
# Set the regex formats for check compilations
cd_format = re.compile(" cd (.*)")
pushd_format = re.compile(" pushd (.*)")

# Set the counter to 0
c = 0
Expand Down Expand Up @@ -212,14 +213,17 @@ def comp_test(info):
folders = []
# Search for the folders to be created
for line in out.split("\n"):
found_format = ""
if "cd" in line and "cd .." not in line:
found_format = cd_format.findall(line)
if len(found_format) > 0:
if (
";" not in found_format[0]
and "/" not in found_format[0]
):
folders.append(found_format[0])
elif "pushd" in line and "popd" not in line:
found_format = pushd_format.findall(line)
if len(found_format) > 0:
if (
";" not in found_format[0]
and "/" not in found_format[0]
):
folders.append(found_format[0])
if len(folders) == 0:
logger.warning(
f'NOT TESTING {model}{version}: "cd" command not found'
Expand Down
2 changes: 1 addition & 1 deletion src/esm_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

__author__ = """Dirk Barbi, Paul Gierz"""
__email__ = "[email protected]"
__version__ = "6.43.4"
__version__ = "6.43.5"

import functools
import inspect
Expand Down
2 changes: 1 addition & 1 deletion src/esm_utilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

__author__ = """Paul Gierz"""
__email__ = "[email protected]"
__version__ = "6.43.4"
__version__ = "6.43.5"

from .utils import *

0 comments on commit c513be5

Please sign in to comment.