コード例 #1
0
ファイル: sample1.py プロジェクト: parker1333752/svc_analyzer
def connect_handler(socket):
    vertx.logger().info('I am connected')

    @socket.data_handler
    def receive(buffer):
        vertx.logger().info('receive %d bytes of data, <%s>'%(buffer.length,buffer))

    def period_send(tid):
        socket.write_str('hello socket\r\n')
    tid=vertx.set_periodic(1000,period_send)

    @socket.close_handler
    def closed():
        vertx.logger().info('I am disconnected')
コード例 #2
0
def connect_handler(socket):
    vertx.logger().info('I am connected')

    @socket.data_handler
    def receive(buffer):
        vertx.logger().info('receive %d bytes of data, <%s>' %
                            (buffer.length, buffer))

    def period_send(tid):
        socket.write_str('hello socket\r\n')

    tid = vertx.set_periodic(1000, period_send)

    @socket.close_handler
    def closed():
        vertx.logger().info('I am disconnected')
コード例 #3
0
import vertx
from core.event_bus import EventBus
from core.file_system import FileSystem
from core.http import RouteMatcher 

from server import upload
from server import file_service
#inicialize
server = vertx.create_http_server()

route_matcher = RouteMatcher()
logger = vertx.logger()
fs = vertx.file_system()
app_config = vertx.config()

#set global
path_web = app_config['paths']['web']
path_public = app_config['paths']['path_public']
path_symlink = app_config['paths']['path_symlink']

#cros module variable
##TODO
upload.path_public = path_public
file_service.path_public = path_public
file_service.path_private = app_config['paths']['path_private']
upload.path_symlink = path_symlink
upload.path_upload = app_config['paths']['path_private']
upload.path_temp = app_config['paths']['path_temp']

def index_handler(req):    
    req.response.send_file( "%sindex.html"% path_web)
コード例 #4
0
def listen_handler(err, server):
    if err is None:
        vertx.logger().info('Server is listen OK')
    else:
        err.printStackTrace()
コード例 #5
0
 def closed():
     vertx.logger().info('I am disconnected')
コード例 #6
0
 def receive(buffer):
     vertx.logger().info('receive %d bytes of data, <%s>' %
                         (buffer.length, buffer))
コード例 #7
0
import vertx
from core.event_bus import EventBus
import uuid

logger = vertx.logger()


class CredentialManager(object):
    ADDRESS = 'hbdriver:credentials'

    def __init__(self, credentials, address=ADDRESS):
        self._pool = list(credentials)
        self._inuse = {}
        EventBus.register_handler(address, handler=self.handle)

    def handle(self, msg):
        cmd = msg.body['command']
        actor = msg.body['id']
        if cmd == 'acquire':
            try:
                creds = self._pool.pop(0)
                self._inuse[actor] = creds
                logger.info("%s has acquired credentials" % actor)
                msg.reply(dict(status=200, credentials=creds))
            except IndexError:
                msg.reply(dict(status=404, msg="No credentials available"))
        if cmd == 'release':
            try:
                creds = self._inuse.pop(actor)
                self._pool.append(creds)
                logger.info("%s has released credentials" % actor)
コード例 #8
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import vertx

from frobnicate import handler

_log = vertx.logger()

_log.info("hello there")

server = vertx.create_http_server()
server.request_handler(handler)
server.listen(8080)
コード例 #9
0
ファイル: sample1.py プロジェクト: parker1333752/svc_analyzer
def listen_handler(err, server):
    if err is None:
        vertx.logger().info('Server is listen OK')
    else:
        err.printStackTrace()
コード例 #10
0
ファイル: sample1.py プロジェクト: parker1333752/svc_analyzer
 def closed():
     vertx.logger().info('I am disconnected')
コード例 #11
0
ファイル: sample1.py プロジェクト: parker1333752/svc_analyzer
 def receive(buffer):
     vertx.logger().info('receive %d bytes of data, <%s>'%(buffer.length,buffer))
コード例 #12
0
ファイル: data_producer.py プロジェクト: logart/vertx
import vertx
import random as rnd
import time as time
from core.event_bus import EventBus


def create_package():
    result = {
        'time': int(round(time.time() * 1000)),
        'data': 200  #rnd.randint(0,500),
    }

    return result


def handler(tid):
    EventBus.publish("data.source.raw", create_package())


tid = vertx.set_periodic(1, handler=handler)

vertx.logger().info("DataProducer started")