def foo(): debug('foo: Hi World', label="LABEL") debug([1, 2, 3]) for i in range(3): debug("Now we're cookin") check("invariant: %d < 2" % i, lambda: i < 2) for j in range(debug(1, label="ONE")): debug("nested loop", enabled=True) return "42"
def foo(): debug('foo: Hi World', label="LABEL") debug("foo: well") for i in range(3): debug("foo: Now we're cookin") check(f"invariant: {i} < 2", lambda: i < 2) for i in range(debug(1, label="ONE")): debug("foo: 2 tabs in", enabled=True) return "42"
def search(self, grep): for w in sh("wmctrl -l -G -p"): tok = w.split() if (type(grep) == int and str(grep) == w[2]) or \ (type(grep) == str and grep in w): self.wid = tok[0] self.pid = int(tok[2]) self.rx = int(tok[3])/2 self.ry = int(tok[4])/2 dbg.debug("found: %s, (%s,%s) = %s by %s" \ % (self.pid, self.rx, self.ry, self.wid, grep)) break
def process_action(self): self.next = self.pick_action dbg.infom( '*', '%s:%s' % (prettify(self.action), "same" if self.action.equiv() else "#R<changed#>")) # dbg.infom('*', '[%s]%s:%s' % (prettify(self.action.tic), # prettify(self.action), # "S" if self.action.equiv() else "#R<D#>")) # ipopov: conjecture: # The purpose of this if/elif/else chain is to prevent the redo # from continuing if any of the statements in the elif's return to # the effect that other nodes have been updated during this pass # through process_action(). Why do we care? Because this class is # implemented as a state machine, and processing maintains the # invariant that the action being redone now is the earliest one. # But connect() and prepare_redo() may affect the invariant. if (not self.action.cancel and self.action.equiv() and all([ self.cur_state[n] >= self.action for n in self.action.outputs | set([self.action.actor]) ])): dbg.info('skipping', self.action) for n in self.action.inputs: self.set_cs(n, max(self.cur_state[n], self.action)) self.set_color(self.action, self.colors['skipped']) elif not self.action.connect(): dbg.debug('retrying after connect') elif not self.prepare_redo(): dbg.debug('retrying after prepare') elif self.action.cancel: if hasattr(self.action, 'cancel_hook'): self.action.cancel_hook() dbg.info('cancelled action', self.action) self.next = self.update_state self.set_color(self.action, self.colors['cancelled']) else: dbg.info('#G<redoing#> ', prettify(self.action)) self.save_ckpts(self.action.outputs, self.action) try: self.action.redo() except mgrapi.ReschedulePendingException: dbg.info('rescheduling %s' % prettify(self.action)) return else: self.next = self.update_state self.set_color(self.action, self.colors['redone'])
def run_poll(self, action): while True: if self.run.poll() is not None: for a in [x for x in self.actions if x > action]: if not isinstance(a, PhpExit): cancel_action(a) return with open(self.log_file, 'r') as f: m = f.read() if '\n' in m: self.runmsg = m open(self.log_file, 'w').close() break dbg.debug('php message', self.runmsg.strip()) (_, _, type, _, _) = self.runmsg.strip().split(' ') nextact = min([x for x in self.actions if x > action]) ts = util.between(action.tac, nextact.tic) if type == 'query': q = DbQueryAction(('nquery', self.pid, time.time())) q.tic = ts + (3, ) q.tac = ts + (4, ) q.argsnode = mgrutil.BufferNode(q.name + ('args', ), ts + (2, ), None) q.retnode = mgrutil.BufferNode(q.name + ('ret', ), ts + (5, ), None) q.connect() c = PhpDbCall(self, q.argsnode) c.tic = ts c.tac = ts + (1, ) c.connect() r = PhpDbRet(self, q.retnode) r.tic = ts + (6, ) r.tac = ts + (7, ) r.connect() else: raise Exception('unknown PHP message type', type)
def bar(i, j=None): debug("bar " + str(i)) debug(pp_stuff, pretty=False) if i > 1: bar(i - 1) return "99", i else: debug(pp_stuff, pretty=True) return foo(), i
def redo(self): dbg.debug('php response', self.retnode.data) with open(self.actor.get_file, 'w') as f: f.write(urllib.quote(self.retnode.data)) self.actor.run_poll(self)
self.pid1.setSetPoint(self.pid1.getSetPoint()+(self.ramp/60.*delta_t)) elif(self.pid1.getSetPoint() > self.setPoint ) : self.pid1.setSetPoint(self.pid1.getSetPoint()-self.ramp/60.*delta_t) else: self.pid1.setSetPoint(self.setPoint) self.ntc1.update() self.ntc2.update() if self.ctl1.isRunning(): self.pid1.calculate(self.t1.getVal()) self.comm.update() time.sleep(1) # self.fh.write("%s;%2.2f;%2.2f;%2.2f;%3.2f\n"% # self.logger.add([round(time.time(),2), #round(self.pid1.getCtlSig(),2),round(self.pid1.getCtlSig(),2),round(self.t1.getVal(),2),round(self.t1.getVal(),2)]) def main(): logging.basicConfig(format='%(asctime)s:%(levelname)s:%(message)s', filename='brew.log', level=logging.DEBUG,datefmt='%d.%m.%Y %H:%M:%S') logging.debug('Start') s=start() s.mainLoop() if __name__=="__main__": import dbg from os import path if path.exists("/tmp/brewdbg"): dbg.debug() main()