Skip to content

Commit

Permalink
Merge branch 'develop' for release 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
da4089 committed Jul 18, 2016
2 parents 6c14915 + 7ba29db commit 5a4be2c
Show file tree
Hide file tree
Showing 8 changed files with 1,114 additions and 456 deletions.
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ script:
- cd unit_tests
- env PYTHONOPATH=.. python -m unittest --verbose test_all
- cd ..
- env PYTHONPATH=. python ./rnps-ouch -f port &
- while test ! -f port; do sleep 1; done
- env PYTHONPATH=. python ./rnps-ouch -f nasdaq_port &
- while test ! -f nasdaq_port; do sleep 1; done
- cd robot_tests
- pybot -v OUCH_PORT:`cat ../port` *.robot
- pybot -v OUCH_PORT:`cat ../nasdaq_port` {001,002,003,004}*.robot
- cd ..
- rm -f port
- rm -f nasdaq_port
- env PYTHONPATH=. python ./rnps-asxouch -f asx_port &
- while test ! -f asx_port; do sleep 1; done
- cd robot_tests
- pybot -v OUCH_PORT:`cat ../asx_port` 005*.robot
- cd ..
- rm -f asx_port
- cd docs
- make html
- cd ..
104 changes: 104 additions & 0 deletions rnps-asxouch
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#! /usr/bin/env python
########################################################################
# robot-nps, Network Protocol Simulator for Robot Framework
#
# Copyright (C) 2015-2016 David Arnold
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########################################################################

import argparse
import logging

from rnps import AsxOuchRobot

from twistedremoteserver import TwistedRemoteServer
from twisted.internet import reactor
from twisted.web.resource import Resource
from twisted.web.server import Site


########################################################################

if __name__ == "__main__":
# Logging
root = logging.getLogger()
root.setLevel(logging.DEBUG)

ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)

fmt = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(fmt)
root.addHandler(ch)

logging.getLogger().debug("Logging initialised.")


parser = argparse.ArgumentParser(description="A Robot Framework remote "
"server that provides both "
"client and server-side "
"simulation of the ASX "
"OUCH SR8 protocol.")
parser.add_argument("-p", "--port",
nargs=1,
type=int,
help="TCP port number for remote Robot Framework "
"access.",
default=0)
parser.add_argument("-i", "--interface",
nargs=1,
type=str,
help="IP address of listening interface. Default is "
"%(default)s.",
default="0.0.0.0")
parser.add_argument("-f", "--file",
nargs=1,
type=str,
help="Name of file to write listening port to.",
default=None)
args = parser.parse_args()
interface = args.interface

if type(args.port) == type([]):
port = args.port[0]
else:
port = args.port

if type(args.file) == type([]):
port_file = args.file[0]
else:
port_file = args.file

robot = AsxOuchRobot()
robot_api = TwistedRemoteServer(robot, interface, port)

root = Resource()
root.putChild("RPC2", robot_api)
factory = Site(root)
listener = reactor.listenTCP(port, factory, interface=interface)
if port_file:
f = open(port_file, "w")
f.write("%u\n" % listener.getHost().port)
f.close()

logging.getLogger().info("Listening on %s:%u",
interface,
listener.getHost().port)
reactor.run()



########################################################################
2 changes: 2 additions & 0 deletions rnps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Main RNPS package.

import errors

from asxouch_robot import *
from ouch_robot import *
Loading

0 comments on commit 5a4be2c

Please sign in to comment.