Exemple #1
0
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)
Exemple #2
0
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)
Exemple #3
0
    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()
Exemple #4
0
    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()
Exemple #5
0
    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()
Exemple #6
0
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)
Exemple #7
0
 def test_bad_load(self):
     with self.assertRaises(NameError):
         conf.load("jarvis", pathes= [self.data_file_name("serverconf_bad.py")])
Exemple #8
0
 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")
Exemple #9
0
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)
Exemple #10
0
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()