How to use _get_build_url method in Slash

Best Python code snippet using slash

gui.py

Source:gui.py Github

copy

Full Screen

...95 if controlID == self.BUILD_LIST_ID:96 self._selected_build = self._builds[self._build_list.getSelectedPosition()]97 self.close()98 elif controlID == self.SOURCE_LIST_ID:99 self._build_url = self._get_build_url()100 build_links = self._get_build_links(self._build_url)101 if build_links:102 self._selected_source_item.setLabel2('')103 self._selected_source_item = self._sources_list.getSelectedItem()104 self._selected_source_position = self._sources_list.getSelectedPosition()105 self._selected_source_item.setLabel2('selected')106 self._selected_source = self._selected_source_item.getLabel()107 self._set_builds(build_links)108 threading.Thread(target=self._get_and_set_build_info,109 args=(self._build_url,)).start()110 else:111 self._sources_list.selectItem(self._selected_source_position)112 elif controlID == self.SETTINGS_BUTTON_ID:113 self.close()114 addon.open_settings()115 elif controlID == self.HISTORY_BUTTON_ID:116 dialog = HistoryDialog(history.get_full_install_history())117 dialog.doModal()118 elif controlID == self.CANCEL_BUTTON_ID:119 if utils.remove_update_files():120 utils.notify(L10n(32034))121 self._cancel_button.setVisible(False)122 funcs.remove_notify_file()123 self._info_textbox.setText("")124 def onAction(self, action):125 action_id = action.getId()126 if action_id in (xbmcgui.ACTION_MOVE_DOWN, xbmcgui.ACTION_MOVE_UP,127 xbmcgui.ACTION_PAGE_DOWN, xbmcgui.ACTION_PAGE_UP,128 xbmcgui.ACTION_MOUSE_MOVE):129 self._set_build_info()130 elif action_id == xbmcgui.ACTION_SHOW_INFO:131 build_version = self._build_list.getSelectedItem().getLabel()132 try:133 info = self._build_infos[build_version]134 except KeyError:135 log.log("Build details for build {} not found".format(build_version))136 else:137 if info.details is not None:138 try:139 details = info.details.get_text()140 except Exception as e:141 log.log("Unable to retrieve build details: {}".format(e))142 else:143 if details:144 build = "[B]{}[/B]\n\n".format(L10n(32035)).format(build_version)145 dialog = InfoDialog(build, details)146 dialog.doModal()147 elif action_id in (xbmcgui.ACTION_PREVIOUS_MENU, xbmcgui.ACTION_NAV_BACK):148 self.close()149 def onFocus(self, controlID):150 if controlID != self.BUILD_LIST_ID:151 self._info_textbox.setText("")152 self._builds_focused = False153 if controlID == self.BUILD_LIST_ID:154 self._builds_focused = True155 self._set_build_info()156 elif controlID == self.SOURCE_LIST_ID:157 self._info_textbox.setText("[COLOR=white]{}[/COLOR]".format(L10n(32141)))158 elif controlID == self.SETTINGS_BUTTON_ID:159 self._info_textbox.setText("[COLOR=white]{}[/COLOR]".format(L10n(32036)))160 elif controlID == self.HISTORY_BUTTON_ID:161 self._info_textbox.setText("[COLOR=white]{}[/COLOR]".format(L10n(32037)))162 elif controlID == self.CANCEL_BUTTON_ID:163 self._info_textbox.setText("[COLOR=white]{}[/COLOR]".format(L10n(32038)))164 @utils.showbusy165 def _get_build_links(self, build_url):166 links = []167 try:168 links = build_url.builds()169 except requests.ConnectionError as e:170 utils.connection_error(str(e))171 except builds.BuildURLError as e:172 utils.bad_url(build_url.url, str(e))173 except requests.RequestException as e:174 utils.url_error(build_url.url, str(e))175 else:176 if not links:177 utils.bad_url(build_url.url, L10n(32039).format(builds.arch))178 return links179 def _get_build_infos(self, build_url):180 log.log("Retrieving build information")181 info = {}182 for info_extractor in build_url.info_extractors:183 try:184 info.update(info_extractor.get_info())185 except Exception as e:186 log.log("Unable to retrieve build info: {}".format(str(e)))187 return info188 def _set_build_info(self):189 if self._builds_focused:190 selected_item = self._build_list.getSelectedItem()191 try:192 build_version = selected_item.getLabel()193 except AttributeError:194 log.log("Unable to get selected build name")195 else:196 try:197 info = self._build_infos[build_version].summary198 except KeyError:199 info = ""200 log.log("Build info for build {} not found".format(build_version))201 else:202 log.log("Info for build {}:\n\t{}".format(build_version, info))203 self._info_textbox.setText(info)204 def _get_and_set_build_info(self, build_url):205 self._build_infos = self._get_build_infos(build_url)206 self._set_build_info()207 def _get_build_url(self):208 source = self._sources_list.getSelectedItem().getLabel()209 build_url = self._sources[source]210 log.log("Full URL = " + build_url.url)211 return build_url212 def _set_builds(self, builds):213 self._builds = builds214 self._build_list.reset()215 for build in builds:216 li = xbmcgui.ListItem()217 li.setLabel(build.version)218 li.setLabel2(build.date)219 if build > self._installed_build:220 icon = 'upgrade'221 elif build < self._installed_build:...

Full Screen

Full Screen

products.py

Source:products.py Github

copy

Full Screen

