Skip to content
Snippets Groups Projects
Select Git revision
  • 60e2fe1f8d2c85c38ac3e7f795fe079eecc25aea
  • master default protected
  • packages-all-prefer-require
  • jl
  • clang
  • target-x86_64_v3
  • v25.07-stable protected
  • acts-37.4.0
  • py-tensorflow-cuda
  • eic-dev-cuda
  • v25.06-stable protected
  • test-docker-layer-caching
  • autoload-epic-main-bin-thisepic
  • py-numba
  • eic-dbg-prod
  • py-jsonschema-4.17
  • gcc-14.2.0
  • wdconinc-master-patch-96292
  • root-patch-cling-write-lock
  • highfive-mpi
  • push-builder
  • v25.07.0-stable
  • v25.06.1-stable
  • v25.06.0-stable
  • v25.05.0-stable
  • v25.04.1-stable
  • v25.04.0-stable
  • v25.03.1-stable
  • v25.03.0-stable
  • v25.02.0-stable
  • v25.01.1-stable
  • v25.01.0-stable
  • v24.12.0-stable
  • 24.11.2
  • 24.11.2-stable
  • v24.11.2-stable
  • v24.11.1-stable
  • v24.11.0-stable
  • v24.10.1-stable
  • v24.10.0-stable
  • v24.09.0-stable
41 results

util.py

Blame
  • util.py 1.07 KiB
    #!/usr/bin/env python3
    
    ## eic_container: Argonne Universal EIC Container
    
    '''
    Utility functions for this container
    
    Authors:
        - Whitney Armstrong <warmstrong@anl.gov>
        - Sylvester Joosten <sjoosten@anl.gov>
    '''
    
    import os
    
    class InvalidArgumentError(Exception):
        pass
    
    def smart_mkdir(dir):
        '''functions as mkdir -p, with a write-check.
        
        Raises an exception if the directory is not writeable.
        '''
        if not os.path.exists(dir):
            try:
                os.makedirs(dir)
            except Exception as e:
                print('ERROR: unable to create directory', dir)
                raise e
        if not os.access(dir, os.W_OK):
            print('ERROR: We do not have the write privileges to', dir)
            raise InvalidArgumentError()
    
    def project_version():
        '''Return the project version based on the current git branch/tag.'''
        ## Shell command to get the current git version
        git_version_cmd = 'git symbolic-ref -q --short HEAD || git describe --tags --exact-match'
        ## Strip will remove the leading \n character
        return os.popen(git_version_cmd).read().strip()