4 new revisions:

Revision: c7edb6f2085b
Author:   Pekka Klärck
Date:     Fri Sep 16 05:59:16 2011
Log: moved logging to separate _log method to ease possible custom logging
http://code.google.com/p/robotframework/source/detail?r=c7edb6f2085b

Revision: a928bfd8901b
Author:   Pekka Klärck
Date:     Fri Sep 16 06:17:49 2011
Log: Fixed two problems in the implementation to support __init__ and __int...
http://code.google.com/p/robotframework/source/detail?r=a928bfd8901b

Revision: 07d4ffc425ac
Author:   Pekka Klärck
Date:     Fri Sep 16 07:12:00 2011
Log: Store dynamically got init's doc so that no need to get it again....
http://code.google.com/p/robotframework/source/detail?r=07d4ffc425ac

Revision: e38bbb8b5520
Author:   Pekka Klärck
Date:     Fri Sep 16 07:18:23 2011
Log: Better test data for manually testing dynamic __intro__ and __init__....
http://code.google.com/p/robotframework/source/detail?r=e38bbb8b5520

==============================================================================
Revision: c7edb6f2085b
Author:   Pekka Klärck
Date:     Fri Sep 16 05:59:16 2011
Log: moved logging to separate _log method to ease possible custom logging
http://code.google.com/p/robotframework/source/detail?r=c7edb6f2085b

Modified:
 /tools/remoteserver/robotremoteserver.py

=======================================
--- /tools/remoteserver/robotremoteserver.py    Fri Sep 16 02:09:55 2011
+++ /tools/remoteserver/robotremoteserver.py    Fri Sep 16 05:59:16 2011
@@ -32,7 +32,8 @@
         self._allow_stop = allow_stop
         self._register_functions()
         self._register_signal_handlers()
- print 'Robot Framework remote server starting at %s:%s' % (host, port)
+        self._log('Robot Framework remote server starting at %s:%s'
+                  % (host, port))
         self.serve_forever()

     def _register_functions(self):
@@ -59,10 +60,10 @@
     def stop_remote_server(self):
prefix = 'Robot Framework remote server at %s:%s ' % self.server_address
         if self._allow_stop:
-            print prefix + 'stopping'
+            self._log(prefix + 'stopping')
             self._shutdown = True
         else:
-            print '*WARN* ' + prefix + 'does not allow stopping'
+            self._log(prefix + 'does not allow stopping', 'WARN')
         return True

     def get_keyword_names(self):
@@ -144,7 +145,7 @@
         if isinstance(ret, (basestring, int, long, float)):
             return ret
         if isinstance(ret, (tuple, list)):
-            return [ self._handle_return_value(item) for item in ret ]
+            return [self._handle_return_value(item) for item in ret]
         if isinstance(ret, dict):
             return dict([(self._str(key), self._handle_return_value(value))
                          for key, value in ret.items()])
@@ -164,3 +165,8 @@
         sys.stdout.close()
         sys.stdout = sys.__stdout__
         return output
+
+    def _log(self, msg, level=None):
+        if level:
+            msg = '*%s* %s' % (level.upper(), msg)
+        print msg

==============================================================================
Revision: a928bfd8901b
Author:   Pekka Klärck
Date:     Fri Sep 16 06:17:49 2011
Log: Fixed two problems in the implementation to support __init__ and __intro__.

Update issue 186
The implementation to support __init__ and __intro__ had two problems:

1) inspect.getdoc returns None when there's no docstring. Not all XML-RPC
   implementations support None so it's safer to return an empty string.

2) The code used `x if e else y` syntax which only works with Python 2.5
   and newer. The remote server itself is (or at least should be --
   unfortunatley cannot test that easily right now) compatible also with
   earlier Python versions.

Both of the above problems were fixed by this commit.
http://code.google.com/p/robotframework/source/detail?r=a928bfd8901b

Modified:
 /tools/remoteserver/robotremoteserver.py

=======================================
--- /tools/remoteserver/robotremoteserver.py    Fri Sep 16 05:59:16 2011
+++ /tools/remoteserver/robotremoteserver.py    Fri Sep 16 06:17:49 2011
@@ -92,7 +92,9 @@

     def get_keyword_arguments(self, name):
         kw = self._get_keyword(name)
