cloudflarepycli


Namecloudflarepycli JSON
Version 1.8.1 PyPI version JSON
download
home_pagehttps://github.com/tevslin/cloudflarepycli
Summary"Python CLI and python class for retrieving user's realtime performance statistics"
upload_time2023-09-22 20:06:01
maintainer
docs_urlNone
author"Tom Evslin"
requires_python>=3.7
license
keywords speedtest cloudflare latency jitter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Temporary note
PyPi is still version 1.8.0

# cloudflarepycli

Python CLI and python class for retrieving user's realtime performance statistics.

## Purpose

Retrieve near-term performance data about the service provided to a user by an ISP. The data includes up and download speeds, latency, and jitter. The CLI makes it possible to pipe the data to other processes for possible uploading, analysis etc. and/or to build a GUI for displaying current and past data. The cloudflareclass.py module is useful for varying the types of test that are done. I will use both in future projects to expand the functionality.

## Install

pip install cloudflarepycli \
Windows users must also: pip install wres

## CLI usage

Type 'cfspeedtest' in the environment where you installed the package. Note that this is a shell command, not a Python command.

### Options

  -h, --help  show help message and exit
  
  --debug     log network io
  
  --json      write json to sysout instead of formatted results
  
  --version   show program's version number and exit
  
## Cloudflareclass Documentation

The Cloudflare Connection Testing Class is a Python module that facilitates testing the speed and latency of your internet connection to Cloudflare's servers. It utilizes the `requests` library to perform various tests and provides insights into download and upload speeds, latency, and other connection metrics.

### Features

- Measures download and upload speeds to Cloudflare's servers.
- Calculates latency and jitter for connection stability assessment.
- Provides information about your IP address, ISP, test location, and more.
- Easy-to-use class interface to conduct various connection tests.

### Function arguments

  ```python
  cloudflare(thedict=None,debug=False,print=True,downtests=None,uptests=None,latencyreps=20)
  ```


- `thedict`: dictionary to store results in
    - if not passed in, created here
    - if passed in, used and update - allows keeping partial results from previous runs
    - each result has a key and the entry is a dict with "time" and "value" items
- `debug`: if True, turns on io logging for debugging
- `printit`: if True, results are printed as well as added to the dictionary
- `downtests`: tuple of download tests to be performed
    - if None, four download tests are performed consecutively: 100kB, 1MB, 10MB, and 25MB
    - format is ((size, reps, label)......)
        - size: size of block to download
        - reps: number of times to repeat test
        - label: text label for test - also becomes key in the dict
- `uptests`: tuple of upload tests to be performed
    - if None, three upload tests are performed consecutively: 100kB, 1MB, and 10MB
    - format is ((size, reps, label)......)
        - size: size of block to upload
        - reps: number of times to repeat test
        - label: text label for test - also becomes key in the dict
- `latencyreps`: number of repetitions for latency test

#### Usage

The `cloudflare` class provides methods to perform various connection tests and retrieve relevant information. Here's a brief overview of its main methods:

- `runalltests()`: Runs a full suite of tests, including latency, jitter, download, and upload tests. Returns a dictionary with test results.
- `getfulldata()`: Retrieves information about your IP address, ISP, test location, and more.
- `download(numbytes, iterations)`: Runs download tests for the specified number of bytes and iterations. Returns timing results.
- `upload(numbytes, iterations)`: Runs upload tests for the specified number of bytes and iterations. Returns timing results.

Refer to the `cloudflareclass.py`` file for detailed documentation on each method and its parameters.

### Stand-alone usage
#### Getting Started

1. Install the required dependencies:
    ```bash
    pip install requests numpy
    ```
2. Download the cloudflareclass.py file and include it in your project.
3. Import the cloudflare class in your Python script:
    ```python
    from cloudflareclass import cloudflare
    ```
4. Create an instance of the cloudflare class and run tests:
    ```python
    cf = cloudflare()
    results = cf.runalltests()
    print(results)
    ```

#### Example

```python
from cloudflareclass import cloudflare

