def __call__(self, db, known_hosts = dict()): nscache = dns_cache() for (section, params) in self.__sections: yield lookup_engines[section](db, self.__network, params, known_hosts, nscache)
return 'NULL' def getquoted(self): return 'NULL' psycopg2.extensions.register_adapter(list, list_adapter) psycopg2.extensions.register_adapter(type(None), None_adapter) if __name__ == "__main__": try: db = connectdb("pinger") except: print "I am unable to connect to the database, exiting." sys.exit() db.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) nscache = dns_cache() log("Starting pinger...") shares = 0 online = 0 start = datetime.datetime.now() for proto in default_ports.iteritems(): on, off = update_shares_state(db, "protocol='%s' AND port=0" % proto[0], proto[1]) shares += on + off online += on for port in get_shares_ports(db): on, off = update_shares_state(db, "port=%d" % port, port) shares += on + off online += on