コード例 #1
0
def main():
    common.configure_logging()
    parser = argparse.ArgumentParser()
    parser.add_argument('num_sources', type=int, nargs='?',
                        default=DEFAULT_NUM_SOURCES)
    parser.add_argument('server_host', nargs='?',
                        default=common.DEFAULT_SERVER_HOST)
    args = parser.parse_args()

    capture = cv2.VideoCapture(0)
    def gen_producer(n):
        text = 'client {}'.format(n)
        async def producer():
            _, frame = capture.read()
            cv2.putText(frame, text, ORG, FONT_FACE, FONT_SCALE, COLOR)
            _, jpeg_frame=cv2.imencode('.jpg', frame)
            input_frame = gabriel_pb2.InputFrame()
            input_frame.payload_type = gabriel_pb2.PayloadType.IMAGE
            input_frame.payloads.append(jpeg_frame.tobytes())

            return input_frame
        return producer

    producer_wrappers = [
        ProducerWrapper(producer=gen_producer(i), source_name=str(i))
        for i in range(args.num_sources)
    ]
    client = WebsocketClient(
        args.server_host, common.WEBSOCKET_PORT, producer_wrappers,
        push_source.consumer)
    client.launch()
コード例 #2
0
def main():
    common.configure_logging('korred')
    data = common.Data()
    handler = Handler(data=data)
    NativeMessageInterface(
        callback=handler.handle,
        interactive=os.getenv('INTERACTIVE', False),
    ).run()
コード例 #3
0
ファイル: engine.py プロジェクト: OFIGroup/gabriel
def main():
    common.configure_logging()
    args = common.parse_source_name_server_host()
    engine = DisplayEngine(args.source_name)

    server_address = SERVER_ADDRESS_FORMAT.format(args.server_host,
                                                  common.ZMQ_PORT)
    engine_runner.run(engine, args.source_name, server_address)
コード例 #4
0
ファイル: push_client.py プロジェクト: OFIGroup/gabriel
def main():
    common.configure_logging()
    args = common.parse_source_name_server_host()
    source = push_source.Source(args.source_name)
    p = multiprocessing.Process(target=send_frames, args=(source, ))
    p.start()
    producer_wrappers = [source.get_producer_wrapper()]
    client = WebsocketClient(args.server_host, common.WEBSOCKET_PORT,
                             producer_wrappers, push_source.consumer)
    client.launch()
    p.terminate()
コード例 #5
0
ファイル: server.py プロジェクト: OFIGroup/gabriel
def main():
    common.configure_logging()
    parser = argparse.ArgumentParser()
    parser.add_argument(
        'source_name', nargs='?', default=common.DEFAULT_SOURCE_NAME)
    args = parser.parse_args()

    def engine_factory():
        return DisplayEngine()

    local_engine.run(engine_factory, args.source_name, input_queue_maxsize=60,
                     port=common.WEBSOCKET_PORT, num_tokens=2)
コード例 #6
0
ファイル: client.py プロジェクト: OFIGroup/gabriel
def main():
    common.configure_logging()
    parser = argparse.ArgumentParser()
    parser.add_argument('source_name',
                        nargs='?',
                        default=common.DEFAULT_SOURCE_NAME)
    parser.add_argument('server_host', nargs='?', default=DEFAULT_SERVER_HOST)
    args = parser.parse_args()

    capture = cv2.VideoCapture(0)
    opencv_adapter = OpencvAdapter(preprocess, produce_extras, consume_frame,
                                   capture, args.source_name)

    client = WebsocketClient(args.server_host, common.WEBSOCKET_PORT,
                             opencv_adapter.get_producer_wrappers(),
                             opencv_adapter.consumer)
    client.launch()
コード例 #7
0
    # Do useful things with it

    # Look in the object store
    c_list = client_manager.object_store.container_list()
    print("Name\tCount\tBytes")
    for c in c_list:
        print("%s\t%d\t%d" % (c['name'], c['count'], c['bytes']))

    if len(c_list) > 0:
        # See what is in the first container
        o_list = client_manager.object_store.object_list(c_list[0]['name'])
        print("\nObject")
        for o in o_list:
            print("%s" % o)

    # Look at the compute flavors
    flavor_list = client_manager.compute.flavors.list()
    print("\nFlavors:")
    for f in flavor_list:
        print("%s" % f)


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='ClientManager Example')
    opts = common.base_parser(
        clientmanager.build_plugin_option_parser(parser),
    ).parse_args()

    common.configure_logging(opts)
    sys.exit(common.main(opts, run))
コード例 #8
0
ファイル: datavis.py プロジェクト: serjinio/python_tutors
            return
        if len(df) < 100:
            drawstyle = {'linestyle': 'None', 'marker': 'o',
                         'markersize': 6}
        else:
            drawstyle = {}
        for c in df.columns:
            if isinstance(df[c][df.index[0]], complex):
                axes.plot(df.index, np.real(df[c]),
                          label=name + " - Re(" + str(c) + ")", **drawstyle)
                axes.plot(df.index, np.imag(df[c]),
                          label=name + " - Im(" + str(c) + ")", **drawstyle)
            else:
                axes.plot(df.index, df[c], label=name + " - " + str(c),
                          **drawstyle)

    def _draw_sample_sine(self):
        args = np.arange(1000.)
        df = pd.DataFrame(np.sin(np.radians(args)), index=args, columns=['y'])
        self.add_object(df, 'sin(x)')

    def _exit(self):
        self.window.destroy()


if __name__ == '__main__':
    common.configure_logging()
    root = tk.Tk()
    data_viewer(root)
    root.mainloop()
コード例 #9
0
pointsWritten = 0  # keeps track of the points written in the last 10 minutes

points_lock = threading.Lock()
devices_lock = threading.Lock()
transducers_dict_lock = threading.Lock()
transducers_locks = dict()

# Change Thread name in Python 3.6+
if sys.version_info.major >= 3 and sys.version_info.minor > 5:
    ex = ThreadPoolExecutor(max_workers=NUM_THREAD_WORKERS,
                            thread_name_prefix="Consumer")
else:
    ex = ThreadPoolExecutor(max_workers=NUM_THREAD_WORKERS)

# set logging configurations
common.configure_logging(conf)

# create Influx client
influx_client = influxdb.InfluxDBClient(conf['influxdb_host'],
                                        conf['influxdb_port'],
                                        conf['influxdb_user'],
                                        conf['influxdb_password'],
                                        INFLUX_DATABASE)

# start mqtt client
mqtt_client = MqttClient(host=conf['mqtt_broker'],
                         port=conf['mqtt_broker_port'],
                         client_id=conf['client_id'],
                         service_id=conf['service_id'],
                         password=conf['password'],
                         enable_ssl=bool(conf['enable_ssl']),
コード例 #10
0
def main():
    global root_dir
    arg_parser = argparse.ArgumentParser()
    arg_parser.add_argument('--output-dir', '-d')
    arg_parser.add_argument('--test-domain',
                            '-t',
                            default='testobjects.cedexis.localhost')
    arg_parser.add_argument(
        '--verbose',
        '-v',
        action='count',
        default=0,
        help=
        'Verbosity level; you can specify up to 3 times for increasing detail')
    args = arg_parser.parse_args()
    common.configure_logging(args.verbose)

    if not args.output_dir is None:
        root_dir = args.output_dir

    # `multiple` are multiples of 1024
    file_sizes = [
        None,
        {
            'multiple':
            2,
            'prefix':
            'r16',
            'generator_fn':
            generate_test_object(create_javascript_output),
            'compressors': [
                {
                    'compressor': common.compression.identity_compressor,
                    'padding_start_size': int(9.86e2),
                    'padding_file': 'padding-200K.txt',
                },
                {
                    'compressor': common.compression.gzip_compressor,
                    'padding_start_size': int(1.14e3),
                    'padding_file': 'padding-200K.txt',
                },
            ]
        },
        {
            'multiple':
            15,
            'prefix':
            'r16',
            'generator_fn':
            generate_test_object(create_javascript_output),
            'compressors': [
                {
                    'compressor': common.compression.identity_compressor,
                    'padding_start_size': int(6.214e3),
                    'padding_file': 'padding-200K.txt',
                },
                {
                    'compressor': common.compression.gzip_compressor,
                    'padding_start_size': int(9.227e3),
                    'padding_file': 'padding-200K.txt',
                },
            ]
        },
        {
            'multiple':
            100,
            'prefix':
            'r16xl',
            'generator_fn':
            generate_test_object(create_javascript_output),
            'compressors': [
                #{
                #    'compressor': common.compression.identity_compressor,
                #    'padding_start_size': int(4.178e4),
                #    'padding_file': 'padding-200K.txt',
                #},
                {
                    'compressor': common.compression.gzip_compressor,
                    'padding_start_size': int(6.612e4),
                    'padding_file': 'padding-200K.txt',
                },
            ]
        },
        {
            'multiple':
            15,
            'filename':
            'r16.html',
            'generator_fn':
            generate_test_object(create_dsa_output),
            'compressors': [
                #{
                #    'compressor': common.compression.identity_compressor,
                #    'padding_start_size': int(5.5e3),
                #    'padding_file': 'padding-200K.txt',
                #},
                {
                    'compressor': common.compression.gzip_compressor,
                    'padding_start_size': int(9e3),
                    'padding_file': 'padding-200K.txt',
                },
            ]
        },
    ]

    try:
        for file_size_info in file_sizes:
            if file_size_info is None:
                logger.info('Producing small test object')
                output_file_path = os.path.join(root_dir, 'r16.js')
                if os.path.exists(output_file_path):
                    os.unlink(output_file_path)
                output = create_javascript_output(None)
                common.compression.identity_compressor.generate_compressed_file(
                    output, root_dir, 'r16.js')
            else:
                for compressor_info in file_size_info['compressors']:
                    file_size_info['generator_fn'](file_size_info,
                                                   compressor_info,
                                                   args.test_domain)

    except common.errors.InvalidJavaScriptError as e:
        logger.error('Exception: %r', e)
        raise
コード例 #11
0
ファイル: korredd.py プロジェクト: dair-targ/Korred
            ]),
            app='Console',
            new_instance=False,
        )


def main():
    data = common.Data()
    with Daemon(data):
        # TODO: Check for configuration validity and ask user if the old configuration should be kept
        NativeMessagingConfiguration().write()
        launchctl_manager = LaunchctlManager()
        app = App(launchctl_manager)
        menu_item = rumps.MenuItem(title='Launch at Login')
        menu_item.state = launchctl_manager.is_loaded()
        app.menu = [
            'Install Firefox Extension...',
            menu_item,
            'View Logs',
        ]
        app.run()


if __name__ == "__main__":
    common.configure_logging('korredd')
    try:
        main()
    except Exception as e:
        logging.critical('Critical error', e)
    logging.info('Quit korredd')