-        return self._arguments_from_kw(kw) if kw else []
+        if not kw:
+            return []
+        return self._arguments_from_kw(kw)

     def _arguments_from_kw(self, kw):
         args, varargs, _, defaults = inspect.getargspec(kw)
@@ -107,7 +109,7 @@

     def get_keyword_documentation(self, name):
         if name == '__intro__':
-            return inspect.getdoc(self._library)
+            return inspect.getdoc(self._library) or ''
         if name == '__init__' and inspect.ismodule(self._library):
             return ''
         return inspect.getdoc(self._get_keyword(name)) or ''
@@ -116,7 +118,9 @@
         if name == 'stop_remote_server':
             return self.stop_remote_server
         kw = getattr(self._library, name, None)
-        return kw if inspect.isroutine(kw) else None
+        if inspect.isroutine(kw):
+            return kw
+        return None

     def _get_error_details(self):
         exc_type, exc_value, exc_tb = sys.exc_info()

==============================================================================
Revision: 07d4ffc425ac
Author:   Pekka Klärck
Date:     Fri Sep 16 07:12:00 2011
Log:      Store dynamically got init's doc so that no need to get it again.

Update issue 186
Changed getting the __init__ doc so that the doc is stored and not reget.

The duplication in this code is pretty bad but I'm not sure is removig
it worth another base class.
http://code.google.com/p/robotframework/source/detail?r=07d4ffc425ac

Modified:
 /src/robot/running/handlers.py

=======================================
--- /src/robot/running/handlers.py      Fri Sep 16 03:36:56 2011
+++ /src/robot/running/handlers.py      Fri Sep 16 07:12:00 2011
@@ -260,6 +260,7 @@
         except DataError:
             return True

+
 class _XTimesHandler(_RunKeywordHandler):

     def __init__(self, handler, name):
@@ -290,8 +291,9 @@

     @property
     def doc(self):
-        if self._docgetter():
-            return self._docgetter() or self._doc
+        if self._docgetter:
+            self._doc = self._docgetter() or self._doc
+            self._docgetter = None
         return self._doc

     def _parse_arguments(self, handler_method):
@@ -306,8 +308,9 @@

     @property
     def doc(self):
-        if self._docgetter():
-            return self._docgetter() or self._doc
+        if self._docgetter:
+            self._doc = self._docgetter() or self._doc
+            self._docgetter = None
         return self._doc

     def _parse_arguments(self, handler_method):

==============================================================================
Revision: e38bbb8b5520
Author:   Pekka Klärck
Date:     Fri Sep 16 07:18:23 2011
Log: Better test data for manually testing dynamic __intro__ and __init__.

Update issue 186
I did some manual testing and noticed __init__ arguments do not work.
I looked at the code and it seems that this functionality is still missing.
Most likely this needs to be handled with argsgetter similar to docgetter
used for getting the __init__ doc.

This commit contains changes to libdoc's and remote server's examples that
can be used for manually testing this. Creating automated end-to-end or
integration tests would be great too.
http://code.google.com/p/robotframework/source/detail?r=e38bbb8b5520

Modified:
 /tools/libdoc/test/dynamic.py
 /tools/remoteserver/example/examplelibrary.py

=======================================
--- /tools/libdoc/test/dynamic.py       Fri Apr 16 01:15:50 2010
+++ /tools/libdoc/test/dynamic.py       Fri Sep 16 07:18:23 2011
@@ -1,5 +1,8 @@
 class dynamic:

+    def __init__(self, a=1, b=2):
+        """This doc nor args should not be used."""
+
     def get_keyword_names(self):
         return ['Keyword 1', 'KW 2']

@@ -7,7 +10,9 @@
         print name, args

     def get_keyword_arguments(self, name):
-        return [ 'arg%d' % (i+1) for i in range(int(name[-1])) ]
+        if name == '__init__':
+            return ['x=1, y=2']
+        return ['arg%d' % (i+1) for i in range(int(name[-1]))]

     def get_keyword_documentation(self, name):
         return '''Dummy documentation for `%s`.
=======================================
--- /tools/remoteserver/example/examplelibrary.py       Fri Sep 16 01:07:39 2011
+++ /tools/remoteserver/example/examplelibrary.py       Fri Sep 16 07:18:23 2011
@@ -11,7 +11,7 @@
     starting from Robot Framework 2.6.2.
     """

-    def __init__(self):
+    def __init__(self, a=1):
         """This library takes no arguments."""

     def count_items_in_directory(self, path):

Reply via email to