Ejemplo n.º 1
0
def load(hostname):
    global __config

    ses = osrf.ses.ClientSession(OSRF_APP_SETTINGS)
    req = ses.request(OSRF_METHOD_GET_HOST_CONFIG, hostname)
    resp = req.recv(timeout=30)
    __config = resp.content()
    req.cleanup()
    ses.cleanup()
Ejemplo n.º 2
0
def load(hostname):
    global __config

    ses = osrf.ses.ClientSession(OSRF_APP_SETTINGS)
    req = ses.request(OSRF_METHOD_GET_HOST_CONFIG, hostname)
    resp = req.recv(timeout=30)
    __config = resp.content()
    req.cleanup()
    ses.cleanup()
Ejemplo n.º 3
0
    def handle_math_bench(self, parts):
        ''' Sends a series of request to the opensrf.math service and collects timing stats. '''

        count = int(parts.pop(0))
        ses = osrf.ses.ClientSession('opensrf.math')
        times = []

        for cnt in range(100):
            if cnt % 10:
                sys.stdout.write('.')
            else:
                sys.stdout.write( str( cnt / 10 ) )
        print ""

        for cnt in range(count):
        
            starttime = time.time()
            req = ses.request('add', 1, 2)
            resp = req.recv(timeout=2)
            endtime = time.time()
        
            if resp.content() == 3:
                sys.stdout.write("+")
                sys.stdout.flush()
                times.append( endtime - starttime )
            else:
                print "What happened? %s" % str(resp.content())
        
            req.cleanup()
            if not ( (cnt + 1) % 100):
                print ' [%d]' % (cnt + 1)
        
        ses.cleanup()
        total = 0
        for cnt in times:
            total += cnt 
        print "\naverage time %f" % (total / len(times))
Ejemplo n.º 4
0
    def handle_math_bench(self, parts):
        ''' Sends a series of request to the opensrf.math service and collects timing stats. '''

        count = int(parts.pop(0))
        ses = osrf.ses.ClientSession('opensrf.math')
        times = []

        for cnt in range(100):
            if cnt % 10:
                sys.stdout.write('.')
            else:
                sys.stdout.write(str(cnt / 10))
        print ""

        for cnt in range(count):

            starttime = time.time()
            req = ses.request('add', 1, 2)
            resp = req.recv(timeout=2)
            endtime = time.time()

            if resp.content() == 3:
                sys.stdout.write("+")
                sys.stdout.flush()
                times.append(endtime - starttime)
            else:
                print "What happened? %s" % str(resp.content())

            req.cleanup()
            if not ((cnt + 1) % 100):
                print ' [%d]' % (cnt + 1)

        ses.cleanup()
        total = 0
        for cnt in times:
            total += cnt
        print "\naverage time %f" % (total / len(times))
Ejemplo n.º 5
0
            content = resp.content()

            if content is not None:
                last_content = content
                if self.get_var('SRFSH_OUTPUT_NET_OBJ_KEYS') == 'true':
                    self.report("Received Data: %s\n" % osrf.json.debug_net_object(content))
                else:
                    if self.get_var('SRFSH_OUTPUT_FORMAT_JSON') == 'true':
                        self.report("Received Data: %s\n" % osrf.json.pprint(osrf.json.to_json(content)))
                    else:
                        self.report("Received Data: %s\n" % osrf.json.to_json(content))

        req.cleanup()
        if not using_active:
            ses.cleanup()

        self.report("\n" + '-'*60 + "\n")
        self.report("Total request time: %f\n" % total)
        self.report('-'*60 + "\n")

        return last_content


    def handle_math_bench(self, parts):
        ''' Sends a series of request to the opensrf.math service and collects timing stats. '''

        count = int(parts.pop(0))
        ses = osrf.ses.ClientSession('opensrf.math')
        times = []
Ejemplo n.º 6
0
                last_content = content
                if self.get_var('SRFSH_OUTPUT_NET_OBJ_KEYS') == 'true':
                    self.report("Received Data: %s\n" %
                                osrf.json.debug_net_object(content))
                else:
                    if self.get_var('SRFSH_OUTPUT_FORMAT_JSON') == 'true':
                        self.report(
                            "Received Data: %s\n" %
                            osrf.json.pprint(osrf.json.to_json(content)))
                    else:
                        self.report("Received Data: %s\n" %
                                    osrf.json.to_json(content))

        req.cleanup()
        if not using_active:
            ses.cleanup()

        self.report("\n" + '-' * 60 + "\n")
        self.report("Total request time: %f\n" % total)
        self.report('-' * 60 + "\n")

        return last_content

    def handle_math_bench(self, parts):
        ''' Sends a series of request to the opensrf.math service and collects timing stats. '''

        count = int(parts.pop(0))
        ses = osrf.ses.ClientSession('opensrf.math')
        times = []

        for cnt in range(100):