idx int64 0 252k | question stringlengths 48 5.28k | target stringlengths 5 1.23k |
|---|---|---|
8,600 | def refresh ( self ) : client = self . _get_client ( ) endpoint = self . _endpoint . format ( resource_id = self . resource_id or "" , parent_id = self . parent_id or "" , grandparent_id = self . grandparent_id or "" ) response = client . get_resource ( endpoint ) self . _reset_model ( response ) | Get the latest representation of the current model . |
8,601 | def commit ( self , if_match = None , wait = True , timeout = None ) : if not self . _changes : LOG . debug ( "No changes available for %s: %s" , self . __class__ . __name__ , self . resource_id ) return LOG . debug ( "Apply all the changes on the current %s: %s" , self . __class__ . __name__ , self . resource_id ) cli... | Apply all the changes on the current model . |
8,602 | def _set_fields ( self , fields ) : super ( _BaseHNVModel , self ) . _set_fields ( fields ) if not self . resource_ref : endpoint = self . _endpoint . format ( resource_id = self . resource_id , parent_id = self . parent_id , grandparent_id = self . grandparent_id ) self . resource_ref = re . sub ( "(/networking/v[0-9]... | Set or update the fields value . |
8,603 | def get_resource ( self ) : references = { "resource_id" : None , "parent_id" : None , "grandparent_id" : None } for model_cls , regexp in self . _regexp . iteritems ( ) : match = regexp . search ( self . resource_ref ) if match is not None : references . update ( match . groupdict ( ) ) return model_cls . get ( ** ref... | Return the associated resource . |
8,604 | def _get_nr_bins ( count ) : if count <= 30 : k = np . ceil ( np . sqrt ( count ) ) else : k = np . ceil ( np . log2 ( count ) ) + 1 return int ( k ) | depending on the number of data points compute a best guess for an optimal number of bins |
8,605 | def plot_histograms ( ertobj , keys , ** kwargs ) : if isinstance ( ertobj , pd . DataFrame ) : df = ertobj else : df = ertobj . data if df . shape [ 0 ] == 0 : raise Exception ( 'No data present, cannot plot' ) if isinstance ( keys , str ) : keys = [ keys , ] figures = { } merge_figs = kwargs . get ( 'merge' , True ) ... | Generate histograms for one or more keys in the given container . |
8,606 | def plot_histograms_extra_dims ( dataobj , keys , ** kwargs ) : if isinstance ( dataobj , pd . DataFrame ) : df_raw = dataobj else : df_raw = dataobj . data if kwargs . get ( 'subquery' , False ) : df = df_raw . query ( kwargs . get ( 'subquery' ) ) else : df = df_raw split_timestamps = True if split_timestamps : group... | Produce histograms grouped by the extra dimensions . |
8,607 | def parse_substring ( allele , pred , max_len = None ) : result = "" pos = 0 if max_len is None : max_len = len ( allele ) else : max_len = min ( max_len , len ( allele ) ) while pos < max_len and pred ( allele [ pos ] ) : result += allele [ pos ] pos += 1 return result , allele [ pos : ] | Extract substring of letters for which predicate is True |
8,608 | def fetch ( self ) : if not self . local_path : self . make_local_path ( ) fetcher = BookFetcher ( self ) fetcher . fetch ( ) | just pull files from PG |
8,609 | def make ( self ) : logger . debug ( "preparing to add all git files" ) num_added = self . local_repo . add_all_files ( ) if num_added : self . local_repo . commit ( "Initial import from Project Gutenberg" ) file_handler = NewFilesHandler ( self ) file_handler . add_new_files ( ) num_added = self . local_repo . add_all... | turn fetched files into a local repo make auxiliary files |
8,610 | def push ( self ) : self . github_repo . create_and_push ( ) self . _repo = self . github_repo . repo return self . _repo | create a github repo and push the local repo into it |
8,611 | def tag ( self , version = 'bump' , message = '' ) : self . clone_from_github ( ) self . github_repo . tag ( version , message = message ) | tag and commit |
8,612 | def format_title ( self ) : def asciify ( _title ) : _title = unicodedata . normalize ( 'NFD' , unicode ( _title ) ) ascii = True out = [ ] ok = u"1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- '," for ch in _title : if ch in ok : out . append ( ch ) elif unicodedata . category ( ch ) [ 0 ] == ( "L" ) ... | Takes a string and sanitizes it for Github s url name format |
8,613 | def _request ( self , path , method , body = None ) : url = '/' . join ( [ _SERVER , path ] ) ( resp , content ) = _HTTP . request ( url , method , headers = self . _headers , body = body ) content_type = resp . get ( 'content-type' ) if content_type and content_type . startswith ( 'application/json' ) : content = json... | Make a request from the API . |
8,614 | def put ( self , path , payload ) : body = json . dumps ( payload ) return self . _request ( path , 'PUT' , body ) | Make a PUT request from the API . |
8,615 | def post ( self , path , payload ) : body = json . dumps ( payload ) return self . _request ( path , 'POST' , body ) | Make a POST request from the API . |
8,616 | def create_child ( self , modules ) : binder = self . _binder . create_child ( ) return Injector ( modules , binder = binder , stage = self . _stage ) | Create a new injector that inherits the state from this injector . |
8,617 | def validate ( self , message , schema_name ) : err = None try : jsonschema . validate ( message , self . schemas [ schema_name ] ) except KeyError : msg = ( f'Schema "{schema_name}" was not found (available: ' f'{", ".join(self.schemas.keys())})' ) err = { 'msg' : msg } except jsonschema . ValidationError as e : msg =... | Validate a message given a schema . |
8,618 | def compose ( * functions ) : def inner ( func1 , func2 ) : return lambda * x , ** y : func1 ( func2 ( * x , ** y ) ) return functools . reduce ( inner , functions ) | evaluates functions from right to left . |
8,619 | def validate_instance ( instance ) : excludes = settings . AUTOMATED_LOGGING [ 'exclude' ] [ 'model' ] for excluded in excludes : if ( excluded in [ instance . _meta . app_label . lower ( ) , instance . __class__ . __name__ . lower ( ) ] or instance . __module__ . lower ( ) . startswith ( excluded ) ) : return False re... | Validating if the instance should be logged or is excluded |
8,620 | def get_current_user ( ) : thread_local = AutomatedLoggingMiddleware . thread_local if hasattr ( thread_local , 'current_user' ) : user = thread_local . current_user if isinstance ( user , AnonymousUser ) : user = None else : user = None return user | Get current user object from middleware |
8,621 | def get_current_environ ( ) : thread_local = AutomatedLoggingMiddleware . thread_local if hasattr ( thread_local , 'request_uri' ) : request_uri = thread_local . request_uri else : request_uri = None if hasattr ( thread_local , 'application' ) : application = thread_local . application application = Application . objec... | Get current application and path object from middleware |
8,622 | def processor ( status , sender , instance , updated = None , addition = '' ) : logger = logging . getLogger ( __name__ ) if validate_instance ( instance ) : user = get_current_user ( ) application = instance . _meta . app_label model_name = instance . __class__ . __name__ level = settings . AUTOMATED_LOGGING [ 'loglev... | This is the standard logging processor . |
8,623 | def parents ( self ) : parents = [ ] if self . parent is None : return [ ] category = self while category . parent is not None : parents . append ( category . parent ) category = category . parent return parents [ : : - 1 ] | Returns a list of all the current category s parents . |
8,624 | def root_parent ( self , category = None ) : return next ( filter ( lambda c : c . is_root , self . hierarchy ( ) ) ) | Returns the topmost parent of the current category . |
8,625 | def active ( self ) -> bool : states = self . _client . get_state ( self . _state_url ) [ 'states' ] for state in states : state = state [ 'State' ] if int ( state [ 'Id' ] ) == self . _state_id : return state [ 'IsActive' ] == "1" return False | Indicate if this RunState is currently active . |
8,626 | def to_reasonable_unit ( value , units , round_digits = 2 ) : def to_unit ( unit ) : return float ( value ) / unit [ 1 ] exponents = [ abs ( Decimal ( to_unit ( u ) ) . adjusted ( ) - 1 ) for u in units ] best = min ( enumerate ( exponents ) , key = itemgetter ( 1 ) ) [ 0 ] return dict ( val = round ( to_unit ( units [... | Convert a value to the most reasonable unit . |
8,627 | def get_text ( self ) : done_units = to_reasonable_unit ( self . done , self . units ) current = round ( self . current / done_units [ 'multiplier' ] , 2 ) percent = int ( self . current * 100 / self . done ) return '{0:.2f} of {1:.2f} {2} ({3}%)' . format ( current , done_units [ 'val' ] , done_units [ 'label' ] , per... | Return extended progress bar text |
8,628 | def add_progress ( self , delta , done = None ) : if done is not None : self . done = done self . bar . current = max ( min ( self . done , self . current + delta ) , 0 ) self . rate_display . set_text ( self . rate_text ) self . remaining_time_display . set_text ( self . remaining_time_text ) return self . current == ... | Add to the current progress amount |
8,629 | async def valid_token_set ( self ) : is_valid = False if self . _auth_client . token : now = datetime . datetime . utcnow ( ) skew = datetime . timedelta ( seconds = 60 ) if self . _auth_client . expiry > ( now + skew ) : is_valid = True return is_valid | Check for validity of token and refresh if none or expired . |
8,630 | async def request ( self , method , url , params = None , headers = None , data = None , json = None , token_refresh_attempts = 2 , ** kwargs ) : if all ( [ data , json ] ) : msg = ( '"data" and "json" request parameters can not be used ' 'at the same time' ) logging . warn ( msg ) raise exceptions . GCPHTTPError ( msg... | Make an asynchronous HTTP request . |
8,631 | async def get_json ( self , url , json_callback = None , ** kwargs ) : if not json_callback : json_callback = json . loads response = await self . request ( method = 'get' , url = url , ** kwargs ) return json_callback ( response ) | Get a URL and return its JSON response . |
8,632 | async def get_all ( self , url , params = None ) : if not params : params = { } items = [ ] next_page_token = None while True : if next_page_token : params [ 'pageToken' ] = next_page_token response = await self . get_json ( url , params = params ) items . append ( response ) next_page_token = response . get ( 'nextPag... | Aggregate data from all pages of an API query . |
8,633 | def check_config ( ) : configfile = ConfigFile ( ) global data if data . keys ( ) > 0 : print ( "gitberg config file exists" ) print ( "\twould you like to edit your gitberg config file?" ) else : print ( "No config found" ) print ( "\twould you like to create a gitberg config file?" ) answer = input ( " ) if not answe... | Report if there is an existing config file |
8,634 | async def main ( ) : async with aiohttp . ClientSession ( ) as session : data = Luftdaten ( SENSOR_ID , loop , session ) await data . get_data ( ) if not await data . validate_sensor ( ) : print ( "Station is not available:" , data . sensor_id ) return if data . values and data . meta : print ( "Sensor values:" , data ... | Sample code to retrieve the data . |
8,635 | async def list_instances ( self , project , page_size = 100 , instance_filter = None ) : url = ( f'{self.BASE_URL}{self.api_version}/projects/{project}' '/aggregated/instances' ) params = { 'maxResults' : page_size } if instance_filter : params [ 'filter' ] = instance_filter responses = await self . list_all ( url , pa... | Fetch all instances in a GCE project . |
8,636 | def infer_alpha_chain ( beta ) : if beta . gene . startswith ( "DRB" ) : return AlleleName ( species = "HLA" , gene = "DRA1" , allele_family = "01" , allele_code = "01" ) elif beta . gene . startswith ( "DPB" ) : return AlleleName ( species = "HLA" , gene = "DPA1" , allele_family = "01" , allele_code = "03" ) elif beta... | Given a parsed beta chain of a class II MHC infer the most frequent corresponding alpha chain . |
8,637 | def create_ticket ( subject , tags , ticket_body , requester_email = None , custom_fields = [ ] ) : payload = { 'ticket' : { 'subject' : subject , 'comment' : { 'body' : ticket_body } , 'group_id' : settings . ZENDESK_GROUP_ID , 'tags' : tags , 'custom_fields' : custom_fields } } if requester_email : payload [ 'ticket'... | Create a new Zendesk ticket |
8,638 | def message ( message , title = '' ) : return backend_api . opendialog ( "message" , dict ( message = message , title = title ) ) | Display a message |
8,639 | def ask_file ( message = 'Select file for open.' , default = '' , title = '' , save = False ) : return backend_api . opendialog ( "ask_file" , dict ( message = message , default = default , title = title , save = save ) ) | A dialog to get a file name . The default argument specifies a file path . |
8,640 | def ask_folder ( message = 'Select folder.' , default = '' , title = '' ) : return backend_api . opendialog ( "ask_folder" , dict ( message = message , default = default , title = title ) ) | A dialog to get a directory name . Returns the name of a directory or None if user chose to cancel . If the default argument specifies a directory name and that directory exists then the dialog box will start with that directory . |
8,641 | def ask_ok_cancel ( message = '' , default = 0 , title = '' ) : return backend_api . opendialog ( "ask_ok_cancel" , dict ( message = message , default = default , title = title ) ) | Display a message with choices of OK and Cancel . |
8,642 | def ask_yes_no ( message = '' , default = 0 , title = '' ) : return backend_api . opendialog ( "ask_yes_no" , dict ( message = message , default = default , title = title ) ) | Display a message with choices of Yes and No . |
8,643 | def register ( self , receiver_id , receiver ) : assert receiver_id not in self . receivers self . receivers [ receiver_id ] = receiver ( receiver_id ) | Register a receiver . |
8,644 | def get ( self , sched_rule_id ) : path = '/' . join ( [ 'schedulerule' , sched_rule_id ] ) return self . rachio . get ( path ) | Retrieve the information for a scheduleRule entity . |
8,645 | def parse ( self , message , schema ) : func = { 'audit-log' : self . _parse_audit_log_msg , 'event' : self . _parse_event_msg , } [ schema ] return func ( message ) | Parse message according to schema . |
8,646 | def start ( self , zone_id , duration ) : path = 'zone/start' payload = { 'id' : zone_id , 'duration' : duration } return self . rachio . put ( path , payload ) | Start a zone . |
8,647 | def startMultiple ( self , zones ) : path = 'zone/start_multiple' payload = { 'zones' : zones } return self . rachio . put ( path , payload ) | Start multiple zones . |
8,648 | def get ( self , zone_id ) : path = '/' . join ( [ 'zone' , zone_id ] ) return self . rachio . get ( path ) | Retrieve the information for a zone entity . |
8,649 | def start ( self ) : zones = [ { "id" : data [ 0 ] , "duration" : data [ 1 ] , "sortOrder" : count } for ( count , data ) in enumerate ( self . _zones , 1 ) ] self . _api . startMultiple ( zones ) | Start the schedule . |
8,650 | def clean_translation ( self ) : translation = self . cleaned_data [ 'translation' ] if self . instance and self . instance . content_object : obj = self . instance . content_object field = obj . _meta . get_field ( self . instance . field ) max_length = field . max_length if max_length and len ( translation ) > max_le... | Do not allow translations longer than the max_lenght of the field to be translated . |
8,651 | def _get_merge_rules ( properties , path = None ) : if path is None : path = ( ) for key , value in properties . items ( ) : new_path = path + ( key , ) types = _get_types ( value ) if value . get ( 'omitWhenMerged' ) or value . get ( 'mergeStrategy' ) == 'ocdsOmit' : yield ( new_path , { 'omitWhenMerged' } ) elif 'arr... | Yields merge rules as key - value pairs in which the first element is a JSON path as a tuple and the second element is a list of merge properties whose values are true . |
8,652 | def get_merge_rules ( schema = None ) : schema = schema or get_release_schema_url ( get_tags ( ) [ - 1 ] ) if isinstance ( schema , dict ) : deref_schema = jsonref . JsonRef . replace_refs ( schema ) else : deref_schema = _get_merge_rules_from_url_or_path ( schema ) return dict ( _get_merge_rules ( deref_schema [ 'prop... | Returns merge rules as key - value pairs in which the key is a JSON path as a tuple and the value is a list of merge properties whose values are true . |
8,653 | def unflatten ( processed , merge_rules ) : unflattened = OrderedDict ( ) for key in processed : current_node = unflattened for end , part in enumerate ( key , 1 ) : if isinstance ( part , IdValue ) : for node in current_node : if isinstance ( node , IdDict ) and node . identifier == part . identifier : current_node = ... | Unflattens a processed object into a JSON object . |
8,654 | def merge ( releases , schema = None , merge_rules = None ) : if not merge_rules : merge_rules = get_merge_rules ( schema ) merged = OrderedDict ( { ( 'tag' , ) : [ 'compiled' ] } ) for release in sorted ( releases , key = lambda release : release [ 'date' ] ) : release = release . copy ( ) ocid = release [ 'ocid' ] da... | Merges a list of releases into a compiledRelease . |
8,655 | def merge_versioned ( releases , schema = None , merge_rules = None ) : if not merge_rules : merge_rules = get_merge_rules ( schema ) merged = OrderedDict ( ) for release in sorted ( releases , key = lambda release : release [ 'date' ] ) : release = release . copy ( ) ocid = release . pop ( 'ocid' ) merged [ ( 'ocid' ,... | Merges a list of releases into a versionedRelease . |
8,656 | def chunks ( items , size ) : return [ items [ i : i + size ] for i in range ( 0 , len ( items ) , size ) ] | Split list into chunks of the given size . Original order is preserved . |
8,657 | def login ( self ) : _LOGGER . debug ( "Attempting to login to ZoneMinder" ) login_post = { 'view' : 'console' , 'action' : 'login' } if self . _username : login_post [ 'username' ] = self . _username if self . _password : login_post [ 'password' ] = self . _password req = requests . post ( urljoin ( self . _server_url... | Login to the ZoneMinder API . |
8,658 | def _zm_request ( self , method , api_url , data = None , timeout = DEFAULT_TIMEOUT ) -> dict : try : for _ in range ( ZoneMinder . LOGIN_RETRIES ) : req = requests . request ( method , urljoin ( self . _server_url , api_url ) , data = data , cookies = self . _cookies , timeout = timeout , verify = self . _verify_ssl )... | Perform a request to the ZoneMinder API . |
8,659 | def get_monitors ( self ) -> List [ Monitor ] : raw_monitors = self . _zm_request ( 'get' , ZoneMinder . MONITOR_URL ) if not raw_monitors : _LOGGER . warning ( "Could not fetch monitors from ZoneMinder" ) return [ ] monitors = [ ] for raw_result in raw_monitors [ 'monitors' ] : _LOGGER . debug ( "Initializing camera %... | Get a list of Monitors from the ZoneMinder API . |
8,660 | def get_run_states ( self ) -> List [ RunState ] : raw_states = self . get_state ( 'api/states.json' ) if not raw_states : _LOGGER . warning ( "Could not fetch runstates from ZoneMinder" ) return [ ] run_states = [ ] for i in raw_states [ 'states' ] : raw_state = i [ 'State' ] _LOGGER . info ( "Initializing runstate %s... | Get a list of RunStates from the ZoneMinder API . |
8,661 | def get_active_state ( self ) -> Optional [ str ] : for state in self . get_run_states ( ) : if state . active : return state . name return None | Get the name of the active run state from the ZoneMinder API . |
8,662 | def set_active_state ( self , state_name ) : _LOGGER . info ( 'Setting ZoneMinder run state to state %s' , state_name ) return self . _zm_request ( 'GET' , 'api/states/change/{}.json' . format ( state_name ) , timeout = 120 ) | Set the ZoneMinder run state to the given state name via ZM API . |
8,663 | def is_available ( self ) -> bool : status_response = self . get_state ( 'api/host/daemonCheck.json' ) if not status_response : return False return status_response . get ( 'result' ) == 1 | Indicate if this ZoneMinder service is currently available . |
8,664 | def _build_server_url ( server_host , server_path ) -> str : server_url = urljoin ( server_host , server_path ) if server_url [ - 1 ] == '/' : return server_url return '{}/' . format ( server_url ) | Build the server url making sure it ends in a trailing slash . |
8,665 | def get ( self , flex_sched_rule_id ) : path = '/' . join ( [ 'flexschedulerule' , flex_sched_rule_id ] ) return self . rachio . get ( path ) | Retrieve the information for a flexscheduleRule entity . |
8,666 | def upload_all_books ( book_id_start , book_id_end , rdf_library = None ) : logger . info ( "starting a gitberg mass upload: {0} -> {1}" . format ( book_id_start , book_id_end ) ) for book_id in range ( int ( book_id_start ) , int ( book_id_end ) + 1 ) : cache = { } errors = 0 try : if int ( book_id ) in missing_pgid :... | Uses the fetch make push subcommands to mirror Project Gutenberg to a github3 api |
8,667 | def upload_list ( book_id_list , rdf_library = None ) : with open ( book_id_list , 'r' ) as f : cache = { } for book_id in f : book_id = book_id . strip ( ) try : if int ( book_id ) in missing_pgid : print ( u'missing\t{}' . format ( book_id ) ) continue upload_book ( book_id , rdf_library = rdf_library , cache = cache... | Uses the fetch make push subcommands to add a list of pg books |
8,668 | def translate ( self ) : translations = [ ] for lang in settings . LANGUAGES : if lang [ 0 ] == self . _get_default_language ( ) : continue if self . translatable_slug is not None : if self . translatable_slug not in self . translatable_fields : self . translatable_fields = self . translatable_fields + ( self . transla... | Create all translations objects for this Translatable instance . |
8,669 | def translations_objects ( self , lang ) : return Translation . objects . filter ( object_id = self . id , content_type = ContentType . objects . get_for_model ( self ) , lang = lang ) | Return the complete list of translation objects of a Translatable instance |
8,670 | def translations ( self , lang ) : key = self . _get_translations_cache_key ( lang ) trans_dict = cache . get ( key , { } ) if self . translatable_slug is not None : if self . translatable_slug not in self . translatable_fields : self . translatable_fields = self . translatable_fields + ( self . translatable_slug , ) i... | Return the list of translation strings of a Translatable instance in a dictionary form |
8,671 | def get_translation_obj ( self , lang , field , create = False ) : trans = None try : trans = Translation . objects . get ( object_id = self . id , content_type = ContentType . objects . get_for_model ( self ) , lang = lang , field = field , ) except Translation . DoesNotExist : if create : trans = Translation . object... | Return the translation object of an specific field in a Translatable istance |
8,672 | def get_translation ( self , lang , field ) : key = self . _get_translation_cache_key ( lang , field ) trans = cache . get ( key , '' ) if not trans : trans_obj = self . get_translation_obj ( lang , field ) trans = getattr ( trans_obj , 'translation' , '' ) if not trans : trans = getattr ( self , field , '' ) cache . s... | Return the translation string of an specific field in a Translatable istance |
8,673 | def set_translation ( self , lang , field , text ) : auto_slug_obj = None if lang == self . _get_default_language ( ) : raise CanNotTranslate ( _ ( 'You are not supposed to translate the default language. ' 'Use the model fields for translations in default language' ) ) trans_obj = self . get_translation_obj ( lang , f... | Store a translation string in the specified field for a Translatable istance |
8,674 | def translations_link ( self ) : translation_type = ContentType . objects . get_for_model ( Translation ) link = urlresolvers . reverse ( 'admin:%s_%s_changelist' % ( translation_type . app_label , translation_type . model ) , ) object_type = ContentType . objects . get_for_model ( self ) link += '?content_type__id__ex... | Print on admin change list the link to see all translations for this object |
8,675 | def comparison_callback ( sender , instance , ** kwargs ) : if validate_instance ( instance ) and settings . AUTOMATED_LOGGING [ 'to_database' ] : try : old = sender . objects . get ( pk = instance . pk ) except Exception : return None try : mdl = ContentType . objects . get_for_model ( instance ) cur , ins = old . __d... | Comparing old and new object to determin which fields changed how |
8,676 | def save_callback ( sender , instance , created , update_fields , ** kwargs ) : if validate_instance ( instance ) : status = 'add' if created is True else 'change' change = '' if status == 'change' and 'al_chl' in instance . __dict__ . keys ( ) : changelog = instance . al_chl . modification change = ' to following chan... | Save object & link logging entry |
8,677 | def requires_refcount ( cls , func ) : @ functools . wraps ( func ) def requires_active_handle ( * args , ** kwargs ) : if cls . refcount ( ) == 0 : raise NoHandleException ( ) return func ( * args , ** kwargs ) return requires_active_handle | The requires_refcount decorator adds a check prior to call func to verify that there is an active handle . if there is no such handle a NoHandleException exception is thrown . |
8,678 | def auto ( cls , func ) : @ functools . wraps ( func ) def auto_claim_handle ( * args , ** kwargs ) : with cls ( ) : return func ( * args , ** kwargs ) return auto_claim_handle | The auto decorator wraps func in a context manager so that a handle is obtained . |
8,679 | def get_gpubsub_publisher ( config , metrics , changes_channel , ** kw ) : builder = gpubsub_publisher . GPubsubPublisherBuilder ( config , metrics , changes_channel , ** kw ) return builder . build_publisher ( ) | Get a GPubsubPublisher client . |
8,680 | def get_reconciler ( config , metrics , rrset_channel , changes_channel , ** kw ) : builder = reconciler . GDNSReconcilerBuilder ( config , metrics , rrset_channel , changes_channel , ** kw ) return builder . build_reconciler ( ) | Get a GDNSReconciler client . |
8,681 | def get_authority ( config , metrics , rrset_channel , ** kwargs ) : builder = authority . GCEAuthorityBuilder ( config , metrics , rrset_channel , ** kwargs ) return builder . build_authority ( ) | Get a GCEAuthority client . |
8,682 | async def refresh_token ( self ) : url , headers , body = self . _setup_token_request ( ) request_id = uuid . uuid4 ( ) logging . debug ( _utils . REQ_LOG_FMT . format ( request_id = request_id , method = 'POST' , url = url , kwargs = None ) ) async with self . _session . post ( url , headers = headers , data = body ) ... | Refresh oauth access token attached to this HTTP session . |
8,683 | def get ( self , dev_id ) : path = '/' . join ( [ 'device' , dev_id ] ) return self . rachio . get ( path ) | Retrieve the information for a device entity . |
8,684 | def getEvent ( self , dev_id , starttime , endtime ) : path = 'device/%s/event?startTime=%s&endTime=%s' % ( dev_id , starttime , endtime ) return self . rachio . get ( path ) | Retrieve events for a device entity . |
8,685 | def getForecast ( self , dev_id , units ) : assert units in [ 'US' , 'METRIC' ] , 'units must be either US or METRIC' path = 'device/%s/forecast?units=%s' % ( dev_id , units ) return self . rachio . get ( path ) | Retrieve current and predicted forecast . |
8,686 | def stopWater ( self , dev_id ) : path = 'device/stop_water' payload = { 'id' : dev_id } return self . rachio . put ( path , payload ) | Stop all watering on device . |
8,687 | def rainDelay ( self , dev_id , duration ) : path = 'device/rain_delay' payload = { 'id' : dev_id , 'duration' : duration } return self . rachio . put ( path , payload ) | Rain delay device . |
8,688 | def on ( self , dev_id ) : path = 'device/on' payload = { 'id' : dev_id } return self . rachio . put ( path , payload ) | Turn ON all features of the device . |
8,689 | def off ( self , dev_id ) : path = 'device/off' payload = { 'id' : dev_id } return self . rachio . put ( path , payload ) | Turn OFF all features of the device . |
8,690 | def create_wallet ( self , master_secret = b"" ) : master_secret = deserialize . bytes_str ( master_secret ) bip32node = control . create_wallet ( self . testnet , master_secret = master_secret ) return bip32node . hwif ( as_private = True ) | Create a BIP0032 - style hierarchical wallet . |
8,691 | def create_key ( self , master_secret = b"" ) : master_secret = deserialize . bytes_str ( master_secret ) bip32node = control . create_wallet ( self . testnet , master_secret = master_secret ) return bip32node . wif ( ) | Create new private key and return in wif format . |
8,692 | def confirms ( self , txid ) : txid = deserialize . txid ( txid ) return self . service . confirms ( txid ) | Returns number of confirms or None if unpublished . |
8,693 | def get_time_period ( value ) : for time_period in TimePeriod : if time_period . period == value : return time_period raise ValueError ( '{} is not a valid TimePeriod' . format ( value ) ) | Get the corresponding TimePeriod from the value . |
8,694 | def update_monitor ( self ) : result = self . _client . get_state ( self . _monitor_url ) self . _raw_result = result [ 'monitor' ] | Update the monitor and monitor status from the ZM server . |
8,695 | def function ( self , new_function ) : self . _client . change_state ( self . _monitor_url , { 'Monitor[Function]' : new_function . value } ) | Set the MonitorState of this Monitor . |
8,696 | def is_recording ( self ) -> Optional [ bool ] : status_response = self . _client . get_state ( 'api/monitors/alarm/id:{}/command:status.json' . format ( self . _monitor_id ) ) if not status_response : _LOGGER . warning ( 'Could not get status for monitor {}' . format ( self . _monitor_id ) ) return None status = statu... | Indicate if this Monitor is currently recording . |
8,697 | def is_available ( self ) -> bool : status_response = self . _client . get_state ( 'api/monitors/daemonStatus/id:{}/daemon:zmc.json' . format ( self . _monitor_id ) ) if not status_response : _LOGGER . warning ( 'Could not get availability for monitor {}' . format ( self . _monitor_id ) ) return False monitor_status = ... | Indicate if this Monitor is currently available . |
8,698 | def get_events ( self , time_period , include_archived = False ) -> Optional [ int ] : date_filter = '1%20{}' . format ( time_period . period ) if time_period == TimePeriod . ALL : date_filter = '100%20year' archived_filter = '/Archived=:0' if include_archived : archived_filter = '' event = self . _client . get_state (... | Get the number of events that have occurred on this Monitor . |
8,699 | def _build_image_url ( self , monitor , mode ) -> str : query = urlencode ( { 'mode' : mode , 'buffer' : monitor [ 'StreamReplayBuffer' ] , 'monitor' : monitor [ 'Id' ] , } ) url = '{zms_url}?{query}' . format ( zms_url = self . _client . get_zms_url ( ) , query = query ) _LOGGER . debug ( 'Monitor %s %s URL (without a... | Build and return a ZoneMinder camera image url . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.