예제 #1
0
파일: views.py 프로젝트: relic7/nd1404
def get_actions(request):  
    import os, settings
    from mprocessor.config import Configurator
    workspace = request.session.get('workspace')
    
    c = Configurator()
    actions_modules =  c.get("MPROCESSOR", "plugins")
    src_dir = '/'.join(settings.ROOT_PATH.split('/')[:-1]) #removing dam dir, it ends with src dir
    actions_dir = actions_modules.replace('.', '/')
    all_files = os.listdir(os.path.join(src_dir, actions_dir))
    
    resp = {'scripts':[]}
    modules_to_load = []
    try:
        for filename in all_files:
            if filename.endswith('.py') and not filename.endswith('_idl.py'):
                modules_to_load.append(filename.split('.py')[0])
                
        top_module = __import__(actions_modules, fromlist=modules_to_load)
        logger.debug('modules_to_load %s'%modules_to_load)
        for module in modules_to_load:
            try:
                logger.debug(module)
                
                module_loaded = getattr(top_module, module, None)
                if module_loaded:
                    logger.debug(module_loaded)
                    
                    
                    if hasattr(module_loaded, 'inspect'):
                        tmp = module_loaded.inspect(workspace)
                        tmp.update({'name': module})
                        resp['scripts'].append(tmp)
                        media_type = request.POST.get('media_type') # if no media_type all actions will be returned
            except Exception, ex:
                logger.error(ex)
                continue
        
    except Exception, ex:
        logger.exception(ex)
        raise ex        
예제 #2
0
파일: settings.py 프로젝트: relic7/nd1404


DEMO_STRING="Development Demo" 
PYTHONPATH= ""
CAPTCHA_PRIVATE_KEY = '6LeIrcMSAAAAAF_F3yhg0AyO65M5bpj4Kb4OW9tC'

ROOT_PATH = os.path.dirname(os.path.abspath(__file__))

sys.path.append(PYTHONPATH)
sys.path.append(ROOT_PATH)

REMOVE_OLD_PROCESSES= True
CONFIRM_REGISTRATION = True
from mprocessor.config import Configurator
c = Configurator()
MPROCESSOR_STORAGE = c.get('STORAGE', 'cache_dir')
STORAGE_SERVER_URL= '/storage/'


INSTALLATIONPATH = os.path.join(os.getenv('HOME'), ".dam"  )
BACKUP_PATH = os.path.join(INSTALLATIONPATH, 'file_backup')
sys.path.append(INSTALLATIONPATH)

THUMBS_DIR = os.path.join(INSTALLATIONPATH,  'thumbs')

from config import *
dir_log = os.path.join(INSTALLATIONPATH, 'log')