20
20
from requests .adapters import HTTPAdapter , Retry
21
21
22
22
from ._local import set_current
23
- from .logs .log_manager import LogManager , MAX_LOG_BATCH_PAYLOAD_SIZE
24
23
from .core .rp_requests import (
25
24
HttpRequest ,
26
25
ItemStartRequest ,
29
28
LaunchFinishRequest
30
29
)
31
30
from .helpers import uri_join , verify_value_length
31
+ from .logs .log_manager import LogManager , MAX_LOG_BATCH_PAYLOAD_SIZE
32
32
from .static .defines import NOT_FOUND
33
33
from .steps import StepReporter
34
34
@@ -59,6 +59,7 @@ def __init__(self,
59
59
launch_id = None ,
60
60
http_timeout = (10 , 10 ),
61
61
log_batch_payload_size = MAX_LOG_BATCH_PAYLOAD_SIZE ,
62
+ mode = 'DEFAULT' ,
62
63
** _ ):
63
64
"""Initialize required attributes.
64
65
@@ -100,6 +101,7 @@ def __init__(self,
100
101
self .session = requests .Session ()
101
102
self .step_reporter = StepReporter (self )
102
103
self ._item_stack = []
104
+ self .mode = mode
103
105
if retries :
104
106
retry_strategy = Retry (
105
107
total = retries ,
@@ -244,10 +246,19 @@ def get_launch_ui_url(self):
244
246
245
247
:return: launch URL or all launches URL.
246
248
"""
247
- ui_id = self .get_launch_ui_id ()
249
+ launch_info = self .get_launch_info ()
250
+ ui_id = launch_info .get ('id' ) if launch_info else None
248
251
if not ui_id :
249
252
return
250
- path = 'ui/#{0}/launches/all/{1}' .format (self .project , ui_id )
253
+ mode = launch_info .get ('mode' ) if launch_info else None
254
+ if not mode :
255
+ mode = self .mode
256
+
257
+ launch_type = "launches" if mode .upper () == 'DEFAULT' else 'userdebug'
258
+
259
+ path = 'ui/#{project_name}/{launch_type}/all/{launch_id}' .format (
260
+ project_name = self .project .lower (), launch_type = launch_type ,
261
+ launch_id = ui_id )
251
262
url = uri_join (self .endpoint , path )
252
263
logger .debug ('get_launch_ui_url - ID: %s' , self .launch_id )
253
264
return url
@@ -282,7 +293,6 @@ def start_launch(self,
282
293
start_time ,
283
294
description = None ,
284
295
attributes = None ,
285
- mode = None ,
286
296
rerun = False ,
287
297
rerun_of = None ,
288
298
** kwargs ):
@@ -292,12 +302,21 @@ def start_launch(self,
292
302
:param start_time: Launch start time
293
303
:param description: Launch description
294
304
:param attributes: Launch attributes
295
- :param mode: Launch mode
296
305
:param rerun: Enables launch rerun mode
297
306
:param rerun_of: Rerun mode. Specifies launch to be re-runned.
298
307
Should be used with the 'rerun' option.
299
308
"""
300
309
url = uri_join (self .base_url_v2 , 'launch' )
310
+
311
+ # We are moving 'mode' param to the constructor, next code for the
312
+ # transition period only.
313
+ my_kwargs = dict (kwargs )
314
+ mode = my_kwargs .get ('mode' )
315
+ if not mode :
316
+ mode = self .mode
317
+ else :
318
+ del my_kwargs ['mode' ]
319
+
301
320
request_payload = LaunchStartRequest (
302
321
name = name ,
303
322
start_time = start_time ,
@@ -306,7 +325,7 @@ def start_launch(self,
306
325
mode = mode ,
307
326
rerun = rerun ,
308
327
rerun_of = rerun_of or kwargs .get ('rerunOf' ),
309
- ** kwargs
328
+ ** my_kwargs
310
329
).payload
311
330
response = HttpRequest (self .session .post ,
312
331
url = url ,
0 commit comments