1818"""
1919
2020from __future__ import with_statement
21- import xmlrpclib
21+ import xmlrpc
22+ import xmlrpc .client
2223import time
2324import subprocess
2425import socket
@@ -37,23 +38,23 @@ def start(libraries=
3738 'org.robotframework.examplelib.Static:/Static' ):
3839 if not os .path .exists (os .path .join (BASE , 'libs' , 'target' , 'examplelib-jar-with-dependencies.jar' )):
3940 cmd = 'mvn -f "%s" clean package' % os .path .join (BASE , 'libs' , 'pom.xml' )
40- print 'Building the test libraries with command:\n %s' % cmd
41+ print ( 'Building the test libraries with command:\n %s' % cmd )
4142 subprocess .call (cmd , shell = True )
4243 files = glob .glob (os .path .join (dirname (BASE ), 'target' ) + os .sep + '*jar-with-dependencies.jar' )
4344 if not files :
4445 raise Exception ('Build jrobotremoteserver including the standalone jar first' )
4546 rs_path = os .path .join (dirname (BASE ), 'target' , files [0 ])
4647 tl_path = os .path .join (BASE , 'libs' , 'target' , 'examplelib-jar-with-dependencies.jar' )
4748 os .environ ['CLASSPATH' ] = rs_path + os .pathsep + tl_path
48- print 'CLASSPATH: %s' % os .environ ['CLASSPATH' ]
49+ print ( 'CLASSPATH: %s' % os .environ ['CLASSPATH' ])
4950 results = _get_result_directory ()
5051 port = "8270"
5152 args = ['java' , 'org.robotframework.remoteserver.RemoteServer' , '--port' , port ]
5253 libraries = [x .strip () for x in libraries .split (',' )]
5354 paths = [x .partition (':' )[2 ] for x in libraries ]
5455 for lib in libraries :
5556 args .extend (['--library' , lib ])
56- print 'adding library %s on path %s' % (lib .split (':' )[0 ], lib .split (':' )[1 ])
57+ print ( 'adding library %s on path %s' % (lib .split (':' )[0 ], lib .split (':' )[1 ]) )
5758 with open (join (results , 'server.txt' ), 'w' ) as output :
5859 server = subprocess .Popen (args ,
5960 stdout = output , stderr = subprocess .STDOUT ,
@@ -82,24 +83,24 @@ def test(port, path, attempts=1):
8283 if i > 0 :
8384 time .sleep (1 )
8485 try :
85- ret = xmlrpclib .ServerProxy (url ).run_keyword ('get_server_language' , [])
86- except socket .error , ( errno , errmsg ) :
86+ ret = xmlrpc . client .ServerProxy (url ).run_keyword ('get_server_language' , [])
87+ except socket .error :
8788 pass
88- except xmlrpclib .Error , err :
89+ except xmlrpc .Error :
8990 errmsg = err .faultString
9091 break
9192 else :
92- print "Remote server running on port %s, path %s" % (port , path )
93+ print ( "Remote server running on port %s, path %s" % (port , path ) )
9394 return True
94- print "Failed to connect to remote server on port %s path %s: %s" % (port , path , errmsg )
95+ print ( "Failed to connect to remote server on port %s path %s: %s" % (port , path , errmsg ) )
9596 return False
9697
9798
9899def stop (port = 8270 , path = "/" ):
99100 if test (port , path ):
100101 server = xmlrpclib .ServerProxy ('http://localhost:%s%s' % (port , path ))
101102 server .stop_remote_server ()
102- print "Remote server on port %s path %s stopped" % (port , path )
103+ print ( "Remote server on port %s path %s stopped" % (port , path ) )
103104
104105
105106if __name__ == '__main__' :
0 commit comments