...38 def _format_date_part(part):39 if part < 10:40 part = "0" + str(part)41 return str(part)42 def _get_build_url(self, product, date):43 url = self._baseurl44 year = str(date.year)45 month = self._format_date_part(date.month)46 day = self._format_date_part(date.day)47 url += year + "/" + month + "/"48 linkregex = '^' + year + '-' + month + '-' + day + '-' + '[\d-]+' + \49 product['reponame'] + '/$'50 cachekey = year + '-' + month51 if cachekey in self._monthlinks:52 monthlinks = self._monthlinks[cachekey]53 else:54 monthlinks = self._url_links(url)55 self._monthlinks[cachekey] = monthlinks56 # first parse monthly list to get correct directory57 for dirlink in monthlinks:58 dirhref = dirlink.get("href")59 if re.match(linkregex, dirhref):60 # now parse the page for the correct build url61 for url in [url + dirhref, url + dirhref + "en-US/"]:62 for link in self._url_links(url):63 href = link.get("href")64 if re.match(product['buildregex'], href):65 return url + href66 return None67 def _get_latest_build_url(self, product):68 baseurl = product['latest']69 matches = []70 for link in self._url_links(baseurl):71 href = link.get("href")72 # sometimes there will be multiple matching products between73 # merges. in that case, we grab the greater of them (as the74 # latest has a higher version number)75 if re.match(product['buildregex'], href):76 matches.append(href)77 if not matches:78 raise Exception("Could not find matching build!")79 return baseurl + sorted(matches)[-1]80 def get_build(self, product, date=None):81 if not date:82 url = self._get_latest_build_url(product)83 datestr = "latest"84 else:85 url = self._get_build_url(product, date)86 datestr = date.strftime("%Y-%m-%d")87 fname = os.path.join(DOWNLOAD_DIR,88 "%s-%s.apk" % (product['name'], datestr))89 if date and os.path.exists(fname):90 print "Build already exists for %s. Skipping download." % datestr91 return fname92 print "Downloading '%s' to '%s'" % (url, fname)93 dl = urllib2.urlopen(url)94 with open(fname, 'w') as f:95 f.write(dl.read())96 return fname97products = [98 {99 "name": "nightly",...

Full Screen

Full Screen

antigate.py

Source:antigate.py Github

copy

Full Screen

...40 def _update_params(self, defaults, additional):41 if additional is not None and additional:42 defaults.update(additional)43 return defaults44 def _get_build_url(self, action='get', data=None):45 params = urlencode(self._update_params(46 {'key': self.key, 'action': action}, data47 ))48 return self._get_domain('res.php?%s' % params)49 def _get_result_url(self, action='get', captcha_id=None):50 return self._get_build_url(action, {51 'id': captcha_id and captcha_id or self.captcha_id})52 def _get_balance_url(self):53 return self._get_build_url('getbalance')54 def _get_stats_url(self):55 return self._get_build_url('getstats', {56 'date': datetime.now().strftime('%Y-%m-%d')})57 def _body(self, key):58 body = self.g.response.body.split('|')59 if len(body) != 2 or body[0] != 'OK':60 raise AntiGateError(body[0])61 setattr(self, key, body[1])62 return body[1]63 def _response_to_dict(self):64 return parse(self.g.response.body.lower())['response']65 def _go(self, url, err):66 self.g.go(url)67 if self.g.response.code != 200:68 raise AntiGateError('Code: %d\nMessage: %s\nBody: %s' % (69 self.g.response.code, err, self.g.response.body70 ))71 def _send(self, captcha_file, binary=False):72 if binary:73 body = base64.b64encode(captcha_file)74 self.g.setup(post=self._update_params(75 {'method': 'base64', 'key': self.key, 'body': body},76 self.send_config77 ))78 else:79 self.g.setup(multipart_post=self._update_params(80 {'method': 'post', 'key': self.key,81 'file': UploadFile(captcha_file)},82 self.send_config83 ))84 self._go(self._get_input_url(), 'Can not send captcha')85 return self._body('captcha_id')86 def send(self, captcha_file, binary=False):87 self.logger.debug('Sending captcha')88 while True:89 try:90 return self._send(captcha_file, binary)91 except AntiGateError:92 msg = exc_info()[1]93 self.logger.debug(msg)94 if str(msg) != 'ERROR_NO_SLOT_AVAILABLE':95 raise AntiGateError(msg)96 def _get(self, captcha_id=None):97 self.g.reset()98 self._go(self._get_result_url(captcha_id=captcha_id),99 'Can not get captcha')100 return self._body('captcha_key')101 def get(self, captcha_id=None):102 self.logger.debug('Fetching result')103 sleep(10)104 while True:105 try:106 return self._get(captcha_id)107 except AntiGateError:108 msg = exc_info()[1]109 self.logger.debug(msg)110 if str(msg) == 'CAPCHA_NOT_READY':111 sleep(5)112 else:113 raise AntiGateError(msg)114 def _get_multi(self, ids):115 self._go(self._get_build_url(data={116 'ids': ','.join(map(str, ids))}), 'Can not get result')117 return self.g.response.body.split('|')118 def get_multi(self, ids):119 results = self._get_multi(ids)120 while 'CAPCHA_NOT_READY' in results:121 sleep(10)122 results = self._get_multi(ids)123 return results124 def abuse(self):125 self._go(self._get_result_url('reportbad'), 'Can not send report')126 return True127 def balance(self):128 self._go(self._get_balance_url(), 'Can not get balance')129 return float(self.g.response.body)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful