def send_message(text=None, recipient=None): if recipient is None: recipient = ui.ask_value("recipient", "Message recipient") if text is None: text = ui.ask_value("text", "Message text") payload = {"recipient": recipient, "message": text} r = requests.post(SEND_ADDRESS, data=payload) if r.status_code != requests.codes.ok: ui.inform("Failed with code: %s" % r.status_code) exit() ui.inform("Sent message with id %s" % r.content)
def send_message(text=None, recipient=None): if recipient is None: recipient = ui.ask_value("recipient", "Message recipient") if text is None: text = ui.ask_value("text", "Message text") message = client.message_send(cfg.get('ENDPOINT_ID'), cfg.get('MIXNET_ID'), cfg.get('MIXERS'), text, recipient) ui.inform("Sent message with id %s" % message['id'])
def main(text=None, recipient=None): ui.inform("Welcome to Panoramix sphinxmix agent!") ui.inform("Configuration file is: %s" % config_file) ui.inform("Set PANORAMIX_CONFIG environment variable to override") url = on("MIXNET_URL", lambda: ui.ask_value("MIXNET_URL", "Give sphinxmix mixnet URL")) mixnet_url_process(url) on("KEY", set_key_wizard) agent.main()
def main(): ui.inform("Welcome to Panoramix client!") ui.inform("Configuration file is: %s" % config_file) ui.inform("Set PANORAMIX_CONFIG environment variable to override") args = parser.parse_args() if args.output is None and args.ack is None: send_message() return if args.output is not None: output_cycle(args.output) if args.ack is not None: ack_cycle(args.ack)
def ack_cycle(cycle): client = SphinxmixClient() client.register_catalog_url(cfg.get('CATALOG_URL')) output_endpoint_id = '%s_output' % cfg.get('ENDPOINT_ID') r = client.cycle_set_state(output_endpoint_id, cycle, 'ACK') ui.inform(r)
def output_cycle(cycle): client = SphinxmixClient() client.register_catalog_url(cfg.get('CATALOG_URL')) output_endpoint_id = '%s_output' % cfg.get('ENDPOINT_ID') messages = client.messages_list(output_endpoint_id, cycle=cycle) ui.inform(messages)