Using robotremoteserver to expose multiple libraries

387 views
Skip to first unread message

teegee

unread,
Nov 2, 2016, 12:34:23 AM11/2/16
to robotframework-users
I might be approaching this from the wrong direction, so don't hold back.

I would like to use robotremoteserver to make multiple libraries remotely accessible to a different PC. I found two possible ways to do that:
1) Launch multiple servers each exposing a single library (testlib simple.py)
While this approach works, I didn't like the fact that I needed to start a separate python instance for each library in a separate console. So I added a "detatch" option to the class, which prevents the initialisation of the signals, which meant I could run them each in a separate thread off the same python instance. It's ugly but it works.

2) Do magic and combine multiple libraries in one new class that pretends to have all of the libraries' keywords (testlib.py)
This didn't go so well. I managed to get the keywords re-exported in the main library but running them didn't work. For example, usually I can do this:
Run    calc.exe
to start a calculator via the AutoItLibrary. But with my new Frankenstein library I get argument errors:
Keyword 'Remote.Run' expected 2 to 4 arguments, got 1.

Is there a better way to do this?
testlib simple.py
testlib.py

Tatu Aalto

unread,
Nov 2, 2016, 3:08:48 AM11/2/16
to thomas....@gmail.com, robotframework-users

Ugh

Generally speaking, I don't see anything wrong in your idea. With that kind multi node environment, I would also build similar kind of setup.

The error is easier to debug, when you run the test with --loglevel trace set from command line. It will give you full stack trace and with that it's easier to see where the error happens.

-Tatu
Send from my mobile


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Pekka Klärck

unread,
Nov 2, 2016, 7:35:52 AM11/2/16
to thomas....@gmail.com, robotframework-users
Hi,

It would be best if RobotRemoteServer would allow registering multiple
libraries to be hosted on different ports. That shouldn't be too
complicated to implement either, but at least I don't have time to
look at that in the near future.

Your approach to combine libraries ought to work fine, though. The
problem you encountered may be related to your "Frankenstein library"
using library classes, not instances, internally. If that's not the
problem, please provide tracebacks and other available information as
Tatu suggested.

Cheers,
.peke
> --
> You received this message because you are subscribed to the Google Groups
> "robotframework-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to robotframework-u...@googlegroups.com.
> To post to this group, send email to robotframe...@googlegroups.com.
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

teegee

unread,
Nov 2, 2016, 7:22:01 PM11/2/16
to robotframework-users
Tatu, Pekka, thanks for your replies.

I got the library working by replacing the class variable with an actual instance.
I also decided to prepend the module name to the exported keywords to avoid duplicates.
The result is appropriately named and attached if anyone is interested :)
frankenlib.py

vvs1

unread,
Nov 13, 2017, 4:40:06 AM11/13/17
to robotframework-users
Hello, teegee. Is your approach still working? Have you design new versions of "frankenlib"?

I've tried to run this code and have error about run_keyword (i've added some debug prints into __getattr__ method)  :

FrankenLib: Running File: frankenlib.py, Version: 0.2

run_keyword
######
run
######
Traceback (most recent call last):
  File "frankenlib.py", line 92, in <module>
    RobotRemoteServer(FrankenLib(), *sys.argv[1:])
  File "C:\Python27\lib\site-packages\robotremoteserver.py", line 73, in __init__
    self._library = RemoteLibraryFactory(library)
  File "C:\Python27\lib\site-packages\robotremoteserver.py", line 256, in RemoteLibraryFactory
    run_keyword = dynamic_method(library, 'run_keyword')
  File "C:\Python27\lib\site-packages\robotremoteserver.py", line 266, in dynamic_method
    method = getattr(library, name, None)
  File "frankenlib.py", line 50, in __getattr__
    module_num = self._modulenames.index(module)
ValueError: 'run' is not in list

четверг, 3 ноября 2016 г., 2:22:01 UTC+3 пользователь teegee написал:

teegee

unread,
Nov 13, 2017, 4:40:22 PM11/13/17
to robotframework-users
Hi,

Unfortunatley, I'm no longer using robotframework. There is no version of frankenlib but from what I remember, you had to prefix the library name where the keyword is originally coming from to the command.
Maybe we can figure this out if you post your calling code

vvs1

unread,
Nov 14, 2017, 4:11:15 AM11/14/17
to robotframework-users
Hi, thx for answering.

Errors aren't from calling code, just can't run remote server. Maybe because of newer versions of remote server  and other libs .  

Your first testlib.py  could run , but can't handle simple "Run" keyword :
C:\>python testlib.py
[]
MyLibrary: Running File: testlib.py, Version: 0.1
Could not find run_keyword
Could not find runKeyword
Could not find __dir__
Could not find __members__
Could not find __methods__
Robot Framework remote server at 127.0.0.1:8270 started.

вторник, 14 ноября 2017 г., 0:40:22 UTC+3 пользователь teegee написал:
Reply all
Reply to author
Forward
0 new messages