idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
26,300 | def wave ( self , wave_first = True , thread_id = None , thread_type = None ) : thread_id , thread_type = self . _getThread ( thread_id , thread_type ) data = self . _getSendData ( thread_id = thread_id , thread_type = thread_type ) data [ "action_type" ] = "ma-type:user-generated-message" data [ "lightweight_action_at... | Says hello with a wave to a thread! |
26,301 | def quickReply ( self , quick_reply , payload = None , thread_id = None , thread_type = None ) : quick_reply . is_response = True if isinstance ( quick_reply , QuickReplyText ) : return self . send ( Message ( text = quick_reply . title , quick_replies = [ quick_reply ] ) ) elif isinstance ( quick_reply , QuickReplyLoc... | Replies to a chosen quick reply |
26,302 | def sendLocation ( self , location , message = None , thread_id = None , thread_type = None ) : self . _sendLocation ( location = location , current = True , message = message , thread_id = thread_id , thread_type = thread_type , ) | Sends a given location to a thread as the user s current location |
26,303 | def sendPinnedLocation ( self , location , message = None , thread_id = None , thread_type = None ) : self . _sendLocation ( location = location , current = False , message = message , thread_id = thread_id , thread_type = thread_type , ) | Sends a given location to a thread as a pinned location |
26,304 | def _upload ( self , files , voice_clip = False ) : file_dict = { "upload_{}" . format ( i ) : f for i , f in enumerate ( files ) } data = { "voice_clip" : voice_clip } j = self . _postFile ( self . req_url . UPLOAD , files = file_dict , query = data , fix_request = True , as_json = True , ) if len ( j [ "payload" ] [ ... | Uploads files to Facebook |
26,305 | def _sendFiles ( self , files , message = None , thread_id = None , thread_type = ThreadType . USER ) : thread_id , thread_type = self . _getThread ( thread_id , thread_type ) data = self . _getSendData ( message = self . _oldMessage ( message ) , thread_id = thread_id , thread_type = thread_type , ) data [ "action_typ... | Sends files from file IDs to a thread |
26,306 | def sendRemoteFiles ( self , file_urls , message = None , thread_id = None , thread_type = ThreadType . USER ) : file_urls = require_list ( file_urls ) files = self . _upload ( get_files_from_urls ( file_urls ) ) return self . _sendFiles ( files = files , message = message , thread_id = thread_id , thread_type = thread... | Sends files from URLs to a thread |
26,307 | def sendLocalFiles ( self , file_paths , message = None , thread_id = None , thread_type = ThreadType . USER ) : file_paths = require_list ( file_paths ) with get_files_from_paths ( file_paths ) as x : files = self . _upload ( x ) return self . _sendFiles ( files = files , message = message , thread_id = thread_id , th... | Sends local files to a thread |
26,308 | def sendRemoteVoiceClips ( self , clip_urls , message = None , thread_id = None , thread_type = ThreadType . USER ) : clip_urls = require_list ( clip_urls ) files = self . _upload ( get_files_from_urls ( clip_urls ) , voice_clip = True ) return self . _sendFiles ( files = files , message = message , thread_id = thread_... | Sends voice clips from URLs to a thread |
26,309 | def sendLocalVoiceClips ( self , clip_paths , message = None , thread_id = None , thread_type = ThreadType . USER ) : clip_paths = require_list ( clip_paths ) with get_files_from_paths ( clip_paths ) as x : files = self . _upload ( x , voice_clip = True ) return self . _sendFiles ( files = files , message = message , t... | Sends local voice clips to a thread |
26,310 | def forwardAttachment ( self , attachment_id , thread_id = None ) : thread_id , thread_type = self . _getThread ( thread_id , None ) data = { "attachment_id" : attachment_id , "recipient_map[{}]" . format ( generateOfflineThreadingID ( ) ) : thread_id , } j = self . _post ( self . req_url . FORWARD_ATTACHMENT , data , ... | Forwards an attachment |
26,311 | def createGroup ( self , message , user_ids ) : data = self . _getSendData ( message = self . _oldMessage ( message ) ) if len ( user_ids ) < 2 : raise FBchatUserError ( "Error when creating group: Not enough participants" ) for i , user_id in enumerate ( user_ids + [ self . _uid ] ) : data [ "specific_to_list[{}]" . f... | Creates a group with the given ids |
26,312 | def addUsersToGroup ( self , user_ids , thread_id = None ) : thread_id , thread_type = self . _getThread ( thread_id , None ) data = self . _getSendData ( thread_id = thread_id , thread_type = ThreadType . GROUP ) data [ "action_type" ] = "ma-type:log-message" data [ "log_message_type" ] = "log:subscribe" user_ids = re... | Adds users to a group . |
26,313 | def removeUserFromGroup ( self , user_id , thread_id = None ) : thread_id , thread_type = self . _getThread ( thread_id , None ) data = { "uid" : user_id , "tid" : thread_id } j = self . _post ( self . req_url . REMOVE_USER , data , fix_request = True , as_json = True ) | Removes users from a group . |
26,314 | def changeGroupApprovalMode ( self , require_admin_approval , thread_id = None ) : thread_id , thread_type = self . _getThread ( thread_id , None ) data = { "set_mode" : int ( require_admin_approval ) , "thread_fbid" : thread_id } j = self . _post ( self . req_url . APPROVAL_MODE , data , fix_request = True , as_json =... | Changes group s approval mode |
26,315 | def _changeGroupImage ( self , image_id , thread_id = None ) : thread_id , thread_type = self . _getThread ( thread_id , None ) data = { "thread_image_id" : image_id , "thread_id" : thread_id } j = self . _post ( self . req_url . THREAD_IMAGE , data , fix_request = True , as_json = True ) return image_id | Changes a thread image from an image id |
26,316 | def changeGroupImageRemote ( self , image_url , thread_id = None ) : ( image_id , mimetype ) , = self . _upload ( get_files_from_urls ( [ image_url ] ) ) return self . _changeGroupImage ( image_id , thread_id ) | Changes a thread image from a URL |
26,317 | def changeGroupImageLocal ( self , image_path , thread_id = None ) : with get_files_from_paths ( [ image_path ] ) as files : ( image_id , mimetype ) , = self . _upload ( files ) return self . _changeGroupImage ( image_id , thread_id ) | Changes a thread image from a local path |
26,318 | def changeThreadTitle ( self , title , thread_id = None , thread_type = ThreadType . USER ) : thread_id , thread_type = self . _getThread ( thread_id , thread_type ) if thread_type == ThreadType . USER : return self . changeNickname ( title , thread_id , thread_id = thread_id , thread_type = thread_type ) data = { "thr... | Changes title of a thread . If this is executed on a user thread this will change the nickname of that user effectively changing the title |
26,319 | def changeNickname ( self , nickname , user_id , thread_id = None , thread_type = ThreadType . USER ) : thread_id , thread_type = self . _getThread ( thread_id , thread_type ) data = { "nickname" : nickname , "participant_id" : user_id , "thread_or_other_fbid" : thread_id , } j = self . _post ( self . req_url . THREAD_... | Changes the nickname of a user in a thread |
26,320 | def reactToMessage ( self , message_id , reaction ) : data = { "action" : "ADD_REACTION" if reaction else "REMOVE_REACTION" , "client_mutation_id" : "1" , "actor_id" : self . _uid , "message_id" : str ( message_id ) , "reaction" : reaction . value if reaction else None , } data = { "doc_id" : 1491398900900362 , "variab... | Reacts to a message or removes reaction |
26,321 | def createPlan ( self , plan , thread_id = None ) : thread_id , thread_type = self . _getThread ( thread_id , None ) data = { "event_type" : "EVENT" , "event_time" : plan . time , "title" : plan . title , "thread_id" : thread_id , "location_id" : plan . location_id or "" , "location_name" : plan . location or "" , "aco... | Sets a plan |
26,322 | def editPlan ( self , plan , new_plan ) : data = { "event_reminder_id" : plan . uid , "delete" : "false" , "date" : new_plan . time , "location_name" : new_plan . location or "" , "location_id" : new_plan . location_id or "" , "title" : new_plan . title , "acontext" : ACONTEXT , } j = self . _post ( self . req_url . PL... | Edits a plan |
26,323 | def deletePlan ( self , plan ) : data = { "event_reminder_id" : plan . uid , "delete" : "true" , "acontext" : ACONTEXT } j = self . _post ( self . req_url . PLAN_CHANGE , data , fix_request = True , as_json = True ) | Deletes a plan |
26,324 | def changePlanParticipation ( self , plan , take_part = True ) : data = { "event_reminder_id" : plan . uid , "guest_state" : "GOING" if take_part else "DECLINED" , "acontext" : ACONTEXT , } j = self . _post ( self . req_url . PLAN_PARTICIPATION , data , fix_request = True , as_json = True ) | Changes participation in a plan |
26,325 | def createPoll ( self , poll , thread_id = None ) : thread_id , thread_type = self . _getThread ( thread_id , None ) data = OrderedDict ( [ ( "question_text" , poll . title ) , ( "target_id" , thread_id ) ] ) for i , option in enumerate ( poll . options ) : data [ "option_text_array[{}]" . format ( i ) ] = option . tex... | Creates poll in a group thread |
26,326 | def updatePollVote ( self , poll_id , option_ids = [ ] , new_options = [ ] ) : data = { "question_id" : poll_id } for i , option_id in enumerate ( option_ids ) : data [ "selected_options[{}]" . format ( i ) ] = option_id for i , option_text in enumerate ( new_options ) : data [ "new_options[{}]" . format ( i ) ] = opti... | Updates a poll vote |
26,327 | def setTypingStatus ( self , status , thread_id = None , thread_type = None ) : thread_id , thread_type = self . _getThread ( thread_id , thread_type ) data = { "typ" : status . value , "thread" : thread_id , "to" : thread_id if thread_type == ThreadType . USER else "" , "source" : "mercury-chat" , } j = self . _post (... | Sets users typing status in a thread |
26,328 | def markAsDelivered ( self , thread_id , message_id ) : data = { "message_ids[0]" : message_id , "thread_ids[%s][0]" % thread_id : message_id , } r = self . _post ( self . req_url . DELIVERED , data ) return r . ok | Mark a message as delivered |
26,329 | def removeFriend ( self , friend_id = None ) : payload = { "friend_id" : friend_id , "unref" : "none" , "confirm" : "Confirm" } r = self . _post ( self . req_url . REMOVE_FRIEND , payload ) query = parse_qs ( urlparse ( r . url ) . query ) if "err" not in query : log . debug ( "Remove was successful!" ) return True els... | Removes a specifed friend from your friend list |
26,330 | def blockUser ( self , user_id ) : data = { "fbid" : user_id } r = self . _post ( self . req_url . BLOCK_USER , data ) return r . ok | Blocks messages from a specifed user |
26,331 | def unblockUser ( self , user_id ) : data = { "fbid" : user_id } r = self . _post ( self . req_url . UNBLOCK_USER , data ) return r . ok | Unblocks messages from a blocked user |
26,332 | def moveThreads ( self , location , thread_ids ) : thread_ids = require_list ( thread_ids ) if location == ThreadLocation . PENDING : location = ThreadLocation . OTHER if location == ThreadLocation . ARCHIVED : data_archive = dict ( ) data_unpin = dict ( ) for thread_id in thread_ids : data_archive [ "ids[{}]" . format... | Moves threads to specifed location |
26,333 | def markAsSpam ( self , thread_id = None ) : thread_id , thread_type = self . _getThread ( thread_id , None ) r = self . _post ( self . req_url . MARK_SPAM , { "id" : thread_id } ) return r . ok | Mark a thread as spam and delete it |
26,334 | def deleteMessages ( self , message_ids ) : message_ids = require_list ( message_ids ) data = dict ( ) for i , message_id in enumerate ( message_ids ) : data [ "message_ids[{}]" . format ( i ) ] = message_id r = self . _post ( self . req_url . DELETE_MESSAGES , data ) return r . ok | Deletes specifed messages |
26,335 | def muteThreadReactions ( self , mute = True , thread_id = None ) : thread_id , thread_type = self . _getThread ( thread_id , None ) data = { "reactions_mute_mode" : int ( mute ) , "thread_fbid" : thread_id } r = self . _post ( self . req_url . MUTE_REACTIONS , data , fix_request = True ) | Mutes thread reactions |
26,336 | def muteThreadMentions ( self , mute = True , thread_id = None ) : thread_id , thread_type = self . _getThread ( thread_id , None ) data = { "mentions_mute_mode" : int ( mute ) , "thread_fbid" : thread_id } r = self . _post ( self . req_url . MUTE_MENTIONS , data , fix_request = True ) | Mutes thread mentions |
26,337 | def _pullMessage ( self ) : data = { "msgs_recv" : 0 , "sticky_token" : self . _sticky , "sticky_pool" : self . _pool , "clientid" : self . _client_id , "state" : "active" if self . _markAlive else "offline" , } return self . _get ( self . req_url . STICKY , data , fix_request = True , as_json = True ) | Call pull api with seq value to get message data . |
26,338 | def _parseMessage ( self , content ) : self . _seq = content . get ( "seq" , "0" ) if "lb_info" in content : self . _sticky = content [ "lb_info" ] [ "sticky" ] self . _pool = content [ "lb_info" ] [ "pool" ] if "batches" in content : for batch in content [ "batches" ] : self . _parseMessage ( batch ) if "ms" not in co... | Get message and author name from content . May contain multiple messages in the content . |
26,339 | def doOneListen ( self , markAlive = None ) : if markAlive is not None : self . _markAlive = markAlive try : if self . _markAlive : self . _ping ( ) content = self . _pullMessage ( ) if content : self . _parseMessage ( content ) except KeyboardInterrupt : return False except requests . Timeout : pass except requests . ... | Does one cycle of the listening loop . This method is useful if you want to control fbchat from an external event loop |
26,340 | def listen ( self , markAlive = None ) : if markAlive is not None : self . setActiveStatus ( markAlive ) self . startListening ( ) self . onListening ( ) while self . listening and self . doOneListen ( ) : pass self . stopListening ( ) | Initializes and runs the listening loop continually |
26,341 | def onMessage ( self , mid = None , author_id = None , message = None , message_object = None , thread_id = None , thread_type = ThreadType . USER , ts = None , metadata = None , msg = None , ) : log . info ( "{} from {} in {}" . format ( message_object , thread_id , thread_type . name ) ) | Called when the client is listening and somebody sends a message |
26,342 | def onColorChange ( self , mid = None , author_id = None , new_color = None , thread_id = None , thread_type = ThreadType . USER , ts = None , metadata = None , msg = None , ) : log . info ( "Color change from {} in {} ({}): {}" . format ( author_id , thread_id , thread_type . name , new_color ) ) | Called when the client is listening and somebody changes a thread s color |
26,343 | def onEmojiChange ( self , mid = None , author_id = None , new_emoji = None , thread_id = None , thread_type = ThreadType . USER , ts = None , metadata = None , msg = None , ) : log . info ( "Emoji change from {} in {} ({}): {}" . format ( author_id , thread_id , thread_type . name , new_emoji ) ) | Called when the client is listening and somebody changes a thread s emoji |
26,344 | def onTitleChange ( self , mid = None , author_id = None , new_title = None , thread_id = None , thread_type = ThreadType . USER , ts = None , metadata = None , msg = None , ) : log . info ( "Title change from {} in {} ({}): {}" . format ( author_id , thread_id , thread_type . name , new_title ) ) | Called when the client is listening and somebody changes the title of a thread |
26,345 | def onImageChange ( self , mid = None , author_id = None , new_image = None , thread_id = None , thread_type = ThreadType . GROUP , ts = None , msg = None , ) : log . info ( "{} changed thread image in {}" . format ( author_id , thread_id ) ) | Called when the client is listening and somebody changes the image of a thread |
26,346 | def onNicknameChange ( self , mid = None , author_id = None , changed_for = None , new_nickname = None , thread_id = None , thread_type = ThreadType . USER , ts = None , metadata = None , msg = None , ) : log . info ( "Nickname change from {} in {} ({}) for {}: {}" . format ( author_id , thread_id , thread_type . name ... | Called when the client is listening and somebody changes the nickname of a person |
26,347 | def onAdminAdded ( self , mid = None , added_id = None , author_id = None , thread_id = None , thread_type = ThreadType . GROUP , ts = None , msg = None , ) : log . info ( "{} added admin: {} in {}" . format ( author_id , added_id , thread_id ) ) | Called when the client is listening and somebody adds an admin to a group thread |
26,348 | def onAdminRemoved ( self , mid = None , removed_id = None , author_id = None , thread_id = None , thread_type = ThreadType . GROUP , ts = None , msg = None , ) : log . info ( "{} removed admin: {} in {}" . format ( author_id , removed_id , thread_id ) ) | Called when the client is listening and somebody removes an admin from a group thread |
26,349 | def onApprovalModeChange ( self , mid = None , approval_mode = None , author_id = None , thread_id = None , thread_type = ThreadType . GROUP , ts = None , msg = None , ) : if approval_mode : log . info ( "{} activated approval mode in {}" . format ( author_id , thread_id ) ) else : log . info ( "{} disabled approval mo... | Called when the client is listening and somebody changes approval mode in a group thread |
26,350 | def onMessageSeen ( self , seen_by = None , thread_id = None , thread_type = ThreadType . USER , seen_ts = None , ts = None , metadata = None , msg = None , ) : log . info ( "Messages seen by {} in {} ({}) at {}s" . format ( seen_by , thread_id , thread_type . name , seen_ts / 1000 ) ) | Called when the client is listening and somebody marks a message as seen |
26,351 | def onMessageDelivered ( self , msg_ids = None , delivered_for = None , thread_id = None , thread_type = ThreadType . USER , ts = None , metadata = None , msg = None , ) : log . info ( "Messages {} delivered to {} in {} ({}) at {}s" . format ( msg_ids , delivered_for , thread_id , thread_type . name , ts / 1000 ) ) | Called when the client is listening and somebody marks messages as delivered |
26,352 | def onMarkedSeen ( self , threads = None , seen_ts = None , ts = None , metadata = None , msg = None ) : log . info ( "Marked messages as seen in threads {} at {}s" . format ( [ ( x [ 0 ] , x [ 1 ] . name ) for x in threads ] , seen_ts / 1000 ) ) | Called when the client is listening and the client has successfully marked threads as seen |
26,353 | def onPeopleAdded ( self , mid = None , added_ids = None , author_id = None , thread_id = None , ts = None , msg = None , ) : log . info ( "{} added: {} in {}" . format ( author_id , ", " . join ( added_ids ) , thread_id ) ) | Called when the client is listening and somebody adds people to a group thread |
26,354 | def onPersonRemoved ( self , mid = None , removed_id = None , author_id = None , thread_id = None , ts = None , msg = None , ) : log . info ( "{} removed: {} in {}" . format ( author_id , removed_id , thread_id ) ) | Called when the client is listening and somebody removes a person from a group thread |
26,355 | def onGamePlayed ( self , mid = None , author_id = None , game_id = None , game_name = None , score = None , leaderboard = None , thread_id = None , thread_type = None , ts = None , metadata = None , msg = None , ) : log . info ( '{} played "{}" in {} ({})' . format ( author_id , game_name , thread_id , thread_type . n... | Called when the client is listening and somebody plays a game |
26,356 | def onReactionAdded ( self , mid = None , reaction = None , author_id = None , thread_id = None , thread_type = None , ts = None , msg = None , ) : log . info ( "{} reacted to message {} with {} in {} ({})" . format ( author_id , mid , reaction . name , thread_id , thread_type . name ) ) | Called when the client is listening and somebody reacts to a message |
26,357 | def onReactionRemoved ( self , mid = None , author_id = None , thread_id = None , thread_type = None , ts = None , msg = None , ) : log . info ( "{} removed reaction from {} message in {} ({})" . format ( author_id , mid , thread_id , thread_type ) ) | Called when the client is listening and somebody removes reaction from a message |
26,358 | def onBlock ( self , author_id = None , thread_id = None , thread_type = None , ts = None , msg = None ) : log . info ( "{} blocked {} ({}) thread" . format ( author_id , thread_id , thread_type . name ) ) | Called when the client is listening and somebody blocks client |
26,359 | def onLiveLocation ( self , mid = None , location = None , author_id = None , thread_id = None , thread_type = None , ts = None , msg = None , ) : log . info ( "{} sent live location info in {} ({}) with latitude {} and longitude {}" . format ( author_id , thread_id , thread_type , location . latitude , location . long... | Called when the client is listening and somebody sends live location info |
26,360 | def onUserJoinedCall ( self , mid = None , joined_id = None , is_video_call = None , thread_id = None , thread_type = None , ts = None , metadata = None , msg = None , ) : log . info ( "{} joined call in {} ({})" . format ( joined_id , thread_id , thread_type . name ) ) | Called when the client is listening and somebody joins a group call |
26,361 | def onPollCreated ( self , mid = None , poll = None , author_id = None , thread_id = None , thread_type = None , ts = None , metadata = None , msg = None , ) : log . info ( "{} created poll {} in {} ({})" . format ( author_id , poll , thread_id , thread_type . name ) ) | Called when the client is listening and somebody creates a group poll |
26,362 | def onPollVoted ( self , mid = None , poll = None , added_options = None , removed_options = None , author_id = None , thread_id = None , thread_type = None , ts = None , metadata = None , msg = None , ) : log . info ( "{} voted in poll {} in {} ({})" . format ( author_id , poll , thread_id , thread_type . name ) ) | Called when the client is listening and somebody votes in a group poll |
26,363 | def onPlanDeleted ( self , mid = None , plan = None , author_id = None , thread_id = None , thread_type = None , ts = None , metadata = None , msg = None , ) : log . info ( "{} deleted plan {} in {} ({})" . format ( author_id , plan , thread_id , thread_type . name ) ) | Called when the client is listening and somebody deletes a plan |
26,364 | def onPlanParticipation ( self , mid = None , plan = None , take_part = None , author_id = None , thread_id = None , thread_type = None , ts = None , metadata = None , msg = None , ) : if take_part : log . info ( "{} will take part in {} in {} ({})" . format ( author_id , plan , thread_id , thread_type . name ) ) else ... | Called when the client is listening and somebody takes part in a plan or not |
26,365 | def graphql_queries_to_json ( * queries ) : rtn = { } for i , query in enumerate ( queries ) : rtn [ "q{}" . format ( i ) ] = query . value return json . dumps ( rtn ) | Queries should be a list of GraphQL objects |
26,366 | def get_tags ( ) : tags = getattr ( flask . g , 'bukudb' , get_bukudb ( ) ) . get_tag_all ( ) result = { 'tags' : tags [ 0 ] } if request . path . startswith ( '/api/' ) : res = jsonify ( result ) else : res = render_template ( 'bukuserver/tags.html' , result = result ) return res | get tags . |
26,367 | def create_app ( config_filename = None ) : app = FlaskAPI ( __name__ ) per_page = int ( os . getenv ( 'BUKUSERVER_PER_PAGE' , str ( views . DEFAULT_PER_PAGE ) ) ) per_page = per_page if per_page > 0 else views . DEFAULT_PER_PAGE app . config [ 'BUKUSERVER_PER_PAGE' ] = per_page url_render_mode = os . getenv ( 'BUKUSER... | create app . |
26,368 | def search ( self ) : "redirect to bookmark search" form = forms . HomeForm ( ) bbm_filter = bs_filters . BookmarkBukuFilter ( all_keywords = False , deep = form . deep . data , regex = form . regex . data ) op_text = bbm_filter . operation ( ) values_combi = sorted ( itertools . product ( [ True , False ] , repeat = 3... | redirect to bookmark search |
26,369 | def autolink ( self , link , is_email = False ) : text = link = escape_link ( link ) if is_email : link = 'mailto:%s' % link return '<a href="%s">%s</a>' % ( link , text ) | Rendering a given link or email address . |
26,370 | def init ( * args , ** kwargs ) : global _initial_client client = Client ( * args , ** kwargs ) Hub . current . bind_client ( client ) rv = _InitGuard ( client ) if client is not None : _initial_client = weakref . ref ( client ) return rv | Initializes the SDK and optionally integrations . |
26,371 | def current ( self ) : rv = _local . get ( None ) if rv is None : rv = Hub ( GLOBAL_HUB ) _local . set ( rv ) return rv | Returns the current instance of the hub . |
26,372 | def get_integration ( self , name_or_class ) : if isinstance ( name_or_class , str ) : integration_name = name_or_class elif name_or_class . identifier is not None : integration_name = name_or_class . identifier else : raise ValueError ( "Integration has no name" ) client = self . _stack [ - 1 ] [ 0 ] if client is not ... | Returns the integration for this hub by name or class . If there is no client bound or the client does not have that integration then None is returned . |
26,373 | def bind_client ( self , new ) : top = self . _stack [ - 1 ] self . _stack [ - 1 ] = ( new , top [ 1 ] ) | Binds a new client to the hub . |
26,374 | def capture_event ( self , event , hint = None ) : client , scope = self . _stack [ - 1 ] if client is not None : rv = client . capture_event ( event , hint , scope ) if rv is not None : self . _last_event_id = rv return rv return None | Captures an event . The return value is the ID of the event . |
26,375 | def capture_message ( self , message , level = None ) : if self . client is None : return None if level is None : level = "info" return self . capture_event ( { "message" : message , "level" : level } ) | Captures a message . The message is just a string . If no level is provided the default level is info . |
26,376 | def capture_exception ( self , error = None ) : client = self . client if client is None : return None if error is None : exc_info = sys . exc_info ( ) else : exc_info = exc_info_from_error ( error ) event , hint = event_from_exception ( exc_info , client_options = client . options ) try : return self . capture_event (... | Captures an exception . |
26,377 | def push_scope ( self , callback = None ) : if callback is not None : with self . push_scope ( ) as scope : callback ( scope ) return None client , scope = self . _stack [ - 1 ] new_layer = ( client , copy . copy ( scope ) ) self . _stack . append ( new_layer ) return _ScopeManager ( self ) | Pushes a new layer on the scope stack . Returns a context manager that should be used to pop the scope again . Alternatively a callback can be provided that is executed in the context of the scope . |
26,378 | def configure_scope ( self , callback = None ) : client , scope = self . _stack [ - 1 ] if callback is not None : if client is not None : callback ( scope ) return None @ contextmanager def inner ( ) : if client is not None : yield scope else : yield Scope ( ) return inner ( ) | Reconfigures the scope . |
26,379 | def flush ( self , timeout = None , callback = None ) : client , scope = self . _stack [ - 1 ] if client is not None : return client . flush ( timeout = timeout , callback = callback ) | Alias for self . client . flush |
26,380 | def capture_event ( self , event , hint = None , scope = None ) : if self . transport is None : return None if hint is None : hint = { } rv = event . get ( "event_id" ) if rv is None : event [ "event_id" ] = rv = uuid . uuid4 ( ) . hex if not self . _should_capture ( event , hint , scope ) : return None event = self . ... | Captures an event . |
26,381 | def flush ( self , timeout = None , callback = None ) : if self . transport is not None : if timeout is None : timeout = self . options [ "shutdown_timeout" ] self . transport . flush ( timeout = timeout , callback = callback ) | Wait timeout seconds for the current events to be sent . If no timeout is provided the shutdown_timeout option value is used . |
26,382 | def setup_integrations ( integrations , with_defaults = True ) : integrations = dict ( ( integration . identifier , integration ) for integration in integrations or ( ) ) logger . debug ( "Setting up integrations (with default = %s)" , with_defaults ) if with_defaults : for integration_cls in iter_default_integrations ... | Given a list of integration instances this installs them all . When with_defaults is set to True then all default integrations are added unless they were already provided before . |
26,383 | def clear ( self ) : self . _level = None self . _fingerprint = None self . _transaction = None self . _user = None self . _tags = { } self . _contexts = { } self . _extras = { } self . clear_breadcrumbs ( ) self . _should_capture = True self . _span = None | Clears the entire scope . |
26,384 | def add_error_processor ( self , func , cls = None ) : if cls is not None : real_func = func def func ( event , exc_info ) : try : is_inst = isinstance ( exc_info [ 1 ] , cls ) except Exception : is_inst = False if is_inst : return real_func ( event , exc_info ) return event self . _error_processors . append ( func ) | Register a scope local error processor on the scope . |
26,385 | def apply_to_event ( self , event , hint = None ) : def _drop ( event , cause , ty ) : logger . info ( "%s (%s) dropped event (%s)" , ty , cause , event ) return None if self . _level is not None : event [ "level" ] = self . _level event . setdefault ( "breadcrumbs" , [ ] ) . extend ( self . _breadcrumbs ) if event . g... | Applies the information contained on the scope to the given event . |
26,386 | def default_callback ( pending , timeout ) : def echo ( msg ) : sys . stderr . write ( msg + "\n" ) echo ( "Sentry is attempting to send %i pending error messages" % pending ) echo ( "Waiting up to %s seconds" % timeout ) echo ( "Press Ctrl-%s to quit" % ( os . name == "nt" and "Break" or "C" ) ) sys . stderr . flush (... | This is the default shutdown callback that is set on the options . It prints out a message to stderr that informs the user that some events are still pending and the process is waiting for them to flush out . |
26,387 | def get_host ( environ ) : if environ . get ( "HTTP_HOST" ) : rv = environ [ "HTTP_HOST" ] if environ [ "wsgi.url_scheme" ] == "http" and rv . endswith ( ":80" ) : rv = rv [ : - 3 ] elif environ [ "wsgi.url_scheme" ] == "https" and rv . endswith ( ":443" ) : rv = rv [ : - 4 ] elif environ . get ( "SERVER_NAME" ) : rv =... | Return the host for the given WSGI environment . Yanked from Werkzeug . |
26,388 | def get_request_url ( environ ) : return "%s://%s/%s" % ( environ . get ( "wsgi.url_scheme" ) , get_host ( environ ) , wsgi_decoding_dance ( environ . get ( "PATH_INFO" ) or "" ) . lstrip ( "/" ) , ) | Return the absolute URL without query string for the given WSGI environment . |
26,389 | def _get_environ ( environ ) : keys = [ "SERVER_NAME" , "SERVER_PORT" ] if _should_send_default_pii ( ) : keys += [ "REMOTE_ADDR" , "HTTP_X_FORWARDED_FOR" , "HTTP_X_REAL_IP" ] for key in keys : if key in environ : yield key , environ [ key ] | Returns our whitelisted environment variables . |
26,390 | def get_client_ip ( environ ) : try : return environ [ "HTTP_X_FORWARDED_FOR" ] . split ( "," ) [ 0 ] . strip ( ) except ( KeyError , IndexError ) : pass try : return environ [ "HTTP_X_REAL_IP" ] except KeyError : pass return environ . get ( "REMOTE_ADDR" ) | Infer the user IP address from various headers . This cannot be used in security sensitive situations since the value may be forged from a client but it s good enough for the event payload . |
26,391 | def event_hint_with_exc_info ( exc_info = None ) : if exc_info is None : exc_info = sys . exc_info ( ) else : exc_info = exc_info_from_error ( exc_info ) if exc_info [ 0 ] is None : exc_info = None return { "exc_info" : exc_info } | Creates a hint with the exc info filled in . |
26,392 | def format_and_strip ( template , params , strip_string = strip_string ) : chunks = template . split ( u"%s" ) if not chunks : raise ValueError ( "No formatting placeholders found" ) params = list ( reversed ( params ) ) rv_remarks = [ ] rv_original_length = 0 rv_length = 0 rv = [ ] def realign_remark ( remark ) : retu... | Format a string containing %s for placeholders and call strip_string on each parameter . The string template itself does not have a maximum length . |
26,393 | def store_api_url ( self ) : return "%s://%s%sapi/%s/store/" % ( self . scheme , self . host , self . path , self . project_id , ) | Returns the API url for storing events . |
26,394 | def to_header ( self , timestamp = None ) : rv = [ ( "sentry_key" , self . public_key ) , ( "sentry_version" , self . version ) ] if timestamp is not None : rv . append ( ( "sentry_timestamp" , str ( to_timestamp ( timestamp ) ) ) ) if self . client is not None : rv . append ( ( "sentry_client" , self . client ) ) if s... | Returns the auth header a string . |
26,395 | def _register_bounds_validator_if_needed ( parser , name , flag_values ) : if parser . lower_bound is not None or parser . upper_bound is not None : def checker ( value ) : if value is not None and parser . is_outside_bounds ( value ) : message = '%s is not %s' % ( value , parser . syntactic_help ) raise _exceptions . ... | Enforces lower and upper bounds for numeric flags . |
26,396 | def DEFINE ( parser , name , default , help , flag_values = _flagvalues . FLAGS , serializer = None , module_name = None , ** args ) : DEFINE_flag ( _flag . Flag ( parser , serializer , name , default , help , ** args ) , flag_values , module_name ) | Registers a generic Flag object . |
26,397 | def DEFINE_string ( name , default , help , flag_values = _flagvalues . FLAGS , ** args ) : parser = _argument_parser . ArgumentParser ( ) serializer = _argument_parser . ArgumentSerializer ( ) DEFINE ( parser , name , default , help , flag_values , serializer , ** args ) | Registers a flag whose value can be any string . |
26,398 | def DEFINE_boolean ( name , default , help , flag_values = _flagvalues . FLAGS , module_name = None , ** args ) : DEFINE_flag ( _flag . BooleanFlag ( name , default , help , ** args ) , flag_values , module_name ) | Registers a boolean flag . |
26,399 | def DEFINE_float ( name , default , help , lower_bound = None , upper_bound = None , flag_values = _flagvalues . FLAGS , ** args ) : parser = _argument_parser . FloatParser ( lower_bound , upper_bound ) serializer = _argument_parser . ArgumentSerializer ( ) DEFINE ( parser , name , default , help , flag_values , serial... | Registers a flag whose value must be a float . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.