Example #1
0
def regen_identity():
    uuid = config.get_uuid()
    if uuid == "":
        uuid = generate_uuid()
    psw = gen_random_text(6)
    config.set_uuid_psw(uuid, psw)
    gen_identity_img()
Example #2
0
def gen_identity():
    if config.get_uuid() == "":
        uuid = generate_uuid()
        psw = gen_random_text(6)
        config.set_uuid_psw(uuid, psw)
    qrimg = os.path.join(config.PROJECT_DIR, config.get_identity_path())
    if not os.path.isfile(qrimg):
        gen_identity_img(qrimg)
Example #3
0
#!/usr/bin/env python

import socket, config, time
import sender, receiver, log
from message import MessageTransporter

if __name__ == '__main__':

    port = config.get_available_port()
    config.insert_proc_on_group (port)
    proc_id = config.get_uuid()
    ip = config.get_ip()
    transporter = MessageTransporter(ip, port) 

    log.log('process {proc_id} waiting for start at {ip}:{port}'.format(ip = ip, port=port, proc_id = proc_id))
    start_message = transporter.receive()
    log.log('{proc_id} received start message:[{msg}]'.format(proc_id = proc_id, msg = start_message))

    group = [proc for proc in config.get_group() if proc['port'] != port]
    send_msgs_count = int(start_message['start'])

    time.sleep(3)

    #starting receiver thread
    received_msgs_count = (len(group) + 1) * send_msgs_count
    receiver = receiver.Receiver(proc_id, group, received_msgs_count, transporter)
    receiver.start()

    #starting sender thread
    sender = sender.Sender(proc_id, group, send_msgs_count, transporter)
    sender.start()
Example #4
0
def gen_identity_img(qrimg):

    json_str = str({'UUID': config.get_uuid(), 'PSW': config.get_psw()})
    qr = pyqrcode.create(json_str)
    qr.png(qrimg, scale=5)