cf = cloudflare()
results = cf.runalltests()
print(results)
```

## Source repository

https://github.com/tevslin/cloudflarepycli

## How it works

Tests for latency are done by requesting one byte packets from Cloudflare, measuring the elapsed time to get a response, and subtracting the server processing time taken from the header in the returned message. Jitter is computed as the mean of the absolute difference between the arrival of consecutive requests.

The cloudflareclass.py module makes Python requests to various subaddresses of [speed.cloudflare.com](https://speed.cloudflare.com). Their API is not documented, as far as I know, and so that is a vulnerability for this code.

Mirroring the performance of the Cloudflare webpage, the CLI does multiple uploads and downloads with different block sizes and the 90th percentile of all these tests is used for calculating up and download times. Results are similar to those obtained from the webpage. Tests can be varied using the cloudflareclass module.

Unlike Ookla's speedtest CLI, Cloudflare does not require downloading a licensed exe. Cloudflare uses test sites from its own network of caching and hosting centers. This is useful because much of the content users would be retrieving is actually coming from these centers. On the other hand, coverage may be thin in some parts of the world.

## Privacy

No identifying information is sent to any website other than the IP address which servers can see in an HTTP request. Cloudflare can probably deduce something from the tests it runs. No results are sent anywhere. Because this an application and not running in a browser, there are no cookies.

Full source is available in this package.

## Background

Billions of federal dollars are being disbursed to improve broadband availability and quality, especially in rural areas. Tools are needed to assure that ISPs deliver the quality they promise. This software is a pro bono contribution to getting those tools written. 

## Disclaimers

No claims of any sort are made for this software. It has been tested on Windows 10 and 11, MacOS, and  Raspberry Pi OS and should work on other Linux versions but not tested. Use and/or redistribute solely at your own risk. No commitment is made to maintain this software. As noted above, changes made by Cloudflare might break the functionality.

I have no affiliation with Cloudflare, any hosting service, or any ISP (except as a customer).



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tevslin/cloudflarepycli",
    "name": "cloudflarepycli",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "speedtest,cloudflare,latency,jitter",
    "author": "\"Tom Evslin\"",
    "author_email": "tevslin@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9c/1a/26397da28163932a5fbe3d885666d96c4d0c0c3ef65942b3bc2cf897d842/cloudflarepycli-1.8.1.tar.gz",
    "platform": null,
    "description": "# Temporary note\r\nPyPi is still version 1.8.0\r\n\r\n# cloudflarepycli\r\n\r\nPython CLI and python class for retrieving user's realtime performance statistics.\r\n\r\n## Purpose\r\n\r\nRetrieve near-term performance data about the service provided to a user by an ISP. The data includes up and download speeds, latency, and jitter. The CLI makes it possible to pipe the data to other processes for possible uploading, analysis etc. and/or to build a GUI for displaying current and past data. The cloudflareclass.py module is useful for varying the types of test that are done. I will use both in future projects to expand the functionality.\r\n\r\n## Install\r\n\r\npip install cloudflarepycli \\\r\nWindows users must also: pip install wres\r\n\r\n## CLI usage\r\n\r\nType 'cfspeedtest' in the environment where you installed the package. Note that this is a shell command, not a Python command.\r\n\r\n### Options\r\n\r\n  -h, --help  show help message and exit\r\n  \r\n  --debug     log network io\r\n  \r\n  --json      write json to sysout instead of formatted results\r\n  \r\n  --version   show program's version number and exit\r\n  \r\n## Cloudflareclass Documentation\r\n\r\nThe Cloudflare Connection Testing Class is a Python module that facilitates testing the speed and latency of your internet connection to Cloudflare's servers. It utilizes the `requests` library to perform various tests and provides insights into download and upload speeds, latency, and other connection metrics.\r\n\r\n### Features\r\n\r\n- Measures download and upload speeds to Cloudflare's servers.\r\n- Calculates latency and jitter for connection stability assessment.\r\n- Provides information about your IP address, ISP, test location, and more.\r\n- Easy-to-use class interface to conduct various connection tests.\r\n\r\n### Function arguments\r\n\r\n  ```python\r\n  cloudflare(thedict=None,debug=False,print=True,downtests=None,uptests=None,latencyreps=20)\r\n  ```\r\n\r\n\r\n- `thedict`: dictionary to store results in\r\n    - if not passed in, created here\r\n    - if passed in, used and update - allows keeping partial results from previous runs\r\n    - each result has a key and the entry is a dict with \"time\" and \"value\" items\r\n- `debug`: if True, turns on io logging for debugging\r\n- `printit`: if True, results are printed as well as added to the dictionary\r\n- `downtests`: tuple of download tests to be performed\r\n    - if None, four download tests are performed consecutively: 100kB, 1MB, 10MB, and 25MB\r\n    - format is ((size, reps, label)......)\r\n        - size: size of block to download\r\n        - reps: number of times to repeat test\r\n        - label: text label for test - also becomes key in the dict\r\n- `uptests`: tuple of upload tests to be performed\r\n    - if None, three upload tests are performed consecutively: 100kB, 1MB, and 10MB\r\n    - format is ((size, reps, label)......)\r\n        - size: size of block to upload\r\n        - reps: number of times to repeat test\r\n        - label: text label for test - also becomes key in the dict\r\n- `latencyreps`: number of repetitions for latency test\r\n\r\n#### Usage\r\n\r\nThe `cloudflare` class provides methods to perform various connection tests and retrieve relevant information. Here's a brief overview of its main methods:\r\n\r\n- `runalltests()`: Runs a full suite of tests, including latency, jitter, download, and upload tests. Returns a dictionary with test results.\r\n- `getfulldata()`: Retrieves information about your IP address, ISP, test location, and more.\r\n- `download(numbytes, iterations)`: Runs download tests for the specified number of bytes and iterations. Returns timing results.\r\n- `upload(numbytes, iterations)`: Runs upload tests for the specified number of bytes and iterations. Returns timing results.\r\n\r\nRefer to the `cloudflareclass.py`` file for detailed documentation on each method and its parameters.\r\n\r\n### Stand-alone usage\r\n#### Getting Started\r\n\r\n1. Install the required dependencies:\r\n    ```bash\r\n    pip install requests numpy\r\n    ```\r\n2. Download the cloudflareclass.py file and include it in your project.\r\n3. Import the cloudflare class in your Python script:\r\n    ```python\r\n    from cloudflareclass import cloudflare\r\n    ```\r\n4. Create an instance of the cloudflare class and run tests:\r\n    ```python\r\n    cf = cloudflare()\r\n    results = cf.runalltests()\r\n    print(results)\r\n    ```\r\n\r\n#### Example\r\n\r\n```python\r\nfrom cloudflareclass import cloudflare\r\n\r\ncf = cloudflare()\r\nresults = cf.runalltests()\r\nprint(results)\r\n```\r\n\r\n## Source repository\r\n\r\nhttps://github.com/tevslin/cloudflarepycli\r\n\r\n## How it works\r\n\r\nTests for latency are done by requesting one byte packets from Cloudflare, measuring the elapsed time to get a response, and subtracting the server processing time taken from the header in the returned message. Jitter is computed as the mean of the absolute difference between the arrival of consecutive requests.\r\n\r\nThe cloudflareclass.py module makes Python requests to various subaddresses of [speed.cloudflare.com](https://speed.cloudflare.com). Their API is not documented, as far as I know, and so that is a vulnerability for this code.\r\n\r\nMirroring the performance of the Cloudflare webpage, the CLI does multiple uploads and downloads with different block sizes and the 90th percentile of all these tests is used for calculating up and download times. Results are similar to those obtained from the webpage. Tests can be varied using the cloudflareclass module.\r\n\r\nUnlike Ookla's speedtest CLI, Cloudflare does not require downloading a licensed exe. Cloudflare uses test sites from its own network of caching and hosting centers. This is useful because much of the content users would be retrieving is actually coming from these centers. On the other hand, coverage may be thin in some parts of the world.\r\n\r\n## Privacy\r\n\r\nNo identifying information is sent to any website other than the IP address which servers can see in an HTTP request. Cloudflare can probably deduce something from the tests it runs. No results are sent anywhere. Because this an application and not running in a browser, there are no cookies.\r\n\r\nFull source is available in this package.\r\n\r\n## Background\r\n\r\nBillions of federal dollars are being disbursed to improve broadband availability and quality, especially in rural areas. Tools are needed to assure that ISPs deliver the quality they promise. This software is a pro bono contribution to getting those tools written. \r\n\r\n## Disclaimers\r\n\r\nNo claims of any sort are made for this software. It has been tested on Windows 10 and 11, MacOS, and  Raspberry Pi OS and should work on other Linux versions but not tested. Use and/or redistribute solely at your own risk. No commitment is made to maintain this software. As noted above, changes made by Cloudflare might break the functionality.\r\n\r\nI have no affiliation with Cloudflare, any hosting service, or any ISP (except as a customer).\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "\"Python CLI and python class for retrieving user's realtime performance statistics\"",
    "version": "1.8.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/tevslin/cloudflarepycli/issues",
        "Homepage": "https://github.com/tevslin/cloudflarepycli"
    },
    "split_keywords": [
        "speedtest",
        "cloudflare",
        "latency",
        "jitter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e1e1733949078a1b2d83543088a1235415bdbc53c4f265d29b2fc1bb7d91d7f6",
                "md5": "b30bd5dbe090497655891c481cb97e2d",
                "sha256": "82e1a3bc64524170d69ca7ffff00d2224487353599b195d14a0384c581ec4860"
            },
            "downloads": -1,
            "filename": "cloudflarepycli-1.8.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b30bd5dbe090497655891c481cb97e2d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 8382,
            "upload_time": "2023-09-22T20:05:59",
            "upload_time_iso_8601": "2023-09-22T20:05:59.876359Z",
            "url": "https://files.pythonhosted.org/packages/e1/e1/733949078a1b2d83543088a1235415bdbc53c4f265d29b2fc1bb7d91d7f6/cloudflarepycli-1.8.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9c1a26397da28163932a5fbe3d885666d96c4d0c0c3ef65942b3bc2cf897d842",
                "md5": "418412ae894fa745ced392933e62daac",
                "sha256": "3c5fd8fe81b8b9c8a2af669c08efc618a063695ee9f2da8649919ff95f62c5d3"
            },
            "downloads": -1,
            "filename": "cloudflarepycli-1.8.1.tar.gz",
            "has_sig": false,
            "md5_digest": "418412ae894fa745ced392933e62daac",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 9829,
            "upload_time": "2023-09-22T20:06:01",
            "upload_time_iso_8601": "2023-09-22T20:06:01.412078Z",
            "url": "https://files.pythonhosted.org/packages/9c/1a/26397da28163932a5fbe3d885666d96c4d0c0c3ef65942b3bc2cf897d842/cloudflarepycli-1.8.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-22 20:06:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tevslin",
    "github_project": "cloudflarepycli",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cloudflarepycli"
}
        
Elapsed time: 0.12108s