def get_build_id(routine_id, search_name, matching_name, archived=False): print('Looking up testray build by routine (archived = %r)' % archived) base_url = 'https://testray.liferay.com/home/-/testray/builds/index.json' parameters = { 'name': search_name, 'testrayRoutineId': routine_id, 'archived': archived, 'cur': 0, 'delta': 100, 'start': -1, 'end': -1 } json_response = json.loads(get_liferay_content(base_url, parameters)) if json_response['status'] != 200: print('Unable to determine testray build for testray routine %s, search string %s' % (routine_id, search_name)) return None matching_build_ids = [ build['testrayBuildId'] for build in json_response['data'] if build['name'].find(matching_name) != -1 ] if len(matching_build_ids) == 0: if not archived: return get_build_id(routine_id, search_name, matching_name, True) print('Unable to determine build for testray routine %s, search string %s, matching string %s' % (routine_id, search_name, matching_name)) return None return matching_build_ids[0]
def get_project_id(url): version = get_liferay_version(url) if version is None: return None print('Looking up testray projects for Liferay version %s' % version) base_url = 'https://testray.liferay.com/home/-/testray/projects/index.json' parameters = {'cur': 0, 'delta': 100, 'start': -1, 'end': -1} json_response = json.loads(get_liferay_content(base_url, parameters)) if json_response['status'] != 200: print('Unable to determine testray project from %s' % url) return None matching_name = 'Liferay Portal %s' % (master_version if version == 'master' else version) matching_project_ids = [ project['testrayProjectId'] for project in json_response['data'] if project['name'] == matching_name ] if len(matching_project_ids) != 1: print('Unable to determine testray project from %s' % url) return None return matching_project_ids[0]
def get_run_id(build_id, run_number): if build_id is None: return None print('Looking up testray run by testray build') base_url = 'https://testray.liferay.com/api/jsonws/osb-testray-web.runs/index' parameters = { 'testrayBuildId': build_id, 'cur': 0, 'delta': 100, } json_response = json.loads(get_liferay_content(base_url, parameters)) if json_response['status'] != 200: print('Unable to determine testray runs for testray build %s' % (build_id)) return None first_runs = [ run['testrayRunId'] for run in json_response['data'] if run['number'] == run_number ] if len(first_runs) == 0: print('Unable to determine testray runs for testray build %s' % (build_id)) return None return first_runs[0]
def get_class_name_id(class_name): api_url = 'https://loop.liferay.com/api/jsonws/classname/fetch-class-name-id' params = { 'value': class_name } return json.loads(get_liferay_content(api_url, params))
def get_routine_id(url): project_id = get_project_id(url) if project_id is None: return None print('Looking up testray routine by project') base_url = 'https://testray.liferay.com/home/-/testray/routines/index.json' parameters = { 'testrayProjectId': project_id, 'cur': 0, 'delta': 100, 'start': -1, 'end': -1, 'orderByCol': 'name', 'orderByType': 'asc' } json_response = json.loads(get_liferay_content(base_url, parameters)) if json_response['status'] != 200: print('Unable to determine testray routine from %s' % url) return None matching_name = None if url.find('https://github.com') == 0: matching_name = 'CE Pull Request' if url.find( '-ee') == -1 else 'EE Pull Request' elif url.find('fix-pack-de-') == 0 or url.find( 'fix-pack-dxp-') == 0 or url.find('fix-pack-base-') == 0: matching_name = 'Fix Pack Tester' elif url.find('portal-') == 0: matching_name = 'Fix Pack Tester' elif url.find('https://files.liferay.com') == 0: matching_name = 'Hotfix Tester' elif url.find('http://files.liferay.com') == 0: matching_name = 'Hotfix Tester' else: print('Unable to determine testray routine from %s' % url) matching_routine_ids = [ routine['testrayRoutineId'] for routine in json_response['data'] if routine['name'] == matching_name ] if len(matching_routine_ids) != 1: print('Unable to determine testray routine from %s' % url) return None return matching_routine_ids[0]
def get_fix_pack(columns): for link_tag in columns['name'].find_all('a'): if link_tag.text != fix_pack_name: continue html = get_liferay_content(link_tag['href']) soup = BeautifulSoup(html, 'html.parser') for fp_label in soup.find_all('label'): if fp_label['for'] is not None and fp_label['for'].find('git-hash') > 0: fp_url = fp_label.find_parent('div').find('a')['href'] tag_names.append(fp_url[fp_url.find('...')+3:])
def get_fix_name_from_id(fix_id): if fix_id is None: return None base_url = 'https://patcher.liferay.com/group/guest/patching/-/osb_patcher/fixes/%s/edit' % fix_id fix_html = get_liferay_content(base_url) soup = BeautifulSoup(fix_html, 'html.parser') textarea = soup.find('textarea', {'id': '_1_WAR_osbpatcherportlet_patcherFixName'}) if textarea is None: return None return textarea.text.strip()
def get_reference(class_name_id, class_pk): if class_pk not in external_references[class_name_id]: class_name = class_names[class_name_id] api_url = 'https://loop.liferay.com/api/jsonws/loop-portlet.%s/view' % loop_service_paths[class_name] params = { 'id': class_pk } response = json.loads(get_liferay_content(api_url, params)) data = response['data'] if class_name == 'com.liferay.loop.model.LoopDivision': data = data['loopDivisionCompositeJSONObject'] external_references[class_name_id][class_pk] = '[%s](https://loop.liferay.com%s)' % (data['name'], data['displayURL']) return external_references[class_name_id][class_pk]
def get_patcher_build(url): build_url_parts = url.split('/') build_id = build_url_parts[-1] if not build_id.isnumeric(): return None print('Looking up metadata for patcher build %s' % build_id) base_url = 'https://patcher.liferay.com/api/jsonws/osb-patcher-portlet.builds/view' parameters = {'id': build_id} json_response = json.loads( get_liferay_content(base_url, parameters, 'post')) if json_response['status'] != 200: print('Unable to retrieve patcher account code for %s' % url) return None return json_response['data']
def get_run_id(build_id): if build_id is None: return None print('Looking up testray run by testray build') base_url = 'https://testray.liferay.com/home/-/testray/runs/index.json' parameters = { 'testrayBuildId': build_id, 'cur': 0, 'delta': 100, } json_response = json.loads(get_liferay_content(base_url, parameters)) if json_response['status'] != 200: print('Unable to determine testray runs for testray build %s' % (build_id)) return None runs = json_response['data'] run_factors = [(run, { factor['testrayFactorCategoryName']: factor['testrayFactorOptionName'] for factor in run['testrayFactors'] }) for run in runs] first_run_ids = [ run['testrayRunId'] for run, run_factor in run_factors if run_factor['Application Server'].find('Tomcat') != -1 and run_factor['Database'].find('MySQL') != -1 ] if len(first_run_ids) == 0: print('Unable to determine testray runs for testray build %s' % (build_id)) return None return first_run_ids[0]
def process_patcher_search_container(base_url, parameters, container_name, column_names, callback): namespaced_parameters = get_namespaced_parameters('1_WAR_osbpatcherportlet', parameters) namespaced_parameters['p_p_state'] = 'exclusive' html = get_liferay_content(base_url, namespaced_parameters) soup = BeautifulSoup(html, 'html.parser') namespaced_container_name = '_1_WAR_osbpatcherportlet_%s' % container_name search_container = soup.find('div', {'id': namespaced_container_name}) if search_container is None: print('Unable to find search results %s' % namespaced_container_name) return table = search_container.find('table') if table is None: print('Unable to find search results %s' % (namespaced_container_name)) return thead = table.find('thead') tbody = table.find('tbody') if thead is None or tbody is None: print('No search results %s' % (namespaced_container_name)) return column_indices = [-1] * len(column_names) for i, th in enumerate(thead.find_all('th')): th_text = th.text.strip().lower() for j, column_name in enumerate(column_names): if th_text == column_name: column_indices[j] = i missing_column = False for column_index, column_name in zip(column_indices, column_names): if column_index == -1: print('Unable to find column %s in search results %s' % (column_name, namespaced_container_name)) missing_column = True if missing_column: return for tr in tbody.find_all('tr'): cells = tr.find_all('td') if cells is None: continue null_cell = False for index in column_indices: if cells[index] is None: null_cell = True break if not null_cell: callback({name: cells[index] for index, name in zip(column_indices, column_names)})
def get_previous_patcher_build(patcher_build): if patcher_build is None: return None account_code = patcher_build['patcherBuildAccountEntryCode'] if account_code is None: return None print('Looking up patcher builds for account %s' % account_code) base_url = 'https://patcher.liferay.com/api/jsonws/osb-patcher-portlet.accounts/view' parameters = {'limit': 10, 'patcherBuildAccountEntryCode': account_code} json_response = json.loads(get_liferay_content(base_url, parameters)) if json_response['status'] != 200: print('Unable to retrieve patcher account builds for %s' % account_code) return None matching_builds = [ build for build in json_response['data'] if (build['statusLabel'] == 'complete' or build['statusLabel'] == 'released') and build['downloadURL'][-8:] == patcher_build['downloadURL'][-8:] and build['patcherBuildId'] != patcher_build['patcherBuildId'] ] account_parameters = {'patcherBuildAccountEntryCode': account_code} successful_builds = [ build for build in matching_builds if build['qaStatusLabel'] == 'qa-automation-passed' ] if len(successful_builds) > 0: matching_builds = successful_builds same_baseline_builds = [ build for build in matching_builds if build['patcherProjectVersionId'] == patcher_build['patcherProjectVersionId'] ] if len(same_baseline_builds) > 0: matching_builds = same_baseline_builds account_parameters['patcherProjectVersionId'] = patcher_build[ 'patcherProjectVersionId'] account_base_url = 'https://patcher.liferay.com/group/guest/patching/-/osb_patcher/accounts/view' account_namespaced_parameters = get_namespaced_parameters( '1_WAR_osbpatcherportlet', account_parameters) account_query_string = '&'.join([ '%s=%s' % (key, value) for key, value in account_namespaced_parameters.items() ]) webbrowser.open_new_tab('%s?%s' % (account_base_url, account_query_string)) patcher_build_fixes = get_fix_names(patcher_build) if len(matching_builds) == 0: best_matching_build = None best_matching_build_diff = patcher_build_fixes best_matching_build_name = patcher_build['patcherProjectVersionName'] else: best_matching_build = None best_matching_build_fixes = None best_matching_build_diff = patcher_build_fixes for matching_build in matching_builds: matching_build_fixes = get_fix_names(matching_build) matching_build_diff = patcher_build_fixes - matching_build_fixes if len(matching_build_diff) < len(best_matching_build_diff): best_matching_build = matching_build best_matching_build_fixes = matching_build_fixes best_matching_build_diff = matching_build_diff if best_matching_build is not None: best_matching_build_name = 'fix-pack-fix-%s' % best_matching_build[ 'patcherFixId'] new_fixes = get_new_fixes(patcher_build['patcherBuildId'], best_matching_build_diff) if len(same_baseline_builds) > 0: webbrowser.open_new_tab( 'https://github.com/liferay/liferay-portal-ee/compare/%s...fix-pack-fix-%s' % (best_matching_build_name, patcher_build['patcherFixId'])) else: tag_name = patcher_build['patcherProjectVersionName'] if tag_name.find('6.2') == 0: tag_name = None patcher_build_name = get_62_fix_pack(patcher_build) if patcher_build_name is None: tag_name = 'fix-pack-base-6210-%s' % tag_name.split( ' ')[1].lower() else: tag_name = get_62_fix_pack_tag(patcher_build_name) webbrowser.open_new_tab( 'https://github.com/liferay/liferay-portal-ee/compare/%s...fix-pack-fix-%s' % (tag_name, patcher_build['patcherFixId'])) return best_matching_build
def get_class_name_id(class_name): api_url = 'https://loop.liferay.com/api/jsonws/classname/fetch-class-name-id' params = {'value': class_name} return json.loads(get_liferay_content(api_url, params)) class_name_id = get_class_name_id('com.liferay.loop.model.LoopPerson') api_url = 'https://loop.liferay.com/api/jsonws/loop-portlet.people/search' params = {'keywords': screen_name, 'start': -1, 'end': -1} response_body = json.loads(get_liferay_content(api_url, params))['data'] assert response_body[ 'total'] == 1, '%s did not match exactly one user' % screen_name loop_person = response_body['results'][0] class_pk = loop_person['entityClassPK'] api_url = 'https://loop.liferay.com/api/jsonws/loop-portlet.feed/viewOldFeed' params = { 'childAssetEntrySetsLimit': 0, 'classNameId': class_name_id, 'classPK': class_pk, 'createTime': 0, 'likedParticipantsLimit': 0,