# Path: app/__metadata__.py
# APP_NAME = 'LXDUI'
# APP_CLI_CMD = 'lxdui'
# VERSION = '2.2'
# GIT_URL = 'https://github.com/AdaptiveScale/lxdui.git'
# LXD_URL = 'http://localhost:8443'
# LICENSE = 'Apache 2.0'
# AUTHOR = 'AdaptiveScale, Inc.'
# AUTHOR_URL = 'http://www.adaptivescale.com'
# AUTHOR_EMAIL = 'info@adaptivescale.com'
# KEYWORDS = 'lxc lxc-containers lxd'
# IMAGE_HUB = 'http://hub.kuti.io'
# AUTO_LOAD_CONFIG = True
# DEFAULT_CONFIG_FORMAT = 'ini'


import os
from pathlib import Path, PurePath
from app import __metadata__ as meta
SNAP_COMMON - Directory for system data that is common across revisions of a snap
SNAP_USER_DATA - Directory for user data, backed up and restored across snap refresh and snap revert operations.


#check is HOME directory is writable - this path will be different in a snap
#check if there is an existing config in ~/.config/lxdui
#if it exists than use that
#on init prompt user to overwrite the ~/.config/lxdui directory

store logs in SNAP_COMMON
store conf in SNAP_USER_DATA
'''

def writable(path):
    return os.access(path, os.W_OK)

def genConf(path):
    if Path(path).exists():
        files = Path.glob('*.conf')
        if ['auth.conf', 'log.conf', APP + '.conf'] in files:
            return False
    else:
        return True

home = str(Path.home())
snap_conf = os.getenv('SNAP_USER_DATA')

if snap_conf:
    if writable(snap_conf):
        #create directory for config data

# Path: app/__metadata__.py
# APP_NAME = 'LXDUI'
# APP_CLI_CMD = 'lxdui'
# VERSION = '2.2'
# GIT_URL = 'https://github.com/AdaptiveScale/lxdui.git'
# LXD_URL = 'http://localhost:8443'
# LICENSE = 'Apache 2.0'
# AUTHOR = 'AdaptiveScale, Inc.'
# AUTHOR_URL = 'http://www.adaptivescale.com'
# AUTHOR_EMAIL = 'info@adaptivescale.com'
# KEYWORDS = 'lxc lxc-containers lxd'
# IMAGE_HUB = 'http://hub.kuti.io'
# AUTO_LOAD_CONFIG = True
# DEFAULT_CONFIG_FORMAT = 'ini'


# Path: app/api/utils/snap.py
import os
from pathlib import Path, PurePath
from app import __metadata__ as meta

SNAP_COMMON - Directory for system data that is common across revisions of a snap
SNAP_USER_DATA - Directory for user data, backed up and restored across snap refresh and snap revert operations.


#check is HOME directory is writable - this path will be different in a snap
#check if there is an existing config in ~/.config/lxdui
#if it exists than use that
#on init prompt user to overwrite the ~/.config/lxdui directory

store logs in SNAP_COMMON
store conf in SNAP_USER_DATA
'''

def writable(path):
    return os.access(path, os.W_OK)

def genConf(path):
    if Path(path).exists():
        files = Path.glob('*.conf')
        if ['auth.conf', 'log.conf', APP + '.conf'] in files:
            return False
    else:
        return True

home = str(Path.home())
snap_conf = os.getenv('SNAP_USER_DATA')

if snap_conf:
    if writable(snap_conf):
        #create directory for config data

        Path.mkdir(meta.APP_NAME.lower())