Utils
download_cloudflared(cloudflared_path, command, force=False)
Downloads the cloudflared binary if it does not exist or if force is True.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cloudflared_path |
str
|
The path where the cloudflared binary should be saved. |
required |
command |
str
|
The command to run. |
required |
force |
bool
|
Whether to force the download even if the file exists. Defaults to False. |
False
|
Side Effects
Downloads the cloudflared binary.
Examples:
Source code in src/with_cloudflared/utils.py
download_file(url)
Downloads a file from a given URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
The URL of the file to download. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The path where the file was downloaded. |
Side Effects
Downloads a file from a given URL.
Examples:
Source code in src/with_cloudflared/utils.py
extract_tarball(tar_path, filename)
Extracts a tarball file at a given path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tar_path |
str
|
The path where the tarball file is located. |
required |
filename |
str
|
The name of the tarball file. |
required |
Side Effects
Extracts the tarball file at the given path.
Examples:
Source code in src/with_cloudflared/utils.py
get_command(system, machine)
Retrieves the command for a given system and machine from the CLOUDFLARED_CONFIG.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
system |
str
|
The system for which the command is needed. |
required |
machine |
str
|
The machine for which the command is needed. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The command for the given system and machine. |
Raises:
Type | Description |
---|---|
Exception
|
If the machine is not supported on the system. |
Examples:
Source code in src/with_cloudflared/utils.py
get_url(system, machine)
Retrieves the URL for a given system and machine from the CLOUDFLARED_CONFIG.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
system |
str
|
The system for which the URL is needed. |
required |
machine |
str
|
The machine for which the URL is needed. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The URL for the given system and machine. |
Raises:
Type | Description |
---|---|
Exception
|
If the machine is not supported on the system. |
Examples:
>>> get_url('Linux', 'x86_64')
'https://bin.equinox.io/c/VdrWdbjqyF/cloudflared-stable-linux-amd64.tgz'