コード例 #1
0
    def _read_disabled_packages_config_(self):
        '''
        '''

        try:
            setting_folder = \
                application_services.get_default_settings_folder_name()
            package_dir = \
                get_module_dir(application_services.get_name())
            settings_dir = \
                os.path.join(package_dir, setting_folder)

            app_setting_file_name = \
                os.path.join(settings_dir, 'app.config')

            config_parser = ConfigParser.ConfigParser()
            config_parser.read(app_setting_file_name)

            if config_parser.has_section('packages'):
                disabled_packages = config_parser.get('packages',
                                                      'disabled_packages',
                                                      None)
                if disabled_packages is not None:
                    disabled_packages_list = disabled_packages.split(',')
                    for disabled_package in disabled_packages_list:
                        striped_disabled_package = disabled_package.strip()
                        if striped_disabled_package != '':
                            self.__disabled_packages.append(
                                striped_disabled_package)
        except:
            import traceback
            print traceback.format_exc()
コード例 #2
0
    def load(self, package_name):
        '''
        Loads the package and it's sub packages.
        
        @param package_name: package name
        '''

        print ">> Disabled packages:"
        for disabled_package in self.__disabled_packages:
            print "    [%s]" % disabled_package

        parent = []
        if get_module_parent(package_name):
            parent.append(get_module_parent(package_name))
        self.__load__(package_name, parent)
        path = get_module_dir(package_name)
        sub_packages = os.listdir(path)
        for sub_package in sub_packages:
            if sub_package.find('.') < 0:
                self.__load__("%s.%s" % (package_name, sub_package),
                              [package_name])

        loaded_packages_count = len(self.get_loaded_packages(package_name))

        print ""
        print ">> %s:[%d] packages loaded." % (package_name,
                                               loaded_packages_count)
        print ">> Total loaded packages: %d" % (len(
            self.get_loaded_packages()))
        print ">> Disabled packages: %d" % (len(self.__disabled_packages))
        print ""

        return loaded_packages_count
コード例 #3
0
    def load_all_configs(self, package, extension = '.config'):
        '''
        Loads all configuration of a package by looking in settings directory.
        
        @param package: a python package
        '''

        package_dir = get_module_dir(package)
        settings_dir = os.path.join(package_dir, 
                                    ConfigManager.SETTINGS_FOLDER_NAME)
        
        config_files = {}
        if os.path.exists(settings_dir):
            for file_name in os.listdir(settings_dir):
                if file_name.endswith(extension):
                    config_files[file_name] = os.path.join(settings_dir, file_name)

       
        if self.__default_settings_folder_name is not None:
            if self.__default_settings_folder_name != ConfigManager.SETTINGS_FOLDER_NAME:
                new_settings_dir = os.path.join(package_dir, 
                                               self.__default_settings_folder_name)
                
                if os.path.exists(new_settings_dir):
                    settings_dir = new_settings_dir
                    for file_name in os.listdir(settings_dir):
                        if file_name.endswith(extension):
                            config_files[file_name] = os.path.join(settings_dir, file_name)

        for file_name in config_files:
            file_path = config_files[file_name]
            alias = "%s.%s" % (str(package), file_name.replace(extension, ''))
            self.add_std_config(alias, file_path)
コード例 #4
0
    def get_application_dir(self):
        '''
        Returns application running path.
        
        @rtype: str
        '''

        return get_module_dir(self.__class__.__module__)
コード例 #5
0
    def get_name(self):
        '''
        Returns application's name.
        
        @return: str
        '''

        path = get_module_dir(self.__class__.__module__)
        head, sep, tail = path.rstrip(os.path.sep).rpartition(os.path.sep)
        return tail
コード例 #6
0
    def _get_template_(self, name):
        '''
        
        @param name:
        '''

        templates_dir = os.path.join(get_module_dir('deltapy.admin.actions'),
                                     'templates')
        file = open(os.path.join(templates_dir, name))
        return file.read()
コード例 #7
0
 def __auto_import__(self, package_name, parent):
     try:
         package_dir = get_module_dir(package_name)
         sub_modules = os.listdir(package_dir)
         for module_name in sub_modules:
             if module_name.find('__init__.py') == 0:
                 continue
             head, sep, tail = module_name.partition('.')
             module = __import__("%s.%s" % (package_name, head),
                                 fromlist=parent or [])
     except Exception:
         print 'Error in loading package [{0}]'.format(package_name)
         raise
コード例 #8
0
    def _load_(self):
        '''
        Loads all command line actions.
        '''

        action_modules = {}
        file_path = os.path.join(get_module_dir(__name__), 'actions')
        for file_name in os.listdir(file_path):
            file_full_path = os.path.join(file_path, file_name)
            if file_full_path.endswith('.py') or file_full_path.endswith(
                    '.pyc'):
                module_name = file_name.split('.')[0]
                action_modules['deltapy.admin.actions.{module}'.format(
                    module=module_name)] = file_full_path

        for module_name in action_modules:
            types = activator.get_types(module_name,
                                        CommandLineAction,
                                        parent='deltapy.admin.actions')
            for command_line_action_class in types:
                action = command_line_action_class()
                self._actions[action.get_name()] = action
コード例 #9
0
'''
Created on Sep 28, 2009

@author: Abi.Mohammadi & Majid.Vesal
'''

from deltapy.utils import get_module_dir
import Ice
import os
Ice.loadSlice(os.path.join(get_module_dir('deltapy.communication.ice'), 'services.ice'))
import DeltaIce
from deltapy.packaging.package import Package
import deltapy.communication.services as communication
  

class IcePackage(Package):

    __disable__ = True

    def load(self):
        Package.load(self)
        
        from deltapy.communication.ice.factory import IceFactory 
        communication.register_factory('ice', IceFactory())
    
    def unload(self):
        Package.unload(self)