Problems closing a valve block with a Python Block

Hello:
We have successfully used a GUI block to open (or close) a valve by
pressing the mouse button.
Now we want to open (or close) the valve from a Python block that we
are writing after comparing two messages. If the messages are the same,
we want to open the valve, otherwise the valve should remain closed.

Below is the xml definition of our Python block as well as the Python
code. The problem we are having is that GRC does not allow us to compile
the code. The variable beacon_tx is not recognized by the valve block.

Can somebody help u with this issue?

Thanks.

XML FILE


<?xml version="1.0"?> compare conditions_compare conditions import conditions conditions.compare() in int

beacon_tx
in
int


PYTHON CODE


import numpy
import smbus
import time
import subprocess
beacon_tx
from gnuradio import gr

class compare(gr.sync_block):
“”"
docstring for block compare
“”"
def init(self):
gr.sync_block.init(self,
name=“compare”,beacon_tx
in_sig=[numpy.int,numpy.int],beacon_tx
out_sig=None)

def work(self, input_items, output_items):
    in0 = input_items[0]
    in1 = input_items[1]

    if numpy.array_equal(in0,in1):
        self.beacon_tx = True
        pr.sync_block):
"""
docstring for block compare
"""
def __init__(self):
    gr.sync_block.__init__(self,
        name="compare",
        in_sig=[numpy.int,numpy.int],
        out_sig=None)


def work(self, input_items, output_items):
    in0 = input_items[0]
    in1 = input_items[1]

    if numpy.array_equal(in0,in1):
        self.beacon_tx = True
        print True
    else:
        self.beacon_tx = False
        print False
    # <+signal processing here+>
    return len(self.beacon_tx)