Beispiel #1
0
 def test_remove(self):
     conf = Conf('primtux')
     lines = startup.split('\n')
     lines = [line + '\n' for line in lines]
     r = conf.load(lines[:-1])
     has_removed = conf.remove(conf.get_soft('/usr/local/bin/primtux/handymenu-maxi'))
     assert has_removed == True
     assert str(conf) == startup_delete
Beispiel #2
0
 def test_disable(self):
     conf = Conf('primtux')
     lines = startup.split('\n')
     lines = [line + '\n' for line in lines]
     r = conf.load(lines[:-1])
     soft = conf.get_soft('rox -p 1')
     conf.disable(soft)
     soft = conf.get_soft('lxpanel')
     conf.disable(soft)
     assert str(conf) == after_disable
Beispiel #3
0
 def test_enable(self):
     conf = Conf('primtux')
     lines = startup.split('\n')
     lines = [line + '\n' for line in lines]
     r = conf.load(lines[:-1])
     soft = conf.get_soft('/usr/local/bin/primtux/handymenu-mini')
     conf.enable(soft)
     assert str(conf) == after_enable
Beispiel #4
0
 def test_add(self):
     conf = Conf('primtux')
     lines = startup.split('\n')
     lines = [line + '\n' for line in lines]
     conf.load(lines[:-1])
     soft = Soft('firefox', 'firefox', '', '')
     conf.add(soft)
     assert str(conf) == startup_add
Beispiel #5
0
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import sys
import argparse
import re
from lib import workplace, moodle, tools
from lib.tools import debug
from lib.config import Conf

Wp = workplace.Workplace()
C = Conf()

# Arguments
parser = argparse.ArgumentParser(description="Rebases branches")
parser.add_argument('-i', '--issues', metavar='issues', required=True, nargs='+', help='issues to be rebased')
parser.add_argument('-s', '--suffix', metavar='suffix', help='the suffix of the branch of those issues')
parser.add_argument('-v', '--versions', metavar='version', nargs='+', choices=[ str(x) for x in range(13, int(C.get('masterBranch'))) ] + ['master'], help='versions to rebase the issues on. Ignored if names is set.')
parser.add_argument('-p', '--push', action='store_true', help='push the branch after successful rebase')
parser.add_argument('-r', '--remote', metavar='remote', help='the remote to push the branch to. Default is %s.' % C.get('myRemote'))
parser.add_argument('-f', '--force-push', action='store_true', help='Force the push', dest='forcepush')
parser.add_argument('names', metavar='names', default=None, nargs='*', help='name of the instances to rebase')
args = parser.parse_args()

names = args.names
issues = args.issues
versions = args.versions
Beispiel #6
0
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import sys
import argparse
from lib import workplace, tools, jira
from lib.tools import debug
from lib.config import Conf

Wp = workplace.Workplace()
C = Conf()

# Arguments
parser = argparse.ArgumentParser(description="Backports a branch")
parser.add_argument('-b', '--branch', metavar='branch', help='the branch to backport if not the current one. If omitted, guessed from instance name.')
parser.add_argument('-r', '--remote', metavar='remote', help='the remote to fetch from. Default is %s.' % C.get('myRemote'))
parser.add_argument('-i', '--integration', action='store_true', help='backport to integration instances.', dest='integration')
parser.add_argument('-d', '--dont-push', action='store_true', help='if name is specified, the branch is pushed to the remote (-p) before backporting. This disables this behaviour.', dest='dontpush')
parser.add_argument('-e', '--dont-fetch', action='store_true', help='By default the upstream branch is fetched. This disables this behaviour.', dest='dontfetch')
parser.add_argument('-p', '--push', action='store_true', help='push the branch after successful backport')
parser.add_argument('-t', '--push-to', metavar='remote', help='the remote to push the branch to. Default is %s.' % C.get('myRemote'), dest='pushremote')
parser.add_argument('-f', '--force-push', action='store_true', help='Force the push', dest='forcepush')
parser.add_argument('-j', '--update-jira', action='store_true', help='also add the github links to the jira issue.', dest='updatejira')
parser.add_argument('name', metavar='name', default=None, nargs='?', help='name of the instance to backport from. Can be omitted if branch is specified.')
parser.add_argument('-v', '--versions', metavar='version', required=True, nargs='+', choices=[str(x) for x in range(13, int(C.get('masterBranch')))] + ['master'], help='versions to backport to')
args = parser.parse_args()
Beispiel #7
0
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import sys
import argparse
from lib import workplace, tools, jira
from lib.tools import debug
from lib.config import Conf

Wp = workplace.Workplace()
C = Conf()

# Arguments
parser = argparse.ArgumentParser(description="Push a branch to a remote.")
parser.add_argument('-b',
                    '--branch',
                    metavar='branch',
                    help='the branch to push. Default is current branch.')
parser.add_argument('-r',
                    '--remote',
                    metavar='remote',
                    help='remote to push to. Default is your remote.')
parser.add_argument(
    '-f',
    '--force',
    action='store_true',
Beispiel #8
0
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""
import sys
import argparse
import os
import urllib
import re
from time import sleep
from lib import workplace
from lib.tools import debug, process, ProcessInThread
from lib.config import Conf

C = Conf()

# Arguments
parser = argparse.ArgumentParser(description="Initialise Behat")
parser.add_argument("-r", "--run", action="store_true", help="run the tests")
parser.add_argument(
    "-j", "--no-javascript", action="store_true", help="skip the tests involving Javascript", dest="nojavascript"
)
parser.add_argument(
    "-s",
    "--switch-completely",
    action="store_true",
    help="force the switch completely setting. This will be automatically enabled for PHP < 5.4",
    dest="switchcompletely",
)
parser.add_argument(
Beispiel #9
0
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import sys
import argparse
from lib.tools import debug
from lib.config import Conf

C = Conf()

# Arguments
parser = argparse.ArgumentParser(description='Manage your configuration')
parser.add_argument('command',
                    metavar='command',
                    choices=['flatlist', 'list', 'show', 'set'],
                    help='the action to perform')
parser.add_argument('arguments',
                    metavar='arguments',
                    default=None,
                    nargs='*',
                    help='arguments for the command')
args = parser.parse_args()

if args.command == 'list':
Beispiel #10
0
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import os
import sys
import argparse

from lib import tools, workplace
from lib.tools import debug
from lib.config import Conf

C = Conf()

# Arguments
parser = argparse.ArgumentParser(description='Completely remove an instance')
parser.add_argument('name', help='name of the instance')
parser.add_argument('-y',
                    action='store_true',
                    help='do not ask for confirmation',
                    dest='do')
args = parser.parse_args()

Wp = workplace.Workplace()
try:
    M = Wp.get(args.name)
except:
    debug('This is not a Moodle instance')
Beispiel #11
0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import sys
import argparse
from lib.tools import debug
from lib.config import Conf

try:
    C = Conf()
except:
    # Quietly die here. The main reason would be that the config file could not
    # be loaded for some reason, which means that the environment has not been
    # set yet. Therefore we exit quietly. This is a very specific case for
    # moodle-alias as it is used in the Moodle bash script which does not know
    # if the environment is properly set or not.
    sys.exit()

# Arguments
parser = argparse.ArgumentParser(description='Manage your aliases')
parser.add_argument('command',
                    metavar='command',
                    choices=['list', 'show', 'add', 'remove'],
                    help='the action to perform')
parser.add_argument('arguments',
Beispiel #12
0
http://github.com/FMCorz/mdk
"""

import sys
import os
import argparse
import re

from lib import db, moodle, workplace
from lib.tools import debug, yesOrNo
from lib.config import Conf

DB = db.DB
Wp = workplace.Workplace()
C = Conf()

# Arguments
parser = argparse.ArgumentParser(
    description='Creates a new instance of Moodle')
parser.add_argument('-t',
                    '--integration',
                    action='store_true',
                    help='create an instance from integration')
parser.add_argument(
    '-i',
    '--install',
    action='store_true',
    help='launch the installation script after creating the instance',
    dest='install')
parser.add_argument('-r',
Beispiel #13
0
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""
import sys
import os
import argparse

from lib import db, moodle, workplace
from lib.tools import debug
from lib.config import Conf

DB = db.DB
Wp = workplace.Workplace()
C = Conf()

# Arguments
parser = argparse.ArgumentParser(description='Install a Moodle instance')
parser.add_argument('-e', '--engine', action='store', choices=['mysqli', 'pgsql'], default=C.get('defaultEngine'), help='database engine to use', metavar='engine')
parser.add_argument('-f', '--fullname', action='store', help='full name of the instance', metavar='fullname')
parser.add_argument('-r', '--run', action='store', nargs='*', help='scripts to run after installation', metavar='run')
parser.add_argument('name', metavar='name', default=None, nargs='?', help='name of the instance')
args = parser.parse_args()

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

M = Wp.resolve(name)
if not M:
Beispiel #14
0
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import sys
import argparse
import re
from lib import workplace, tools, jira
from lib.tools import debug
from lib.config import Conf

Wp = workplace.Workplace()
C = Conf()

# Arguments
parser = argparse.ArgumentParser(
    description="Pull a branch from a tracker issue.")
parser.add_argument(
    '-i',
    '--integration',
    action='store_true',
    help=
    'checkout the stable branch before proceeding to the pull (Integration mode).'
)
parser.add_argument(
    '-t',
    '--testing',
    action='store_true',
Beispiel #15
0
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import sys
import os
import argparse
from lib import workplace
from lib.tools import debug
from lib.config import Conf

Wp = workplace.Workplace()
C = Conf()

# Arguments
parser = argparse.ArgumentParser(description='Perform several checks on your current installation')
# parser.add_argument('-f', '--fix', dest='fix', action='store_true', help='Fix the problems where possible')
parser.add_argument('-i', '--integration', action='store_true', help='runs the script on the integration instances', dest='integration')
parser.add_argument('-s', '--stable', action='store_true', help='runs the script on the stable instances', dest='stable')
parser.add_argument('names', metavar='names', default=None, nargs='*', help='name of the instances')
args = parser.parse_args()

# Check configuration file
debug('[Config file]')
distSettings = Conf(os.path.dirname(__file__), 'config-dist.json').get()
allSettings = C.get()

errors = []
Beispiel #16
0
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import sys
import argparse
from lib import workplace, tools, jira
from lib.tools import debug
from lib.config import Conf

Wp = workplace.Workplace()
C = Conf()

# Arguments
parser = argparse.ArgumentParser(description="Backports a branch")
parser.add_argument(
    '-b',
    '--branch',
    metavar='branch',
    help=
    'the branch to backport if not the current one. If omitted, guessed from instance name.'
)
parser.add_argument('-r',
                    '--remote',
                    metavar='remote',
                    help='the remote to fetch from. Default is %s.' %
                    C.get('myRemote'))
Beispiel #17
0
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import sys
import argparse
from lib import workplace, tools, jira
from lib.tools import debug
from lib.config import Conf

Wp = workplace.Workplace()
C = Conf()

# Arguments
parser = argparse.ArgumentParser(description="Push a branch to a remote.")
parser.add_argument('-b', '--branch', metavar='branch', help='the branch to push. Default is current branch.')
parser.add_argument('-r', '--remote', metavar='remote', help='remote to push to. Default is your remote.')
parser.add_argument('-f', '--force', action='store_true', help='force the push (does not apply on the stable branch).')
parser.add_argument('-t', '--update-tracker', action='store_true', help='also add the diff information to the tracker issue.', dest='updatetracker')
parser.add_argument('-s', '--include-stable', action='store_true', help='also push the stable branch (MOODLE_xx_STABLE, master)', dest='includestable')
parser.add_argument('-k', '--force-stable', action='store_true', help='force the push on the stable branch', dest='forcestable')
parser.add_argument('name', metavar='name', default=None, nargs='?', help='name of the instance to work on')
args = parser.parse_args()

M = Wp.resolve(args.name)
if not M:
    debug('This is not a Moodle instance')
        l.show()
        h.pack_start(drag_vbox, True, True, False)
        vbox.pack_start(h, True, True, False)

        conf.open()
        conf.save()

        for soft in conf.softs:
            self._add_soft(conf, soft, vbox)

        # activate header
        vbox.pack_end(hbox_header, False, False, False)

        swin = Gtk.ScrolledWindow()
        swin.add_with_viewport(vbox)
        self.add(swin)
        self.set_default_size(800, 600)
        self.show_all()


if __name__ == "__main__":
    user = None
    if len(sys.argv) > 1:
        user = sys.argv[1]
    gtk_style()
    win = FluxBoxLauncherWindow(Conf(user))
    win.connect("destroy", Gtk.main_quit)
    win.show_all()
    Gtk.main()
    exit(0)
Beispiel #19
0
    def run(self, args):

        # Check root.
        if os.getuid() != 0:
            raise Exception('You must execute this as root.\n  sudo mdk init')

        # Check what user we want to initialise for.
        while True:
            username = question('What user are you initialising MDK for?', get_current_user())
            try:
                user = pwd.getpwnam(username)
            except:
                logging.warning('Error while getting information for user %s' % (username))
                continue

            try:
                usergroup = grp.getgrgid(user.pw_gid)
            except:
                logging.warning('Error while getting the group of user %s' % (username))
                continue

            break

        # Default directories.
        userdir = self.resolve_directory('~/.moodle-sdk', username)
        scriptdir = os.path.dirname(os.path.realpath(__file__))

        # Create the main MDK folder.
        if not os.path.isdir(userdir):
            logging.info('Creating directory %s.' % userdir)
            os.mkdir(userdir, 0755)
            os.chown(userdir, user.pw_uid, usergroup.gr_gid)

        # Checking if the config file exists.
        userconfigfile = os.path.join(userdir, 'config.json')
        if os.path.isfile(userconfigfile):
            logging.info('Config file %s already in place.' % userconfigfile)
            if not args.force:
                raise Exception('Aborting. Use --force to continue.')

        elif not os.path.isfile(userconfigfile):
            logging.info('Creating user config file in %s.' % userconfigfile)
            open(userconfigfile, 'w')
            os.chown(userconfigfile, user.pw_uid, usergroup.gr_gid)

        # If the group moodle-sdk exists, then we want to add the user to it.
        try:
            group = grp.getgrnam('moodle-sdk')
            if not username in group.gr_mem:
                logging.info('Adding user %s to group %s.' % (username, group.gr_name))
                # This command does not work for some reason...
                # os.initgroups(username, group.gr_gid)
                chgrp = subprocess.Popen(['usermod', '-a', '-G', 'moodle-sdk', username])
                chgrp.wait()
        except KeyError:
            # Raised when the group has not been found.
            group = None
            pass

        # Loading the configuration.
        from lib.config import Conf as Config
        C = Config(userfile=userconfigfile)

        # Asks the user what needs to be asked.
        while True:
            www = question('What is the DocumentRoot of your virtual host?', C.get('dirs.www'))
            www = self.resolve_directory(www, username)
            try:
                if not os.path.isdir(www):
                    os.mkdir(www, 0775)
                    os.chown(www, user.pw_uid, usergroup.gr_gid)
            except:
                logging.error('Error while creating directory %s' % www)
                continue
            else:
                C.set('dirs.www', www)
                break

        while True:
            storage = question('Where do you want to store your Moodle instances?', C.get('dirs.storage'))
            storage = self.resolve_directory(storage, username)
            try:
                if not os.path.isdir(storage):
                    if storage != www:
                        os.mkdir(storage, 0775)
                        os.chown(storage, user.pw_uid, usergroup.gr_gid)
                    else:
                        logging.error('Error! dirs.www and dirs.storage must be different!')
                        continue
            except:
                logging.error('Error while creating directory %s' % storage)
                continue
            else:
                C.set('dirs.storage', storage)
                break

        # The default configuration file should point to the right directory for dirs.mdk,
        # we will just ensure that it exists.
        mdkdir = C.get('dirs.mdk')
        mdkdir = self.resolve_directory(mdkdir, username)
        if not os.path.isdir(mdkdir):
            try:
                logging.info('Creating MDK directory %s' % mdkdir)
                os.mkdir(mdkdir, 0775)
                os.chown(mdkdir, user.pw_uid, usergroup.gr_gid)
            except:
                logging.error('Error while creating %s, please fix manually.' % mdkdir)

        # Git repository.
        github = question('What is your Github username? (Leave blank if not using Github)')
        if github != None:
            C.set('remotes.mine', C.get('remotes.mine').replace('YourGitHub', github))
            C.set('repositoryUrl', C.get('repositoryUrl').replace('YourGitHub', github))
            C.set('diffUrlTemplate', C.get('diffUrlTemplate').replace('YourGitHub', github))
            C.set('myRemote', 'github')
            C.set('upstreamRemote', 'origin')
        else:
            C.set('remotes.mine', question('What is your remote?', C.get('remotes.mine')))
            C.set('myRemote', question('What to call your remote?', C.get('myRemote')))
            C.set('upstreamRemote', question('What to call the upsream remote (official Moodle remote)?', C.get('upstreamRemote')))

        # Database settings.
        C.set('db.mysqli.user', question('What is your MySQL user?', C.get('db.mysqli.user')))
        C.set('db.mysqli.passwd', question('What is your MySQL password?', C.get('db.mysqli.passwd'), password=True))
        C.set('db.pgsql.user', question('What is your PostgreSQL user?', C.get('db.pgsql.user')))
        C.set('db.pgsql.passwd', question('What is your PostgreSQL password?', C.get('db.pgsql.passwd'), password=True))

        print ''
        print 'MDK has been initialised with minimal configuration.'
        print 'For more settings, edit your config file: %s.' % userconfigfile
        print 'Use %s as documentation.' % os.path.join(scriptdir, 'config-dist.json')
        print ''
        print 'Type the following command to create your first instance:'
        print '  mdk create'
        print '(This will take some time, but don\'t worry, that\'s because the cache is still empty)'
        print ''
        print '/!\ Please logout/login before to avoid permission issues: sudo su `whoami`'
Beispiel #20
0
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""
import sys
import argparse
from lib import workplace
from lib.tools import debug, process
from lib.config import Conf

C = Conf()

# Arguments
parser = argparse.ArgumentParser(description='Initialize PHPUnit')
parser.add_argument('-f',
                    '--force',
                    action='store_true',
                    help='force the initialisation')
parser.add_argument('-r',
                    '--run',
                    action='store_true',
                    help='also run the tests')
parser.add_argument('name',
                    metavar='name',
                    default=None,
                    nargs='?',
Beispiel #21
0
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import sys
import argparse
import re
from lib import workplace, moodle, tools
from lib.tools import debug
from lib.config import Conf

Wp = workplace.Workplace()
C = Conf()

# Arguments
parser = argparse.ArgumentParser(description="Rebases branches")
parser.add_argument('-i',
                    '--issues',
                    metavar='issues',
                    required=True,
                    nargs='+',
                    help='issues to be rebased')
parser.add_argument('-s',
                    '--suffix',
                    metavar='suffix',
                    help='the suffix of the branch of those issues')
parser.add_argument(
    '-v',
Beispiel #22
0
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import os
import sys
import argparse
import re

from lib import git, tools, moodle, workplace
from lib.tools import debug
from lib.config import Conf

C = Conf()

# Arguments
parser = argparse.ArgumentParser(description='Creates a branch associated to an MDL issue')
parser.add_argument('issue', help='issue number')
parser.add_argument('suffix', nargs='?', default='', help='suffix of the branch')
parser.add_argument('-n', '--name', metavar='name', default=None, help='name of the instance')
args = parser.parse_args()

Wp = workplace.Workplace()

# Loading instance
M = Wp.resolve(args.name)
if not M:
    debug('This is not a Moodle instance')
    sys.exit(1)
Beispiel #23
0
 def test_load(self):
     conf = Conf('primtux')
     lines = startup.split('\n')
     lines = [line + '\n' for line in lines]
     conf.load(lines[:-1])
     assert str(conf) == startup
Beispiel #24
0
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import sys
import os
import argparse
from lib import workplace
from lib.tools import debug
from lib.config import Conf

Wp = workplace.Workplace()
C = Conf()

# Arguments
parser = argparse.ArgumentParser(
    description='Perform several checks on your current installation')
# parser.add_argument('-f', '--fix', dest='fix', action='store_true', help='Fix the problems where possible')
parser.add_argument('-i',
                    '--integration',
                    action='store_true',
                    help='runs the script on the integration instances',
                    dest='integration')
parser.add_argument('-s',
                    '--stable',
                    action='store_true',
                    help='runs the script on the stable instances',
                    dest='stable')
Beispiel #25
0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import sys
import argparse
from lib.tools import debug
from lib.config import Conf

try:
    C = Conf()
except:
    # Quietly die here. The main reason would be that the config file could not
    # be loaded for some reason, which means that the environment has not been
    # set yet. Therefore we exit quietly. This is a very specific case for
    # moodle-alias as it is used in the Moodle bash script which does not know
    # if the environment is properly set or not.
    sys.exit()

# Arguments
parser = argparse.ArgumentParser(description='Manage your aliases')
parser.add_argument('command', metavar='command', choices=['list', 'show', 'add', 'remove'], help='the action to perform')
parser.add_argument('arguments', type=str, metavar='arguments', default=None, nargs=argparse.REMAINDER, help='arguments for the command')
args = parser.parse_args()

if args.command == 'list':
Beispiel #26
0
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""
import sys
import argparse
import os
import urllib
import re
from time import sleep
from lib import workplace
from lib.tools import debug, process, ProcessInThread
from lib.config import Conf

C = Conf()

# Arguments
parser = argparse.ArgumentParser(description='Initialise Behat')
parser.add_argument('-r', '--run', action='store_true', help='run the tests')
parser.add_argument('-j',
                    '--no-javascript',
                    action='store_true',
                    help='skip the tests involving Javascript',
                    dest='nojavascript')
parser.add_argument(
    '-s',
    '--switch-completely',
    action='store_true',
    help=
    'force the switch completely setting. This will be automatically enabled for PHP < 5.4',
Beispiel #27
0
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import sys
import argparse
import re
from lib import workplace, tools, jira
from lib.tools import debug
from lib.config import Conf

Wp = workplace.Workplace()
C = Conf()

# Arguments
parser = argparse.ArgumentParser(description="Pull a branch from a tracker issue.")
parser.add_argument('-i', '--integration', action='store_true', help='checkout the stable branch before proceeding to the pull (Integration mode).')
parser.add_argument('-t', '--testing', action='store_true', help='checkout a testing branch before proceeding to the pull (Testing mode).')
parser.add_argument('issue', metavar='issue', default=None, nargs='?', help='tracker issue to pull from (MDL-12345, 12345). If not specified, read from current branch.')
args = parser.parse_args()

M = Wp.resolve()
if not M:
    debug('This is not a Moodle instance')
    sys.exit(1)

if args.testing and args.integration:
    debug('You cannot combine --integration and --testing')
Beispiel #28
0
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""
import sys
import os
import argparse

from lib import db, moodle, workplace
from lib.tools import debug
from lib.config import Conf

DB = db.DB
Wp = workplace.Workplace()
C = Conf()

# Arguments
parser = argparse.ArgumentParser(description='Install a Moodle instance')
parser.add_argument('-e',
                    '--engine',
                    action='store',
                    choices=['mysqli', 'pgsql'],
                    default=C.get('defaultEngine'),
                    help='database engine to use',
                    metavar='engine')
parser.add_argument('-f',
                    '--fullname',
                    action='store',
                    help='full name of the instance',
                    metavar='fullname')
Beispiel #29
0
http://github.com/FMCorz/mdk
"""

import sys
import os
import argparse
import re

from lib import db, moodle, workplace
from lib.tools import debug, yesOrNo
from lib.config import Conf

DB = db.DB
Wp = workplace.Workplace()
C = Conf()

# Arguments
parser = argparse.ArgumentParser(description='Creates a new instance of Moodle')
parser.add_argument('-t', '--integration', action='store_true', help='create an instance from integration')
parser.add_argument('-i', '--install', action='store_true', help='launch the installation script after creating the instance', dest='install')
parser.add_argument('-r', '--run', action='store', nargs='*', help='scripts to run after installation', metavar='run')
parser.add_argument('-v', '--version', action='store', choices=[str(x) for x in range(13, int(C.get('masterBranch')))] + ['master'], default='master', help='version of Moodle', metavar='version')
parser.add_argument('-s', '--suffix', action='store', help='suffix for the instance name', metavar='suffix')
parser.add_argument('-e', '--engine', action='store', choices=['mysqli', 'pgsql'], default=C.get('defaultEngine'), help='database engine to use', metavar='engine')
args = parser.parse_args()

engine = args.engine
version = args.version
name = Wp.generateInstanceName(version, integration=args.integration, suffix=args.suffix)
Beispiel #30
0
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""
import sys
import argparse
from lib import workplace
from lib.tools import debug, process
from lib.config import Conf

C = Conf()

# Arguments
parser = argparse.ArgumentParser(description='Initialize PHPUnit')
parser.add_argument('-f', '--force', action='store_true', help='force the initialisation')
parser.add_argument('-r', '--run', action='store_true', help='also run the tests')
parser.add_argument('name', metavar='name', default=None, nargs='?', help='name of the instance')
args = parser.parse_args()

Wp = workplace.Workplace(C.get('dirs.storage'))

# Loading instance
M = Wp.resolve(args.name)
if not M:
    debug('This is not a Moodle instance')
    sys.exit(1)
Beispiel #31
0
    group = grp.getgrnam('moodle-sdk')
    if not username in group.gr_mem:
        debug('Adding user %s to group %s.' % (username, group.gr_name))
        # This command does not work for some reason...
        # os.initgroups(username, group.gr_gid)
        chgrp = subprocess.Popen(
            ['usermod', '-a', '-G', 'moodle-sdk', username])
        chgrp.wait()
except KeyError:
    # Raised when the group has not been found.
    group = None
    pass

# Loading the configuration.
from lib.config import Conf as Config
C = Config(userfile=userconfigfile)

# Asks the user what needs to be asked.
while True:
    www = question('What is the DocumentRoot of your virtual host?',
                   C.get('dirs.www'))
    www = resolve_directory(www, username)
    try:
        if not os.path.isdir(www):
            os.mkdir(www, 0775)
            os.chown(www, user.pw_uid, usergroup.gr_gid)
    except:
        debug('Error while creating directory %s' % www)
        continue
    else:
        C.set('dirs.www', www)
Beispiel #32
0
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

http://github.com/FMCorz/mdk
"""

import sys
import argparse
from lib.tools import debug
from lib.config import Conf

C = Conf()

# Arguments
parser = argparse.ArgumentParser(description="Manage your configuration")
parser.add_argument(
    "command", metavar="command", choices=["flatlist", "list", "show", "set"], help="the action to perform"
)
parser.add_argument("arguments", metavar="arguments", default=None, nargs="*", help="arguments for the command")
args = parser.parse_args()

if args.command == "list":

    def show_list(settings, ident):
        for name, setting in settings.items():
            if type(setting) != dict:
                print u"{0:<20}: {1}".format(u" " * ident + name, setting)
Beispiel #33
0
http://github.com/FMCorz/mdk
"""

import sys
import argparse
import os
import re
import logging
from lib.command import CommandRunner
from lib.commands import getCommand, commandsList
from lib.config import Conf
from lib.tools import process
from version import __version__

C = Conf()

try:
    debuglevel = getattr(logging, C.get('debug').upper())
except AttributeError:
    debuglevel = logging.WARNING

logging.basicConfig(format='%(message)s', level=debuglevel)

availaliases = [str(x) for x in C.get('aliases').keys()]
choices = sorted(commandsList + availaliases)

parser = argparse.ArgumentParser(description='Moodle Development Kit', add_help=False)
parser.add_argument('-h', '--help', action='store_true', help='show this help message and exit')
parser.add_argument('-l', '--list', action='store_true', help='list the available commands')
parser.add_argument('-v', '--version', action='store_true', help='display the current version')
Beispiel #34
0
try:
    group = grp.getgrnam('moodle-sdk')
    if not username in group.gr_mem:
        debug('Adding user %s to group %s.' % (username, group.gr_name))
        # This command does not work for some reason...
        # os.initgroups(username, group.gr_gid)
        chgrp = subprocess.Popen(['usermod', '-a', '-G', 'moodle-sdk', username])
        chgrp.wait()
except KeyError:
    # Raised when the group has not been found.
    group = None
    pass

# Loading the configuration.
from lib.config import Conf as Config
C = Config(userfile=userconfigfile)

# Asks the user what needs to be asked.
while True:
    www = question('What is the DocumentRoot of your virtual host?', C.get('dirs.www'))
    www = resolve_directory(www, username)
    try:
        if not os.path.isdir(www):
            os.mkdir(www, 0775)
            os.chown(www, user.pw_uid, usergroup.gr_gid)
    except:
        debug('Error while creating directory %s' % www)
        continue
    else:
        C.set('dirs.www', www)
        break