Exemple #1
0
    def __init__(self,phase,portTable):
	self.phase = phase
        self.domip=""
        self.port_table=bindpyrame.init_ports_table(portTable)
        self.apipools=apipools.api_pool()
        self.devices_lifo=[]
        self.current_id=0
Exemple #2
0
def web_socket_transfer_data(request):
    received_request = request.ws_stream.receive_message()
    if received_request is None:
        return
    received_request = json.loads(received_request)
    port_string = received_request.pop("port")
    command = received_request.pop("command")
    params = []
    i = 1
    for param in received_request:
        params.append(received_request["param%d"%i])
        i += 1
    try:
        table = bindpyrame.init_ports_table("/opt/pyrame/ports.txt")
        port = bindpyrame.get_port(port_string,table)
        retcode,res=bindpyrame.sendcmd("localhost",port,command,*params)
    except Exception as e:
        retcode = 0
        res = str(e)
    answer = json.dumps({"retcode": retcode, "res": res})
    request.ws_stream.send_message(answer, binary=False)
Exemple #3
0
# 
# Pyrame is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrame.  If not, see <http://www.gnu.org/licenses/>

import bindpyrame
import socket
socket.setdefaulttimeout(20)
import sys

try:
    table = bindpyrame.init_ports_table("/opt/pyrame/ports.txt")
    port = bindpyrame.get_port("TEST_PORT",table)
except Exception as e:
    print e
    sys.exit(1)

# SENDCMD
try:
    retcode,res=bindpyrame.sendcmd("localhost",port,"twoargs_test","arg1","arg2")
except Exception as e:
    print e
    sys.exit(1)
print("sendcmd: retcode=%d res=%s"%(retcode,res))

print("");