@@ -269,11 +269,6 @@ def __init__(self, port=0, debug=False, java9_or_newer='auto-detect'):
269
269
270
270
self ._initiate (port , debug , java9_or_newer )
271
271
272
- if os .path .exists (self ._output ("remote-stderr" )):
273
- shutil .rmtree (self ._output ("remote-stderr" ))
274
- if os .path .exists (self ._output ("remote-stdout" )):
275
- shutil .rmtree (self ._output ("remote-stdout" ))
276
-
277
272
def _initiate (self , port = 0 , debug = False , java9_or_newer = 'auto-detect' ):
278
273
if RemoteSwingLibrary .DEBUG is None :
279
274
RemoteSwingLibrary .DEBUG = _tobool (debug )
@@ -395,7 +390,7 @@ def set_java_tool_options(self, close_security_dialogs=True, remote_port=0, dir_
395
390
logger .debug ("Set _JAVA_OPTIONS='%s'" % java_policy )
396
391
397
392
def start_application (self , alias , command , timeout = 60 , name_contains = "" , close_security_dialogs = False ,
398
- remote_port = 0 , dir_path = None , custom = None ):
393
+ remote_port = 0 , dir_path = None , stdout = None , stderr = None , custom = None ):
399
394
"""Starts the process in the ``command`` parameter on the host operating system.
400
395
The given ``alias`` is stored to identify the started application in RemoteSwingLibrary.
401
396
@@ -412,27 +407,39 @@ def start_application(self, alias, command, timeout=60, name_contains="", close_
412
407
``dir_path`` is the path where security dialogs screenshots are saved. It is working both with relative
413
408
and absolute path. If ``dir_path`` is not specified the screenshots will not be taken.
414
409
410
+ ``stdout`` is the path where to write stdout to.
411
+
412
+ ``stderr`` is the path where to write stderr to.
413
+
415
414
``custom`` is a customizable field that can be set when starting the Java agent.
416
415
"""
417
416
close_security_dialogs = _tobool (close_security_dialogs )
418
- stdout = "remote-stdout" + "/" + "remote-stdout-" + re . sub ( '[:. ]' , '-' , str ( datetime . datetime . now ())) + '.txt'
419
- stderr = "remote-stderr" + "/" + "remote-stderr-" + re . sub ( '[:. ]' , '-' , str ( datetime .datetime .now ())) + '.txt'
420
-
421
- stderr_dir = self . _output ( "remote-stderr" )
422
- stdout_dir = self . _output ( "remote- stdout" )
423
-
424
- if not os . path . exists ( stderr_dir ):
425
- os .makedirs ( stderr_dir )
417
+
418
+ now = datetime .datetime .now ()
419
+ current_date = now . strftime ( "%Y%m%d%H%M%S" )
420
+
421
+ if stdout is None :
422
+ stdout_file_name = current_date + ".remoteswinglibrary" + ".out"
423
+ stdout = self . _output ( stdout_file_name )
424
+ ( stdout_dir , stdout_file_name ) = os .path . split ( stdout )
426
425
if not os .path .exists (stdout_dir ):
427
426
os .makedirs (stdout_dir )
427
+
428
+ if stderr is None :
429
+ stderr_file_name = current_date + ".remoteswinglibrary" + ".err"
430
+ stderr = self ._output (stderr_file_name )
431
+ if stderr != "STDOUT" :
432
+ (stderr_dir , stderr_file_name ) = os .path .split (stderr )
433
+ if not os .path .exists (stderr_dir ):
434
+ os .makedirs (stderr_dir )
428
435
429
436
logger .info ('<a href="%s">Link to stdout</a>' % stdout , html = True )
430
437
logger .info ('<a href="%s">Link to stderr</a>' % stderr , html = True )
431
438
REMOTE_AGENTS_LIST .set_received_to_old ()
432
439
with self ._agent_java_tool_options (close_security_dialogs , remote_port , dir_path , custom ):
433
440
self .PROCESS .start_process (command , alias = alias , shell = True ,
434
- stdout = self . _output ( stdout ) ,
435
- stderr = self . _output ( stderr ) )
441
+ stdout = stdout ,
442
+ stderr = stderr )
436
443
try :
437
444
self ._application_started (alias , timeout , name_contains , remote_port , accept_old = False )
438
445
except TimeoutError :
0 commit comments