示例#1
0
def test_add_import_hook():
    capnp.add_import_hook([this_dir])

    # Make sure any previous imports of addressbook_capnp are gone
    capnp.cleanup_global_schema_parser()

    import addressbook_capnp
    addressbook_capnp.AddressBook.new_message()
示例#2
0
def test_remove_import_hook():
    capnp.add_import_hook([this_dir])
    capnp.remove_import_hook()

    if 'addressbook_capnp' in sys.modules:
        del sys.modules['addressbook_capnp'] # hack to deal with it being imported already

    with pytest.raises(ImportError):
        import addressbook_capnp
示例#3
0
def test_remove_import_hook():
    capnp.add_import_hook([this_dir])
    capnp.remove_import_hook()

    if 'addressbook_capnp' in sys.modules:
        # hack to deal with it being imported already
        del sys.modules['addressbook_capnp']

    with pytest.raises(ImportError):
        import addressbook_capnp  # noqa: F401
示例#4
0
def test_multiple_add_import_hook():
    capnp.add_import_hook()
    capnp.add_import_hook()
    capnp.add_import_hook([this_dir])

    import addressbook_capnp
    addressbook_capnp.AddressBook.new_message()
示例#5
0
def test_multiple_add_import_hook():
    capnp.add_import_hook()
    capnp.add_import_hook()
    capnp.add_import_hook([this_dir])

    import addressbook_capnp
    addressbook_capnp.AddressBook.new_message()
示例#6
0
# Michael Berg-Mohnicke <*****@*****.**>
#
# Maintainers:
# Currently maintained by the authors.
#
# This file has been created at the Institute of
# Landscape Systems Analysis at the ZALF.
# Copyright (C: Leibniz Centre for Agricultural Landscape Research (ZALF)

import monica_io3
import time
import json
import sys
import os
import capnp
capnp.add_import_hook(additional_paths=[
                      "../../../../vcpkg/packages/capnproto_x64-windows-static/include/", "../../../../capnproto_schemas/"])
import common_capnp
import climate_data_capnp
import cluster_admin_service_capnp
import model_capnp


def main():

    config = {
        "port": "6666",
        "server": "localhost",
        "sim.json": os.path.join(os.path.dirname(__file__), '../sim-min.json'),
        "crop.json": os.path.join(os.path.dirname(__file__), '../crop-min.json'),
        "site.json": os.path.join(os.path.dirname(__file__), '../site-min.json'),
        "climate.csv": os.path.join(os.path.dirname(__file__), '../climate-min.csv'),
示例#7
0
def test_bundled_import_hook():
    # stream.capnp should be bundled, or provided by the system capnproto
    capnp.add_import_hook()
    import stream_capnp  # noqa: F401
示例#8
0
#!/usr/bin/env python
from __future__ import print_function
import os
import sys

import capnp
capnp.add_import_hook([os.getcwd(), "/usr/local/include/"])  # change this to be auto-detected?

import test_capnp  # noqa: E402


def decode(name):
    class_name = name[0].upper() + name[1:]
    print(getattr(test_capnp, class_name).from_bytes(sys.stdin.read())._short_str())


def encode(name):
    val = getattr(test_capnp, name)
    class_name = name[0].upper() + name[1:]
    message = getattr(test_capnp, class_name).from_dict(val.to_dict())
    print(message.to_bytes())


if sys.argv[1] == 'decode':
    decode(sys.argv[2])
else:
    encode(sys.argv[2])
示例#9
0
## $QT_END_LICENSE$
##
#############################################################################

import sys
from os.path import abspath, dirname, join

from PySide2.QtCore import QObject, Slot
from PySide2.QtGui import QGuiApplication
from PySide2.QtQml import QQmlApplicationEngine

from style_rc import *

import capnp
capnp.add_import_hook(additional_paths=[
    "../capnproto_schemas/", "../capnproto_schemas/capnp_schemas/"
])
#import model_capnp as m
import climate_data_capnp as cd

cmip_service = capnp.TwoPartyClient("localhost:9000").bootstrap().cast_as(
    cd.Climate.Service)


class Bridge(QObject):
    def callCallback(self, info):
        print(info)
        print("still isCallable:", self._cb.isCallable())
        self._cb.call([info.name])

    @Slot("QJSValue")
示例#10
0
#!/usr/bin/env python
from __future__ import print_function
import capnp
import os
capnp.add_import_hook([os.getcwd(), "/usr/local/include/"]) # change this to be auto-detected?

import test_capnp

import sys

def decode(name):
    class_name = name[0].upper() + name[1:]
    print(getattr(test_capnp, class_name).from_bytes(sys.stdin.read())._short_str())

def encode(name):
    val = getattr(test_capnp, name)
    class_name = name[0].upper() + name[1:]
    message = getattr(test_capnp, class_name).from_dict(val.to_dict())
    print(message.to_bytes())

if sys.argv[1] == 'decode':
    decode(sys.argv[2])
else:
    encode(sys.argv[2])
示例#11
0
import sys
import os
from datetime import date, timedelta
import json
import time

import capnp

capnp.add_import_hook(additional_paths=["capnproto_schemas"])
import fbp_capnp


class Process(fbp_capnp.FBP.Input.Server):
    def __init__(self, out):
        self._out = out

    def input_context(self, context):  # (data :Text);
        data = context.params.data
        time.sleep(1)
        self._out.input(data + " -> output")
        print("outputed", data + " -> output")


class Consumer(fbp_capnp.FBP.Input.Server):
    def __init__(self):
        self.count = 0
        self.start = 0

    def input(self, data, _context, **kwargs):  # (data :Text);
        if self.count == 0:
            self.start = time.time()