# Path: mdk/command.py
# class Command(object):
#     """Represents a command"""
# 
#     _arguments = [
#             (
#                 ['foo'],
#                 {
#                     'help': 'I\'m an argument'
#                 }
#             ),
#             (
#                 ['-b', '--bar'],
#                 {
#                     'action': 'store_true',
#                     'help': 'I\'m a flag'
#                 }
#             )
#         ]
#     _description = 'Undocumented command'
# 
#     __C = None
#     __Wp = None
# 
#     def __init__(self, config):
#         self.__C = config
# 
#     def argumentError(self, message):
#         raise CommandArgumentError(message)
# 
#     @property
#     def arguments(self):
#         return self._arguments
# 
#     @property
#     def C(self):
#         return self.__C
# 
#     @property
#     def description(self):
#         return self._description
# 
#     def run(self, args):
#         return True
# 
#     @property
#     def Wp(self):
#         if not self.__Wp:
#             from .workplace import Workplace
#             self.__Wp = Workplace()
#         return self.__Wp
# 
# Path: mdk/tools.py
# def mkdir(path, perms=0o755):
#     """Creates a directory ignoring the OS umask"""
#     oldumask = os.umask(0000)
#     os.mkdir(path, perms)
#     os.umask(oldumask)


import os
import logging
from .. import db
from ..command import Command
from ..tools import mkdir
                {
                    'action': 'store',
                    'help': 'scripts to run after installation',
                    'metavar': 'run',
                    'nargs': '*'
                }
            ),
            (
                ['name'],
                {
                    'default': None,
                    'help': 'name of the instance',
                    'metavar': 'name',
                    'nargs': '?'
                })
        ]

    def run(self, args):

        name = args.name
        engine = args.engine
        fullname = args.fullname

        M = self.Wp.resolve(name)
        if not M:
            raise Exception('This is not a Moodle instance')

        name = M.get('identifier')
        dataDir = self.Wp.getPath(name, 'data')
        if not os.path.isdir(dataDir):

# Path: mdk/command.py
# class Command(object):
#     """Represents a command"""
# 
#     _arguments = [
#             (
#                 ['foo'],
#                 {
#                     'help': 'I\'m an argument'
#                 }
#             ),
#             (
#                 ['-b', '--bar'],
#                 {
#                     'action': 'store_true',
#                     'help': 'I\'m a flag'
#                 }
#             )
#         ]
#     _description = 'Undocumented command'
# 
#     __C = None
#     __Wp = None
# 
#     def __init__(self, config):
#         self.__C = config
# 
#     def argumentError(self, message):
#         raise CommandArgumentError(message)
# 
#     @property
#     def arguments(self):
#         return self._arguments
# 
#     @property
#     def C(self):
#         return self.__C
# 
#     @property
#     def description(self):
#         return self._description
# 
#     def run(self, args):
#         return True
# 
#     @property
#     def Wp(self):
#         if not self.__Wp:
#             from .workplace import Workplace
#             self.__Wp = Workplace()
#         return self.__Wp
# 
# Path: mdk/tools.py
# def mkdir(path, perms=0o755):
#     """Creates a directory ignoring the OS umask"""
#     oldumask = os.umask(0000)
#     os.mkdir(path, perms)
#     os.umask(oldumask)


# Path: mdk/commands/install.py
import os
import logging
from .. import db
from ..command import Command
from ..tools import mkdir

                {
                    'action': 'store',
                    'help': 'scripts to run after installation',
                    'metavar': 'run',
                    'nargs': '*'
                }
            ),
            (
                ['name'],
                {
                    'default': None,
                    'help': 'name of the instance',
                    'metavar': 'name',
                    'nargs': '?'
                })
        ]

    def run(self, args):

        name = args.name
        engine = args.engine
        fullname = args.fullname

        M = self.Wp.resolve(name)
        if not M:
            raise Exception('This is not a Moodle instance')

        name = M.get('identifier')
        dataDir = self.Wp.getPath(name, 'data')
        if not os.path.isdir(dataDir):

            mkdir(dataDir, 0o777)