# Path: simple_monitor_alert/utils/files.py
# def makedirs(path, mode=0o777, exist_ok=False):
#     if not exist_ok or (exist_ok and not os.path.exists(path)):
#         os.makedirs(path, mode)


import distutils
import filecmp
import getpass
import shutil
import subprocess
import pwd
import grp
import pip
import os
import sys
import uuid
from distutils.version import LooseVersion
from setuptools import setup, find_packages, Command
from distutils.util import convert_path
from fnmatch import fnmatchcase
from simple_monitor_alert.utils.files import makedirs
    from pip.req import parse_requirements
from setuptools.command.install import install
])


def create_backup(file):
    if not os.path.lexists(file):
        return
    backup_file = file + '.bak'
    i = 0
    while os.path.lexists(backup_file):
        new_backup_file = '{}{}'.format(backup_file, i)
        if not os.path.lexists(new_backup_file):
            backup_file = new_backup_file
            break
        i += 1
    shutil.move(file, backup_file)


class SystemInstallCommand(install):
    """Custom install setup to help run shell commands (outside shell) before installation"""

    def run(self):
        print('Starting Python module installation.')
        self.do_egg_install()
        print('-' * 80)
        if getpass.getuser() != 'root':
            print('WARNING: Simple-Monitor-Alert installed as "{}". Install as root to create the system files!')
            return
        print('Installing things that are not Python (system files).')
        for directory in [ENABLED_MONITORS_DIR, os.path.dirname(AVAILABLE_MONITORS_DIR)]:
            print('Creating directory {}'.format(directory))

# Path: simple_monitor_alert/utils/files.py
# def makedirs(path, mode=0o777, exist_ok=False):
#     if not exist_ok or (exist_ok and not os.path.exists(path)):
#         os.makedirs(path, mode)


# Path: setup.py
import distutils
import filecmp
import getpass
import shutil
import subprocess
import pwd
import grp
import pip
import os
import sys
import uuid
from distutils.version import LooseVersion
from setuptools import setup, find_packages, Command
from distutils.util import convert_path
from fnmatch import fnmatchcase
from simple_monitor_alert.utils.files import makedirs
    from pip.req import parse_requirements
from setuptools.command.install import install

])


def create_backup(file):
    if not os.path.lexists(file):
        return
    backup_file = file + '.bak'
    i = 0
    while os.path.lexists(backup_file):
        new_backup_file = '{}{}'.format(backup_file, i)
        if not os.path.lexists(new_backup_file):
            backup_file = new_backup_file
            break
        i += 1
    shutil.move(file, backup_file)


class SystemInstallCommand(install):
    """Custom install setup to help run shell commands (outside shell) before installation"""

    def run(self):
        print('Starting Python module installation.')
        self.do_egg_install()
        print('-' * 80)
        if getpass.getuser() != 'root':
            print('WARNING: Simple-Monitor-Alert installed as "{}". Install as root to create the system files!')
            return
        print('Installing things that are not Python (system files).')
        for directory in [ENABLED_MONITORS_DIR, os.path.dirname(AVAILABLE_MONITORS_DIR)]:
            print('Creating directory {}'.format(directory))

            makedirs(directory, exist_ok=True)