vendor_helpers
sc_crawler.vendor_helpers
#
Functions:
| Name | Description |
|---|---|
fetch_servers |
Fetch servers of a region/zone. |
parallel_fetch_servers |
Fetch servers of all regions/zones in parallel on 8 threads. |
preprocess_servers |
Preprocess servers before inserting into the database. |
add_vendor_id |
Adds |
fetch_servers
#
Fetch servers of a region/zone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable
|
A function that takes the region or zone id as its first and only argument.
The returning list must conform with the Server object, or need to
be in a format that preprocess_servers's
|
required |
where
|
str
|
required | |
vendor
|
Optional[Vendor]
|
Optional Vendor instance used for logging and progress bar updates. |
required |
Source code in sc_crawler/vendor_helpers.py
parallel_fetch_servers
#
Fetch servers of all regions/zones in parallel on 8 threads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vendor
|
Vendor
|
Required Vendor instance used for the regions lookup, logging and progress bar updates. |
required |
fn
|
Callable
|
A function to be passed to fetch_servers. |
required |
id_cols
|
Field name to be used to deduplicate the list of server dicts. |
required | |
by
|
Literal['regions', 'zones']
|
What objects of the |
required |
Source code in sc_crawler/vendor_helpers.py
preprocess_servers
#
Preprocess servers before inserting into the database.
Takes a list of dicts and tranform to a list of dicts that follows the Server schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
servers
|
List[dict]
|
To be passed to |
required |
vendor
|
Vendor
|
The related Vendor instance used for database connection, logging and progress bar updates. |
required |
fn
|
Callable
|
A function that takes a server from |
required |