_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q29700
get_options
train
def get_options(server): """Retrieve the available HTTP verbs""" try: response = requests.options( server, allow_redirects=False, verify=False, timeout=5) except (requests.exceptions.ConnectionError, requests.exceptions.MissingSchema):
python
{ "resource": "" }
q29701
cmd_ping
train
def cmd_ping(ip, interface, count, timeout, wait, verbose): """The classic ping tool that send ICMP echo requests. \b # habu.ping 8.8.8.8 IP / ICMP 8.8.8.8 > 192.168.0.5 echo-reply 0 / Padding IP / ICMP 8.8.8.8 > 192.168.0.5 echo-reply 0 / Padding IP / ICMP 8.8.8.8 > 192.168.0.5 echo-reply 0 / ...
python
{ "resource": "" }
q29702
cmd_host
train
def cmd_host(verbose): """Collect information about the host where habu is running. Example: \b $ habu.host { "kernel": [ "Linux", "demo123", "5.0.6-200.fc29.x86_64", "#1 SMP Wed Apr 3 15:09:51 UTC 2019", "x86_64", "x8...
python
{ "resource": "" }
q29703
cmd_extract_hostname
train
def cmd_extract_hostname(infile, check, verbose, jsonout): """Extract hostnames from a file or stdin. Example: \b $ cat /var/log/some.log | habu.extract.hostname www.google.com ibm.com fileserver.redhat.com """ if verbose: logging.basicConfig(level=logging.INFO, format='%(...
python
{ "resource": "" }
q29704
cmd_b64
train
def cmd_b64(f, do_decode): """ Encodes or decode data in base64, just like the command base64. \b $ echo awesome | habu.b64 YXdlc29tZQo= \b $ echo YXdlc29tZQo= | habu.b64 -d awesome """ data = f.read() if not data:
python
{ "resource": "" }
q29705
cmd_shodan
train
def cmd_shodan(ip, no_cache, verbose, output): """Simple shodan API client. Prints the JSON result of a shodan query. Example: \b $ habu.shodan 8.8.8.8 { "hostnames": [ "google-public-dns-a.google.com" ], "country_code": "US", "org": "Google", ...
python
{ "resource": "" }
q29706
cmd_hasher
train
def cmd_hasher(f, algorithm): """Compute various hashes for the input data, that can be a file or a stream. Example: \b $ habu.hasher README.rst md5 992a833cd162047daaa6a236b8ac15ae README.rst ripemd160 0566f9141e65e57cae93e0e3b70d1d8c2ccb0623 README.rst sha1 d7dbfd2c5e...
python
{ "resource": "" }
q29707
cmd_tcpflags
train
def cmd_tcpflags(ip, port, flags, rflags, verbose): """Send TCP packets with different flags and tell what responses receives. It can be used to analyze how the different TCP/IP stack implementations and configurations responds to packet with various flag combinations. Example: \b # habu.tcpf...
python
{ "resource": "" }
q29708
cmd_land
train
def cmd_land(ip, count, port, iface, verbose): """This command implements the LAND attack, that sends packets forging the source IP address to be the same that the destination IP. Also uses the same source and destination port. The attack is very old, and can be used to make a Denial of Service on ...
python
{ "resource": "" }
q29709
query_bulk
train
def query_bulk(names): """Query server with multiple entries.""" answers = [__threaded_query(name) for name in names] while True:
python
{ "resource": "" }
q29710
lookup_reverse
train
def lookup_reverse(ip_address): """Perform a reverse lookup of IP address.""" try: type(ipaddress.ip_address(ip_address)) except ValueError: return {}
python
{ "resource": "" }
q29711
lookup_forward
train
def lookup_forward(name): """Perform a forward lookup of a hostname.""" ip_addresses = {} addresses = list(set(str(ip[4][0]) for ip in socket.getaddrinfo( name, None))) if addresses is None: return ip_addresses for address in addresses: if type(ipaddress.ip_address(address...
python
{ "resource": "" }
q29712
cmd_crtsh
train
def cmd_crtsh(domain, no_cache, no_validate, verbose): """Downloads the certificate transparency logs for a domain and check with DNS queries if each subdomain exists. Uses multithreading to improve the performance of the DNS queries. Example: \b $ sudo habu.crtsh securetia.com [ ...
python
{ "resource": "" }
q29713
cmd_dns_lookup_forward
train
def cmd_dns_lookup_forward(hostname, verbose): """Perform a forward lookup of a given hostname. Example: \b $ habu.dns.lookup.forward google.com { "ipv4": "172.217.168.46", "ipv6": "2a00:1450:400a:802::200e" } """ if verbose: logging.basicConfig(level=logging.IN...
python
{ "resource": "" }
q29714
cmd_cve_2018_9995
train
def cmd_cve_2018_9995(ip, port, verbose): """Exploit the CVE-2018-9995 vulnerability, present on various DVR systems. Note: Based on the original code from Ezequiel Fernandez (@capitan_alfa). Reference: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-9995 Example: \b $ python habu.cv...
python
{ "resource": "" }
q29715
Command.pid
train
def pid(self): """The process' PID.""" # Support for pexpect's functionality. if hasattr(self.subprocess,
python
{ "resource": "" }
q29716
Command.run
train
def run(self, block=True, binary=False, cwd=None): """Runs the given command, with or without pexpect functionality enabled.""" self.blocking = block # Use subprocess. if self.blocking: popen_kwargs = self._default_popen_kwargs.copy() popen_kwargs['universal_newl...
python
{ "resource": "" }
q29717
Command.send
train
def send(self, s, end=os.linesep, signal=False): """Sends the given string or signal to std_in.""" if self.blocking: raise RuntimeError('send can only be used on non-blocking commands.') if not signal: if self._uses_subprocess:
python
{ "resource": "" }
q29718
cmd_arp_sniff
train
def cmd_arp_sniff(iface): """Listen for ARP packets and show information for each device. Columns: Seconds from last packet | IP | MAC | Vendor Example: \b 1 192.168.0.1 a4:08:f5:19:17:a4 Sagemcom Broadband SAS 7 192.168.0.2 64:bc:0c:33:e5:57 LG Electronics (Mobile Communicati...
python
{ "resource": "" }
q29719
cmd_web_tech
train
def cmd_web_tech(url, no_cache, verbose): """Use Wappalyzer apps.json database to identify technologies used on a web application. Reference: https://github.com/AliasIO/Wappalyzer Note: This tool only sends one request. So, it's stealth and not suspicious. \b $ habu.web.tech https://woocomerce.co...
python
{ "resource": "" }
q29720
cmd_tcpscan
train
def cmd_tcpscan(ip, port, iface, flags, sleeptime, timeout, show_all, verbose): """TCP Port Scanner. Print the ports that generated a response with the SYN flag or (if show use -a) all the ports that generated a response. It's really basic compared with nmap, but who is comparing? Example: \...
python
{ "resource": "" }
q29721
cmd_dns_lookup_reverse
train
def cmd_dns_lookup_reverse(ip_address, verbose): """Perform a reverse lookup of a given IP address. Example: \b $ $ habu.dns.lookup.reverse 8.8.8.8 { "hostname": "google-public-dns-a.google.com" } """ if verbose: logging.basicConfig(level=logging.INFO, format='%(message...
python
{ "resource": "" }
q29722
cmd_crack_luhn
train
def cmd_crack_luhn(number): """Having known values for a Luhn validated number, obtain the possible unknown numbers. Numbers that use the Luhn algorithm for validation are Credit Cards, IMEI, National Provider Identifier in the United States, Canadian Social Insurance Numbers, Israel ID Numbers and Gre...
python
{ "resource": "" }
q29723
cmd_protoscan
train
def cmd_protoscan(ip, iface, timeout, all_protocols, verbose): """ Send IP packets with different protocol field content to guess what layer 4 protocols are available. The output shows which protocols doesn't generate a 'protocol-unreachable' ICMP response. Example: \b $ sudo python c...
python
{ "resource": "" }
q29724
cmd_http_options
train
def cmd_http_options(server, verbose): """Retrieve the available HTTP methods of a web server. Example: \b $ habu.http.options -v http://google.com { "allowed": "GET, HEAD" } """ if verbose: logging.basicConfig(level=logging.INFO, format='%(message)s') if verbose: ...
python
{ "resource": "" }
q29725
cmd_arp_ping
train
def cmd_arp_ping(ip, iface, verbose): """ Send ARP packets to check if a host it's alive in the local network. Example: \b # habu.arp.ping 192.168.0.1 Ether / ARP is at a4:08:f5:19:17:a4 says 192.168.0.1 / Padding """ if verbose: logging.basicConfig(level=logging.INFO, format=...
python
{ "resource": "" }
q29726
cmd_dhcp_starvation
train
def cmd_dhcp_starvation(iface, timeout, sleeptime, verbose): """Send multiple DHCP requests from forged MAC addresses to fill the DHCP server leases. When all the available network addresses are assigned, the DHCP server don't send responses. So, some attacks, like DHCP spoofing, can be made. \b ...
python
{ "resource": "" }
q29727
cmd_http_headers
train
def cmd_http_headers(server, verbose): """Retrieve the HTTP headers of a web server. Example: \b $ habu.http.headers http://duckduckgo.com { "Server": "nginx", "Date": "Sun, 14 Apr 2019 00:00:55 GMT", "Content-Type": "text/html", "Content-Length": "178", "Co...
python
{ "resource": "" }
q29728
cmd_fernet
train
def cmd_fernet(key, decrypt, ttl, i, o): """Fernet cipher. Uses AES-128-CBC with HMAC Note: You must use a key to cipher with Fernet. Use the -k paramenter or set the FERNET_KEY configuration value. The keys can be generated with the command habu.fernet.genkey Reference: https://github.com/...
python
{ "resource": "" }
q29729
cmd_isn
train
def cmd_isn(ip, port, count, iface, graph, verbose): """Create TCP connections and print the TCP initial sequence numbers for each one. \b $ sudo habu.isn -c 5 www.portantier.com 1962287220 1800895007 589617930 3393793979 469428558 Note: You can get a graphical representation (...
python
{ "resource": "" }
q29730
cmd_traceroute
train
def cmd_traceroute(ip, port, iface): """TCP traceroute. Identify the path to a destination getting the ttl-zero-during-transit messages. Note: On the internet, you can have various valid paths to a device. Example: \b # habu.traceroute 45.77.113.133 IP / ICMP 192.168.0.1 > 192.168.0.5 ti...
python
{ "resource": "" }
q29731
web_screenshot
train
def web_screenshot(url, outfile, browser=None): """Create a screenshot of a website.""" valid_browsers = ['firefox', 'chromium-browser'] available_browsers = [ b for b in valid_browsers if which(b) ] if not available_browsers: print("You don't have firefox or chromium-browser in your PATH".for...
python
{ "resource": "" }
q29732
cmd_config_set
train
def cmd_config_set(key, value): """Set VALUE to the config KEY. Note: By default, KEY is converted to uppercase. Example: \b $ habu.config.set DNS_SERVER 8.8.8.8 """ habucfg = loadcfg(environment=False)
python
{ "resource": "" }
q29733
cmd_cymon_ip_timeline
train
def cmd_cymon_ip_timeline(ip, no_cache, verbose, output, pretty): """Simple cymon API client. Prints the JSON result of a cymon IP timeline query. Example: \b $ habu.cymon.ip.timeline 8.8.8.8 { "timeline": [ { "time_label": "Aug. 18, 2018", ...
python
{ "resource": "" }
q29734
gather_details
train
def gather_details(): """Get details about the host that is executing habu.""" try: data = { 'kernel': platform.uname(), 'distribution': platform.linux_distribution(), 'libc': platform.libc_ver(), 'arch': platform.machine(), 'python_version': p...
python
{ "resource": "" }
q29735
get_internal_ip
train
def get_internal_ip(): """Get the local IP addresses.""" nics = {} for interface_name in interfaces(): addresses = ifaddresses(interface_name) try: nics[interface_name] = { 'ipv4': addresses[AF_INET],
python
{ "resource": "" }
q29736
geo_location
train
def geo_location(ip_address): """Get the Geolocation of an IP address.""" try: type(ipaddress.ip_address(ip_address)) except ValueError: return {}
python
{ "resource": "" }
q29737
cmd_nmap_ports
train
def cmd_nmap_ports(scanfile, protocol): """Read an nmap report and print the tested ports. Print the ports that has been tested reading the generated nmap output. You can use it to rapidly reutilize the port list for the input of other tools. Supports and detects the 3 output formats (nmap, gnmap and...
python
{ "resource": "" }
q29738
cmd_web_report
train
def cmd_web_report(input_file, verbose, browser): """Uses Firefox or Chromium to take a screenshot of the websites. Makes a report that includes the HTTP headers. The expected format is one url per line. Creates a directory called 'report' with the content inside. \b $ echo https://www.porta...
python
{ "resource": "" }
q29739
cmd_synflood
train
def cmd_synflood(ip, interface, count, port, forgemac, forgeip, verbose): """Launch a lot of TCP connections and keeps them opened. Some very old systems can suffer a Denial of Service with this. Reference: https://en.wikipedia.org/wiki/SYN_flood Example: \b # sudo habu.synflood 172.16.0.10 ...
python
{ "resource": "" }
q29740
cmd_usercheck
train
def cmd_usercheck(username, no_cache, verbose, wopen): """Check if the given username exists on various social networks and other popular sites. \b $ habu.usercheck portantier { "aboutme": "https://about.me/portantier", "disqus": "https://disqus.com/by/portantier/", "github": "h...
python
{ "resource": "" }
q29741
cmd_dhcp_discover
train
def cmd_dhcp_discover(iface, timeout, verbose): """Send a DHCP request and show what devices has replied. Note: Using '-v' you can see all the options (like DNS servers) included on the responses. \b # habu.dhcp_discover Ether / IP / UDP 192.168.0.1:bootps > 192.168.0.5:bootpc / BOOTP / DHCP "...
python
{ "resource": "" }
q29742
cmd_nmap_excluded
train
def cmd_nmap_excluded(lowest, highest): """ Prints a random port that is not present on nmap-services file so is not scanned automatically by nmap. Useful for services like SSH or RDP, that are continuously scanned on their default ports. Example: \b # habu.nmap.excluded 58567 """ ...
python
{ "resource": "" }
q29743
cmd_jshell
train
def cmd_jshell(ip, port, verbose): """Control a web browser through Websockets. Bind a port (default: 3333) and listen for HTTP connections. On connection, send a JavaScript code that opens a WebSocket that can be used to send commands to the connected browser. You can write the commands directly...
python
{ "resource": "" }
q29744
cmd_xor
train
def cmd_xor(k, i, o): """XOR cipher. Note: XOR is not a 'secure cipher'. If you need strong crypto you must use algorithms like AES. You can use habu.fernet for that. Example: \b $ habu.xor -k mysecretkey -i /bin/ls > xored $ habu.xor -k mysecretkey -i xored > uxored $ sha1sum /bin/ls
python
{ "resource": "" }
q29745
cmd_server_ftp
train
def cmd_server_ftp(address, port, enable_ssl, ssl_cert, ssl_key, verbose): """Basic fake FTP server, whith the only purpose to steal user credentials. Supports SSL/TLS. Example: \b # sudo habu.server.ftp --ssl --ssl-cert /tmp/cert.pem --ssl-key /tmp/key.pem Listening on port 21 Accepted c...
python
{ "resource": "" }
q29746
cmd_whois_domain
train
def cmd_whois_domain(domain): """Simple whois client to check domain names. Example: \b $ habu.whois.domain portantier.com { "domain_name": "portantier.com", "registrar": "Amazon Registrar, Inc.", "whois_server": "whois.registrar.amazon.com", ... """
python
{ "resource": "" }
q29747
cmd_gateway_find
train
def cmd_gateway_find(network, iface, host, tcp, dport, timeout, verbose): """ Try to reach an external IP using any host has a router. Useful to find routers in your network. First, uses arping to detect alive hosts and obtain MAC addresses. Later, create a network packet and put each MAC address...
python
{ "resource": "" }
q29748
cmd_extract_email
train
def cmd_extract_email(infile, verbose, jsonout): """Extract email addresses from a file or stdin. Example: \b $ cat /var/log/auth.log | habu.extract.email john@securetia.com raven@acmecorp.net
python
{ "resource": "" }
q29749
cmd_karma_bulk
train
def cmd_karma_bulk(infile, jsonout, badonly, verbose): """Show which IP addresses are inside blacklists using the Karma online service. Example: \b $ cat /var/log/auth.log | habu.extract.ipv4 | habu.karma.bulk 172.217.162.4 spamhaus_drop,alienvault_spamming 23.52.213.96 CLEAN 190.210....
python
{ "resource": "" }
q29750
Pool.terminate
train
def terminate(self): """Terminate pool. Close pool with instantly closing all acquired connections also. """ self.close() for conn in list(self._used):
python
{ "resource": "" }
q29751
Cursor.execute
train
async def execute(self, query, args=None): """Executes the given operation Executes the given operation substituting any markers with the given parameters. For example, getting all rows where id is 5: cursor.execute("SELECT * FROM t1 WHERE id = %s", (5,)) :param quer...
python
{ "resource": "" }
q29752
Cursor.executemany
train
async def executemany(self, query, args): """Execute the given operation multiple times The executemany() method will execute the operation iterating over the list of parameters in seq_params. Example: Inserting 3 new employees and their phone number data = [ ...
python
{ "resource": "" }
q29753
SSCursor.fetchall
train
async def fetchall(self): """Fetch all, as per MySQLdb. Pretty useless for large queries, as it is buffered. """ rows = [] while True:
python
{ "resource": "" }
q29754
Connection.close
train
def close(self): """Close socket connection""" if self._writer:
python
{ "resource": "" }
q29755
Connection.ensure_closed
train
async def ensure_closed(self): """Send quit command and then close socket connection""" if self._writer is None: # connection
python
{ "resource": "" }
q29756
Connection.cursor
train
def cursor(self, *cursors): """Instantiates and returns a cursor By default, :class:`Cursor` is returned. It is possible to also give a custom cursor through the cursor_class parameter, but it needs to be a subclass of :class:`Cursor` :param cursor: custom cursor class. ...
python
{ "resource": "" }
q29757
Connection.ping
train
async def ping(self, reconnect=True): """Check if the server is alive""" if self._writer is None and self._reader is None: if reconnect: await self._connect() reconnect = False
python
{ "resource": "" }
q29758
Connection.write_packet
train
def write_packet(self, payload): """Writes an entire "mysql packet" in its entirety to the network addings its length and sequence number. """ # Internal note: when you build
python
{ "resource": "" }
q29759
MySQLResult._read_rowdata_packet
train
async def _read_rowdata_packet(self): """Read a rowdata packet for each data row in the result set.""" rows = [] while True: packet = await self.connection._read_packet() if self._check_packet_is_eof(packet): # release reference to kill cyclic
python
{ "resource": "" }
q29760
MySQLResult._get_descriptions
train
async def _get_descriptions(self): """Read a column descriptor packet for each column in the result.""" self.fields = [] self.converters = [] use_unicode = self.connection.use_unicode conn_encoding = self.connection.encoding description = [] for i in range(self.fi...
python
{ "resource": "" }
q29761
Transaction.rollback
train
async def rollback(self): """Roll back this transaction.""" if not self._parent._is_active: return
python
{ "resource": "" }
q29762
TwoPhaseTransaction.prepare
train
async def prepare(self): """Prepare this TwoPhaseTransaction. After a PREPARE, the transaction can be committed. """ if not self._parent.is_active:
python
{ "resource": "" }
q29763
SAConnection.execute
train
def execute(self, query, *multiparams, **params): """Executes a SQL query with optional parameters. query - a SQL query string or any sqlalchemy expression. *multiparams/**params - represent bound parameter values to be used in the execution. Typically, the format is a dictionary ...
python
{ "resource": "" }
q29764
SAConnection.scalar
train
async def scalar(self, query, *multiparams, **params): """Executes a SQL query and
python
{ "resource": "" }
q29765
SAConnection.begin_nested
train
async def begin_nested(self): """Begin a nested transaction and return a transaction handle. The returned object is an instance of :class:`.NestedTransaction`. Nested transactions require SAVEPOINT support in the underlying database. Any transaction in the hierarchy may .commi...
python
{ "resource": "" }
q29766
SAConnection.begin_twophase
train
async def begin_twophase(self, xid=None): """Begin a two-phase or XA transaction and return a transaction handle. The returned object is an instance of TwoPhaseTransaction, which in addition to the methods provided by Transaction, also provides a TwoPhaseTransaction.prep...
python
{ "resource": "" }
q29767
SAConnection.rollback_prepared
train
async def rollback_prepared(self, xid, *, is_prepared=True): """Rollback prepared twophase transaction.""" if not is_prepared:
python
{ "resource": "" }
q29768
SAConnection.commit_prepared
train
async def commit_prepared(self, xid, *, is_prepared=True): """Commit prepared twophase transaction.""" if not is_prepared:
python
{ "resource": "" }
q29769
SAConnection.close
train
async def close(self): """Close this SAConnection. This results in a release of the underlying database resources, that is, the underlying connection referenced internally. The underlying connection is typically restored back to the connection-holding Pool referenced by the Engi...
python
{ "resource": "" }
q29770
ResultProxy.first
train
async def first(self): """Fetch the first row and then close the result set unconditionally. Returns None if no row is present. """ if self._metadata is None: self._non_result()
python
{ "resource": "" }
q29771
get_value
train
def get_value(data, name, field, allow_many_nested=False): """Get a value from a dictionary. Handles ``MultiDict`` types when ``multiple=True``. If the value is not found, return `missing`. :param object data: Mapping (e.g. `dict`) or list-like instance to pull the value from. :param str name: ...
python
{ "resource": "" }
q29772
Parser._validated_locations
train
def _validated_locations(self, locations): """Ensure that the given locations argument is valid. :raises: ValueError if a given locations includes an invalid location. """ # The set difference between the given locations and the available locations # will be the set of invalid l...
python
{ "resource": "" }
q29773
Parser.parse_arg
train
def parse_arg(self, name, field, req, locations=None): """Parse a single argument from a request. .. note:: This method does not perform validation on the argument. :param str name: The name of the value. :param marshmallow.fields.Field field: The marshmallow `Field` for th...
python
{ "resource": "" }
q29774
Parser._parse_request
train
def _parse_request(self, schema, req, locations): """Return a parsed arguments dictionary for the current request.""" if schema.many: assert ( "json" in locations ), "schema.many=True is only supported for JSON location" # The ad hoc Nested field is mo...
python
{ "resource": "" }
q29775
Parser._get_schema
train
def _get_schema(self, argmap, req): """Return a `marshmallow.Schema` for the given argmap and request. :param argmap: Either a `marshmallow.Schema`, `dict` of argname -> `marshmallow.fields.Field` pairs, or a callable that returns a `marshmallow.Schema` instance. :param ...
python
{ "resource": "" }
q29776
Parser.parse
train
def parse( self, argmap, req=None, locations=None, validate=None, error_status_code=None, error_headers=None, ): """Main request parsing method. :param argmap: Either a `marshmallow.Schema`, a `dict` of argname -> `marshmallow.fiel...
python
{ "resource": "" }
q29777
Parser.use_kwargs
train
def use_kwargs(self, *args, **kwargs): """Decorator that injects parsed arguments into a view function or method as keyword arguments. This is a shortcut to :meth:`use_args` with ``as_kwargs=True``. Example usage with Flask: ::
python
{ "resource": "" }
q29778
Parser.handle_error
train
def handle_error( self, error, req, schema, error_status_code=None, error_headers=None ): """Called if an error occurs while parsing args. By default, just logs and
python
{ "resource": "" }
q29779
parse_json_body
train
def parse_json_body(req): """Return the decoded JSON body from the request.""" content_type = req.headers.get("Content-Type") if content_type and core.is_json(content_type): try: return core.parse_json(req.body) except TypeError:
python
{ "resource": "" }
q29780
get_value
train
def get_value(d, name, field): """Handle gets from 'multidicts' made of lists It handles cases: ``{"key": [value]}`` and ``{"key": value}`` """ multiple = core.is_multiple(field) value = d.get(name, core.missing) if value is core.missing:
python
{ "resource": "" }
q29781
TornadoParser.handle_error
train
def handle_error(self, error, req, schema, error_status_code, error_headers): """Handles errors during parsing. Raises a `tornado.web.HTTPError` with a 400 error. """ status_code = error_status_code or self.DEFAULT_VALIDATION_STATUS
python
{ "resource": "" }
q29782
PyramidParser.parse_matchdict
train
def parse_matchdict(self, req, name, field): """Pull a value from the request's `matchdict`."""
python
{ "resource": "" }
q29783
PyramidParser.handle_error
train
def handle_error(self, error, req, schema, error_status_code, error_headers): """Handles errors during parsing. Aborts the current HTTP request and responds with a 400 error. """ status_code = error_status_code or self.DEFAULT_VALIDATION_STATUS response = exception_response( ...
python
{ "resource": "" }
q29784
route
train
def route(*args, response_formatter=jsonify, **kwargs): """Combines `Flask.route` and webargs parsing. Allows arguments to be specified as function annotations. An output schema can optionally be specified by a return annotation. """ def decorator(func): @app.route(*args, **kwargs) ...
python
{ "resource": "" }
q29785
BaseRequestHandler.write_error
train
def write_error(self, status_code, **kwargs): """Write errors as JSON.""" self.set_header("Content-Type", "application/json") if "exc_info" in kwargs: etype, exc, traceback = kwargs["exc_info"] if hasattr(exc, "messages"): self.write({"errors": exc.message...
python
{ "resource": "" }
q29786
HTTPError.to_dict
train
def to_dict(self, *args, **kwargs): """Override `falcon.HTTPError` to include error messages in responses.""" ret = super(HTTPError, self).to_dict(*args, **kwargs)
python
{ "resource": "" }
q29787
FalconParser.parse_headers
train
def parse_headers(self, req, name, field): """Pull a header value from the request."""
python
{ "resource": "" }
q29788
FalconParser.parse_cookies
train
def parse_cookies(self, req, name, field): """Pull a cookie value from the request.""" cookies = self._cache.get("cookies") if cookies is None:
python
{ "resource": "" }
q29789
FalconParser.get_request_from_view_args
train
def get_request_from_view_args(self, view, args, kwargs): """Get request from a resource method's arguments. Assumes that request is the second argument. """ req = args[1]
python
{ "resource": "" }
q29790
FalconParser.handle_error
train
def handle_error(self, error, req, schema, error_status_code, error_headers): """Handles errors during parsing.""" status = status_map.get(error_status_code or self.DEFAULT_VALIDATION_STATUS) if status is None:
python
{ "resource": "" }
q29791
AsyncParser.parse
train
async def parse( self, argmap: ArgMap, req: Request = None, locations: typing.Iterable = None, validate: Validate = None, error_status_code: typing.Union[int, None] = None, error_headers: typing.Union[typing.Mapping[str, str], None] = None, ) -> typing.Union[t...
python
{ "resource": "" }
q29792
AIOHTTPParser.parse_cookies
train
def parse_cookies(self, req: Request, name: str, field: Field) -> typing.Any:
python
{ "resource": "" }
q29793
AIOHTTPParser.parse_match_info
train
def parse_match_info(self, req: Request, name: str, field: Field) -> typing.Any: """Pull
python
{ "resource": "" }
q29794
AIOHTTPParser.handle_error
train
def handle_error( self, error: ValidationError, req: Request, schema: Schema, error_status_code: typing.Union[int, None] = None, error_headers: typing.Union[typing.Mapping[str, str], None] = None, ) -> "typing.NoReturn": """Handle ValidationErrors and return a...
python
{ "resource": "" }
q29795
BottleParser.handle_error
train
def handle_error(self, error, req, schema, error_status_code, error_headers): """Handles errors during parsing. Aborts the current request with a 400 error. """ status_code = error_status_code or self.DEFAULT_VALIDATION_STATUS raise bottle.HTTPError(
python
{ "resource": "" }
q29796
handle_request_parsing_error
train
def handle_request_parsing_error(err, req, schema, error_status_code, error_headers): """webargs error handler
python
{ "resource": "" }
q29797
DateAddResource.post
train
def post(self, value, addend, unit): """A date adder endpoint.""" value = value or dt.datetime.utcnow() if unit == "minutes": delta = dt.timedelta(minutes=addend) else:
python
{ "resource": "" }
q29798
get_stats_daily
train
def get_stats_daily(start=None, end=None, last=None, **kwargs): """ Stats Historical Daily This call will return daily stats for a given month or day. .. warning:: This endpoint is marked as "in development" by the provider. Reference: https://iexcloud.io/docs/api/#stats-historical-daily-in-dev ...
python
{ "resource": "" }
q29799
get_stats_summary
train
def get_stats_summary(start=None, end=None, **kwargs): """ Stats Historical Summary Reference: https://iexcloud.io/docs/api/#stats-historical-summary Data Weighting: ``Free`` Parameters ---------- start: datetime.datetime, default None, optional Start of data retrieval period e...
python
{ "resource": "" }