code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def get_browsersteps_available_screenshots(self):
"For knowing which screenshots are available to show the user in BrowserSteps UI"
available = []
for f in Path(self.watch_data_dir).glob('step_before-*.jpeg'):
step_n=re.search(r'step_before-(\d+)', f.name)
if step_n:
... | For knowing which screenshots are available to show the user in BrowserSteps UI | get_browsersteps_available_screenshots | python | dgtlmoon/changedetection.io | changedetectionio/model/Watch.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/model/Watch.py | Apache-2.0 |
def compile_error_texts(self, has_proxies=None):
"""Compile error texts for this watch.
Accepts has_proxies parameter to ensure it works even outside app context"""
from flask import url_for
from markupsafe import Markup
output = [] # Initialize as list since we're using append... | Compile error texts for this watch.
Accepts has_proxies parameter to ensure it works even outside app context | compile_error_texts | python | dgtlmoon/changedetection.io | changedetectionio/model/Watch.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/model/Watch.py | Apache-2.0 |
def find_sub_packages(package_name):
"""
Find all sub-packages within the given package.
:param package_name: The name of the base package to scan for sub-packages.
:return: A list of sub-package names.
"""
package = importlib.import_module(package_name)
return [name for _, name, is_pkg in ... |
Find all sub-packages within the given package.
:param package_name: The name of the base package to scan for sub-packages.
:return: A list of sub-package names.
| find_sub_packages | python | dgtlmoon/changedetection.io | changedetectionio/processors/__init__.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/processors/__init__.py | Apache-2.0 |
def find_processors():
"""
Find all subclasses of DifferenceDetectionProcessor in the specified package.
:param package_name: The name of the package to scan for processor modules.
:return: A list of (module, class) tuples.
"""
package_name = "changedetectionio.processors" # Name of the curren... |
Find all subclasses of DifferenceDetectionProcessor in the specified package.
:param package_name: The name of the package to scan for processor modules.
:return: A list of (module, class) tuples.
| find_processors | python | dgtlmoon/changedetection.io | changedetectionio/processors/__init__.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/processors/__init__.py | Apache-2.0 |
def available_processors():
"""
Get a list of processors by name and description for the UI elements
:return: A list :)
"""
processor_classes = find_processors()
available = []
for package, processor_class in processor_classes:
available.append((processor_class, package.name))
... |
Get a list of processors by name and description for the UI elements
:return: A list :)
| available_processors | python | dgtlmoon/changedetection.io | changedetectionio/processors/__init__.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/processors/__init__.py | Apache-2.0 |
def get_itemprop_availability(html_content) -> Restock:
"""
Kind of funny/cool way to find price/availability in one many different possibilities.
Use 'extruct' to find any possible RDFa/microdata/json-ld data, make a JSON string from the output then search it.
"""
from jsonpath_ng import parse
... |
Kind of funny/cool way to find price/availability in one many different possibilities.
Use 'extruct' to find any possible RDFa/microdata/json-ld data, make a JSON string from the output then search it.
| get_itemprop_availability | python | dgtlmoon/changedetection.io | changedetectionio/processors/restock_diff/processor.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/processors/restock_diff/processor.py | Apache-2.0 |
def prepare_filter_prevew(datastore, watch_uuid, form_data):
'''Used by @app.route("/edit/<string:uuid>/preview-rendered", methods=['POST'])'''
from changedetectionio import forms, html_tools
from changedetectionio.model.Watch import model as watch_model
from concurrent.futures import ProcessPoolExecuto... | Used by @app.route("/edit/<string:uuid>/preview-rendered", methods=['POST']) | prepare_filter_prevew | python | dgtlmoon/changedetection.io | changedetectionio/processors/text_json_diff/__init__.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/processors/text_json_diff/__init__.py | Apache-2.0 |
def register_watch_operation_handlers(socketio, datastore):
"""Register Socket.IO event handlers for watch operations"""
@socketio.on('watch_operation')
def handle_watch_operation(data):
"""Handle watch operations like pause, mute, recheck via Socket.IO"""
try:
op = data.get... | Register Socket.IO event handlers for watch operations | register_watch_operation_handlers | python | dgtlmoon/changedetection.io | changedetectionio/realtime/events.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/realtime/events.py | Apache-2.0 |
def handle_watch_operation(data):
"""Handle watch operations like pause, mute, recheck via Socket.IO"""
try:
op = data.get('op')
uuid = data.get('uuid')
logger.debug(f"Socket.IO: Received watch operation '{op}' for UUID {uuid}")
i... | Handle watch operations like pause, mute, recheck via Socket.IO | handle_watch_operation | python | dgtlmoon/changedetection.io | changedetectionio/realtime/events.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/realtime/events.py | Apache-2.0 |
def polling_emit_running_or_queued_watches_threaded(self):
"""Threading version of polling for Windows compatibility"""
import time
import threading
logger.info("Queue update thread started (threading mode)")
# Import here to avoid circular imports
from changedet... | Threading version of polling for Windows compatibility | polling_emit_running_or_queued_watches_threaded | python | dgtlmoon/changedetection.io | changedetectionio/realtime/socket_server.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/realtime/socket_server.py | Apache-2.0 |
def handle_watch_update(socketio, **kwargs):
"""Handle watch update signal from blinker"""
try:
watch = kwargs.get('watch')
datastore = kwargs.get('datastore')
# Emit the watch update to all connected clients
from changedetectionio.flask_app import update_q
from changede... | Handle watch update signal from blinker | handle_watch_update | python | dgtlmoon/changedetection.io | changedetectionio/realtime/socket_server.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/realtime/socket_server.py | Apache-2.0 |
def init_socketio(app, datastore):
"""Initialize SocketIO with the main Flask app"""
import platform
import sys
# Platform-specific async_mode selection for better stability
system = platform.system().lower()
python_version = sys.version_info
# Check for SocketIO mode configuration... | Initialize SocketIO with the main Flask app | init_socketio | python | dgtlmoon/changedetection.io | changedetectionio/realtime/socket_server.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/realtime/socket_server.py | Apache-2.0 |
def shutdown():
"""Shutdown the SocketIO server fast and aggressively"""
try:
logger.info("Socket.IO: Fast shutdown initiated...")
# For threading mode, give the thread a very short time to exit gracefully
if hasattr(socketio, 'polling_emitter_thread'):
... | Shutdown the SocketIO server fast and aggressively | shutdown | python | dgtlmoon/changedetection.io | changedetectionio/realtime/socket_server.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/realtime/socket_server.py | Apache-2.0 |
def test_conditions_with_text_and_number(client, live_server):
"""Test that both text and number conditions work together with AND logic."""
set_original_response("50")
test_url = url_for('test_endpoint', _external=True)
# Add our URL to the import page
res = client.post(
url_for... | Test that both text and number conditions work together with AND logic. | test_conditions_with_text_and_number | python | dgtlmoon/changedetection.io | changedetectionio/tests/test_conditions.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/test_conditions.py | Apache-2.0 |
def test_render_anchor_tag_content_true(client, live_server, measure_memory_usage):
"""Testing that the link changes are detected when
render_anchor_tag_content setting is set to true"""
sleep_time_for_fetch_thread = 3
# Give the endpoint time to spin up
time.sleep(1)
# set original html text
... | Testing that the link changes are detected when
render_anchor_tag_content setting is set to true | test_render_anchor_tag_content_true | python | dgtlmoon/changedetection.io | changedetectionio/tests/test_ignorehyperlinks.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/test_ignorehyperlinks.py | Apache-2.0 |
def test_import_custom_xlsx(client, live_server, measure_memory_usage):
"""Test can upload a excel spreadsheet and the watches are created correctly"""
dirname = os.path.dirname(__file__)
filename = os.path.join(dirname, 'import/spreadsheet.xlsx')
with open(filename, 'rb') as f:
data= {
... | Test can upload a excel spreadsheet and the watches are created correctly | test_import_custom_xlsx | python | dgtlmoon/changedetection.io | changedetectionio/tests/test_import.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/test_import.py | Apache-2.0 |
def test_rss_bad_chars_breaking(client, live_server):
"""This should absolutely trigger the RSS builder to go into worst state mode
- source: prefix means no html conversion (which kinda filters out the bad stuff)
- Binary data
- Very long so that the saving is performed by Brotli (and decoded back to ... | This should absolutely trigger the RSS builder to go into worst state mode
- source: prefix means no html conversion (which kinda filters out the bad stuff)
- Binary data
- Very long so that the saving is performed by Brotli (and decoded back to bytes)
Otherwise feedgen should support regular unicode
... | test_rss_bad_chars_breaking | python | dgtlmoon/changedetection.io | changedetectionio/tests/test_rss.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/test_rss.py | Apache-2.0 |
def wait_for_notification_endpoint_output():
'''Apprise can take a few seconds to fire'''
#@todo - could check the apprise object directly instead of looking for this file
from os.path import isfile
for i in range(1, 20):
time.sleep(1)
if isfile("test-datastore/notification.txt"):
... | Apprise can take a few seconds to fire | wait_for_notification_endpoint_output | python | dgtlmoon/changedetection.io | changedetectionio/tests/util.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/util.py | Apache-2.0 |
def wait_for_all_checks(client=None):
"""
Waits until the queue is empty and workers are idle.
Much faster than the original with adaptive timing.
"""
from changedetectionio.flask_app import update_q as global_update_q
from changedetectionio import worker_handler
logger = logging.getLogger(... |
Waits until the queue is empty and workers are idle.
Much faster than the original with adaptive timing.
| wait_for_all_checks | python | dgtlmoon/changedetection.io | changedetectionio/tests/util.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/util.py | Apache-2.0 |
def test_get_auth(url, expected_auth):
"""Test authentication extraction with various URL formats."""
parsed_url = apprise_parse_url(url)
assert _get_auth(parsed_url) == expected_auth | Test authentication extraction with various URL formats. | test_get_auth | python | dgtlmoon/changedetection.io | changedetectionio/tests/apprise/test_apprise_custom_api_call.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/apprise/test_apprise_custom_api_call.py | Apache-2.0 |
def test_get_headers(url, body, expected_content_type):
"""Test header extraction and content type detection."""
parsed_url = apprise_parse_url(url)
headers = _get_headers(parsed_url, body)
if expected_content_type:
assert headers.get("Content-Type") == expected_content_type | Test header extraction and content type detection. | test_get_headers | python | dgtlmoon/changedetection.io | changedetectionio/tests/apprise/test_apprise_custom_api_call.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/apprise/test_apprise_custom_api_call.py | Apache-2.0 |
def test_get_params(url, expected_params):
"""Test parameter extraction with URL encoding and exclusion logic."""
parsed_url = apprise_parse_url(url)
params = _get_params(parsed_url)
assert dict(params) == expected_params | Test parameter extraction with URL encoding and exclusion logic. | test_get_params | python | dgtlmoon/changedetection.io | changedetectionio/tests/apprise/test_apprise_custom_api_call.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/apprise/test_apprise_custom_api_call.py | Apache-2.0 |
def test_apprise_custom_api_call_success(mock_request, url, schema, method):
"""Test successful API calls with different HTTP methods and schemas."""
mock_request.return_value.raise_for_status.return_value = None
meta = {"url": url, "schema": schema}
result = apprise_http_custom_handler(
body="... | Test successful API calls with different HTTP methods and schemas. | test_apprise_custom_api_call_success | python | dgtlmoon/changedetection.io | changedetectionio/tests/apprise/test_apprise_custom_api_call.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/apprise/test_apprise_custom_api_call.py | Apache-2.0 |
def test_invalid_url_parsing():
"""Test handling of invalid URL parsing."""
meta = {"url": "invalid://url", "schema": "invalid"}
result = apprise_http_custom_handler(
body="test", title="Invalid URL", notify_type="info", meta=meta
)
assert result is False | Test handling of invalid URL parsing. | test_invalid_url_parsing | python | dgtlmoon/changedetection.io | changedetectionio/tests/apprise/test_apprise_custom_api_call.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/apprise/test_apprise_custom_api_call.py | Apache-2.0 |
def test_https_method_conversion(
mock_request, input_schema, expected_method
):
"""Validate that methods ending with 's' use HTTPS and correct HTTP method."""
mock_request.return_value.raise_for_status.return_value = None
url = f"{input_schema}://localhost:9999"
result = apprise_http_custom_handl... | Validate that methods ending with 's' use HTTPS and correct HTTP method. | test_https_method_conversion | python | dgtlmoon/changedetection.io | changedetectionio/tests/apprise/test_apprise_custom_api_call.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/apprise/test_apprise_custom_api_call.py | Apache-2.0 |
def search_satellite_data(coordinates, cloud_cover_lt, product="landsat"):
"""
coordinates: bounding box's coordinates
cloud_cover_lt: maximum cloud cover
product: landsat, sentinel
"""
if product == "landsat":
product = "landsat-8-l1-c1"
elif product == "sentinel":
product =... |
coordinates: bounding box's coordinates
cloud_cover_lt: maximum cloud cover
product: landsat, sentinel
| search_satellite_data | python | plant99/felicette | felicette/sat_downloader.py | https://github.com/plant99/felicette/blob/master/felicette/sat_downloader.py | MIT |
def display_file(file_name):
"""
Open given file with default user program.
"""
if sys.platform.startswith("linux"):
os.system("xdg-open %s" % file_name)
elif sys.platform.startswith("darwin"):
os.system("open %s" % file_name) |
Open given file with default user program.
| display_file | python | plant99/felicette | felicette/utils/sys_utils.py | https://github.com/plant99/felicette/blob/master/felicette/utils/sys_utils.py | MIT |
def main(host='localhost', port=8086):
"""Instantiate the connection to the InfluxDB client."""
user = 'root'
password = 'root'
dbname = 'demo'
protocol = 'line'
client = DataFrameClient(host, port, user, password, dbname)
print("Create pandas DataFrame")
df = pd.DataFrame(data=list(ra... | Instantiate the connection to the InfluxDB client. | main | python | influxdata/influxdb-python | examples/tutorial_pandas.py | https://github.com/influxdata/influxdb-python/blob/master/examples/tutorial_pandas.py | MIT |
def main(host='localhost', port=8086):
"""Define function to generate the sin wave."""
now = datetime.datetime.today()
points = []
for angle in range(0, 360):
y = 10 + math.sin(math.radians(angle)) * 10
point = {
"measurement": 'foobar',
"time": int(now.strftime... | Define function to generate the sin wave. | main | python | influxdata/influxdb-python | examples/tutorial_sine_wave.py | https://github.com/influxdata/influxdb-python/blob/master/examples/tutorial_sine_wave.py | MIT |
def loads(s):
"""Generate a sequence of JSON values from a string."""
_decoder = json.JSONDecoder()
while s:
s = s.strip()
obj, pos = _decoder.raw_decode(s)
if not pos:
raise ValueError('no JSON object found at %i' % pos)
yield obj
s = s[pos:] | Generate a sequence of JSON values from a string. | loads | python | influxdata/influxdb-python | influxdb/chunked_json.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/chunked_json.py | MIT |
def from_dsn(cls, dsn, **kwargs):
r"""Generate an instance of InfluxDBClient from given data source name.
Return an instance of :class:`~.InfluxDBClient` from the provided
data source name. Supported schemes are "influxdb", "https+influxdb"
and "udp+influxdb". Parameters for the :class:... | Generate an instance of InfluxDBClient from given data source name.
Return an instance of :class:`~.InfluxDBClient` from the provided
data source name. Supported schemes are "influxdb", "https+influxdb"
and "udp+influxdb". Parameters for the :class:`~.InfluxDBClient`
constructor may als... | from_dsn | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def switch_user(self, username, password):
"""Change the client's username.
:param username: the username to switch to
:type username: str
:param password: the password for the username
:type password: str
"""
self._username = username
self._password = pa... | Change the client's username.
:param username: the username to switch to
:type username: str
:param password: the password for the username
:type password: str
| switch_user | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def request(self, url, method='GET', params=None, data=None, stream=False,
expected_response_code=200, headers=None):
"""Make a HTTP request to the InfluxDB API.
:param url: the path of the HTTP request, e.g. write, query, etc.
:type url: str
:param method: the HTTP meth... | Make a HTTP request to the InfluxDB API.
:param url: the path of the HTTP request, e.g. write, query, etc.
:type url: str
:param method: the HTTP method for the request, defaults to GET
:type method: str
:param params: additional parameters for the request, defaults to None
... | request | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def write(self, data, params=None, expected_response_code=204,
protocol='json'):
"""Write data to InfluxDB.
:param data: the data to be written
:type data: (if protocol is 'json') dict
(if protocol is 'line') sequence of line protocol strings
... | Write data to InfluxDB.
:param data: the data to be written
:type data: (if protocol is 'json') dict
(if protocol is 'line') sequence of line protocol strings
or single string
:param params: additional parameters for the request, defaults to None
... | write | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def query(self,
query,
params=None,
bind_params=None,
epoch=None,
expected_response_code=200,
database=None,
raise_errors=True,
chunked=False,
chunk_size=0,
method="GET"):
... | Send a query to InfluxDB.
.. danger::
In order to avoid injection vulnerabilities (similar to `SQL
injection <https://www.owasp.org/index.php/SQL_Injection>`_
vulnerabilities), do not directly include untrusted data into the
``query`` parameter, use ``bind_params... | query | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def write_points(self,
points,
time_precision=None,
database=None,
retention_policy=None,
tags=None,
batch_size=None,
protocol='json',
consistency=None
... | Write to multiple time series names.
:param points: the list of points to be written in the database
:type points: list of dictionaries, each dictionary represents a point
:type points: (if protocol is 'json') list of dicts, where each dict
represents a point.
... | write_points | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def ping(self):
"""Check connectivity to InfluxDB.
:returns: The version of the InfluxDB the client is connected to
"""
response = self.request(
url="ping",
method='GET',
expected_response_code=204
)
return response.headers['X-Influxd... | Check connectivity to InfluxDB.
:returns: The version of the InfluxDB the client is connected to
| ping | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def get_list_series(self, database=None, measurement=None, tags=None):
"""
Query SHOW SERIES returns the distinct series in your database.
FROM and WHERE clauses are optional.
:param measurement: Show all series from a measurement
:type id: string
:param tags: Show all ... |
Query SHOW SERIES returns the distinct series in your database.
FROM and WHERE clauses are optional.
:param measurement: Show all series from a measurement
:type id: string
:param tags: Show all series that match given tags
:type id: dict
:param database: the d... | get_list_series | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def create_retention_policy(self, name, duration, replication,
database=None,
default=False, shard_duration="0s"):
"""Create a retention policy for a database.
:param name: the name of the new retention policy
:type name: str
... | Create a retention policy for a database.
:param name: the name of the new retention policy
:type name: str
:param duration: the duration of the new retention policy.
Durations such as 1h, 90m, 12h, 7d, and 4w, are all supported
and mean 1 hour, 90 minutes, 12 hours, 7 d... | create_retention_policy | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def alter_retention_policy(self, name, database=None,
duration=None, replication=None,
default=None, shard_duration=None):
"""Modify an existing retention policy for a database.
:param name: the name of the retention policy to modify
... | Modify an existing retention policy for a database.
:param name: the name of the retention policy to modify
:type name: str
:param database: the database for which the retention policy is
modified. Defaults to current client's database
:type database: str
:param dura... | alter_retention_policy | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def drop_retention_policy(self, name, database=None):
"""Drop an existing retention policy for a database.
:param name: the name of the retention policy to drop
:type name: str
:param database: the database for which the retention policy is
dropped. Defaults to current clien... | Drop an existing retention policy for a database.
:param name: the name of the retention policy to drop
:type name: str
:param database: the database for which the retention policy is
dropped. Defaults to current client's database
:type database: str
| drop_retention_policy | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def get_list_retention_policies(self, database=None):
"""Get the list of retention policies for a database.
:param database: the name of the database, defaults to the client's
current database
:type database: str
:returns: all retention policies for the database
:rty... | Get the list of retention policies for a database.
:param database: the name of the database, defaults to the client's
current database
:type database: str
:returns: all retention policies for the database
:rtype: list of dictionaries
:Example:
::
... | get_list_retention_policies | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def create_user(self, username, password, admin=False):
"""Create a new user in InfluxDB.
:param username: the new username to create
:type username: str
:param password: the password for the new user
:type password: str
:param admin: whether the user should have cluster... | Create a new user in InfluxDB.
:param username: the new username to create
:type username: str
:param password: the password for the new user
:type password: str
:param admin: whether the user should have cluster administration
privileges or not
:type admin: ... | create_user | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def set_user_password(self, username, password):
"""Change the password of an existing user.
:param username: the username who's password is being changed
:type username: str
:param password: the new password for the user
:type password: str
"""
text = "SET PASSW... | Change the password of an existing user.
:param username: the username who's password is being changed
:type username: str
:param password: the new password for the user
:type password: str
| set_user_password | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def delete_series(self, database=None, measurement=None, tags=None):
"""Delete series from a database.
Series must be filtered by either measurement and tags.
This method cannot be used to delete all series, use
`drop_database` instead.
:param database: the database from which ... | Delete series from a database.
Series must be filtered by either measurement and tags.
This method cannot be used to delete all series, use
`drop_database` instead.
:param database: the database from which the series should be
deleted, defaults to client's current database
... | delete_series | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def grant_privilege(self, privilege, database, username):
"""Grant a privilege on a database to a user.
:param privilege: the privilege to grant, one of 'read', 'write'
or 'all'. The string is case-insensitive
:type privilege: str
:param database: the database to grant the p... | Grant a privilege on a database to a user.
:param privilege: the privilege to grant, one of 'read', 'write'
or 'all'. The string is case-insensitive
:type privilege: str
:param database: the database to grant the privilege on
:type database: str
:param username: the ... | grant_privilege | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def revoke_privilege(self, privilege, database, username):
"""Revoke a privilege on a database from a user.
:param privilege: the privilege to revoke, one of 'read', 'write'
or 'all'. The string is case-insensitive
:type privilege: str
:param database: the database to revoke... | Revoke a privilege on a database from a user.
:param privilege: the privilege to revoke, one of 'read', 'write'
or 'all'. The string is case-insensitive
:type privilege: str
:param database: the database to revoke the privilege on
:type database: str
:param username:... | revoke_privilege | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def get_list_continuous_queries(self):
"""Get the list of continuous queries in InfluxDB.
:return: all CQs in InfluxDB
:rtype: list of dictionaries
:Example:
::
>> cqs = client.get_list_cqs()
>> cqs
[
{
u... | Get the list of continuous queries in InfluxDB.
:return: all CQs in InfluxDB
:rtype: list of dictionaries
:Example:
::
>> cqs = client.get_list_cqs()
>> cqs
[
{
u'db1': []
},
{
... | get_list_continuous_queries | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def create_continuous_query(self, name, select, database=None,
resample_opts=None):
r"""Create a continuous query for a database.
:param name: the name of continuous query to create
:type name: str
:param select: select statement for the continuous query
... | Create a continuous query for a database.
:param name: the name of continuous query to create
:type name: str
:param select: select statement for the continuous query
:type select: str
:param database: the database for which the continuous query is
created. Defaults ... | create_continuous_query | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def drop_continuous_query(self, name, database=None):
"""Drop an existing continuous query for a database.
:param name: the name of continuous query to drop
:type name: str
:param database: the database for which the continuous query is
dropped. Defaults to current client's ... | Drop an existing continuous query for a database.
:param name: the name of continuous query to drop
:type name: str
:param database: the database for which the continuous query is
dropped. Defaults to current client's database
:type database: str
| drop_continuous_query | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def send_packet(self, packet, protocol='json', time_precision=None):
"""Send an UDP packet.
:param packet: the packet to be sent
:type packet: (if protocol is 'json') dict
(if protocol is 'line') list of line protocol strings
:param protocol: protocol of input data... | Send an UDP packet.
:param packet: the packet to be sent
:type packet: (if protocol is 'json') dict
(if protocol is 'line') list of line protocol strings
:param protocol: protocol of input data, either 'json' or 'line'
:type protocol: str
:param time_precis... | send_packet | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def _parse_dsn(dsn):
"""Parse data source name.
This is a helper function to split the data source name provided in
the from_dsn classmethod
"""
conn_params = urlparse(dsn)
init_args = {}
scheme_info = conn_params.scheme.split('+')
if len(scheme_info) == 1:
scheme = scheme_info[... | Parse data source name.
This is a helper function to split the data source name provided in
the from_dsn classmethod
| _parse_dsn | python | influxdata/influxdb-python | influxdb/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/client.py | MIT |
def __new__(cls, *args, **kwargs):
"""Initialize class attributes for subsequent constructor calls.
:note: *args and **kwargs are not explicitly used in this function,
but needed for Python 2 compatibility.
"""
if not cls.__initialized__:
cls.__initialized__ = True
... | Initialize class attributes for subsequent constructor calls.
:note: *args and **kwargs are not explicitly used in this function,
but needed for Python 2 compatibility.
| __new__ | python | influxdata/influxdb-python | influxdb/helper.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/helper.py | MIT |
def __init__(self, **kw):
"""Call to constructor creates a new data point.
:note: Data points written when `bulk_size` is reached per Helper.
:warning: Data points are *immutable* (`namedtuples`).
"""
cls = self.__class__
timestamp = kw.pop('time', self._current_timestam... | Call to constructor creates a new data point.
:note: Data points written when `bulk_size` is reached per Helper.
:warning: Data points are *immutable* (`namedtuples`).
| __init__ | python | influxdata/influxdb-python | influxdb/helper.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/helper.py | MIT |
def _json_body_(cls):
"""Return the JSON body of given datapoints.
:return: JSON body of these datapoints.
"""
json = []
if not cls.__initialized__:
cls._reset_()
for series_name, data in six.iteritems(cls._datapoints):
for point in data:
... | Return the JSON body of given datapoints.
:return: JSON body of these datapoints.
| _json_body_ | python | influxdata/influxdb-python | influxdb/helper.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/helper.py | MIT |
def _get_unicode(data, force=False):
"""Try to return a text aka unicode object from the given data."""
if isinstance(data, binary_type):
return data.decode('utf-8')
if data is None:
return ''
if force:
if PY2:
return unicode(data)
return str(data)
retu... | Try to return a text aka unicode object from the given data. | _get_unicode | python | influxdata/influxdb-python | influxdb/line_protocol.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/line_protocol.py | MIT |
def make_line(measurement, tags=None, fields=None, time=None, precision=None):
"""Extract the actual point from a given measurement line."""
tags = tags or {}
fields = fields or {}
line = _escape_tag(_get_unicode(measurement))
# tags should be sorted client-side to take load off server
tag_lis... | Extract the actual point from a given measurement line. | make_line | python | influxdata/influxdb-python | influxdb/line_protocol.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/line_protocol.py | MIT |
def make_lines(data, precision=None):
"""Extract points from given dict.
Extracts the points from the given dict and returns a Unicode string
matching the line protocol introduced in InfluxDB 0.9.0.
"""
lines = []
static_tags = data.get('tags')
for point in data['points']:
if static... | Extract points from given dict.
Extracts the points from the given dict and returns a Unicode string
matching the line protocol introduced in InfluxDB 0.9.0.
| make_lines | python | influxdata/influxdb-python | influxdb/line_protocol.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/line_protocol.py | MIT |
def __getitem__(self, key):
"""Retrieve the series name or specific set based on key.
:param key: Either a series name, or a tags_dict, or
a 2-tuple(series_name, tags_dict).
If the series name is None (or not given) then any serie
matching the... | Retrieve the series name or specific set based on key.
:param key: Either a series name, or a tags_dict, or
a 2-tuple(series_name, tags_dict).
If the series name is None (or not given) then any serie
matching the eventual given tags will be given its ... | __getitem__ | python | influxdata/influxdb-python | influxdb/resultset.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/resultset.py | MIT |
def get_points(self, measurement=None, tags=None):
"""Return a generator for all the points that match the given filters.
:param measurement: The measurement name
:type measurement: str
:param tags: Tags to look for
:type tags: dict
:return: Points generator
""... | Return a generator for all the points that match the given filters.
:param measurement: The measurement name
:type measurement: str
:param tags: Tags to look for
:type tags: dict
:return: Points generator
| get_points | python | influxdata/influxdb-python | influxdb/resultset.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/resultset.py | MIT |
def _tag_matches(tags, filter):
"""Check if all key/values in filter match in tags."""
for tag_name, tag_value in filter.items():
# using _sentinel as I'm not sure that "None"
# could be used, because it could be a valid
# series_tags value : when a series has no such... | Check if all key/values in filter match in tags. | _tag_matches | python | influxdata/influxdb-python | influxdb/resultset.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/resultset.py | MIT |
def keys(self):
"""Return the list of keys in the ResultSet.
:return: List of keys. Keys are tuples (series_name, tags)
"""
keys = []
for series in self._get_series():
keys.append(
(series.get('measurement',
series.get('nam... | Return the list of keys in the ResultSet.
:return: List of keys. Keys are tuples (series_name, tags)
| keys | python | influxdata/influxdb-python | influxdb/resultset.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/resultset.py | MIT |
def items(self):
"""Return the set of items from the ResultSet.
:return: List of tuples, (key, generator)
"""
items = []
for series in self._get_series():
series_key = (series.get('measurement',
series.get('name', 'results')),
... | Return the set of items from the ResultSet.
:return: List of tuples, (key, generator)
| items | python | influxdata/influxdb-python | influxdb/resultset.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/resultset.py | MIT |
def _get_points_for_series(self, series):
"""Return generator of dict from columns and values of a series.
:param series: One series
:return: Generator of dicts
"""
for point in series.get('values', []):
yield self.point_from_cols_vals(
series['column... | Return generator of dict from columns and values of a series.
:param series: One series
:return: Generator of dicts
| _get_points_for_series | python | influxdata/influxdb-python | influxdb/resultset.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/resultset.py | MIT |
def point_from_cols_vals(cols, vals):
"""Create a dict from columns and values lists.
:param cols: List of columns
:param vals: List of values
:return: Dict where keys are columns.
"""
point = {}
for col_index, col_name in enumerate(cols):
point[col_n... | Create a dict from columns and values lists.
:param cols: List of columns
:param vals: List of values
:return: Dict where keys are columns.
| point_from_cols_vals | python | influxdata/influxdb-python | influxdb/resultset.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/resultset.py | MIT |
def write_points(self,
dataframe,
measurement,
tags=None,
tag_columns=None,
field_columns=None,
time_precision=None,
database=None,
retention_policy=Non... | Write to multiple time series names.
:param dataframe: data points in a DataFrame
:param measurement: name of measurement
:param tags: dictionary of tags, with string key-values
:param tag_columns: [Optional, default None] List of data tag names
:param field_columns: [Options, d... | write_points | python | influxdata/influxdb-python | influxdb/_dataframe_client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/_dataframe_client.py | MIT |
def query(self,
query,
params=None,
bind_params=None,
epoch=None,
expected_response_code=200,
database=None,
raise_errors=True,
chunked=False,
chunk_size=0,
method="GET",
... |
Query data into a DataFrame.
.. danger::
In order to avoid injection vulnerabilities (similar to `SQL
injection <https://www.owasp.org/index.php/SQL_Injection>`_
vulnerabilities), do not directly include untrusted data into the
``query`` parameter, use `... | query | python | influxdata/influxdb-python | influxdb/_dataframe_client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/_dataframe_client.py | MIT |
def from_dsn(dsn, **kwargs):
r"""Return an instaance of InfluxDBClient from given data source name.
Returns an instance of InfluxDBClient from the provided data source
name. Supported schemes are "influxdb", "https+influxdb",
"udp+influxdb". Parameters for the InfluxDBClient constructor... | Return an instaance of InfluxDBClient from given data source name.
Returns an instance of InfluxDBClient from the provided data source
name. Supported schemes are "influxdb", "https+influxdb",
"udp+influxdb". Parameters for the InfluxDBClient constructor may be
also be passed to this fu... | from_dsn | python | influxdata/influxdb-python | influxdb/influxdb08/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/client.py | MIT |
def switch_user(self, username, password):
"""Change client username.
:param username: the new username to switch to
:type username: string
:param password: the new password to switch to
:type password: string
"""
self._username = username
self._password ... | Change client username.
:param username: the new username to switch to
:type username: string
:param password: the new password to switch to
:type password: string
| switch_user | python | influxdata/influxdb-python | influxdb/influxdb08/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/client.py | MIT |
def write(self, data):
"""Provide as convenience for influxdb v0.9.0, this may change."""
self.request(
url="write",
method='POST',
params=None,
data=data,
expected_response_code=200
)
return True | Provide as convenience for influxdb v0.9.0, this may change. | write | python | influxdata/influxdb-python | influxdb/influxdb08/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/client.py | MIT |
def write_points(self, data, time_precision='s', *args, **kwargs):
"""Write to multiple time series names.
An example data blob is:
data = [
{
"points": [
[
12
]
],
"name... | Write to multiple time series names.
An example data blob is:
data = [
{
"points": [
[
12
]
],
"name": "cpu_load_short",
"columns": [
"value"
... | write_points | python | influxdata/influxdb-python | influxdb/influxdb08/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/client.py | MIT |
def write_points_with_precision(self, data, time_precision='s'):
"""Write to multiple time series names.
DEPRECATED.
"""
warnings.warn(
"write_points_with_precision is deprecated, and will be removed "
"in future versions. Please use "
"``InfluxDBClie... | Write to multiple time series names.
DEPRECATED.
| write_points_with_precision | python | influxdata/influxdb-python | influxdb/influxdb08/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/client.py | MIT |
def create_database(self, database):
"""Create a database on the InfluxDB server.
:param database: the name of the database to create
:type database: string
:rtype: boolean
"""
url = "db"
data = {'name': database}
self.request(
url=url,
... | Create a database on the InfluxDB server.
:param database: the name of the database to create
:type database: string
:rtype: boolean
| create_database | python | influxdata/influxdb-python | influxdb/influxdb08/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/client.py | MIT |
def delete_database(self, database):
"""Drop a database on the InfluxDB server.
:param database: the name of the database to delete
:type database: string
:rtype: boolean
"""
url = "db/{0}".format(database)
self.request(
url=url,
method='... | Drop a database on the InfluxDB server.
:param database: the name of the database to delete
:type database: string
:rtype: boolean
| delete_database | python | influxdata/influxdb-python | influxdb/influxdb08/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/client.py | MIT |
def get_database_list(self):
"""Get the list of databases.
DEPRECATED.
"""
warnings.warn(
"get_database_list is deprecated, and will be removed "
"in future versions. Please use "
"``InfluxDBClient.get_list_database`` instead.",
FutureWarn... | Get the list of databases.
DEPRECATED.
| get_database_list | python | influxdata/influxdb-python | influxdb/influxdb08/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/client.py | MIT |
def delete_series(self, series):
"""Drop a series on the InfluxDB server.
:param series: the name of the series to delete
:type series: string
:rtype: boolean
"""
url = "db/{0}/series/{1}".format(
self._database,
series
)
self.req... | Drop a series on the InfluxDB server.
:param series: the name of the series to delete
:type series: string
:rtype: boolean
| delete_series | python | influxdata/influxdb-python | influxdb/influxdb08/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/client.py | MIT |
def get_list_series(self):
"""Get a list of all time series in a database."""
response = self._query('list series')
return [series[1] for series in response[0]['points']] | Get a list of all time series in a database. | get_list_series | python | influxdata/influxdb-python | influxdb/influxdb08/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/client.py | MIT |
def add_database_user(self, new_username, new_password, permissions=None):
"""Add database user.
:param permissions: A ``(readFrom, writeTo)`` tuple
"""
url = "db/{0}/users".format(self._database)
data = {
'name': new_username,
'password': new_password
... | Add database user.
:param permissions: A ``(readFrom, writeTo)`` tuple
| add_database_user | python | influxdata/influxdb-python | influxdb/influxdb08/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/client.py | MIT |
def alter_database_user(self, username, password=None, permissions=None):
"""Alter a database user and/or their permissions.
:param permissions: A ``(readFrom, writeTo)`` tuple
:raise TypeError: if permissions cannot be read.
:raise ValueError: if neither password nor permissions provid... | Alter a database user and/or their permissions.
:param permissions: A ``(readFrom, writeTo)`` tuple
:raise TypeError: if permissions cannot be read.
:raise ValueError: if neither password nor permissions provided.
| alter_database_user | python | influxdata/influxdb-python | influxdb/influxdb08/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/client.py | MIT |
def send_packet(self, packet):
"""Send a UDP packet along the wire."""
data = json.dumps(packet)
byte = data.encode('utf-8')
self.udp_socket.sendto(byte, (self._host, self._udp_port)) | Send a UDP packet along the wire. | send_packet | python | influxdata/influxdb-python | influxdb/influxdb08/client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/client.py | MIT |
def __init__(self, ignore_nan=True, *args, **kwargs):
"""Initialize an instance of the DataFrameClient."""
super(DataFrameClient, self).__init__(*args, **kwargs)
try:
global pd
import pandas as pd
except ImportError as ex:
raise ImportError('DataFrame... | Initialize an instance of the DataFrameClient. | __init__ | python | influxdata/influxdb-python | influxdb/influxdb08/dataframe_client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/dataframe_client.py | MIT |
def write_points(self, data, *args, **kwargs):
"""Write to multiple time series names.
:param data: A dictionary mapping series names to pandas DataFrames
:param time_precision: [Optional, default 's'] Either 's', 'm', 'ms'
or 'u'.
:param batch_size: [Optional] Value to writ... | Write to multiple time series names.
:param data: A dictionary mapping series names to pandas DataFrames
:param time_precision: [Optional, default 's'] Either 's', 'm', 'ms'
or 'u'.
:param batch_size: [Optional] Value to write the points in batches
instead of all at one ... | write_points | python | influxdata/influxdb-python | influxdb/influxdb08/dataframe_client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/dataframe_client.py | MIT |
def write_points_with_precision(self, data, time_precision='s'):
"""Write to multiple time series names.
DEPRECATED
"""
warnings.warn(
"write_points_with_precision is deprecated, and will be removed "
"in future versions. Please use "
"``DataFrameClie... | Write to multiple time series names.
DEPRECATED
| write_points_with_precision | python | influxdata/influxdb-python | influxdb/influxdb08/dataframe_client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/dataframe_client.py | MIT |
def query(self, query, time_precision='s', chunked=False):
"""Query data into DataFrames.
Returns a DataFrame for a single time series and a map for multiple
time series with the time series as value and its name as key.
:param time_precision: [Optional, default 's'] Either 's', 'm', '... | Query data into DataFrames.
Returns a DataFrame for a single time series and a map for multiple
time series with the time series as value and its name as key.
:param time_precision: [Optional, default 's'] Either 's', 'm', 'ms'
or 'u'.
:param chunked: [Optional, default=Fal... | query | python | influxdata/influxdb-python | influxdb/influxdb08/dataframe_client.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/dataframe_client.py | MIT |
def __init__(self, **kw):
"""Create a new data point.
All fields must be present.
:note: Data points written when `bulk_size` is reached per Helper.
:warning: Data points are *immutable* (`namedtuples`).
"""
cls = self.__class__
if sorted(cls._fields) != sorted... | Create a new data point.
All fields must be present.
:note: Data points written when `bulk_size` is reached per Helper.
:warning: Data points are *immutable* (`namedtuples`).
| __init__ | python | influxdata/influxdb-python | influxdb/influxdb08/helper.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/helper.py | MIT |
def _json_body_(cls):
"""Return JSON body of the datapoints.
:return: JSON body of the datapoints.
"""
json = []
if not cls.__initialized__:
cls._reset_()
for series_name, data in six.iteritems(cls._datapoints):
json.append({'name': series_name,
... | Return JSON body of the datapoints.
:return: JSON body of the datapoints.
| _json_body_ | python | influxdata/influxdb-python | influxdb/influxdb08/helper.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/influxdb08/helper.py | MIT |
def test_load(self):
"""Test reading a sequence of JSON values from a string."""
example_response = \
'{"results": [{"series": [{"measurement": "sdfsdfsdf", ' \
'"columns": ["time", "value"], "values": ' \
'[["2009-11-10T23:00:00Z", 0.64]]}]}, {"series": ' \
... | Test reading a sequence of JSON values from a string. | test_load | python | influxdata/influxdb-python | influxdb/tests/chunked_json_test.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/tests/chunked_json_test.py | MIT |
def request(*args, **kwargs):
"""Request content from the mocked session."""
c = content
# Check method
assert method == kwargs.get('method', 'GET')
if method == 'POST':
data = kwargs.get('data', None)
if data is not None:
# Data must be... | Request content from the mocked session. | request | python | influxdata/influxdb-python | influxdb/tests/client_test.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/tests/client_test.py | MIT |
def setUp(self):
"""Initialize an instance of TestInfluxDBClient object."""
# By default, raise exceptions on warnings
warnings.simplefilter('error', FutureWarning)
self.cli = InfluxDBClient('localhost', 8086, 'username', 'password')
self.dummy_points = [
{
... | Initialize an instance of TestInfluxDBClient object. | setUp | python | influxdata/influxdb-python | influxdb/tests/client_test.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/tests/client_test.py | MIT |
def test_scheme(self):
"""Set up the test schema for TestInfluxDBClient object."""
cli = InfluxDBClient('host', 8086, 'username', 'password', 'database')
self.assertEqual('http://host:8086', cli._baseurl)
cli = InfluxDBClient(
'host', 8086, 'username', 'password', 'database'... | Set up the test schema for TestInfluxDBClient object. | test_scheme | python | influxdata/influxdb-python | influxdb/tests/client_test.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/tests/client_test.py | MIT |
def test_dsn(self):
"""Set up the test datasource name for TestInfluxDBClient object."""
cli = InfluxDBClient.from_dsn('influxdb://192.168.0.1:1886')
self.assertEqual('http://192.168.0.1:1886', cli._baseurl)
cli = InfluxDBClient.from_dsn(self.dsn_string)
self.assertEqual('http:/... | Set up the test datasource name for TestInfluxDBClient object. | test_dsn | python | influxdata/influxdb-python | influxdb/tests/client_test.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/tests/client_test.py | MIT |
def test_cert(self):
"""Test mutual TLS authentication for TestInfluxDBClient object."""
cli = InfluxDBClient(ssl=True, cert='/etc/pki/tls/private/dummy.crt')
self.assertEqual(cli._session.cert, '/etc/pki/tls/private/dummy.crt')
with self.assertRaises(ValueError):
cli = Infl... | Test mutual TLS authentication for TestInfluxDBClient object. | test_cert | python | influxdata/influxdb-python | influxdb/tests/client_test.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/tests/client_test.py | MIT |
def test_switch_database(self):
"""Test switch database in TestInfluxDBClient object."""
cli = InfluxDBClient('host', 8086, 'username', 'password', 'database')
cli.switch_database('another_database')
self.assertEqual('another_database', cli._database) | Test switch database in TestInfluxDBClient object. | test_switch_database | python | influxdata/influxdb-python | influxdb/tests/client_test.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/tests/client_test.py | MIT |
def test_switch_user(self):
"""Test switch user in TestInfluxDBClient object."""
cli = InfluxDBClient('host', 8086, 'username', 'password', 'database')
cli.switch_user('another_username', 'another_password')
self.assertEqual('another_username', cli._username)
self.assertEqual('an... | Test switch user in TestInfluxDBClient object. | test_switch_user | python | influxdata/influxdb-python | influxdb/tests/client_test.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/tests/client_test.py | MIT |
def test_write_points(self):
"""Test write points for TestInfluxDBClient object."""
with requests_mock.Mocker() as m:
m.register_uri(
requests_mock.POST,
"http://localhost:8086/write",
status_code=204
)
cli = InfluxDBCl... | Test write points for TestInfluxDBClient object. | test_write_points | python | influxdata/influxdb-python | influxdb/tests/client_test.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/tests/client_test.py | MIT |
def test_write_points_toplevel_attributes(self):
"""Test write points attrs for TestInfluxDBClient object."""
with requests_mock.Mocker() as m:
m.register_uri(
requests_mock.POST,
"http://localhost:8086/write",
status_code=204
)
... | Test write points attrs for TestInfluxDBClient object. | test_write_points_toplevel_attributes | python | influxdata/influxdb-python | influxdb/tests/client_test.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/tests/client_test.py | MIT |
def test_write_points_batch(self):
"""Test write points batch for TestInfluxDBClient object."""
dummy_points = [
{"measurement": "cpu_usage", "tags": {"unit": "percent"},
"time": "2009-11-10T23:00:00Z", "fields": {"value": 12.34}},
{"measurement": "network", "tags": ... | Test write points batch for TestInfluxDBClient object. | test_write_points_batch | python | influxdata/influxdb-python | influxdb/tests/client_test.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/tests/client_test.py | MIT |
def test_write_points_batch_generator(self):
"""Test write points batch from a generator for TestInfluxDBClient."""
dummy_points = [
{"measurement": "cpu_usage", "tags": {"unit": "percent"},
"time": "2009-11-10T23:00:00Z", "fields": {"value": 12.34}},
{"measurement":... | Test write points batch from a generator for TestInfluxDBClient. | test_write_points_batch_generator | python | influxdata/influxdb-python | influxdb/tests/client_test.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/tests/client_test.py | MIT |
def test_write_points_udp(self):
"""Test write points UDP for TestInfluxDBClient object."""
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
port = random.randint(4000, 8000)
s.bind(('0.0.0.0', port))
cli = InfluxDBClient(
'localhost', 8086, 'root', 'root',
... | Test write points UDP for TestInfluxDBClient object. | test_write_points_udp | python | influxdata/influxdb-python | influxdb/tests/client_test.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/tests/client_test.py | MIT |
def test_write_points_fails(self):
"""Test write points fail for TestInfluxDBClient object."""
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
with _mocked_session(cli, 'post', 500):
cli.write_points([]) | Test write points fail for TestInfluxDBClient object. | test_write_points_fails | python | influxdata/influxdb-python | influxdb/tests/client_test.py | https://github.com/influxdata/influxdb-python/blob/master/influxdb/tests/client_test.py | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.