_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q248800
mobilized
train
def mobilized(normal_fn): """ Replace a view function with a normal and mobile view. For example:: def view(): ... @mobilized(view) def view(): ... The second function is the mobile version of view. The original function is overwritten, and the de...
python
{ "resource": "" }
q248801
format_output
train
def format_output(instances, flag): """return formatted string per instance""" out = [] line_format = '{0}\t{1}\t{2}\t{3}' name_len = _get_max_name_len(instances) + 3 if flag: line_format = '{0:<' + str(name_len+5) + '}{1:<16}{2:<65}{3:<16}' for i in instances:
python
{ "resource": "" }
q248802
ls
train
def ls(ctx, list_formatted): """List RDS instances""" session = create_session(ctx.obj['AWS_PROFILE_NAME']) rds = session.client('rds') instances = rds.describe_db_instances()
python
{ "resource": "" }
q248803
ls
train
def ls(ctx, name): """List EMR instances""" session = create_session(ctx.obj['AWS_PROFILE_NAME']) client = session.client('emr') results = client.list_clusters( ClusterStates=['RUNNING', 'STARTING', 'BOOTSTRAPPING', 'WAITING'] )
python
{ "resource": "" }
q248804
ssh
train
def ssh(ctx, cluster_id, key_file): """SSH login to EMR master node""" session = create_session(ctx.obj['AWS_PROFILE_NAME']) client = session.client('emr') result = client.describe_cluster(ClusterId=cluster_id) target_dns = result['Cluster']['MasterPublicDnsName'] ssh_options = '-o StrictHostKe...
python
{ "resource": "" }
q248805
rm
train
def rm(ctx, cluster_id): """Terminate a EMR cluster""" session = create_session(ctx.obj['AWS_PROFILE_NAME']) client = session.client('emr') try: result = client.describe_cluster(ClusterId=cluster_id) target_dns = result['Cluster']['MasterPublicDnsName'] flag = click.prompt( ...
python
{ "resource": "" }
q248806
get_tag_value
train
def get_tag_value(x, key): """Get a value from tag""" if x is None:
python
{ "resource": "" }
q248807
ls
train
def ls(ctx, name, list_formatted): """List EC2 instances""" session = create_session(ctx.obj['AWS_PROFILE_NAME']) ec2 = session.resource('ec2') if name == '*': instances = ec2.instances.filter() else: condition = {'Name': 'tag:Name', 'Values': [name]}
python
{ "resource": "" }
q248808
up
train
def up(ctx, instance_id): """Start EC2 instance""" session = create_session(ctx.obj['AWS_PROFILE_NAME']) ec2 = session.resource('ec2') try: instance = ec2.Instance(instance_id)
python
{ "resource": "" }
q248809
create_ssh_command
train
def create_ssh_command(session, instance_id, instance_name, username, key_file, port, ssh_options, use_private_ip, gateway_instance_id, gateway_username): """Create SSH Login command string""" ec2 = session.resource('ec2') if instance_id is not None: try: instance ...
python
{ "resource": "" }
q248810
ssh
train
def ssh(ctx, instance_id, instance_name, username, key_file, port, ssh_options, private_ip, gateway_instance_id, gateway_username, dry_run): """SSH to EC2 instance""" session = create_session(ctx.obj['AWS_PROFILE_NAME']) if instance_id is None and instance_name is None: click.echo( ...
python
{ "resource": "" }
q248811
ls
train
def ls(ctx, name, list_instances): """List ELB instances""" session = create_session(ctx.obj['AWS_PROFILE_NAME']) client = session.client('elb') inst = {'LoadBalancerDescriptions': []} if name == '*': inst = client.describe_load_balancers() else: try: inst = client.d...
python
{ "resource": "" }
q248812
ls
train
def ls(ctx, name, list_formatted): """List AutoScaling groups""" session = create_session(ctx.obj['AWS_PROFILE_NAME']) client = session.client('autoscaling') if name == "*": groups = client.describe_auto_scaling_groups() else: groups = client.describe_auto_scaling_groups(
python
{ "resource": "" }
q248813
SocialBlueprint.authenticate
train
def authenticate(self, provider): """ Starts OAuth authorization flow, will redirect to 3rd party site. """ callback_url = url_for(".callback", provider=provider, _external=True)
python
{ "resource": "" }
q248814
SocialBlueprint.callback
train
def callback(self, provider): """ Handles 3rd party callback and processes it's data """ provider = self.get_provider(provider) try:
python
{ "resource": "" }
q248815
register
train
def register(model, fields, restrict_to=None, manager=None, properties=None, contexts=None): """Tell vinaigrette which fields on a Django model should be translated. Arguments: model -- The relevant model class fields -- A list or tuple of field names. e.g. ['name', 'nickname'] restrict_to -- Optio...
python
{ "resource": "" }
q248816
get_page_numbers
train
def get_page_numbers(current_page, num_pages): """Default callable for page listing. Produce a Digg-style pagination. """ if current_page <= 2: start_page = 1 else: start_page = current_page - 2 if num_pages <= 4: end_page = num_pages else: end_page = start_...
python
{ "resource": "" }
q248817
_get_po_paths
train
def _get_po_paths(locales=[]): """Returns paths to all relevant po files in the current project.""" basedirs = [os.path.join('conf', 'locale'), 'locale'] if os.environ.get('DJANGO_SETTINGS_MODULE'): from django.conf import settings basedirs.extend(settings.LOCALE_PATHS) # Gather existin...
python
{ "resource": "" }
q248818
show_pageitems
train
def show_pageitems(_, token): """Show page items. Usage: .. code-block:: html+django {% show_pageitems per_page %} """ # Validate args. if len(token.contents.split()) != 1:
python
{ "resource": "" }
q248819
user_error
train
def user_error(status_code, title, detail, pointer): """Create and return a general user error response that is jsonapi compliant. Required args: status_code: The HTTP status code associated with the problem. title: A short summary of the problem. detail: An explanation specific to the ...
python
{ "resource": "" }
q248820
override
train
def override(original, results): """ If a receiver to a signal returns a value, we override the original value with the last returned value.
python
{ "resource": "" }
q248821
JSONAPIEncoder.default
train
def default(self, value): """ Handle UUID, datetime, and callables. :param value: Value to encode """ if isinstance(value, uuid.UUID): return str(value) elif isinstance(value, datetime.datetime):
python
{ "resource": "" }
q248822
FlaskJSONAPI.init_app
train
def init_app(self, app, sqla, namespace='api', route_prefix='/api'): """ Initialize the adapter if it hasn't already been initialized. :param app: Flask application :param sqla: Flask-SQLAlchemy instance :param namespace: Prefixes all generated routes :param route_prefix...
python
{ "resource": "" }
q248823
FlaskJSONAPI.wrap_handler
train
def wrap_handler(self, api_types, methods, endpoints): """ Allow for a handler to be wrapped in a chain. :param api_types: Types to wrap handlers for :param methods: Methods to wrap handlers for :param endpoints: Endpoints to wrap handlers for """ def wrapper(fn...
python
{ "resource": "" }
q248824
FlaskJSONAPI._call_next
train
def _call_next(self, handler_chain): """ Generates an express-like chain for handling requests. :param handler_chain: The current chain of handlers """ def wrapped(*args, **kwargs): if len(handler_chain) == 1: return handler_chain[0](*args, **kwargs)
python
{ "resource": "" }
q248825
FlaskJSONAPI._setup_adapter
train
def _setup_adapter(self, namespace, route_prefix): """ Initialize the serializer and loop through the views to generate them. :param namespace: Prefix for generated endpoints :param route_prefix: Prefix for route patterns """ self.serializer = JSONAPI( self.s...
python
{ "resource": "" }
q248826
FlaskJSONAPI._generate_view
train
def _generate_view(self, method, endpoint): """ Generate a view for the specified method and endpoint. :param method: HTTP Method :param endpoint: Pattern """ def new_view(**kwargs): if method == Method.GET: data = request.args el...
python
{ "resource": "" }
q248827
JSONAPISerializer._render_resource
train
def _render_resource(self, resource): """Renders a resource's top level members based on json-api spec. Top level members include: 'id', 'type', 'attributes', 'relationships' """ if not resource: return None # Must not render a resource that has same name...
python
{ "resource": "" }
q248828
JSONAPISerializer._render_attributes
train
def _render_attributes(self, resource): """Render the resources's attributes.""" attributes = {} attrs_to_ignore = set() for key, relationship in resource.__mapper__.relationships.items(): attrs_to_ignore.update(set( [column.name for column in relationship.lo...
python
{ "resource": "" }
q248829
JSONAPISerializer._render_relationships
train
def _render_relationships(self, resource): """Render the resource's relationships.""" relationships = {} related_models = resource.__mapper__.relationships.keys() primary_key_val = getattr(resource, self.primary_key) if self.dasherize: mapped_relationships = { ...
python
{ "resource": "" }
q248830
attr_descriptor
train
def attr_descriptor(action, *names): """ Wrap a function that allows for getting or setting of an attribute. This allows for specific handling of an attribute when it comes to serializing and deserializing. :param action: The AttributeActions that this descriptor performs :param names: A list ...
python
{ "resource": "" }
q248831
relationship_descriptor
train
def relationship_descriptor(action, *names): """ Wrap a function for modification of a relationship. This allows for specific handling for serialization and deserialization. :param action: The RelationshipActions that this descriptor performs :param names: A list of names of the relationships this...
python
{ "resource": "" }
q248832
check_permission
train
def check_permission(instance, field, permission): """ Check a permission for a given instance or field. Raises an error if denied. :param instance: The instance to check :param field: The field name to check or None for instance :param permission: The permission to check """ if
python
{ "resource": "" }
q248833
get_attr_desc
train
def get_attr_desc(instance, attribute, action): """ Fetch the appropriate descriptor for the attribute. :param instance: Model instance :param attribute: Name of the attribute :param action: AttributeAction """ descs = instance.__jsonapi_attribute_descriptors__.get(attribute, {}) if act...
python
{ "resource": "" }
q248834
get_rel_desc
train
def get_rel_desc(instance, key, action): """ Fetch the appropriate descriptor for the relationship. :param instance: Model instance :param key: Name of the relationship :param action: RelationshipAction """ descs = instance.__jsonapi_rel_desc__.get(key, {}) if action == RelationshipActi...
python
{ "resource": "" }
q248835
JSONAPI._check_json_data
train
def _check_json_data(self, json_data): """ Ensure that the request body is both a hash and has a data key. :param json_data: The json data provided with the request """ if not isinstance(json_data, dict):
python
{ "resource": "" }
q248836
JSONAPI._fetch_resource
train
def _fetch_resource(self, session, api_type, obj_id, permission): """ Fetch a resource by type and id, also doing a permission check. :param session: SQLAlchemy session :param api_type: The type :param obj_id: ID for the resource :param permission: Permission to check ...
python
{ "resource": "" }
q248837
JSONAPI._render_short_instance
train
def _render_short_instance(self, instance): """ For those very short versions of resources, we have this. :param instance: The instance to render
python
{ "resource": "" }
q248838
JSONAPI._check_instance_relationships_for_delete
train
def _check_instance_relationships_for_delete(self, instance): """ Ensure we are authorized to delete this and all cascaded resources. :param instance: The instance to check the relationships of. """ check_permission(instance, None, Permissions.DELETE) for rel_key, rel in...
python
{ "resource": "" }
q248839
JSONAPI._parse_fields
train
def _parse_fields(self, query): """ Parse the querystring args for fields. :param query: Dict of query args """ field_args = { k: v for k, v in query.items() if k.startswith('fields[')
python
{ "resource": "" }
q248840
JSONAPI._parse_include
train
def _parse_include(self, include): """ Parse the querystring args or parent includes for includes. :param include: Dict of query args or includes """ ret = {} for item in include: if '.' in item: local, remote = item.split('.', 1) ...
python
{ "resource": "" }
q248841
JSONAPI._parse_page
train
def _parse_page(self, query): """ Parse the querystring args for pagination. :param query: Dict of query args """ args = {k[5:-1]: v for k, v in query.items() if k.startswith('page[')} if {'number', 'size'} == set(args.keys()): if not args['number'].isdecima...
python
{ "resource": "" }
q248842
JSONAPI.delete_relationship
train
def delete_relationship(self, session, data, api_type, obj_id, rel_key): """ Delete a resource or multiple resources from a to-many relationship. :param session: SQLAlchemy session :param data: JSON data provided with the request :param api_type: Type of the resource :pa...
python
{ "resource": "" }
q248843
JSONAPI.get_collection
train
def get_collection(self, session, query, api_key): """ Fetch a collection of resources of a specified type. :param session: SQLAlchemy session :param query: Dict of query args :param api_type: The type of the model """ model = self._fetch_model(api_key) i...
python
{ "resource": "" }
q248844
JSONAPI.get_relationship
train
def get_relationship(self, session, query, api_type, obj_id, rel_key): """ Fetch a collection of related resource types and ids. :param session: SQLAlchemy session :param query: Dict of query args :param api_type: Type of the resource :param obj_id: ID of the resource ...
python
{ "resource": "" }
q248845
JSONAPI.patch_relationship
train
def patch_relationship(self, session, json_data, api_type, obj_id, rel_key): """ Replacement of relationship values. :param session: SQLAlchemy session :param json_data: Request JSON Data :param api_type: Type of the resource :param obj_id: ID ...
python
{ "resource": "" }
q248846
JSONAPI.post_relationship
train
def post_relationship(self, session, json_data, api_type, obj_id, rel_key): """ Append to a relationship. :param session: SQLAlchemy session :param json_data: Request JSON Data :param api_type: Type of the resource :param obj_id: ID of the resource :param rel_key...
python
{ "resource": "" }
q248847
map_event_code
train
def map_event_code(event_code): """Map a specific event_code to an event group.""" event_code = int(event_code) # Honestly, these are just guessing based on the below event list. # It could be wrong, I have no idea. if 1100 <= event_code <= 1199: return ALARM_GROUP elif 3100 <= event_c...
python
{ "resource": "" }
q248848
AbodeAutomation.set_active
train
def set_active(self, active): """Activate and deactivate an automation.""" url = CONST.AUTOMATION_EDIT_URL url = url.replace( '$AUTOMATIONID$', self.automation_id) self._automation['is_active'] = str(int(active)) response = self._abode.send_request( meth...
python
{ "resource": "" }
q248849
AbodeAutomation.trigger
train
def trigger(self, only_manual=True): """Trigger a quick-action automation.""" if not self.is_quick_action and only_manual: raise AbodeException((ERROR.TRIGGER_NON_QUICKACTION)) url = CONST.AUTOMATION_APPLY_URL url = url.replace( '$AUTOMATIONID$',
python
{ "resource": "" }
q248850
AbodeAutomation.refresh
train
def refresh(self): """Refresh the automation.""" url = CONST.AUTOMATION_ID_URL url = url.replace( '$AUTOMATIONID$', self.automation_id) response = self._abode.send_request(method="get", url=url) response_object = json.loads(response.text) if isinstance(respo...
python
{ "resource": "" }
q248851
AbodeAutomation.update
train
def update(self, automation): """Update the internal automation json.""" self._automation.update(
python
{ "resource": "" }
q248852
AbodeAutomation.desc
train
def desc(self): """Get a short description of the automation.""" # Auto Away (1) - Location - Enabled active = 'inactive' if self.is_active: active = 'active'
python
{ "resource": "" }
q248853
AbodeSensor._get_numeric_status
train
def _get_numeric_status(self, key): """Extract the numeric value from the statuses object.""" value = self._get_status(key) if value and any(i.isdigit()
python
{ "resource": "" }
q248854
AbodeSensor.temp_unit
train
def temp_unit(self): """Get unit of temp.""" if CONST.UNIT_FAHRENHEIT in self._get_status(CONST.TEMP_STATUS_KEY): return CONST.UNIT_FAHRENHEIT
python
{ "resource": "" }
q248855
AbodeSensor.humidity_unit
train
def humidity_unit(self): """Get unit of humidity.""" if CONST.UNIT_PERCENT in self._get_status(CONST.HUMI_STATUS_KEY):
python
{ "resource": "" }
q248856
AbodeSensor.lux_unit
train
def lux_unit(self): """Get unit of lux.""" if CONST.UNIT_LUX
python
{ "resource": "" }
q248857
AbodeValve.switch_on
train
def switch_on(self): """Open the valve.""" success = self.set_status(CONST.STATUS_ON_INT) if success:
python
{ "resource": "" }
q248858
AbodeValve.switch_off
train
def switch_off(self): """Close the valve.""" success = self.set_status(CONST.STATUS_OFF_INT) if success:
python
{ "resource": "" }
q248859
SocketIO.set_origin
train
def set_origin(self, origin=None): """Set the Origin header.""" if origin:
python
{ "resource": "" }
q248860
SocketIO.set_cookie
train
def set_cookie(self, cookie=None): """Set the Cookie header.""" if cookie:
python
{ "resource": "" }
q248861
SocketIO.on
train
def on(self, event_name, callback): """Register callback for a SocketIO event.""" if not event_name: return False
python
{ "resource": "" }
q248862
SocketIO.start
train
def start(self): """Start a thread to handle SocketIO notifications.""" if not self._thread: _LOGGER.info("Starting SocketIO thread...") self._thread = threading.Thread(target=self._run_socketio_thread,
python
{ "resource": "" }
q248863
SocketIO.stop
train
def stop(self): """Tell the SocketIO thread to terminate.""" if self._thread: _LOGGER.info("Stopping SocketIO thread...") # pylint: disable=W0212 self._running = False
python
{ "resource": "" }
q248864
AbodeEventController.add_device_callback
train
def add_device_callback(self, devices, callback): """Register a device callback.""" if not devices: return False if not isinstance(devices, (tuple, list)): devices = [devices] for device in devices: # Device may be a device_id device_id =...
python
{ "resource": "" }
q248865
AbodeEventController.add_event_callback
train
def add_event_callback(self, event_groups, callback): """Register callback for a group of timeline events.""" if not event_groups: return False if not isinstance(event_groups, (tuple, list)): event_groups = [event_groups] for event_group in event_groups: ...
python
{ "resource": "" }
q248866
AbodeEventController.add_timeline_callback
train
def add_timeline_callback(self, timeline_events, callback): """Register a callback for a specific timeline event.""" if not timeline_events: return False if not isinstance(timeline_events, (tuple, list)): timeline_events = [timeline_events] for timeline_event in...
python
{ "resource": "" }
q248867
AbodeEventController._on_socket_started
train
def _on_socket_started(self): """Socket IO startup callback.""" # pylint: disable=W0212 cookies = self._abode._get_session().cookies.get_dict() cookie_string = "; ".join(
python
{ "resource": "" }
q248868
AbodeEventController._on_device_update
train
def _on_device_update(self, devid): """Device callback from Abode SocketIO server.""" if isinstance(devid, (tuple, list)): devid = devid[0] if devid is None: _LOGGER.warning("Device update with no device id.")
python
{ "resource": "" }
q248869
AbodeEventController._on_mode_change
train
def _on_mode_change(self, mode): """Mode change broadcast from Abode SocketIO server.""" if isinstance(mode, (tuple, list)): mode = mode[0] if mode is None: _LOGGER.warning("Mode change event with no mode.") return if not mode or mode.lower() not in ...
python
{ "resource": "" }
q248870
AbodeEventController._on_timeline_update
train
def _on_timeline_update(self, event): """Timeline update broadcast from Abode SocketIO server.""" if isinstance(event, (tuple, list)): event = event[0] event_type = event.get('event_type') event_code = event.get('event_code') if not event_type or not event_code: ...
python
{ "resource": "" }
q248871
AbodeEventController._on_automation_update
train
def _on_automation_update(self, event): """Automation update broadcast from Abode SocketIO server.""" event_group = TIMELINE.AUTOMATION_EDIT_GROUP if isinstance(event, (tuple, list)): event = event[0]
python
{ "resource": "" }
q248872
Abode.login
train
def login(self, username=None, password=None): """Explicit Abode login.""" if username is not None: self._cache[CONST.ID] = username if password is not None: self._cache[CONST.PASSWORD] = password if (self._cache[CONST.ID] is None or not isinstanc...
python
{ "resource": "" }
q248873
Abode.logout
train
def logout(self): """Explicit Abode logout.""" if self._token: header_data = { 'ABODE-API-KEY': self._token } self._session = requests.session() self._token = None self._panel = None self._user = None se...
python
{ "resource": "" }
q248874
Abode.refresh
train
def refresh(self): """Do a full refresh of all devices and automations."""
python
{ "resource": "" }
q248875
Abode.get_device
train
def get_device(self, device_id, refresh=False): """Get a single device.""" if self._devices is None:
python
{ "resource": "" }
q248876
Abode.get_automations
train
def get_automations(self, refresh=False, generic_type=None): """Get all automations.""" if refresh or self._automations is None: if self._automations is None: # Set up the device libraries self._automations = {} _LOGGER.info("Updating all automati...
python
{ "resource": "" }
q248877
Abode.get_automation
train
def get_automation(self, automation_id, refresh=False): """Get a single automation.""" if self._automations is None: self.get_automations() refresh = False
python
{ "resource": "" }
q248878
Abode.get_alarm
train
def get_alarm(self, area='1', refresh=False): """Shortcut method to get the alarm device."""
python
{ "resource": "" }
q248879
Abode.set_default_mode
train
def set_default_mode(self, default_mode): """Set the default mode when alarms are turned 'on'.""" if default_mode.lower() not
python
{ "resource": "" }
q248880
Abode.set_setting
train
def set_setting(self, setting, value, area='1', validate_value=True): """Set an abode system setting to a given value.""" setting = setting.lower() if setting not in CONST.ALL_SETTINGS: raise AbodeException(ERROR.INVALID_SETTING, CONST.ALL_SETTINGS) if setting in CONST.PANE...
python
{ "resource": "" }
q248881
Abode._panel_settings
train
def _panel_settings(setting, value, validate_value): """Will validate panel settings and values, returns data packet.""" if validate_value: if (setting == CONST.SETTING_CAMERA_RESOLUTION and value not in CONST.SETTING_ALL_CAMERA_RES): raise AbodeException(...
python
{ "resource": "" }
q248882
Abode._area_settings
train
def _area_settings(area, setting, value, validate_value): """Will validate area settings and values, returns data packet.""" if validate_value: # Exit delay has some specific limitations apparently if (setting == CONST.SETTING_EXIT_DELAY_AWAY and value not in ...
python
{ "resource": "" }
q248883
Abode._sound_settings
train
def _sound_settings(area, setting, value, validate_value): """Will validate sound settings and values, returns data packet.""" if validate_value: if (setting in CONST.VALID_SOUND_SETTINGS and value not in CONST.ALL_SETTING_SOUND): raise AbodeException(ERRO...
python
{ "resource": "" }
q248884
Abode._siren_settings
train
def _siren_settings(setting, value, validate_value): """Will validate siren settings and values, returns data packet.""" if validate_value:
python
{ "resource": "" }
q248885
Abode.send_request
train
def send_request(self, method, url, headers=None, data=None, is_retry=False): """Send requests to Abode.""" if not self._token: self.login() if not headers: headers = {} headers['Authorization'] = 'Bearer ' + self._oauth_token header...
python
{ "resource": "" }
q248886
Abode._save_cache
train
def _save_cache(self): """Trigger a cache save.""" if not self._disable_cache:
python
{ "resource": "" }
q248887
get_generic_type
train
def get_generic_type(type_tag): """Map type tag to generic type.""" return { # Alarm DEVICE_ALARM: TYPE_ALARM, # Binary Sensors - Connectivity DEVICE_GLASS_BREAK: TYPE_CONNECTIVITY, DEVICE_KEYPAD: TYPE_CONNECTIVITY, DEVICE_REMOTE_CONTROLLER: TYPE_CONNECTIVITY, ...
python
{ "resource": "" }
q248888
AbodeLock.lock
train
def lock(self): """Lock the device.""" success = self.set_status(CONST.STATUS_LOCKCLOSED_INT) if success:
python
{ "resource": "" }
q248889
AbodeLock.unlock
train
def unlock(self): """Unlock the device.""" success = self.set_status(CONST.STATUS_LOCKOPEN_INT) if success:
python
{ "resource": "" }
q248890
AbodeDevice.set_status
train
def set_status(self, status): """Set device status.""" if self._json_state['control_url']: url = CONST.BASE_URL + self._json_state['control_url'] status_data = { 'status': str(status) } response = self._abode.send_request( ...
python
{ "resource": "" }
q248891
AbodeDevice.set_level
train
def set_level(self, level): """Set device level.""" if self._json_state['control_url']: url = CONST.BASE_URL + self._json_state['control_url'] level_data = { 'level': str(level) } response = self._abode.send_request( "put"...
python
{ "resource": "" }
q248892
AbodeDevice._update_name
train
def _update_name(self): """Set the device name from _json_state, with a sensible default.""" self._name = self._json_state.get('name')
python
{ "resource": "" }
q248893
AbodeLight.set_color_temp
train
def set_color_temp(self, color_temp): """Set device color.""" if self._json_state['control_url']: url = CONST.INTEGRATIONS_URL + self._device_uuid color_data = { 'action': 'setcolortemperature', 'colorTemperature': int(color_temp) } ...
python
{ "resource": "" }
q248894
AbodeLight.color
train
def color(self): """Get light color.""" return (self.get_value(CONST.STATUSES_KEY).get('hue'),
python
{ "resource": "" }
q248895
AbodeLight.has_color
train
def has_color(self): """Device is using color mode.""" if (self.get_value(CONST.STATUSES_KEY).get('color_mode')
python
{ "resource": "" }
q248896
AbodeCamera.capture
train
def capture(self): """Request a new camera image.""" url = str.replace(CONST.CAMS_ID_CAPTURE_URL, '$DEVID$', self.device_id) try: response = self._abode.send_request("put", url) _LOGGER.debug("Capture image response: %s", response.text)
python
{ "resource": "" }
q248897
AbodeCamera.refresh_image
train
def refresh_image(self): """Get the most recent camera image.""" url = str.replace(CONST.TIMELINE_IMAGES_ID_URL, '$DEVID$', self.device_id) response =
python
{ "resource": "" }
q248898
AbodeCamera.update_image_location
train
def update_image_location(self, timeline_json): """Update the image location.""" if not timeline_json: return False # If we get a list of objects back (likely) # then we just want the first one as it should be the "newest" if isinstance(timeline_json, (tuple, list)):...
python
{ "resource": "" }
q248899
AbodeCamera.image_to_file
train
def image_to_file(self, path, get_image=True): """Write the image to a file.""" if not self.image_url or get_image: if not self.refresh_image(): return False response = requests.get(self.image_url, stream=True)
python
{ "resource": "" }