Ejemplo n.º 1
0
class System:
  def __init__(self):
    self.pathing = Pathing()
    self.turtles = {}
    self.validator = RequestValidator()
    self.storage = SQLiteStorage('/tmp/ccturtlesrv.db')
    
    names = self.storage.getAllTurtleNames()
    
    for name in names:
      self.turtles[name] = self.storage.loadTurtle(name)
      tornado.log.app_log.info("Loading turtle '{}'".format(name))
      
  def save(self):
    for turtle in self.turtles.itervalues():
      tornado.log.app_log.info("Saving {}".format(turtle.name))
      self.storage.saveTurtle(turtle)
    self.pathing.save()
    
  def addTurtle(self, turtle):
    self.turtles[turtle.getName()] = turtle
    
  def getTurtle(self, name):
    return self.turtles[name]
  
  def delTurtle(self, name):
    del self.turtles[name]
    self.storage.delTurtle(name)
  
  def hasTurtle(self, name):
    return self.turtles.has_key(name)
Ejemplo n.º 2
0
 def __init__(self):
   self.pathing = Pathing()
   self.turtles = {}
   self.validator = RequestValidator()
   self.storage = SQLiteStorage('/tmp/ccturtlesrv.db')
   
   names = self.storage.getAllTurtleNames()
   
   for name in names:
     self.turtles[name] = self.storage.loadTurtle(name)
     tornado.log.app_log.info("Loading turtle '{}'".format(name))