Skip to content

Commit

Permalink
Merge pull request #528 from JrGoodle/pathlib
Browse files Browse the repository at this point in the history
Migrate to pathlib
  • Loading branch information
JrGoodle committed May 23, 2020
2 parents 23aec18 + 43f9289 commit f98eb4e
Show file tree
Hide file tree
Showing 56 changed files with 262 additions and 240 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-checkout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-forall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-help.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-herd-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-herd-submodules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-herd-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-herd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-lfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-prune.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-reset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-save.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-stash.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-subdirectory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-yaml-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cats-yaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-config-yaml-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-parallel-forall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-parallel-herd-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-parallel-herd-submodules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-parallel-herd-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-parallel-herd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-parallel-reset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
45 changes: 26 additions & 19 deletions src/clowder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,48 @@
"""

import logging
import os
from pathlib import Path
from typing import Optional


PRINT_DEBUG_OUTPUT = "CLOWDER_DEBUG" in os.environ
CURRENT_DIR = os.getcwd()
CLOWDER_CONFIG_DIR = str(Path.home()/'.config'/'clowder')
CLOWDER_CONFIG_YAML = str(Path(CLOWDER_CONFIG_DIR)/'clowder.config.yaml')
CLOWDER_DIR: Optional[str] = None
CLOWDER_REPO_DIR: Optional[str] = None
CLOWDER_REPO_VERSIONS_DIR: Optional[str] = None
CLOWDER_YAML: Optional[str] = None
# logging.basicConfig()
# logging.raiseExceptions = True
# if PRINT_DEBUG_OUTPUT:
# logging.getLogger("CLOWDER DEBUG").setLevel(logging.DEBUG)
# else:
# logging.getLogger("CLOWDER DEBUG").setLevel(logging.ERROR)
# LOG_DEBUG = logging.getLogger("CLOWDER DEBUG")

CURRENT_DIR = Path.cwd()
CLOWDER_CONFIG_DIR = Path.home() / '.config' / 'clowder'
CLOWDER_CONFIG_YAML = Path(CLOWDER_CONFIG_DIR) / 'clowder.config.yaml'
CLOWDER_DIR: Optional[Path] = None
CLOWDER_REPO_DIR: Optional[Path] = None
CLOWDER_REPO_VERSIONS_DIR: Optional[Path] = None
CLOWDER_YAML: Optional[Path] = None


temp_dir = CURRENT_DIR
old_dir = None
# Walk up directory tree to find possible clowder repo (.clowder directory) and set global variable
while old_dir != temp_dir:
old_dir = temp_dir
clowder_repo_dir = os.path.join(temp_dir, '.clowder')
if os.path.exists(clowder_repo_dir) and os.path.isdir(clowder_repo_dir):
CLOWDER_DIR = temp_dir
path = Path.cwd()
while str(path) != path.root:
clowder_repo_dir = path / '.clowder'
if clowder_repo_dir.is_dir():
CLOWDER_DIR = path
CLOWDER_REPO_DIR = clowder_repo_dir
break
else:
temp_dir = os.path.dirname(temp_dir)
path = path.parent


# If clowder repo exists, try to set other global path variables
if CLOWDER_REPO_DIR is not None:
clowder_yaml = os.path.join(CLOWDER_DIR, 'clowder.yaml')
if os.path.islink(clowder_yaml):
clowder_yaml = CLOWDER_DIR / 'clowder.yaml'
if clowder_yaml.is_symlink():
CLOWDER_YAML = clowder_yaml

clowder_versions = os.path.join(CLOWDER_REPO_DIR, 'versions')
if os.path.isdir(clowder_versions):
clowder_versions = CLOWDER_REPO_DIR / 'versions'
if clowder_versions.is_dir():
CLOWDER_REPO_VERSIONS_DIR = clowder_versions
5 changes: 2 additions & 3 deletions src/clowder/cli/forall.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ def _forall_impl(command: List[str], ignore_errors: bool, projects: List[str], p
parallel_config = config.current_clowder_config.parallel
parallel = parallel_config if parallel_config is not None else parallel

if parallel:
if parallel and os.name == "posix":
forall_parallel([" ".join(command)], projects, ignore_errors)
if os.name == "posix":
return
return

for project in projects:
print(project.status())
Expand Down
5 changes: 2 additions & 3 deletions src/clowder/cli/herd.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ def herd(args) -> None:
projects = config.process_projects_arg(args.projects)
projects = filter_projects(CLOWDER_CONTROLLER.projects, projects)

if parallel:
if parallel and os.name == "posix":
herd_parallel(projects, branch=branch, tag=tag, depth=depth, rebase=rebase)
if os.name == "posix":
return
return

validate_project_statuses(projects)
for project in projects:
Expand Down
3 changes: 1 addition & 2 deletions src/clowder/cli/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""

import argparse
import os

from termcolor import colored, cprint

Expand Down Expand Up @@ -37,7 +36,7 @@ def init(args) -> None:
:raise ClowderExit:
"""

clowder_repo_dir = os.path.join(CURRENT_DIR, '.clowder')
clowder_repo_dir = CURRENT_DIR / '.clowder'
if existing_git_repository(clowder_repo_dir):
cprint('Clowder already initialized in this directory\n', 'red')
raise ClowderExit(1)
Expand Down
5 changes: 2 additions & 3 deletions src/clowder/cli/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ def _reset_impl(project_names: List[str], timestamp_project: Optional[str] = Non
projects = config.process_projects_arg(project_names)
projects = filter_projects(CLOWDER_CONTROLLER.projects, projects)

if parallel:
if parallel and os.name == "posix":
reset_parallel(projects, timestamp_project=timestamp_project)
if os.name == "posix":
return
return

timestamp = None
if timestamp_project:
Expand Down

0 comments on commit f98eb4e

Please sign in to comment.