Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, uri, name, log=False):
this_dir = os.path.dirname(__file__)
path = os.path.join(this_dir, "twisted-localserver.py")
ServerProcess.__init__(self, path, name)
self.uri = uri
authority = mechanize._rfc3986.urlsplit(uri)[1]
host, port = urllib.splitport(authority)
if port is None:
port = "80"
self.port = int(port)
# def report(msg):
# print "%s: %s" % (name, msg)
report = lambda msg: None
self.report_hook = report
self._log = log
self._start()
def __init__(self, uri, name, log=False):
this_dir = os.path.dirname(__file__)
path = os.path.join(this_dir, "twisted-localserver.py")
ServerProcess.__init__(self, path, name)
self.uri = uri
authority = mechanize._rfc3986.urlsplit(uri)[1]
host, port = mechanize.polyglot.splitport(authority)
if port is None:
port = "80"
self.port = int(port)
def report(msg):
pass
self.report_hook = report
self._log = log
self._start()
def get_selector(self):
scheme, authority, path, query, fragment = _rfc3986.urlsplit(
self.__r_host)
if path == "":
path = "/" # RFC 2616, section 3.2.2
fragment = None # RFC 3986, section 3.5
return _rfc3986.urlunsplit([scheme, authority, path, query, fragment])
def _mech_open(self,
url,
data=None,
update_history=True,
visit=None,
timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT):
try:
url.get_full_url
except AttributeError:
# string URL -- convert to absolute URL if required
scheme, authority = _rfc3986.urlsplit(url)[:2]
if scheme is None:
# relative URL
if self._response is None:
raise BrowserStateError("can't fetch relative reference: "
"not viewing any document")
url = _rfc3986.urljoin(self._response.geturl(), url)
request = self._request(url, data, visit, timeout)
visit = request.visit
if visit is None:
visit = True
if visit:
self._visit_request(request, update_history)
success = True
def _mech_open(self,
url,
data=None,
update_history=True,
visit=None,
timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT):
try:
url.get_full_url
except AttributeError:
# string URL -- convert to absolute URL if required
scheme, authority = _rfc3986.urlsplit(url)[:2]
if scheme is None:
# relative URL
if self._response is None:
raise BrowserStateError("can't fetch relative reference: "
"not viewing any document")
url = _rfc3986.urljoin(self._response.geturl(), url)
request = self._request(url, data, visit, timeout)
visit = request.visit
if visit is None:
visit = True
if visit:
self._visit_request(request, update_history)
success = True