Author: laukpe
Date: Sat Sep 20 09:43:46 2008
New Revision: 767
Added:
trunk/proto/remote/Remote.py
- copied, changed from r766, /trunk/proto/remote/RobotRemoteLibrary.py
trunk/proto/remote/test/basic_communication.html (contents, props
changed)
Removed:
trunk/proto/remote/RobotRemoteLibrary.py
Modified:
trunk/proto/remote/python/RobotRemoteServer.py
trunk/proto/remote/python/examplelibrary.py
trunk/proto/remote/python/test.sh
Log:
1) Separate suite for basic communication 2) Fixed logging (and other basic
communication)
Copied: trunk/proto/remote/Remote.py (from r766,
/trunk/proto/remote/RobotRemoteLibrary.py)
==============================================================================
--- /trunk/proto/remote/RobotRemoteLibrary.py (original)
+++ trunk/proto/remote/Remote.py Sat Sep 20 09:43:46 2008
@@ -1,7 +1,7 @@
import xmlrpclib
-class RobotRemoteLibrary:
+class Remote:
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
@@ -23,8 +23,7 @@
def run_keyword(self, name, args):
if name == 'Stop Remote Server':
- self._library.stop()
- del self._library # Needed?
+ self._library.stop_remote_server()
return
try:
result = self._library.run_keyword(name, args)
Modified: trunk/proto/remote/python/RobotRemoteServer.py
==============================================================================
--- trunk/proto/remote/python/RobotRemoteServer.py (original)
+++ trunk/proto/remote/python/RobotRemoteServer.py Sat Sep 20 09:43:46 2008
@@ -20,12 +20,13 @@
self._library = library
self.register_function(self.get_keyword_names)
self.register_function(self.run_keyword)
- self.register_function(self.stop)
+ self.register_function(self.stop_remote_server)
# May want to enable this later. May also want to use
DocXMLRPCServer.
# self.register_introspection_functions()
if signal:
- signal.signal(signal.SIGHUP, lambda signum, frame: self.stop())
- signal.signal(signal.SIGINT, lambda signum, frame: self.stop())
+ callback = lambda signum, frame: self.stop_remote_server()
+ signal.signal(signal.SIGHUP, callback)
+ signal.signal(signal.SIGINT, callback)
self.serve_forever()
def serve_forever(self):
@@ -33,7 +34,7 @@
while not self._shutdown:
self.handle_request()
- def stop(self):
+ def stop_remote_server(self):
self._shutdown = True
return True
@@ -47,14 +48,14 @@
result = {'status':'PASS', 'return':'', 'message':'', 'output':''}
try:
return_value = getattr(self._library, name)(*args)
- result['return'] = self._convert_value_for_xmlrpc(return_value)
- except Exception, exception:
+ result['return'] = self._handle_return_value(return_value)
+ except Exception, exp:
result['status'] = 'FAIL'
- result['message'] = exception[0]
+ result['message'] = str(exp) #cepexception[0]
result['output'] = self._restore_stdout()
return result
- def _convert_value_for_xmlrpc(self, return_value):
+ def _handle_return_value(self, return_value):
# Can't set 'allow_none' in init because it's only in Python 2.5
if return_value is None:
return ''
@@ -68,9 +69,10 @@
def _redirect_stdout(self):
# TODO: What about stderr?
sys.stdout = StringIO()
-
+
def _restore_stdout(self):
- output = sys.stdout.read()
+ output = sys.stdout.getvalue()
sys.stdout.close()
sys.stdout = sys.__stdout__
return output
+
Modified: trunk/proto/remote/python/examplelibrary.py
==============================================================================
--- trunk/proto/remote/python/examplelibrary.py (original)
+++ trunk/proto/remote/python/examplelibrary.py Sat Sep 20 09:43:46 2008
@@ -5,17 +5,21 @@
class PythonLibraryExample:
- def do_nothing(self):
+ # Basic communication
+
+ def passing(self):
pass
- def failure(self, message):
+ def failing(self, message):
raise AssertionError(message)
- def error(self):
- 1/0
-
def logging(self, message, level='INFO'):
print '*%s* %s' % (level, message)
+
+ def returning(self):
+ return "returned string"
+
+ # Arguments
def one_argument(self, arg):
print 'arg: %s' % arg
Modified: trunk/proto/remote/python/test.sh
==============================================================================
--- trunk/proto/remote/python/test.sh (original)
+++ trunk/proto/remote/python/test.sh Sat Sep 20 09:43:46 2008
@@ -5,7 +5,7 @@
python python/examplelibrary.py 2> /dev/null &
sleep 1
-pybot --log none --report none --output logs/output.xml
test/remote_library.html
+pybot --log none --report none --output logs/output.xml $*
../../tools/statuschecker/statuschecker.py logs/output.xml
rebot --outputdir logs logs/output.xml
Added: trunk/proto/remote/test/basic_communication.html
==============================================================================
--- (empty file)
+++ trunk/proto/remote/test/basic_communication.html Sat Sep 20 09:43:46
2008
@@ -0,0 +1,259 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+
+ <style type="text/css">
+html {
+ font-family: Arial,Helvetica,sans-serif;
+ background-color: white;
+ color: black;
+}
+p {
+ max-width: 60em;
+}
+table {
+ border-collapse: collapse;
+ empty-cells: show;
+ margin: 1em 0em;
+ border: 0.1em solid black;
+}
+th, td {
+ border-style: solid;
+ border-width: 0.05em 0.1em;
+ border-color: black;
+ padding: 0.1em 0.2em;
+ height: 1.5em;
+}
+th {
+ background-color: rgb(192, 192, 192);
+ color: black;
+ border-width: 0.1em;
+ font-weight: bold;
+ text-align: center;
+ text-transform: capitalize;
+ letter-spacing: 0.1em;
+}
+/* Widths of named columns */
+col.name {
+ width: 10em;
+}
+.action, .value, .arg {
+ width: 15em;
+}
+/* Properties for the name column
+- td:first-child should work in CSS 2.1 avare browsers (tested in Firefox)
+- col.name is against specs but works in IE
+*/
+td:first-child, col.name {
+ background-color: rgb(240, 240, 240);
+ text-transform: capitalize;
+ letter-spacing: 0.1em;
+}
+/* required for IE */
+th {
+ font-style: normal;
+}
+ </style>
+ <title>Robot Test Cases</title></head>
+<body>
+
+<h1>Robot Test Cases</h1>
+
+
+<table border="1">
+
+ <colgroup span="99"><col class="name"><col class="value"
span="4"></colgroup>
+ <thead>
+ <tr>
+
+ <th>Setting</th>
+
+ <th>Value</th>
+
+ <th>Value</th>
+
+ <th>value</th>
+
+ <th>Value</th>
+
+ </tr>
+
+ </thead>
+ <tbody>
+
+ <tr>
+
+ <td>Library</td>
+
+ <td>Remote</td>
+
+ <td>localhost:${PORT}</td>
+
+ <td></td>
+
+ <td></td>
+
+ </tr>
+
+ <tr>
+
+ <td>Suite Teardown</td>
+
+ <td>Stop Remote Server</td>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ </tr><tr><td>Force
Tags</td><td>python</td><td>ruby</td><td></td><td></td></tr>
+
+ </tbody>
+</table>
+
+
+<table border="1">
+
+ <colgroup span="99"><col class="name"><col class="value"
span="4"></colgroup>
+ <thead>
+ <tr>
+
+ <th>Variable</th>
+
+ <th>Value</th>
+
+ <th>Value</th>
+
+ <th>Value</th>
+
+ <th>Value</th>
+
+ </tr>
+
+ </thead>
+ <tbody>
+
+ <tr>
+
+ <td>${PORT} =<br></td><td>8270</td>
+
+
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ </tr>
+
+ <tr>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ </tr>
+
+ </tbody>
+</table>
+
+
+<table border="1">
+
+ <colgroup span="99"><col class="name"><col class="action"><col
class="arg" span="3"></colgroup>
+ <thead>
+ <tr>
+
+ <th>Test Case</th>
+
+ <th>Action</th>
+
+ <th>Argument</th>
+
+ <th>Argument</th>
+
+ <th>Argument</th>
+
+
+
+ </tr>
+
+ </thead>
+ <tbody>
+
+ <tr>
+
+ <td>Passing</td>
+
+ <td>Passing</td>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+
+
+ </tr>
+
+ <tr>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+
+
+ </tr>
+ <tr><td>Failing</td><td>[Documentation]</td><td>FAIL</td><td>This is
the error we get</td><td></td></tr><tr><td></td><td>Failing</td><td>This is
the error we
get</td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Logging</td><td>[Documentation]</td><td>LOG
1</td><td>Hello, world!</td><td></td></tr><tr><td></td><td>...</td><td>LOG
2 WARN</td><td>Warning,
warning!!</td><td></td></tr><tr><td></td><td>Logging</td><td>Hello,
world!</td><td></td><td></td></tr><tr><td></td><td>Logging</td><td>Warning,
warning!!</td><td>WARN</td><td></td></tr>
+
<tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Returning</td><td>${ret}
=</td><td>Returning</td><td></td><td></td></tr>
+ <tr><td></td><td>Should Be Equal</td><td>${ret}</td><td>returned
string</td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr>
+
+ </tbody>
+</table>
+
+
+<table border="1">
+
+ <colgroup span="99"><col class="name"><col class="action"><col
class="arg" span="3"></colgroup>
+ <thead>
+ <tr>
+
+ <th>Keyword</th>
+
+ <th>Action</th>
+
+ <th>Argument</th>
+
+ <th>Argument</th>
+
+ <th>Argument</th>
+
+ </tr>
+
+ </thead>
+ <tbody>
+
+
+
+
<tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr>
+
+ </tbody>
+</table>
+
+
+</body></html>
\ No newline at end of file