### Example Command and Output Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/examples/traceroute.md This example shows how to run the traceroute script from the command line with root privileges and provides a sample output, illustrating the HopInfo structure. ```bash $ sudo examples/traceroute 127.0.0.1 HopInfo(ttl=1, hops=[Hop(addr='127.0.0.1', rtt=1.5403e-05, asn=0), Hop(addr='127.0.0.1', rtt=1.0747e-05, asn=0), Hop(addr='127.0.0.1', rtt=5.0981e-05, asn=0)]) ``` -------------------------------- ### Install Gufo Traceroute Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/installation.md Use this command to install the Gufo Traceroute package using pip. ```bash $ pip install gufo_traceroute ``` -------------------------------- ### Basic Traceroute Script Setup Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/examples/traceroute.md This snippet shows the initial setup for a traceroute script, including importing the asyncio module. ```python import asyncio ``` -------------------------------- ### Check Gufo Traceroute Installation Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/installation.md Import the traceroute module to verify that Gufo Traceroute has been installed correctly. ```python from gufo.traceroute import traceroute ``` -------------------------------- ### Check Code Formatting Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/dev/testing.md Use this command to check the formatting of Python code in the examples, src, and tests directories according to project standards. ```shell ruff check examples/ src/ tests/ ``` -------------------------------- ### Using Traceroute as an Async Context Manager Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/examples/traceroute.md This snippet demonstrates using the Traceroute object as an asynchronous context manager with 'async with'. This ensures proper setup and teardown of the traceroute session. ```python async with Traceroute() as traceroute: ``` -------------------------------- ### Upgrade Gufo Traceroute Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/installation.md Run this command to upgrade an existing Gufo Traceroute installation to the latest version using pip. ```bash $ pip install --upgrade gufo_traceroute ``` -------------------------------- ### Check Python Code Lints Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/dev/testing.md This command checks the Python code in the examples, src, and tests directories for linting errors. ```shell ruff examples/ src/ tests/ ``` -------------------------------- ### Build Documentation Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/dev/testing.md Run this command to rebuild and serve the project's documentation locally. It's recommended to use Grammarly for checking documentation content. ```shell mkdocs serve ``` -------------------------------- ### Build Package Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/dev/testing.md Run this command to build the package as both a source distribution and a wheel. Compiled packages will be placed in the 'dist/' directory. ```shell python -m build --sdist --wheel ``` -------------------------------- ### Running the Asynchronous Main Function Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/examples/traceroute.md This snippet shows how to run the main asynchronous function using asyncio.run(), passing the first command-line argument as the target address. This is the entry point for executing the traceroute script. ```python asyncio.run(main(sys.argv[1])) ``` -------------------------------- ### Executing Traceroute and Handling Hops Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/examples/traceroute.md This snippet shows how to initiate the traceroute using the traceroute() method and iterate over the yielded HopInfo objects. The 'tries' parameter controls the number of probes per host. ```python async for info in traceroute.traceroute(addr, tries=3): ``` -------------------------------- ### Importing Sys Module for CLI Arguments Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/examples/traceroute.md This snippet demonstrates importing the sys module to parse command-line arguments for the traceroute script. Note: sys.argv is used for demonstration; argparse is recommended for real-world applications. ```python import sys ``` -------------------------------- ### Basic Traceroute Execution Source: https://github.com/gufolabs/gufo_traceroute/blob/master/README.md This snippet demonstrates the basic usage of Gufo Traceroute to perform a traceroute to a target IP address. It iterates through each hop, printing hop information. Ensure the Traceroute class is imported. ```python async with Traceroute() as tr: async for hop in tr.traceroute("8.8.8.8", tries=3): print(hop) ``` -------------------------------- ### Generate HTML Coverage Report Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/dev/testing.md This command generates a detailed, line-by-line HTML report of code coverage. Open 'dist/coverage/index.html' in a browser to view it. ```shell coverage html ``` -------------------------------- ### Run Test Suite Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/dev/testing.md Execute the entire test suite using pytest. The '-vv' flag provides verbose output. ```shell pytest -vv ``` -------------------------------- ### Generate Coverage Report Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/dev/testing.md After running tests with coverage, use this command to generate a report summarizing the code coverage. ```shell coverage report ``` -------------------------------- ### Run Tests for Coverage Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/dev/testing.md Execute the test suite with coverage tracking enabled. This command runs tests and collects coverage data. ```shell coverage run -m pytest -vv ``` -------------------------------- ### Printing Hop Information Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/examples/traceroute.md This snippet demonstrates how to print the received HopInfo objects, which contain details about each hop in the network path. This is a basic way to visualize the traceroute results. ```python print(info) ``` -------------------------------- ### Importing Traceroute Object Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/examples/traceroute.md This snippet shows how to import the Traceroute object from the gufo.traceroute module, which is essential for performing traceroute operations. ```python from gufo.traceroute import Traceroute ``` -------------------------------- ### Fix Code Formatting Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/dev/testing.md Run this command to automatically fix formatting errors in the specified Python code directories. ```shell ruff format examples/ src/ tests/ ``` -------------------------------- ### Check Python Code Static Typing Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/dev/testing.md Use this command to check the source code for typing errors with strict type checking enabled. ```shell mypy --strict src/ ``` -------------------------------- ### Uninstall Gufo Traceroute Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/installation.md Use this command to uninstall the Gufo Traceroute package using pip. ```bash $ pip uninstall gufo_traceroute ``` -------------------------------- ### Defining Asynchronous Main Function Source: https://github.com/gufolabs/gufo_traceroute/blob/master/docs/examples/traceroute.md This snippet defines the main asynchronous function for the traceroute script. Asynchronous functions are required to run coroutines and handle network operations efficiently. ```python async def main(addr: str): ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.