Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"""Python Module __init__ file."""
from __future__ import print_function

import os
import subprocess
import sys
import threading
from distutils.spawn import find_executable

try:
    from configparser import ConfigParser
except:
    from ConfigParser import ConfigParser


try:
    file_name = '/etc/workloadmgr/vault.conf'
    # Get the path
    source = os.path.abspath(file_name)
    # read the conf file
    config = ConfigParser()
    config.read(source)
    # build a flag containing configuration file info
    # and export it as an environment variable
    flag = '--config-file=' + source
    os.environ['FLAG'] = flag
except Exception as e:
    print("You should create vault.conf file", file=sys.stderr)
    print("Exception: %s" % str(e), file=sys.stderr)
    sys.exit(1)

"""
Build mount points
"""


def mount():
    """Mount s3 fuse mount."""
    from . import s3vaultfuse
    th = threading.Thread(target=s3vaultfuse.run)
    print('Mounting...')
    th.start()
    print('Mounted....')
    th.join()

"""
when the mount function stops running, it actually performs umount.
This is just to clean the remaining folders and files
"""


def umount():
    """umount fuse mount."""
    mp = config['DEFAULT']['vault_data_directory']
    cahce = config['DEFAULT']['vault_data_directory_old']
    sudo_exe = find_executable('sudo')

    subprocess.call([sudo_exe, 'rm', '-rf', mp])
    subprocess.call([sudo_exe, 'rm', '-rf', cahce])


"""
FIX REQUIRD.
    There is a bug that build one additional mount points.
    For now, this function will remove the files and folders
    from this mountpoint.
"""


def clean():
    """Cleanup directory."""
    subprocess.call('find . -empty -type d -delete'.split())