def __uncreateverb(self, subject, agents): r = [] for a in action.concrete_objects(agents): if not self.__workspace.unload(a, True): r.append(errors.doesnt_exist('agent', 'un create')) return async .success(r)
def __loadverb(self,subject,t): tag = self.__process_tag(action.abstract_string(t)) path = find_setup(tag) if not path: print 'no such state',tag thing= 'setup %s' %str(tag) return async.success(errors.doesnt_exist(thing,'load')) def deferred_load(): self.__thing.cancel_timer_slow() self.__thing = None snap = self.prepare_file(path,self.uid,version.version) if not snap: print 'no such state' return async.failure('no such state %s' % tag) print 'loading from version',snap.version(),'in',tag self.setups_changed(path) self.__load(snap,tag) self.__thing = piw.thing() piw.tsd_thing(self.__thing) self.__thing.set_slow_timer_handler(utils.notify(deferred_load)) self.__thing.timer_slow(500) return async.success()
def __runscript(self,subject,arg): name = action.abstract_string(arg) print 'script',name r = self[12].run_script(name) if not r: yield async.Coroutine.success(errors.doesnt_exist(name,'execute')) yield r
def __undefine_slow(self, subject, name): name = action.abstract_string(name) v = self.variables.get(name) if v: if v.has_alternatives(): return async .success(errors.invalid_value(name, 'un define')) del self[v.get_index()] self.update_cache() return async .success() else: return async .success(errors.doesnt_exist(name, 'un define'))
def __destroy(self,subject,agents): r = [] for a in action.concrete_objects(agents): ss = self.dynamic.unload(a) if ss is None: r.append(errors.doesnt_exist('agent','un create')) continue rvt = self.__parse_return(ss) r.append(action.removed_return(a,*rvt)) return async.success(r)
def __add(self,subj,arg): if arg is None: return action.nosync_return() (type,id) = action.crack_ideal(action.arg_objects(arg)[0]) if id >= self.loopdb.size(): return async.success(errors.doesnt_exist('loop %s' % str(id),'add')) file = self.loopdb.basename(id) voice = self[5].new_voice() voice.set_current(id,file) return action.nosync_return()
def __choose(self,subj,arg): (type,id) = action.crack_ideal(action.arg_objects(arg)[0]) if id >= self.loopdb.size(): return async.success(errors.doesnt_exist('loop %s' % id,'choose')) file = self.loopdb.basename(id) voice = self[5].current_voice() if not voice: return async.success(errors.no_current_voice('','choose')) voice.set_current(id,file) return action.nosync_return()
def __run(self, subject, script, arg): name = action.abstract_string(script) words = self.get_var(name) if not words: yield async .Coroutine.success( errors.doesnt_exist('%s does not exist' % name, 'run')) interp = interpreter.Interpreter(self.agent, self.agent.database, SubDelegate(self.agent)) print 'doing', words self.agent.register_interpreter(interp) try: yield interp.process_block(words.split()) finally: self.agent.unregister_interpreter(interp) print 'done', words
def __loadverb(self, subject, t): tag = self.__process_tag(action.abstract_string(t)) path = find_setup(tag) if not path: print 'no such state', tag thing = 'setup %s' % str(tag) return async .success(errors.doesnt_exist(thing, 'load')) def deferred_load(): self.__thing.cancel_timer_slow() self.__thing = None self.__backend.setups_changed(path) self.__workspace.load_file(path) self.__thing = piw.thing() piw.tsd_thing(self.__thing) self.__thing.set_slow_timer_handler(utils.notify(deferred_load)) self.__thing.timer_slow(500) return async .success()
def __open(self,arg,id): id = action.abstract_string(id) if self.set_plugin(id): return action.nosync_return() return async.success(errors.doesnt_exist('plugin "%s"'%id,'open'))