# Path: RapacheCore/Configuration.py
# SYSCONFDIR = '/etc/apache2'
# SITES_ENABLED_DIR = SYSCONFDIR + '/sites-enabled'
# SITES_AVAILABLE_DIR = SYSCONFDIR + '/sites-available'
# MODS_ENABLED_DIR = SYSCONFDIR + '/mods-enabled'
# MODS_AVAILABLE_DIR = SYSCONFDIR + '/mods-available'
# APPPATH = '/usr/bin' #please fill at run-time
# GLADEPATH = '/usr/share/rapache/Glade' #please fill at run-time
# NUMBER_OF_BACKUPS = 10
# TEST_CONNECTION_INTERVAL = 30
# 
# Path: RapacheCore/Shell.py
# class CommandLogEntry:
# class CommandHandler:
#     def __init__(self, command):
#     def __init__(self, ssh_server="localhost", ssh_port=None, ssh_username=None, ssh_password=None):
#     def __get_backup_path(self, path):
#     def get_backup_files(self, path):
#     def read_file_version(self, path, date_stamp):
#     def create_backup(self, path, new_content):
#     def read_file(self, path):
#     def write_file(self, path, content, backup=True):
#     def listdir(self, path):
#     def create_complete_path ( self, complete_path ):
#     def exists(self, path):
#     def readlink(self, path):
#     def move(self, source, destination):
#     def __get_password(self, description, prompt="Password: "):
#     def __sudo_popen (self, command, password ): 
#     def is_auth_needed (self):        
#     def execute(self, command, description = None ):
#     def __output (self, command, returncode, output, error ):
#     def sudo_reset (self):
#     def ask_password(self, description = "Super user priviledges are required to perform this operation"):
#     def sudo_execute(self, command, description = "Super user priviledges are required to perform this operation"):
#     def sudo_read_file(self, path):
#     def sudo_exists(self, path):
#     def sudo_listdir(self, path):


import sys
import os
import tempfile
import re
from RapacheCore import Configuration
from RapacheCore import Shell
from xml.dom.minidom import *
        #name = ".".join(tokens)
        name = self.data['name']
        Shell.command.sudo_execute( [command_name, name] )
        self.data['enabled'] = self.is_enabled()
        self.changed = True
     
     
    def get_description(self):
        name = self.data['name']
        if not self.data.has_key('description'):
            module_descriptions = get_module_descriptions()
            if module_descriptions.has_key(name):
               self.data[ 'description' ] = module_descriptions[name]
               return self.data[ 'description' ]
            elif module_descriptions.has_key("mod_" +name):
               self.data[ 'description' ] = module_descriptions["mod_" +name]
               return self.data[ 'description' ]

        return ""
        
    def get_configuration_file_name(self):
        return os.path.join(Configuration.MODS_AVAILABLE_DIR, self.data['name']+".conf")
    
    def get_backup_files(self):
        return Shell.command.get_backup_files(  os.path.join(Configuration.MODS_AVAILABLE_DIR, self.data['name']+".conf"))
    
    def get_source ( self ):
        return Shell.command.read_file( os.path.join(Configuration.MODS_AVAILABLE_DIR, self.data['name']+".load"))

    def get_configuration ( self ):

# Path: RapacheCore/Configuration.py
# SYSCONFDIR = '/etc/apache2'
# SITES_ENABLED_DIR = SYSCONFDIR + '/sites-enabled'
# SITES_AVAILABLE_DIR = SYSCONFDIR + '/sites-available'
# MODS_ENABLED_DIR = SYSCONFDIR + '/mods-enabled'
# MODS_AVAILABLE_DIR = SYSCONFDIR + '/mods-available'
# APPPATH = '/usr/bin' #please fill at run-time
# GLADEPATH = '/usr/share/rapache/Glade' #please fill at run-time
# NUMBER_OF_BACKUPS = 10
# TEST_CONNECTION_INTERVAL = 30
# 
# Path: RapacheCore/Shell.py
# class CommandLogEntry:
# class CommandHandler:
#     def __init__(self, command):
#     def __init__(self, ssh_server="localhost", ssh_port=None, ssh_username=None, ssh_password=None):
#     def __get_backup_path(self, path):
#     def get_backup_files(self, path):
#     def read_file_version(self, path, date_stamp):
#     def create_backup(self, path, new_content):
#     def read_file(self, path):
#     def write_file(self, path, content, backup=True):
#     def listdir(self, path):
#     def create_complete_path ( self, complete_path ):
#     def exists(self, path):
#     def readlink(self, path):
#     def move(self, source, destination):
#     def __get_password(self, description, prompt="Password: "):
#     def __sudo_popen (self, command, password ): 
#     def is_auth_needed (self):        
#     def execute(self, command, description = None ):
#     def __output (self, command, returncode, output, error ):
#     def sudo_reset (self):
#     def ask_password(self, description = "Super user priviledges are required to perform this operation"):
#     def sudo_execute(self, command, description = "Super user priviledges are required to perform this operation"):
#     def sudo_read_file(self, path):
#     def sudo_exists(self, path):
#     def sudo_listdir(self, path):


# Path: RapacheCore/Module.py
import sys
import os
import tempfile
import re
from RapacheCore import Configuration
from RapacheCore import Shell
from xml.dom.minidom import *

        #name = ".".join(tokens)
        name = self.data['name']
        Shell.command.sudo_execute( [command_name, name] )
        self.data['enabled'] = self.is_enabled()
        self.changed = True
     
     
    def get_description(self):
        name = self.data['name']
        if not self.data.has_key('description'):
            module_descriptions = get_module_descriptions()
            if module_descriptions.has_key(name):
               self.data[ 'description' ] = module_descriptions[name]
               return self.data[ 'description' ]
            elif module_descriptions.has_key("mod_" +name):
               self.data[ 'description' ] = module_descriptions["mod_" +name]
               return self.data[ 'description' ]

        return ""
        
    def get_configuration_file_name(self):
        return os.path.join(Configuration.MODS_AVAILABLE_DIR, self.data['name']+".conf")
    
    def get_backup_files(self):
        return Shell.command.get_backup_files(  os.path.join(Configuration.MODS_AVAILABLE_DIR, self.data['name']+".conf"))
    
    def get_source ( self ):
        return Shell.command.read_file( os.path.join(Configuration.MODS_AVAILABLE_DIR, self.data['name']+".load"))

    def get_configuration ( self ):

        return Shell.command.read_file( self.get_configuration_file_name() )