def ping(self, ip=False): host = DBSession.query(s.host).filter(s.host.ip_as_int == ipToInt(ip)).first() result = pingSMB(ip) if host: DBSession.add(s.ping(host, result)) DBSession.commit() return dict(page='ping', time=result, host=ip)
def pinboard(self, author=None, text=None, offset=0, length=20): offset = int(offset) length = int(length) if author and text: # create new post newpost = post() newpost.author = author newpost.text = text newpost.date = datetime.now() DBSession.add(newpost) DBSession.commit() posts = DBSession.query(post).order_by(post.date.desc())[offset:offset+length] return dict(page="PinBoard", offset=offset, length=length, posts=posts)