def main(**settings): """ This function returns a Pyramid WSGI application. """ listen() # Load dragon configuration conf.load("jarvis") # Setup logging # logging.config.dictConfig(jarvis.LOGGING) # Start the frontend greenlets and create the WSGI application _frontend = frontend.Frontend() _frontend.start(start_wsgi_server=True, forever=True)
def main(**settings): """ This function returns a Pyramid WSGI application. """ listen() # Load dragon configuration conf.load("jarvis") # Setup logging #logging.config.dictConfig(jarvis.LOGGING) # Start the frontend greenlets and create the WSGI application _frontend = frontend.Frontend() _frontend.start(start_wsgi_server=True, forever=True)
def setUp(self): conf.load("jarvis", defaults = {"REDIS_DB":10}) # Refresh the temporary directory try: shutil.rmtree(tmp_dir, True) except: pass os.makedirs(tmp_dir) try: os.makedirs(data_dir) except: pass self.mox = mox.Mox()
def setUp(self): conf.load("jarvis", defaults={"REDIS_DB": 10}) # Refresh the temporary directory try: shutil.rmtree(tmp_dir, True) except: pass os.makedirs(tmp_dir) try: os.makedirs(data_dir) except: pass self.mox = mox.Mox()
def __init__(self): # Build the name parts parts = ["agents", self.__class__.__name__.lower()] # Build the name name = "_".join(parts) # Build the config file name subpath = os.path.join(*parts) + ".py" # Assemble the config pathes basepathes = ["/etc/jarvis", os.path.join(os.getenv("HOME"), ".jarvis.d", "conf")] pathes = [] for p in basepathes: pathes += [os.path.join(p, subpath)] # Load the conf conf.load(name, pathes = pathes) # Retrieve the object containing the conf self.conf = getattr(conf, name) self.client = client.Client()
import jarvis.utils.conf as conf import urllib conf.load("jarvis", defaults = {"SERVER_ADDRESS":"127.0.0.1", "SERVER_PORT":9107}) class Client(object): def __init__(self): self.address = conf.jarvis.SERVER_ADDRESS self.port = conf.jarvis.SERVER_PORT def update(self, id, op, content): body = urllib.urlencode({"op":op, "content":content}) print "CONF JARVIS", dir(conf.jarvis) base_url = "http://%s:%s/state/update/" % (conf.jarvis.SERVER_ADDRESS, conf.jarvis.SERVER_PORT) response = urllib.urlopen(base_url + id + "/", body).read() print "response=", response if response != "OK": raise Exception(response)
def test_bad_load(self): with self.assertRaises(NameError): conf.load("jarvis", pathes= [self.data_file_name("serverconf_bad.py")])
def test_load(self): conf.load("jarvis", pathes=[self.data_file_name("serverconf.py")]) self.assertTrue(conf.jarvis.a == "b") self.assertTrue(conf.jarvis.c == "bbbb")
import jarvis.utils.conf as conf import urllib conf.load("jarvis", defaults={ "SERVER_ADDRESS": "127.0.0.1", "SERVER_PORT": 9107 }) class Client(object): def __init__(self): self.address = conf.jarvis.SERVER_ADDRESS self.port = conf.jarvis.SERVER_PORT def update(self, id, op, content): body = urllib.urlencode({"op": op, "content": content}) print "CONF JARVIS", dir(conf.jarvis) base_url = "http://%s:%s/state/update/" % (conf.jarvis.SERVER_ADDRESS, conf.jarvis.SERVER_PORT) response = urllib.urlopen(base_url + id + "/", body).read() print "response=", response if response != "OK": raise Exception(response)
import jarvis.utils.conf as conf import os.path import jarvis.client as client conf.load("jarvis") class Agent(object): def __init__(self): # Build the name parts parts = ["agents", self.__class__.__name__.lower()] # Build the name name = "_".join(parts) # Build the config file name subpath = os.path.join(*parts) + ".py" # Assemble the config pathes basepathes = ["/etc/jarvis", os.path.join(os.getenv("HOME"), ".jarvis.d", "conf")] pathes = [] for p in basepathes: pathes += [os.path.join(p, subpath)] # Load the conf conf.load(name, pathes = pathes) # Retrieve the object containing the conf self.conf = getattr(conf, name) self.client = client.Client()