Exemple #1
0
    def __init__(self, robot):
        self.robot = robot
        self.robot.init_robot_pos().wait_for_completed()

        self.logger = PykronLogger.getInstance()
        self.M = iCubStateMachine()

        self.yaw_threshold = 10
        self.gp_threshold = 5
        self.follow_threshold = 0.20  # follows for a between 0.0 and follow_threshold, max 1.0 for always

        self.log("init finished")

        # without allow_none the server will complain a lot about those functions not returning anything
        self.server = SimpleXMLRPCServer(('localhost', 8081),
                                         requestHandler=RequestHandler,
                                         allow_none=True)
        self.server.register_introspection_functions()

        # maybe forward the whole instance of the class?
        # TODO split it in half to allow that
        self.server.register_function(self.turnLeft, "turnLeft")
        self.server.register_function(self.turnRight, "turnRight")
        self.server.register_function(self.start_trial, "start_trial")
        self.server.register_function(self.end_trial, "end_trial")
Exemple #2
0
    def __init__(self):
        # WARNING not very pythonic way to check first, but I prefer it
        if hasattr(qApp, 'dekla'):
            raise Exception("Dekla can be __init__ed only once!")
        qApp.dekla = self  # link to the qApp instance

        super().__init__()
        self.windows = dict()
        self.stacks = dict()
        self.options = CuteOptions()

        # old yaml-based logger can be found in the archive/DeklaLogger.py
        self.logger = PykronLogger.getInstance()
Exemple #3
0
from pykron.core import Pykron, PykronLogger
import time
from io import StringIO

app = Pykron()


@app.AsyncRequest(timeout=120)
def fun4():
    logger.log.debug("Fun 4 reporting in")
    time.sleep(1)
    #fun3()
    logger.log.debug("Fun 4 reporting out")
    time.sleep(1)


output = StringIO()

logger = PykronLogger.getInstance()
# we manually add a FileHandler, but this is only for JSON
# execution statistics will not be saved
logger.addStreamHandler(stream=output, format=PykronLogger.FORMAT_JSON)

fun4()
time.sleep(2.5)

print('\n\nJSON stored in memory:')
print(output.getvalue())

app.close()
Exemple #4
0
 def test_create_pykron(self):
     app = Pykron()
     logger = PykronLogger.getInstance()
     app.close()
     time.sleep(1)  # it takes upwards of 25ms usually to stop the loop
     assert app.loop.is_running() == False
Exemple #5
0
''' how much time does it take to spin up a task? '''

import sys

sys.path.append('..')

from pykron.core import Pykron, Task, PykronLogger

import time
import logging
import threading

app = Pykron(logging_level=logging.DEBUG)
logging = PykronLogger.getInstance()


@app.AsyncRequest()
def foo1(t0):
    a = time.perf_counter() - t0
    logging.log.debug(a)
    time.sleep(0.5)


t0 = time.perf_counter()
mytask = foo1(t0)
time.sleep(1)

app.close()
Exemple #6
0
def level1_fun():
    logger = PykronLogger.getInstance()
    for i in range(0,90):
        time.sleep(0.1)
        logger.log.debug('I am still alive')