Пример #1
0
r = Rabbit(credentials=credentials,
           host=host,
           vhost_name=vhost_name,
           profession="agent",
           name="S1_zip",
           data_type="S1_zip")


def forward_message(**msg):
    """
    Always use the same kwarg names as defined in the structure of JSON-message.
    On function call kwarg values will be assigned according to received message.
    The following kwargs are available:
        - msg["time"]
        - msg["source_data"]
        - msg["out_dir"]
        - msg["options"]
    """
    payload = {
        "time": msg["time"],
        "source_data": msg["source_data"],
        "out_dir": msg["out_dir"],
        "options": msg["options"]
    }
    r.say(payload)


r.duty = forward_message

r.run()
Пример #2
0
           host=host,
           vhost_name=vhost_name,
           profession="unit",
           name="S1NGWUnit",
           data_type="S1_render")


def publish(**msg):
    """
    Always use the same kwarg names as defined in the structure of JSON-message.
    On function call kwarg values will be assigned according to received message.
    The following kwargs are available:
        - msg["time"]
        - msg["source_data"]
        - msg["out_dir"]
        - msg["options"]
    """
    result = None
    try:
        source_data = msg["source_data"]
        out_dir = msg["out_dir"]
        shutil.copy2(out_dir + source_data, out_dir + "NGW/" + source_data)
    except TypeError:
        pass
    return result


r.duty = publish

r.run()
Пример #3
0
           vhost_name=vhost_name,
           profession="unit",
           name="S1RenderUnit",
           data_type="S1_zip")


def render(**msg):
    """
    Always use the same kwarg names as defined in the structure of JSON-message.
    On function call kwarg values will be assigned according to received message.
    The following kwargs are available:
        - msg["time"]
        - msg["source_data"]
        - msg["out_dir"]
        - msg["options"]
    """
    result = None
    try:
        source_data = msg["source_data"]
        out_dir = msg["out_dir"]
        s = S1L1Tools(out_dir + source_data)
        s.render(out_dir, ["HH"])
    except TypeError:
        pass
    return result


r.duty = render

r.run()
Пример #4
0
def unpack(**msg):
    """
    Always use the same kwarg names as defined in the structure of JSON-message.
    On function call kwarg values will be assigned according to received message.
    The following kwargs are available:
        - msg["time"]
        - msg["source_data"]
        - msg["out_dir"]
        - msg["options"]
    """
    try:
        source_data = msg["source_data"]
        out_dir = msg["out_dir"]
        full_path = os.path.join(out_dir, source_data)
        s = S1L1Tools(full_path)
        s.export_to_l2(out_dir,
                       projection='+proj=longlat +datum=WGS84 +no_defs',
                       x_scale=1,
                       y_scale=1)
    except OSError as e:  # more likely this is "FileNotFoundError" - wrong source_data path
        print str(e)
        pass
    except Exception as e:  # and these are all other exceptions
        print str(e)
        pass


r.duty = unpack

r.run()