mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-24 06:48:35 +02:00
* No more code inside lib/__init__.py
* Fixed a circular import raised only when using commands like 'manage.py syncdb'
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
This module extra functions/shortcuts to communicate with the system
|
||||
(executing commands, etc.)
|
||||
"""
|
||||
|
||||
from modoboa.lib import parameters
|
||||
|
||||
def exec_cmd(cmd, **kwargs):
|
||||
import subprocess
|
||||
|
||||
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, **kwargs)
|
||||
output = p.communicate()[0]
|
||||
return p.returncode, output
|
||||
|
||||
def exec_as_vuser(cmd):
|
||||
code, output = exec_cmd("sudo -u %s %s" \
|
||||
% (parameters.get_admin("VIRTUAL_UID", app="admin"), cmd))
|
||||
if code:
|
||||
exec_cmd("echo '%s' >> /tmp/vmail.log" % output)
|
||||
return False
|
||||
return True
|
||||
Reference in New Issue
Block a user