Skip to content
Snippets Groups Projects
Commit 3eb210c2 authored by lukas leufen's avatar lukas leufen
Browse files

another fix

parent be63ba2c
Branches
Tags
3 merge requests!17update to v0.4.0,!15new feat split subsets,!13fix bug make tests running
Pipeline #26132 passed
......@@ -135,7 +135,10 @@ class TimeTracking(object):
def prepare_host(create_new=True):
hostname = socket.gethostname()
user = os.getlogin()
try:
user = os.getlogin()
except OSError:
user = "default"
if hostname == 'ZAM144':
path = f'/home/{user}/Data/toar_daily/'
elif hostname == 'zam347':
......@@ -150,10 +153,13 @@ def prepare_host(create_new=True):
logging.error(f"unknown host '{hostname}'")
raise OSError(f"unknown host '{hostname}'")
if not os.path.exists(path):
if create_new:
check_path_and_create(path)
return path
else:
try:
if create_new:
check_path_and_create(path)
return path
else:
raise PermissionError
except PermissionError:
logging.error(f"path '{path}' does not exist for host '{hostname}'.")
raise NotADirectoryError(f"path '{path}' does not exist for host '{hostname}'.")
else:
......
......@@ -171,7 +171,7 @@ class TestPrepareHost:
mock_host.return_value = "linux-gzsx"
with pytest.raises(NotADirectoryError) as e:
prepare_host()
assert "path '/home/zombie21/machinelearningtools' does not exist for host 'linux-gzsx'" in e.value.args[0]
assert "does not exist for host 'linux-gzsx'" in e.value.args[0]
class TestSetExperimentName:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment