Beispiel #1
0
    def setUp(self):
        use_filesystem('test1_db')
        set_namespace('Test1')
        remove_all_jobs()

        reset_jobs_definition_set()
        
        self.jobs = [
                ('a', Cache.DONE),
                ('b', Cache.FAILED),
                ('c', Cache.NOT_STARTED),
                ('d', Cache.DONE),
                ('e', Cache.DONE),
                ('f', Cache.IN_PROGRESS),
                ('g', Cache.DONE),
                ('h', Cache.FAILED),
                ('i', Cache.DONE),
                ('ii', Cache.DONE),
                ('v_rangefinder_nonunif-plot_tensors_tex-0', Cache.DONE),
        ]
        
        for job_id, state in self.jobs:
            comp(dummy, job_id=job_id)
            cache = get_job_cache(job_id)
            cache.state = state
            set_job_cache(job_id, cache)

        self.all = set([job_id for job_id, state in self.jobs])
        select = lambda S: set([id for id, state in self.jobs if state == S])
        self.failed = select(Cache.FAILED)
        self.done = select(Cache.DONE)
        self.in_progress = select(Cache.IN_PROGRESS)
        self.not_started = select(Cache.NOT_STARTED)
Beispiel #2
0
 def setUp(self):
     set_compmake_status(compmake_status_embedded)
     use_filesystem('priorities')
     set_namespace('priorities')
     # make sure everything was clean
     for key in storage.db.keys('*'):
         storage.db.delete(key)
 
     # clear the variable holding the result
     TestOrder.order = []
Beispiel #3
0
 def setUp(self):
     use_filesystem('Simple_db')
     set_namespace('Simple')
     for key in storage.db.keys('*'):
         storage.db.delete(key)
 def setUp(self):
     set_compmake_status(compmake_status_embedded)
     use_filesystem('unpickable')
     set_namespace('unpickable')
     for key in storage.db.keys('*'):
         storage.db.delete(key)
Beispiel #5
0
def main():        
    
    setproctitle('compmake')
    
    parser = OptionParser(version=version)
     
    parser.add_option("--slave", action="store_true",
                      default=False, dest="slave",
                      help="[internal] Runs compmake in slave mode.")
    
    parser.add_option("--redis_events", action="store_true",
                      default=False, dest="redis_events",
                      help="[internal] Relays events using Redis.")
    
    config_populate_optparser(parser)
    
    (options, args) = parser.parse_args()
    
    initialize_backend()

    # We load plugins after we parsed the configuration
    from compmake import plugins #@UnusedImport
    
    if options.redis_events:
        if not compmake_config.db == 'redis': #@UndefinedVariable
            error('Cannot use redis_events without redis.')
            sys.exit(-2)
        
        from compmake.storage.redisdb import RedisInterface

        # register an handler that will capture all events    
        def handler(event):
            RedisInterface.events_push(event) 
    
        remove_all_handlers()    
        register_handler("*", handler)


    
    if not options.slave:
        # XXX make sure this is the default
        set_compmake_status(compmake_status_interactive)
        
        # TODO: add command namespace
        # TODO: add command "load"
        if not args:
            user_error('I expect at least one parameter (module name)')
            sys.exit(-2)
            
        module_name = args[0]
        args = args[1:]
    
        if module_name.endswith('.py') or (module_name.find('/') > 0):
            warning('You passed a string "%s" which looks like a filename.' % 
                    module_name)
            module_name = module_name.replace('/', '.')
            module_name = module_name.replace('.py', '')
            warning('However, I need a module name. I will try with "%s".' % 
                    module_name)
        
        set_namespace(module_name) 
        compmake.is_it_time = True
        try:
            __import__(module_name)
        except Exception as e:
            error('Error while trying to import module "%s": %s' % 
                  (module_name, e)) 
            traceback.print_exc(file=sys.stderr)
            sys.exit(-5)
            
        # TODO: BUG: XXX: remove old jobs those in defined_this_section
    else:
        set_compmake_status(compmake_status_slave)
        
        if not args:
            user_error('I expect at least one parameter (namespace name)')
            sys.exit(-2)
        
        module_name = args.pop(0)
        set_namespace(module_name)
             
    if args:
        try:
            # XXX is this redudant?
            # compmake_config.interactive = False
            retcode = interpret_commands(args)
            # print "Exiting with retcode %s" % retcode
            sys.exit(retcode)
        except UserError as e:
            user_error(e)
            sys.exit(-6)
    else:
        retcode = interactive_console()
        sys.exit(retcode)