-
Notifications
You must be signed in to change notification settings - Fork 13
/
module.py
45 lines (42 loc) · 1.75 KB
/
module.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from fabric.api import *
import os
import re
import utility
@task
def enable(module_name, module_version="", pid=""):
"""
Enables a REDCap module.
"""
utility.write_remote_my_cnf()
enable_module = """
namespace ExternalModules\ExternalModules; require '/var/www/redcap/external_modules/classes/ExternalModules.php';
#\\ExternalModules\\ExternalModules::initialize();
\\ExternalModules\\ExternalModules::enableForProject('%s', '%s');
""" %(module_name, module_version)
run ('php -r \"%s\"' %enable_module)
if pid != "":
enable_module_for_pid = """
namespace ExternalModules\ExternalModules; require '/var/www/redcap/external_modules/classes/ExternalModules.php';
\\ExternalModules\\ExternalModules::enableForProject('%s', '%s', %s);
""" %(module_name, module_version, pid)
run ('php -r \"%s\"' %enable_module_for_pid)
utility.delete_remote_my_cnf()
@task
def disable(module_name, pid=""):
"""
Disables a REDCap module.
"""
utility.write_remote_my_cnf()
if pid != "":
disable_module_for_pid = """
namespace ExternalModules\ExternalModules; require '/var/www/redcap/external_modules/classes/ExternalModules.php';
\\ExternalModules\\ExternalModules::setProjectSetting('%s', %s, 'enabled', false);
""" %(module_name, pid)
run ('php -r \"%s\"' %disable_module_for_pid)
else:
disable_module = """
namespace ExternalModules\ExternalModules; require '/var/www/redcap/external_modules/classes/ExternalModules.php';
\\ExternalModules\\ExternalModules::disable('%s');
""" %module_name
run ('php -r \"%s\"' %disable_module)
utility.delete_remote_my_cnf()