INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
: type context: Context | def mutate_list_of_nodes(node, context):
"""
:type context: Context
"""
return_annotation_started = False
for child_node in node.children:
if child_node.type == 'operator' and child_node.value == '->':
return_annotation_started = True
if return_annotation_started and ... |
: type backup: bool: type context: Context | def mutate_file(backup, context):
"""
:type backup: bool
:type context: Context
"""
with open(context.filename) as f:
code = f.read()
context.source = code
if backup:
with open(context.filename + '.bak', 'w') as f:
f.write(code)
result, number_of_mutations_per... |
Connect to the device. If not connected within the specified timeout then an exception is thrown. | def connect(self, timeout_sec=TIMEOUT_SEC):
"""Connect to the device. If not connected within the specified timeout
then an exception is thrown.
"""
self._central_manager.connectPeripheral_options_(self._peripheral, None)
if not self._connected.wait(timeout_sec):
rai... |
Disconnect from the device. If not disconnected within the specified timeout then an exception is thrown. | def disconnect(self, timeout_sec=TIMEOUT_SEC):
"""Disconnect from the device. If not disconnected within the specified
timeout then an exception is thrown.
"""
# Remove all the services, characteristics, and descriptors from the
# lists of those items. Do this before disconnect... |
Called when advertisement data is received. | def _update_advertised(self, advertised):
"""Called when advertisement data is received."""
# Advertisement data was received, pull out advertised service UUIDs and
# name from advertisement data.
if 'kCBAdvDataServiceUUIDs' in advertised:
self._advertised = self._advertised ... |
Called when GATT characteristics have been discovered. | def _characteristics_discovered(self, service):
"""Called when GATT characteristics have been discovered."""
# Characteristics for the specified service were discovered. Update
# set of discovered services and signal when all have been discovered.
self._discovered_services.add(service)
... |
Called when the specified characteristic has changed its value. | def _characteristic_changed(self, characteristic):
"""Called when the specified characteristic has changed its value."""
# Called when a characteristic is changed. Get the on_changed handler
# for this characteristic (if it exists) and call it.
on_changed = self._char_on_changed.get(cha... |
Called when the specified descriptor has changed its value. | def _descriptor_changed(self, descriptor):
"""Called when the specified descriptor has changed its value."""
# Tell the descriptor it has a new value to read.
desc = descriptor_list().get(descriptor)
if desc is not None:
desc._value_read.set() |
Wait up to timeout_sec for the specified services and characteristics to be discovered on the device. If the timeout is exceeded without discovering the services and characteristics then an exception is thrown. | def discover(self, service_uuids, char_uuids, timeout_sec=TIMEOUT_SEC):
"""Wait up to timeout_sec for the specified services and characteristics
to be discovered on the device. If the timeout is exceeded without
discovering the services and characteristics then an exception is thrown.
"... |
Return the RSSI signal strength in decibels. | def rssi(self, timeout_sec=TIMEOUT_SEC):
"""Return the RSSI signal strength in decibels."""
# Kick off query to get RSSI, then wait for it to return asyncronously
# when the _rssi_changed() function is called.
self._rssi_read.clear()
self._peripheral.readRSSI()
if not sel... |
Block until data is available to read from the UART. Will return a string of data that has been received. Timeout_sec specifies how many seconds to wait for data to be available and will block forever if None ( the default ). If the timeout is exceeded and no data is found then None is returned. | def read(self, timeout_sec=None):
"""Block until data is available to read from the UART. Will return a
string of data that has been received. Timeout_sec specifies how many
seconds to wait for data to be available and will block forever if None
(the default). If the timeout is exceed... |
Return list of GATT characteristics that have been discovered for this service. | def list_characteristics(self):
"""Return list of GATT characteristics that have been discovered for this
service.
"""
paths = self._props.Get(_SERVICE_INTERFACE, 'Characteristics')
return map(BluezGattCharacteristic,
get_provider()._get_objects_by_path(paths)) |
Enable notification of changes for this characteristic on the specified on_change callback. on_change should be a function that takes one parameter which is the value ( as a string of bytes ) of the changed characteristic value. | def start_notify(self, on_change):
"""Enable notification of changes for this characteristic on the
specified on_change callback. on_change should be a function that takes
one parameter which is the value (as a string of bytes) of the changed
characteristic value.
"""
# ... |
Return list of GATT descriptors that have been discovered for this characteristic. | def list_descriptors(self):
"""Return list of GATT descriptors that have been discovered for this
characteristic.
"""
paths = self._props.Get(_CHARACTERISTIC_INTERFACE, 'Descriptors')
return map(BluezGattDescriptor,
get_provider()._get_objects_by_path(paths)) |
Called when the power state changes. | def _state_changed(self, state):
"""Called when the power state changes."""
logger.debug('Adapter state change: {0}'.format(state))
# Handle when powered on.
if state == 5:
self._powered_off.clear()
self._powered_on.set()
# Handle when powered off.
... |
Start scanning for BLE devices. | def start_scan(self, timeout_sec=TIMEOUT_SEC):
"""Start scanning for BLE devices."""
get_provider()._central_manager.scanForPeripheralsWithServices_options_(None, None)
self._is_scanning = True |
Stop scanning for BLE devices. | def stop_scan(self, timeout_sec=TIMEOUT_SEC):
"""Stop scanning for BLE devices."""
get_provider()._central_manager.stopScan()
self._is_scanning = False |
Power on Bluetooth. | def power_on(self, timeout_sec=TIMEOUT_SEC):
"""Power on Bluetooth."""
# Turn on bluetooth and wait for powered on event to be set.
self._powered_on.clear()
IOBluetoothPreferenceSetControllerPowerState(1)
if not self._powered_on.wait(timeout_sec):
raise RuntimeError('... |
Power off Bluetooth. | def power_off(self, timeout_sec=TIMEOUT_SEC):
"""Power off Bluetooth."""
# Turn off bluetooth.
self._powered_off.clear()
IOBluetoothPreferenceSetControllerPowerState(0)
if not self._powered_off.wait(timeout_sec):
raise RuntimeError('Exceeded timeout waiting for adapte... |
Find the first available device that supports this service and return it or None if no device is found. Will wait for up to timeout_sec seconds to find the device. | def find_device(cls, timeout_sec=TIMEOUT_SEC):
"""Find the first available device that supports this service and return
it, or None if no device is found. Will wait for up to timeout_sec
seconds to find the device.
"""
return get_provider().find_device(service_uuids=cls.ADVERTIS... |
Wait until the specified device has discovered the expected services and characteristics for this service. Should be called once before other calls are made on the service. Returns true if the service has been discovered in the specified timeout or false if not discovered. | def discover(cls, device, timeout_sec=TIMEOUT_SEC):
"""Wait until the specified device has discovered the expected services
and characteristics for this service. Should be called once before other
calls are made on the service. Returns true if the service has been
discovered in the spe... |
Return the first child service found that has the specified UUID. Will return None if no service that matches is found. | def find_service(self, uuid):
"""Return the first child service found that has the specified
UUID. Will return None if no service that matches is found.
"""
for service in self.list_services():
if service.uuid == uuid:
return service
return None |
Connect to the device. If not connected within the specified timeout then an exception is thrown. | def connect(self, timeout_sec=TIMEOUT_SEC):
"""Connect to the device. If not connected within the specified timeout
then an exception is thrown.
"""
self._connected.clear()
self._device.Connect()
if not self._connected.wait(timeout_sec):
raise RuntimeError('E... |
Disconnect from the device. If not disconnected within the specified timeout then an exception is thrown. | def disconnect(self, timeout_sec=TIMEOUT_SEC):
"""Disconnect from the device. If not disconnected within the specified
timeout then an exception is thrown.
"""
self._disconnected.clear()
self._device.Disconnect()
if not self._disconnected.wait(timeout_sec):
r... |
Return a list of GattService objects that have been discovered for this device. | def list_services(self):
"""Return a list of GattService objects that have been discovered for
this device.
"""
return map(BluezGattService,
get_provider()._get_objects(_SERVICE_INTERFACE,
self._device.object_path)) |
Wait up to timeout_sec for the specified services and characteristics to be discovered on the device. If the timeout is exceeded without discovering the services and characteristics then an exception is thrown. | def discover(self, service_uuids, char_uuids, timeout_sec=TIMEOUT_SEC):
"""Wait up to timeout_sec for the specified services and characteristics
to be discovered on the device. If the timeout is exceeded without
discovering the services and characteristics then an exception is thrown.
"... |
Return a list of UUIDs for services that are advertised by this device. | def advertised(self):
"""Return a list of UUIDs for services that are advertised by this
device.
"""
uuids = []
# Get UUIDs property but wrap it in a try/except to catch if the property
# doesn't exist as it is optional.
try:
uuids = self._props.Get(_I... |
Return the first child characteristic found that has the specified UUID. Will return None if no characteristic that matches is found. | def find_characteristic(self, uuid):
"""Return the first child characteristic found that has the specified
UUID. Will return None if no characteristic that matches is found.
"""
for char in self.list_characteristics():
if char.uuid == uuid:
return char
... |
Return the first child descriptor found that has the specified UUID. Will return None if no descriptor that matches is found. | def find_descriptor(self, uuid):
"""Return the first child descriptor found that has the specified
UUID. Will return None if no descriptor that matches is found.
"""
for desc in self.list_descriptors():
if desc.uuid == uuid:
return desc
return None |
Read the value of this characteristic. | def read_value(self, timeout_sec=TIMEOUT_SEC):
"""Read the value of this characteristic."""
# Kick off a query to read the value of the characteristic, then wait
# for the result to return asyncronously.
self._value_read.clear()
self._device._peripheral.readValueForCharacteristic... |
Write the specified value to this characteristic. | def write_value(self, value, write_type=0):
"""Write the specified value to this characteristic."""
data = NSData.dataWithBytes_length_(value, len(value))
self._device._peripheral.writeValue_forCharacteristic_type_(data,
self._characteristic,
write_type) |
Enable notification of changes for this characteristic on the specified on_change callback. on_change should be a function that takes one parameter which is the value ( as a string of bytes ) of the changed characteristic value. | def start_notify(self, on_change):
"""Enable notification of changes for this characteristic on the
specified on_change callback. on_change should be a function that takes
one parameter which is the value (as a string of bytes) of the changed
characteristic value.
"""
# ... |
Read the value of this descriptor. | def read_value(self):
"""Read the value of this descriptor."""
pass
# Kick off a query to read the value of the descriptor, then wait
# for the result to return asyncronously.
self._value_read.clear()
self._device._peripheral.readValueForDescriptor(self._descriptor)
... |
Start scanning for BLE devices with this adapter. | def start_scan(self, timeout_sec=TIMEOUT_SEC):
"""Start scanning for BLE devices with this adapter."""
self._scan_started.clear()
self._adapter.StartDiscovery()
if not self._scan_started.wait(timeout_sec):
raise RuntimeError('Exceeded timeout waiting for adapter to start scan... |
Stop scanning for BLE devices with this adapter. | def stop_scan(self, timeout_sec=TIMEOUT_SEC):
"""Stop scanning for BLE devices with this adapter."""
self._scan_stopped.clear()
self._adapter.StopDiscovery()
if not self._scan_stopped.wait(timeout_sec):
raise RuntimeError('Exceeded timeout waiting for adapter to stop scanning... |
Called when the BLE adapter is powered on and ready to scan/ connect to devices. | def centralManagerDidUpdateState_(self, manager):
"""Called when the BLE adapter is powered on and ready to scan/connect
to devices.
"""
logger.debug('centralManagerDidUpdateState called')
# Notify adapter about changed central state.
get_provider()._adapter._state_change... |
Called when the BLE adapter found a device while scanning or has new advertisement data for a device. | def centralManager_didDiscoverPeripheral_advertisementData_RSSI_(self, manager, peripheral, data, rssi):
"""Called when the BLE adapter found a device while scanning, or has
new advertisement data for a device.
"""
logger.debug('centralManager_didDiscoverPeripheral_advertisementData_RSSI... |
Called when a device is connected. | def centralManager_didConnectPeripheral_(self, manager, peripheral):
"""Called when a device is connected."""
logger.debug('centralManager_didConnectPeripheral called')
# Setup peripheral delegate and kick off service discovery. For now just
# assume all services need to be discovered.
... |
Called when a device is disconnected. | def centralManager_didDisconnectPeripheral_error_(self, manager, peripheral, error):
"""Called when a device is disconnected."""
logger.debug('centralManager_didDisconnectPeripheral called')
# Get the device and remove it from the device list, then fire its
# disconnected event.
... |
Called when services are discovered for a device. | def peripheral_didDiscoverServices_(self, peripheral, services):
"""Called when services are discovered for a device."""
logger.debug('peripheral_didDiscoverServices called')
# Make sure the discovered services are added to the list of known
# services, and kick off characteristic discov... |
Called when characteristics are discovered for a service. | def peripheral_didDiscoverCharacteristicsForService_error_(self, peripheral, service, error):
"""Called when characteristics are discovered for a service."""
logger.debug('peripheral_didDiscoverCharacteristicsForService_error called')
# Stop if there was some kind of error.
if error is n... |
Called when characteristics are discovered for a service. | def peripheral_didDiscoverDescriptorsForCharacteristic_error_(self, peripheral, characteristic, error):
"""Called when characteristics are discovered for a service."""
logger.debug('peripheral_didDiscoverDescriptorsForCharacteristic_error called')
# Stop if there was some kind of error.
... |
Called when characteristic value was read or updated. | def peripheral_didUpdateValueForCharacteristic_error_(self, peripheral, characteristic, error):
"""Called when characteristic value was read or updated."""
logger.debug('peripheral_didUpdateValueForCharacteristic_error called')
# Stop if there was some kind of error.
if error is not None... |
Called when descriptor value was read or updated. | def peripheral_didUpdateValueForDescriptor_error_(self, peripheral, descriptor, error):
"""Called when descriptor value was read or updated."""
logger.debug('peripheral_didUpdateValueForDescriptor_error called')
# Stop if there was some kind of error.
if error is not None:
re... |
Called when a new RSSI value for the peripheral is available. | def peripheral_didReadRSSI_error_(self, peripheral, rssi, error):
"""Called when a new RSSI value for the peripheral is available."""
logger.debug('peripheral_didReadRSSI_error called')
# Note this appears to be completely undocumented at the time of this
# writing. Can see more details... |
Initialize the BLE provider. Must be called once before any other calls are made to the provider. | def initialize(self):
"""Initialize the BLE provider. Must be called once before any other
calls are made to the provider.
"""
# Setup the central manager and its delegate.
self._central_manager = CBCentralManager.alloc()
self._central_manager.initWithDelegate_queue_opti... |
Start the OS s main loop to process asyncronous BLE events and then run the specified target function in a background thread. Target function should be a function that takes no parameters and optionally return an integer response code. When the target function stops executing or returns with value then the main loop wi... | def run_mainloop_with(self, target):
"""Start the OS's main loop to process asyncronous BLE events and then
run the specified target function in a background thread. Target
function should be a function that takes no parameters and optionally
return an integer response code. When the t... |
Main entry point for the thread that will run user s code. | def _user_thread_main(self, target):
"""Main entry point for the thread that will run user's code."""
try:
# Run user's code.
return_code = target()
# Assume good result (0 return code) if none is returned.
if return_code is None:
return_co... |
Clear the internal bluetooth device cache. This is useful if a device changes its state like name and it can t be detected with the new state anymore. WARNING: This will delete some files underneath the running user s ~/ Library/ Preferences/ folder! | def clear_cached_data(self):
"""Clear the internal bluetooth device cache. This is useful if a device
changes its state like name and it can't be detected with the new state
anymore. WARNING: This will delete some files underneath the running user's
~/Library/Preferences/ folder!
... |
Disconnect any connected devices that have any of the specified service UUIDs. | def disconnect_devices(self, service_uuids):
"""Disconnect any connected devices that have any of the specified
service UUIDs.
"""
# Get list of connected devices with specified services.
cbuuids = map(uuid_to_cbuuid, service_uuids)
for device in self._central_manager.ret... |
Initialize bluez DBus communication. Must be called before any other calls are made! | def initialize(self):
"""Initialize bluez DBus communication. Must be called before any other
calls are made!
"""
# Ensure GLib's threading is initialized to support python threads, and
# make a default mainloop that all DBus objects will inherit. These
# commands MUST ... |
Start the OS s main loop to process asyncronous BLE events and then run the specified target function in a background thread. Target function should be a function that takes no parameters and optionally return an integer response code. When the target function stops executing or returns with value then the main loop wi... | def run_mainloop_with(self, target):
"""Start the OS's main loop to process asyncronous BLE events and then
run the specified target function in a background thread. Target
function should be a function that takes no parameters and optionally
return an integer response code. When the t... |
Main entry point for the thread that will run user s code. | def _user_thread_main(self, target):
"""Main entry point for the thread that will run user's code."""
try:
# Wait for GLib main loop to start running before starting user code.
while True:
if self._gobject_mainloop is not None and self._gobject_mainloop.is_running... |
Clear any internally cached BLE device data. Necessary in some cases to prevent issues with stale device data getting cached by the OS. | def clear_cached_data(self):
"""Clear any internally cached BLE device data. Necessary in some cases
to prevent issues with stale device data getting cached by the OS.
"""
# Go through and remove any device that isn't currently connected.
for device in self.list_devices():
... |
Disconnect any connected devices that have the specified list of service UUIDs. The default is an empty list which means all devices are disconnected. | def disconnect_devices(self, service_uuids=[]):
"""Disconnect any connected devices that have the specified list of
service UUIDs. The default is an empty list which means all devices
are disconnected.
"""
service_uuids = set(service_uuids)
for device in self.list_device... |
Return a list of all bluez DBus objects that implement the requested interface name and are under the specified path. The default is to search devices under the root of all bluez objects. | def _get_objects(self, interface, parent_path='/org/bluez'):
"""Return a list of all bluez DBus objects that implement the requested
interface name and are under the specified path. The default is to
search devices under the root of all bluez objects.
"""
# Iterate through all t... |
Return a list of all bluez DBus objects from the provided list of paths. | def _get_objects_by_path(self, paths):
"""Return a list of all bluez DBus objects from the provided list of paths.
"""
return map(lambda x: self._bus.get_object('org.bluez', x), paths) |
Print tree of all bluez objects useful for debugging. | def _print_tree(self):
"""Print tree of all bluez objects, useful for debugging."""
# This is based on the bluez sample code get-managed-objects.py.
objects = self._bluez.GetManagedObjects()
for path in objects.keys():
print("[ %s ]" % (path))
interfaces = objects... |
Return devices that advertise the specified service UUIDs and/ or have the specified name. Service_uuids should be a list of Python uuid. UUID objects and is optional. Name is a string device name to look for and is also optional. Will not block instead it returns immediately with a list of found devices ( which might ... | def find_devices(self, service_uuids=[], name=None):
"""Return devices that advertise the specified service UUIDs and/or have
the specified name. Service_uuids should be a list of Python uuid.UUID
objects and is optional. Name is a string device name to look for and is
also optional. ... |
Return the first device that advertises the specified service UUIDs or has the specified name. Will wait up to timeout_sec seconds for the device to be found and if the timeout is zero then it will not wait at all and immediately return a result. When no device is found a value of None is returned. | def find_device(self, service_uuids=[], name=None, timeout_sec=TIMEOUT_SEC):
"""Return the first device that advertises the specified service UUIDs or
has the specified name. Will wait up to timeout_sec seconds for the device
to be found, and if the timeout is zero then it will not wait at all a... |
Retrieve a list of metadata objects associated with the specified list of CoreBluetooth objects. If an object cannot be found then an exception is thrown. | def get_all(self, cbobjects):
"""Retrieve a list of metadata objects associated with the specified
list of CoreBluetooth objects. If an object cannot be found then an
exception is thrown.
"""
try:
with self._lock:
return [self._metadata[x] for x in cb... |
Add the specified CoreBluetooth item with the associated metadata if it doesn t already exist. Returns the newly created or preexisting metadata item. | def add(self, cbobject, metadata):
"""Add the specified CoreBluetooth item with the associated metadata if
it doesn't already exist. Returns the newly created or preexisting
metadata item.
"""
with self._lock:
if cbobject not in self._metadata:
self._... |
Remove any metadata associated with the provided CoreBluetooth object. | def remove(self, cbobject):
"""Remove any metadata associated with the provided CoreBluetooth object.
"""
with self._lock:
if cbobject in self._metadata:
del self._metadata[cbobject] |
Convert Objective - C CBUUID type to native Python UUID type. | def cbuuid_to_uuid(cbuuid):
"""Convert Objective-C CBUUID type to native Python UUID type."""
data = cbuuid.data().bytes()
template = '{:0>8}-0000-1000-8000-00805f9b34fb' if len(data) <= 4 else '{:0>32}'
value = template.format(hexlify(data.tobytes()[:16]).decode('ascii'))
return uuid.UUID(hex=valu... |
Set the red green blue color of the bulb. | def set_color(self, r, g, b):
"""Set the red, green, blue color of the bulb."""
# See more details on the bulb's protocol from this guide:
# https://learn.adafruit.com/reverse-engineering-a-bluetooth-low-energy-light-bulb/overview
command = '\x58\x01\x03\x01\xFF\x00{0}{1}{2}'.format(ch... |
Return an instance of the BLE provider for the current platform. | def get_provider():
"""Return an instance of the BLE provider for the current platform."""
global _provider
# Set the provider based on the current platform.
if _provider is None:
if sys.platform.startswith('linux'):
# Linux platform
from .bluez_dbus.provider import Bluez... |
Convert the byte array to a BigInteger | def toBigInt(byteArray):
"""Convert the byte array to a BigInteger"""
array = byteArray[::-1] # reverse array
out = 0
for key, value in enumerate(array):
decoded = struct.unpack("B", bytes([value]))[0]
out = out | decoded << key * 8
return out |
Encrypt credentials using the google publickey with the RSA algorithm | def encryptPassword(self, login, passwd):
"""Encrypt credentials using the google publickey, with the
RSA algorithm"""
# structure of the binary key:
#
# *-------------------------------------------------------*
# | modulus_length | modulus | exponent_length | exponent |... |
Return the default set of request headers which can later be expanded based on the request type | def getHeaders(self, upload_fields=False):
"""Return the default set of request headers, which
can later be expanded, based on the request type"""
if upload_fields:
headers = self.deviceBuilder.getDeviceUploadHeaders()
else:
headers = self.deviceBuilder.getBaseHe... |
Upload the device configuration of the fake device selected in the __init__ methodi to the google account. | def uploadDeviceConfig(self):
"""Upload the device configuration of the fake device
selected in the __init__ methodi to the google account."""
upload = googleplay_pb2.UploadDeviceConfigRequest()
upload.deviceConfiguration.CopyFrom(self.deviceBuilder.getDeviceConfig())
headers = ... |
Login to your Google Account. For first time login you should provide: * email * password For the following logins you need to provide: * gsfId * authSubToken | def login(self, email=None, password=None, gsfId=None, authSubToken=None):
"""Login to your Google Account.
For first time login you should provide:
* email
* password
For the following logins you need to provide:
* gsfId
* authSubToken"""
... |
Search the play store for an app. | def search(self, query):
""" Search the play store for an app.
nb_result (int): is the maximum number of result to be returned
offset (int): is used to take result starting from an index.
"""
if self.authSubToken is None:
raise LoginError("You need to login before e... |
Get app details from a package name. | def details(self, packageName):
"""Get app details from a package name.
packageName is the app unique ID (usually starting with 'com.')."""
path = DETAILS_URL + "?doc={}".format(requests.utils.quote(packageName))
data = self.executeRequestApi2(path)
return utils.parseProtobufObj... |
Get several apps details from a list of package names. | def bulkDetails(self, packageNames):
"""Get several apps details from a list of package names.
This is much more efficient than calling N times details() since it
requires only one request. If an item is not found it returns an empty object
instead of throwing a RequestError('Item not f... |
Browse categories. If neither cat nor subcat are specified return a list of categories otherwise it return a list of apps using cat ( category ID ) and subCat ( subcategory ID ) as filters. | def browse(self, cat=None, subCat=None):
"""Browse categories. If neither cat nor subcat are specified,
return a list of categories, otherwise it return a list of apps
using cat (category ID) and subCat (subcategory ID) as filters."""
path = BROWSE_URL + "?c=3"
if cat is not None... |
List all possible subcategories for a specific category. If also a subcategory is provided list apps from this category. | def list(self, cat, ctr=None, nb_results=None, offset=None):
"""List all possible subcategories for a specific category. If
also a subcategory is provided, list apps from this category.
Args:
cat (str): category id
ctr (str): subcategory id
nb_results (int): ... |
Browse reviews for an application | def reviews(self, packageName, filterByDevice=False, sort=2,
nb_results=None, offset=None):
"""Browse reviews for an application
Args:
packageName (str): app unique ID.
filterByDevice (bool): filter results for current device
sort (int): sorting crite... |
Download an already purchased app. | def delivery(self, packageName, versionCode=None, offerType=1,
downloadToken=None, expansion_files=False):
"""Download an already purchased app.
Args:
packageName (str): app unique ID (usually starting with 'com.')
versionCode (int): version to download
... |
Download an app and return its raw data ( APK file ). Free apps need to be purchased first in order to retrieve the download cookie. If you want to download an already purchased app use * delivery * method. | def download(self, packageName, versionCode=None, offerType=1, expansion_files=False):
"""Download an app and return its raw data (APK file). Free apps need
to be "purchased" first, in order to retrieve the download cookie.
If you want to download an already purchased app, use *delivery* method.... |
Decorator function that injects a requests. Session instance into the decorated function s actual parameters if not given. | def http_connection(timeout):
"""
Decorator function that injects a requests.Session instance into
the decorated function's actual parameters if not given.
"""
def wrapper(f):
def wrapped(*args, **kwargs):
if not ('connection' in kwargs) or not kwargs['connection']:
... |
Generates a secure authentication token. | def create_token(self, data, options=None):
"""
Generates a secure authentication token.
Our token format follows the JSON Web Token (JWT) standard:
header.claims.signature
Where:
1) 'header' is a stringified, base64-encoded JSON object containing version and algorithm ... |
Helper function that makes an HTTP GET request to the given firebase endpoint. Timeout is 60 seconds. url: The full URL of the firebase endpoint ( DSN appended. ) params: Python dict that is appended to the URL like a querystring. headers: Python dict. HTTP request headers. connection: Predefined HTTP connection instan... | def make_get_request(url, params, headers, connection):
"""
Helper function that makes an HTTP GET request to the given firebase
endpoint. Timeout is 60 seconds.
`url`: The full URL of the firebase endpoint (DSN appended.)
`params`: Python dict that is appended to the URL like a querystring.
`he... |
Helper function that makes an HTTP PUT request to the given firebase endpoint. Timeout is 60 seconds. url: The full URL of the firebase endpoint ( DSN appended. ) data: JSON serializable dict that will be stored in the remote storage. params: Python dict that is appended to the URL like a querystring. headers: Python d... | def make_put_request(url, data, params, headers, connection):
"""
Helper function that makes an HTTP PUT request to the given firebase
endpoint. Timeout is 60 seconds.
`url`: The full URL of the firebase endpoint (DSN appended.)
`data`: JSON serializable dict that will be stored in the remote storag... |
Helper function that makes an HTTP POST request to the given firebase endpoint. Timeout is 60 seconds. url: The full URL of the firebase endpoint ( DSN appended. ) data: JSON serializable dict that will be stored in the remote storage. params: Python dict that is appended to the URL like a querystring. headers: Python ... | def make_post_request(url, data, params, headers, connection):
"""
Helper function that makes an HTTP POST request to the given firebase
endpoint. Timeout is 60 seconds.
`url`: The full URL of the firebase endpoint (DSN appended.)
`data`: JSON serializable dict that will be stored in the remote stor... |
Helper function that makes an HTTP PATCH request to the given firebase endpoint. Timeout is 60 seconds. url: The full URL of the firebase endpoint ( DSN appended. ) data: JSON serializable dict that will be stored in the remote storage. params: Python dict that is appended to the URL like a querystring. headers: Python... | def make_patch_request(url, data, params, headers, connection):
"""
Helper function that makes an HTTP PATCH request to the given firebase
endpoint. Timeout is 60 seconds.
`url`: The full URL of the firebase endpoint (DSN appended.)
`data`: JSON serializable dict that will be stored in the remote st... |
Helper function that makes an HTTP DELETE request to the given firebase endpoint. Timeout is 60 seconds. url: The full URL of the firebase endpoint ( DSN appended. ) params: Python dict that is appended to the URL like a querystring. headers: Python dict. HTTP request headers. connection: Predefined HTTP connection ins... | def make_delete_request(url, params, headers, connection):
"""
Helper function that makes an HTTP DELETE request to the given firebase
endpoint. Timeout is 60 seconds.
`url`: The full URL of the firebase endpoint (DSN appended.)
`params`: Python dict that is appended to the URL like a querystring.
... |
Method that gets the authenticated user. The returning user has the token email and the provider data. | def get_user(self):
"""
Method that gets the authenticated user. The returning user has
the token, email and the provider data.
"""
token = self.authenticator.create_token(self.extra)
user_id = self.extra.get('id')
return FirebaseUser(self.email, token, self.provi... |
Method that constructs a full url with the given url and the snapshot name. | def _build_endpoint_url(self, url, name=None):
"""
Method that constructs a full url with the given url and the
snapshot name.
Example:
full_url = _build_endpoint_url('/users', '1')
full_url => 'http://firebase.localhost/users/1.json'
"""
if not url.endsw... |
Method that simply adjusts authentication credentials for the request. params is the querystring of the request. headers is the header of the request. | def _authenticate(self, params, headers):
"""
Method that simply adjusts authentication credentials for the
request.
`params` is the querystring of the request.
`headers` is the header of the request.
If auth instance is not provided to this class, this method simply
... |
Synchronous GET request. | def get(self, url, name, params=None, headers=None, connection=None):
"""
Synchronous GET request.
"""
if name is None: name = ''
params = params or {}
headers = headers or {}
endpoint = self._build_endpoint_url(url, name)
self._authenticate(params, header... |
Asynchronous GET request with the process pool. | def get_async(self, url, name, callback=None, params=None, headers=None):
"""
Asynchronous GET request with the process pool.
"""
if name is None: name = ''
params = params or {}
headers = headers or {}
endpoint = self._build_endpoint_url(url, name)
self._... |
Synchronous PUT request. There will be no returning output from the server because the request will be made with silent parameter. data must be a JSONable value. | def put(self, url, name, data, params=None, headers=None, connection=None):
"""
Synchronous PUT request. There will be no returning output from
the server, because the request will be made with ``silent``
parameter. ``data`` must be a JSONable value.
"""
assert name, 'Sna... |
Asynchronous PUT request with the process pool. | def put_async(self, url, name, data, callback=None, params=None, headers=None):
"""
Asynchronous PUT request with the process pool.
"""
if name is None: name = ''
params = params or {}
headers = headers or {}
endpoint = self._build_endpoint_url(url, name)
... |
Synchronous POST request. data must be a JSONable value. | def post(self, url, data, params=None, headers=None, connection=None):
"""
Synchronous POST request. ``data`` must be a JSONable value.
"""
params = params or {}
headers = headers or {}
endpoint = self._build_endpoint_url(url, None)
self._authenticate(params, head... |
Asynchronous POST request with the process pool. | def post_async(self, url, data, callback=None, params=None, headers=None):
"""
Asynchronous POST request with the process pool.
"""
params = params or {}
headers = headers or {}
endpoint = self._build_endpoint_url(url, None)
self._authenticate(params, headers)
... |
Synchronous POST request. data must be a JSONable value. | def patch(self, url, data, params=None, headers=None, connection=None):
"""
Synchronous POST request. ``data`` must be a JSONable value.
"""
params = params or {}
headers = headers or {}
endpoint = self._build_endpoint_url(url, None)
self._authenticate(params, hea... |
Synchronous DELETE request. data must be a JSONable value. | def delete(self, url, name, params=None, headers=None, connection=None):
"""
Synchronous DELETE request. ``data`` must be a JSONable value.
"""
if not name: name = ''
params = params or {}
headers = headers or {}
endpoint = self._build_endpoint_url(url, name)
... |
Asynchronous DELETE request with the process pool. | def delete_async(self, url, name, callback=None, params=None, headers=None):
"""
Asynchronous DELETE request with the process pool.
"""
if not name: name = ''
params = params or {}
headers = headers or {}
endpoint = self._build_endpoint_url(url, name)
self... |
Filter queryset based on keywords. Support for multiple - selected parent values. | def do_filter(qs, keywords, exclude=False):
"""
Filter queryset based on keywords.
Support for multiple-selected parent values.
"""
and_q = Q()
for keyword, value in iteritems(keywords):
try:
values = value.split(",")
if len(values) > 0:
or_q = Q()... |
Returns filtered results followed by excluded results below. | def filterchain_all(request, app, model, field, foreign_key_app_name,
foreign_key_model_name, foreign_key_field_name, value):
"""Returns filtered results followed by excluded results below."""
model_class = get_model(app, model)
keywords = get_keywords(field, value)
# SECURITY: Make... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.