def parse(self, item): analysers = BackendOrder.objects.filter( source=self.__scanner.source, backend_module__pipe='ANALYSIS') # Based on the list of analysis components from the database model, loop through, attempt to hook up to the # component and pass an item to it to analyse. for each in analysers: if each not in self.__run: if each not in self.__imports.keys(): if os.path.exists( os.path.join(get_project_root(), ('backend/analysis/pipe/%s.py' % each.backend_module.sys_name))): self.__imports[each] = __import__( ('backend.analysis.pipe.%s' % each.backend_module.sys_name), fromlist=['backend.analysis.pipe']) else: raise IOError item = self.__imports[each].parse(self.__scanner, item) self.__run.append(each) return item
def index_exists(name, index_type): path_to_index = os.path.join(get_project_root(), 'index/whoosh') if index_type == Index_Types.Source: path_to_index = os.path.join(path_to_index, ('sources/%s.whoosh' % name)) elif index_type == Index_Types.Crisees: path_to_index = os.path.join(path_to_index, ('crisees/%s.whoosh' % name)) if os.path.exists(path_to_index): if exists_in(path_to_index, indexname = name): idx = open_dir(path_to_index, indexname = name) return idx.schema return False
def __initialise_sentiment(self): filename = os.path.join(get_project_root(), 'backend/analysis/data/AFINN-111.txt') try: return_dict = dict( map(lambda (w, s): (w, int(s)), [ws.strip().split('\t') for ws in open(filename)])) except IOError: print statuses.fail( "Failed to find the specified sentiment data file.", sub=filename) return {} print statuses.success("Sentiment Analysis successfully initialised.") return return_dict
def parse(self, item): filters = BackendOrder.objects.filter(source = self.__scanner.source, backend_module__pipe = 'FILTER').order_by('step') for each in filters: if each not in self.__run: if each not in self.__imports.keys(): if os.path.exists(os.path.join(get_project_root(), ('backend/filtering/pipe/%s.py' % each.backend_module.sys_name))): self.__imports[each] = __import__(('backend.filtering.pipe.%s' % each.backend_module.sys_name), fromlist = ['backend.filtering.pipe']) else: raise IOError item = self.__imports[each].parse(self.__scanner, item) if item is None: break self.__run.append(each) return item
def open_index(self): path_to_index = os.path.join(get_project_root(), 'index/whoosh') if self.index_type == Index_Types.Source: path_to_index = os.path.join(path_to_index, ('sources/%s.whoosh' % self.name)) elif self.index_type == Index_Types.Crisees: path_to_index = os.path.join(path_to_index, ('crisees/%s.whoosh' % self.name)) if os.path.exists(path_to_index): if exists_in(path_to_index, indexname = self.name): return open_dir(path_to_index, indexname = self.name) else: print statuses.warning( ("Can't find a valid index at %s." % path_to_index), sub = "I'll recreate the index.") rmtree(path_to_index) os.mkdir(path_to_index) return create_in(path_to_index, self.schema, indexname = self.name) else: os.mkdir(path_to_index) return create_in(path_to_index, self.schema, indexname = self.name)
def __init__(self, name): self.tutorial_dir = common.get_tutorial_dir() self.build_config_parent_dir = os.path.realpath( os.path.join(self.tutorial_dir, 'build-config')) self.project_root_dir = common.get_project_root() self.app_dir = os.path.realpath( os.path.join(self.tutorial_dir, 'templates')) self.tutorial_dir_rel = os.path.relpath(self.tutorial_dir, self.project_root_dir) self.build_config_parent_dir_rel = os.path.relpath(self.build_config_parent_dir, self.project_root_dir) self.name = name if self.name == 'camkes': self.suffix = '-camkes' elif self.name == 'sel4': self.suffix = '-sel4' else: raise Exception("unknown environment name %s" % name) self.build_re = re.compile(r'(?P<name>.*)%s' % self.suffix) self.local_solution_dir = os.path.realpath( os.path.join(self.project_root_dir, 'apps%s-solutions' % self.suffix)) self.local_exercise_dir = os.path.realpath( os.path.join(self.project_root_dir, 'apps%s-exercises' % self.suffix)) self.local_template_dir = os.path.realpath( os.path.join(self.project_root_dir, 'apps%s-templates' % self.suffix)) self.local_solution_dir_rel = os.path.relpath( self.app_dir, self.local_solution_dir) self.local_app_symlink = os.path.join(self.project_root_dir, 'apps') self.template_ctx = TemplateCtx()
def __add(self, source): if source not in self.__failed: if os.path.exists(os.path.join(get_project_root(), ('backend/specific/%s.py' % source.sys_name))): module_import = __import__(('backend.specific.%s' % source.sys_name), fromlist = ['backend.specific']) try: module_import.SETTINGS module_import.Schema module_import.Collector scanner = Scanner(source, self.__analysis_manager) scanner.start() self.__current[source] ={ 'import' : module_import, 'threads' : {'scanner': scanner}, 'children': False, } print statuses.success("%s has started." % str(source)) except AttributeError: self.__specific_invalid(source) else: self.__specific_invalid(source)
# Builds and runs all tutorial solutions, comparing output with expected # completion text. import sys, os, argparse, re, pexpect, subprocess, tempfile, logging import signal import psutil import shutil import os.path import xml.sax.saxutils import sh import common # this assumes this script is in a directory inside the tutorial directory TUTORIAL_DIR = common.get_tutorial_dir() TOP_LEVEL_DIR = common.get_project_root() # timeout per test in seconds DEFAULT_TIMEOUT = 1800 # Completion text for each test COMPLETION = { "hello-1": "hello world", "hello-2": "(thread_2: hallo wereld)|(main: hello world)", "hello-2-nolibs": "(thread_2: hallo wereld)|(main: hello world)", "hello-3": "main: got a reply: 0xffff*9e9e", "hello-3-nolibs": "main: got a reply: 0xffff*9e9e", "hello-4": "process_2: got a reply: 0xffff*9e9e", "hello-timer": "timer client wakes up: got the current timer tick:", "hello-camkes-0": "Hello CAmkES World", "hello-camkes-1": "Component echo saying: hello world",
USE_L10N = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = '' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = '' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = os.path.join(get_project_root(), 'static') # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/' # URL prefix for admin static files -- CSS, JavaScript and images. # Make sure to use a trailing slash. # Examples: "http://foo.com/static/admin/", "/static/admin/". ADMIN_MEDIA_PREFIX = '/static/admin/' # Additional locations of static files STATICFILES_DIRS = ( # Put strings here, like "/home/html/static" or "C:/www/django/static". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths.