55from optparse import OptionParser
66from datetime import datetime
77
8- __version__ = '2.6.2 '
8+ __version__ = '2.39 '
99
1010FORMAT = "%(message)s"
1111logging .basicConfig (format = FORMAT )
@@ -329,6 +329,7 @@ def create_project(self, project_name, project_type):
329329 print project
330330
331331 logger .info ("Project %s: %s (%s) created" % (project ['id' ], project ['name' ], project ['type' ] ))
332+ return project
332333
333334 """ Delete a project
334335 """
@@ -380,7 +381,7 @@ def delete_project_parameters(self, project_id, parameter_id):
380381 """ Get project parameters
381382 """
382383 def get_project_parameters (self , project_id ):
383- path = "/ me/projects/%s/config/parameters" % ( project_id )
384+ path = "me/projects/%s/config/parameters" % ( project_id )
384385 return self .get (path = path )
385386
386387 """ Upload additional data file to project
@@ -401,7 +402,7 @@ def set_project_parameters(self, project_id, parameters):
401402 """ Get project config
402403 """
403404 def get_project_config (self , project_id ):
404- path = "/ me/projects/%s/config" % ( project_id )
405+ path = "me/projects/%s/config" % ( project_id )
405406 return self .get (path = path )
406407
407408 """ Set project config according to http://docs.testdroid.com/_pages/client.html#project-config
@@ -438,7 +439,7 @@ def start_test_run(self, project_id, device_group_id=None, device_model_ids=None
438439 sys .exit (1 )
439440
440441 if device_group_id is not None :
441- device_group = self .get ("/ users/%s/device-groups/%s" % (me ['id' ], device_group_id ))
442+ device_group = self .get ("users/%s/device-groups/%s" % (me ['id' ], device_group_id ))
442443 if not 'id' in device_group :
443444 print "Device group %s not found" % device_group_id
444445 sys .exit (1 )
@@ -549,6 +550,14 @@ def get_device_runs(self, project_id, test_run_id, limit=0):
549550 def get_device_run_screenshots_list (self , project_id , test_run_id , device_run_id , limit = 0 ):
550551 return self .get ("me/projects/%s/runs/%s/device-runs/%s/screenshots" % (project_id , test_run_id , device_run_id ), payload = {'limit' : limit })
551552
553+ """ Get list of files for device run
554+ """
555+ def get_device_run_files (self , project_id , test_run_id , device_session_id , tags = None ):
556+ if tags is None :
557+ return self .get ("me/projects/%s/runs/%s/device-sessions/%s/output-file-set/files" % (project_id , test_run_id , device_session_id ))
558+ else :
559+ return self .get ("me/projects/%s/runs/%s/device-sessions/%s/output-file-set/files?tag[]=%s" % (project_id , test_run_id , device_session_id , tags ))
560+
552561 """ Downloads test run files to a directory hierarchy
553562 """
554563 def download_test_run (self , project_id , test_run_id ):
@@ -559,14 +568,14 @@ def download_test_run(self, project_id, test_run_id):
559568 logger .info ("Test run %s: \" %s\" has %s device runs:" % (test_run ['id' ], test_run ['displayName' ], len (device_runs ['data' ])))
560569
561570 for device_run in device_runs ['data' ]:
562- run_status = device_run ['runStatus ' ]
571+ state = device_run ['state ' ]
563572 logger .info ("" )
564- logger .info ("%s \" %s\" %s" % (device_run ['id' ], device_run ['device' ]['displayName' ], run_status ))
573+ logger .info ("%s \" %s\" %s" % (device_run ['id' ], device_run ['device' ]['displayName' ], state ))
565574
566- if run_status in ("SUCCEEDED" , "FAILED" , "EXCLUDED" ):
575+ if state in ("ABORTED" , "TIMEOUT" , "WARNING" , "SUCCEEDED" , "FAILED" , "EXCLUDED" ):
567576 directory = "%s-%s/%d-%s" % (test_run_id , test_run ['displayName' ], device_run ['id' ], device_run ['device' ]['displayName' ])
568- session_id = device_run ['deviceSessionId ' ]
569- files = self .get ( "me/projects/%s/runs/%s/device-sessions/%s/output-file-set/files" % ( project_id , test_run_id , session_id ) )
577+ session_id = device_run ['id ' ]
578+ files = self .get_device_run_files ( project_id , test_run_id , session_id )
570579 for file in files ['data' ]:
571580 if file ['state' ] == "READY" :
572581 full_path = "%s/%s" % (directory , file ['name' ])
@@ -713,6 +722,7 @@ def get_commands(self):
713722 "test-run" : self .get_test_run ,
714723 "test-runs" : self .print_project_test_runs ,
715724 "device-runs" : self .get_device_runs ,
725+ "device-run-files" : self .get_device_run_files ,
716726 "download-test-run" : self .download_test_run ,
717727 "download-test-screenshots" : self .download_test_screenshots
718728 }
0 commit comments