idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
33,300 | def serve ( self , port = None , address = None ) : port = port or self . port address = address or self . address log . info ( 'Starting SMTP server at {0}:{1}' . format ( address , port ) ) server = InboxServer ( self . collator , ( address , port ) , None ) try : asyncore . loop ( ) except KeyboardInterrupt : log . ... | Serves the SMTP server on the given port and address . |
33,301 | def dispatch ( self ) : parser = argparse . ArgumentParser ( description = 'Run an Inbox server.' ) parser . add_argument ( 'addr' , metavar = 'addr' , type = str , help = 'addr to bind to' ) parser . add_argument ( 'port' , metavar = 'port' , type = int , help = 'port to bind to' ) args = parser . parse_args ( ) self ... | Command - line dispatch . |
33,302 | def format_ltime ( endianess , tm_format , data ) : if tm_format == 0 : return '' elif tm_format == 1 or tm_format == 2 : y = data [ 0 ] year = '????' if 90 <= y <= 99 : year = '19' + str ( y ) elif 0 <= y <= 9 : year = '200' + str ( y ) elif 10 <= y <= 89 : year = '20' + str ( y ) month = data [ 1 ] day = data [ 2 ] h... | Return data formatted into a human readable time stamp . |
33,303 | def get_history_entry_record ( endianess , hist_date_time_flag , tm_format , event_number_flag , hist_seq_nbr_flag , data ) : rcd = { } if hist_date_time_flag : tmstmp = format_ltime ( endianess , tm_format , data [ 0 : LTIME_LENGTH . get ( tm_format ) ] ) if tmstmp : rcd [ 'Time' ] = tmstmp data = data [ LTIME_LENGTH ... | Return data formatted into a log entry . |
33,304 | def get_table_idbb_field ( endianess , data ) : bfld = struct . unpack ( endianess + 'H' , data [ : 2 ] ) [ 0 ] proc_nbr = bfld & 0x7ff std_vs_mfg = bool ( bfld & 0x800 ) selector = ( bfld & 0xf000 ) >> 12 return ( proc_nbr , std_vs_mfg , selector ) | Return data from a packed TABLE_IDB_BFLD bit - field . |
33,305 | def get_table_idcb_field ( endianess , data ) : bfld = struct . unpack ( endianess + 'H' , data [ : 2 ] ) [ 0 ] proc_nbr = bfld & 2047 std_vs_mfg = bool ( bfld & 2048 ) proc_flag = bool ( bfld & 4096 ) flag1 = bool ( bfld & 8192 ) flag2 = bool ( bfld & 16384 ) flag3 = bool ( bfld & 32768 ) return ( proc_nbr , std_vs_mf... | Return data from a packed TABLE_IDC_BFLD bit - field . |
33,306 | def unique ( seq , idfunc = None ) : if idfunc is None : idfunc = lambda x : x preserved_type = type ( seq ) seen = { } result = [ ] for item in seq : marker = idfunc ( item ) if marker in seen : continue seen [ marker ] = 1 result . append ( item ) return preserved_type ( result ) | Unique a list or tuple and preserve the order |
33,307 | def do_ipy ( self , args ) : import c1218 . data import c1219 . data from c1219 . access . general import C1219GeneralAccess from c1219 . access . security import C1219SecurityAccess from c1219 . access . log import C1219LogAccess from c1219 . access . telephone import C1219TelephoneAccess vars = { 'termineter.__versio... | Start an interactive Python interpreter |
33,308 | def do_reload ( self , args ) : if args . module is not None : if args . module not in self . frmwk . modules : self . print_error ( 'Invalid Module Selected.' ) return module = self . frmwk . modules [ args . module ] elif self . frmwk . current_module : module = self . frmwk . current_module else : self . print_error... | Reload a module in to the framework |
33,309 | def send ( self , data ) : if not isinstance ( data , C1218Packet ) : data = C1218Packet ( data ) if self . toggle_control : if self . _toggle_bit : data . set_control ( ord ( data . control ) | 0x20 ) self . _toggle_bit = False elif not self . _toggle_bit : if ord ( data . control ) & 0x20 : data . set_control ( ord (... | This sends a raw C12 . 18 frame and waits checks for an ACK response . In the event that a NACK is received this function will attempt to resend the frame up to 3 times . |
33,310 | def recv ( self , full_frame = False ) : payloadbuffer = b'' tries = 3 while tries : tmpbuffer = self . serial_h . read ( 1 ) if tmpbuffer != b'\xee' : self . loggerio . error ( 'did not receive \\xee as the first byte of the frame' ) self . loggerio . debug ( 'received \\x' + binascii . b2a_hex ( tmpbuffer ) . decode ... | Receive a C1218Packet the payload data is returned . |
33,311 | def read ( self , size ) : data = self . serial_h . read ( size ) self . logger . debug ( 'read data, length: ' + str ( len ( data ) ) + ' data: ' + binascii . b2a_hex ( data ) . decode ( 'utf-8' ) ) self . serial_h . write ( ACK ) if sys . version_info [ 0 ] == 2 : data = bytearray ( data ) return data | Read raw data from the serial connection . This function is not meant to be called directly . |
33,312 | def close ( self ) : if self . _initialized : self . stop ( ) self . logged_in = False return self . serial_h . close ( ) | Send a terminate request and then disconnect from the serial device . |
33,313 | def start ( self ) : self . serial_h . flushOutput ( ) self . serial_h . flushInput ( ) self . send ( C1218IdentRequest ( ) ) data = self . recv ( ) if data [ 0 ] != 0x00 : self . logger . error ( 'received incorrect response to identification service request' ) return False self . _initialized = True self . send ( C12... | Send an identity request and then a negotiation request . |
33,314 | def stop ( self , force = False ) : if self . _initialized : self . send ( C1218TerminateRequest ( ) ) data = self . recv ( ) if data == b'\x00' or force : self . _initialized = False self . _toggle_bit = False return True return False | Send a terminate request . |
33,315 | def login ( self , username = '0000' , userid = 0 , password = None ) : if password and len ( password ) > 20 : self . logger . error ( 'password longer than 20 characters received' ) raise Exception ( 'password longer than 20 characters, login failed' ) self . send ( C1218LogonRequest ( username , userid ) ) data = se... | Log into the connected device . |
33,316 | def logoff ( self ) : self . send ( C1218LogoffRequest ( ) ) data = self . recv ( ) if data == b'\x00' : self . _initialized = False return True return False | Send a logoff request . |
33,317 | def get_table_data ( self , tableid , octetcount = None , offset = None ) : if self . caching_enabled and tableid in self . _cacheable_tables and tableid in self . _table_cache . keys ( ) : self . logger . info ( 'returning cached table #' + str ( tableid ) ) return self . _table_cache [ tableid ] self . send ( C1218Re... | Read data from a table . If successful all of the data from the requested table will be returned . |
33,318 | def set_table_data ( self , tableid , data , offset = None ) : self . send ( C1218WriteRequest ( tableid , data , offset ) ) data = self . recv ( ) if data [ 0 ] != 0x00 : status = data [ 0 ] details = ( C1218_RESPONSE_CODES . get ( status ) or 'unknown response code' ) self . logger . error ( 'could not write data to ... | Write data to a table . |
33,319 | def run_procedure ( self , process_number , std_vs_mfg , params = '' ) : seqnum = random . randint ( 2 , 254 ) self . logger . info ( 'starting procedure: ' + str ( process_number ) + ' (' + hex ( process_number ) + ') sequence number: ' + str ( seqnum ) + ' (' + hex ( seqnum ) + ')' ) procedure_request = C1219Procedur... | Initiate a C1219 procedure the request is written to table 7 and the response is read from table 8 . |
33,320 | def add_string ( self , name , help , required = True , default = None ) : self . _options [ name ] = Option ( name , 'str' , help , required , default = default ) | Add a new option with a type of String . |
33,321 | def set_option_value ( self , name , value ) : option = self . get_option ( name ) old_value = option . value if option . type in ( 'str' , 'rfile' ) : option . value = value elif option . type == 'int' : value = value . lower ( ) if not value . isdigit ( ) : if value . startswith ( '0x' ) and string_is_hex ( value [ 2... | Set an option s value . |
33,322 | def get_missing_options ( self ) : return [ option . name for option in self . _options . values ( ) if option . required and option . value is None ] | Get a list of options that are required but with default values of None . |
33,323 | def get_revision ( ) : git_bin = smoke_zephyr . utilities . which ( 'git' ) if not git_bin : return None proc_h = subprocess . Popen ( ( git_bin , 'rev-parse' , 'HEAD' ) , stdout = subprocess . PIPE , stderr = subprocess . PIPE , close_fds = True , cwd = os . path . dirname ( os . path . abspath ( __file__ ) ) ) rev = ... | Retrieve the current git revision identifier . If the git binary can not be found or the repository information is unavailable None will be returned . |
33,324 | def reload_module ( self , module_path = None ) : if module_path is None : if self . current_module is not None : module_path = self . current_module . name else : self . logger . warning ( 'must specify module if not module is currently being used' ) return False if module_path not in self . module : self . logger . e... | Reloads a module into the framework . If module_path is not specified then the current_module variable is used . Returns True on success False on error . |
33,325 | def serial_disconnect ( self ) : if self . _serial_connected : try : self . serial_connection . close ( ) except c1218 . errors . C1218IOError as error : self . logger . error ( 'caught C1218IOError: ' + str ( error ) ) except serial . serialutil . SerialException as error : self . logger . error ( 'caught SerialExcept... | Closes the serial connection to the meter and disconnects from the device . |
33,326 | def serial_get ( self ) : frmwk_c1218_settings = { 'nbrpkts' : self . advanced_options [ 'C1218_MAX_PACKETS' ] , 'pktsize' : self . advanced_options [ 'C1218_PACKET_SIZE' ] } frmwk_serial_settings = termineter . utilities . get_default_serial_settings ( ) frmwk_serial_settings [ 'baudrate' ] = self . advanced_options [... | Create the serial connection from the framework settings and return it setting the framework instance in the process . |
33,327 | def serial_connect ( self ) : self . serial_get ( ) try : self . serial_connection . start ( ) except c1218 . errors . C1218IOError as error : self . logger . error ( 'serial connection has been opened but the meter is unresponsive' ) raise error self . _serial_connected = True return True | Connect to the serial device . |
33,328 | def serial_login ( self ) : if not self . _serial_connected : raise termineter . errors . FrameworkRuntimeError ( 'the serial interface is disconnected' ) username = self . options [ 'USERNAME' ] user_id = self . options [ 'USER_ID' ] password = self . options [ 'PASSWORD' ] if self . options [ 'PASSWORD_HEX' ] : hex_r... | Attempt to log into the meter over the C12 . 18 protocol . Returns True on success False on a failure . This can be called by modules in order to login with a username and password configured within the framework instance . |
33,329 | def run ( self ) : self . factory . register ( User , self . users_factory ) self . factory ( User , 50 ) . create ( ) | Run the database seeds . |
33,330 | def app ( environ , start_response ) : from wsgi import container container . bind ( 'Environ' , environ ) try : for provider in container . make ( 'WSGIProviders' ) : container . resolve ( provider . boot ) except Exception as e : container . make ( 'ExceptionHandler' ) . load_exception ( e ) start_response ( containe... | The WSGI Application Server . |
33,331 | def up ( self ) : with self . schema . create ( 'users' ) as table : table . increments ( 'id' ) table . string ( 'name' ) table . string ( 'email' ) . unique ( ) table . string ( 'password' ) table . string ( 'remember_token' ) . nullable ( ) table . timestamp ( 'verified_at' ) . nullable ( ) table . timestamps ( ) | Run the migrations . |
33,332 | def before ( self ) : user = self . request . user ( ) if user and user . verified_at is None : self . request . redirect ( '/email/verify' ) | Run This Middleware Before The Route Executes . |
33,333 | def show ( self , view : View , request : Request ) : return view . render ( 'welcome' , { 'app' : request . app ( ) . make ( 'Application' ) } ) | Show the welcome page . |
33,334 | def is_valid_address ( s ) : try : pairs = s . split ( ":" ) if len ( pairs ) != 6 : return False if not all ( 0 <= int ( b , 16 ) <= 255 for b in pairs ) : return False except : return False return True | returns True if address is a valid Bluetooth address |
33,335 | def to_full_uuid ( uuid ) : if not is_valid_uuid ( uuid ) : raise ValueError ( "invalid UUID" ) if len ( uuid ) == 4 : return "0000%s-0000-1000-8000-00805F9B34FB" % uuid elif len ( uuid ) == 8 : return "%s-0000-1000-8000-00805F9B34FB" % uuid else : return uuid | converts a short 16 - bit or 32 - bit reserved UUID to a full 128 - bit Bluetooth UUID . |
33,336 | def cancel_inquiry ( self ) : self . names_to_find = { } if self . is_inquiring : try : _bt . hci_send_cmd ( self . sock , _bt . OGF_LINK_CTL , _bt . OCF_INQUIRY_CANCEL ) except _bt . error as e : self . sock . close ( ) self . sock = None raise BluetoothError ( e . args [ 0 ] , "error canceling inquiry: " + e . args [... | Call this method to cancel an inquiry in process . inquiry_complete will still be called . |
33,337 | def device_discovered ( self , address , device_class , rssi , name ) : if name : print ( ( "found: %s - %s (class 0x%X, rssi %s)" % ( address , name , device_class , rssi ) ) ) else : print ( ( "found: %s (class 0x%X)" % ( address , device_class ) ) ) print ( ( "found: %s (class 0x%X, rssi %s)" % ( address , device_cl... | Called when a bluetooth device is discovered . |
33,338 | def read_inquiry_scan_activity ( sock ) : old_filter = sock . getsockopt ( bluez . SOL_HCI , bluez . HCI_FILTER , 14 ) flt = bluez . hci_filter_new ( ) opcode = bluez . cmd_opcode_pack ( bluez . OGF_HOST_CTL , bluez . OCF_READ_INQ_ACTIVITY ) bluez . hci_filter_set_ptype ( flt , bluez . HCI_EVENT_PKT ) bluez . hci_filte... | returns the current inquiry scan interval and window or - 1 on failure |
33,339 | def write_inquiry_scan_activity ( sock , interval , window ) : old_filter = sock . getsockopt ( bluez . SOL_HCI , bluez . HCI_FILTER , 14 ) flt = bluez . hci_filter_new ( ) opcode = bluez . cmd_opcode_pack ( bluez . OGF_HOST_CTL , bluez . OCF_WRITE_INQ_ACTIVITY ) bluez . hci_filter_set_ptype ( flt , bluez . HCI_EVENT_P... | returns 0 on success - 1 on failure |
33,340 | def read_inquiry_mode ( sock ) : old_filter = sock . getsockopt ( bluez . SOL_HCI , bluez . HCI_FILTER , 14 ) flt = bluez . hci_filter_new ( ) opcode = bluez . cmd_opcode_pack ( bluez . OGF_HOST_CTL , bluez . OCF_READ_INQUIRY_MODE ) bluez . hci_filter_set_ptype ( flt , bluez . HCI_EVENT_PKT ) bluez . hci_filter_set_eve... | returns the current mode or - 1 on failure |
33,341 | def splitclass ( classofdevice ) : if not isinstance ( classofdevice , int ) : try : classofdevice = int ( classofdevice ) except ( TypeError , ValueError ) : raise TypeError ( "Given device class '%s' cannot be split" % str ( classofdevice ) ) data = classofdevice >> 2 service = data >> 11 major = ( data >> 6 ) & 0x1F... | Splits the given class of device to return a 3 - item tuple with the major service class major device class and minor device class values . |
33,342 | def _searchservices ( device , name = None , uuid = None , uuidbad = None ) : if not isinstance ( device , _IOBluetooth . IOBluetoothDevice ) : raise ValueError ( "device must be IOBluetoothDevice, was %s" % type ( device ) ) services = [ ] allservices = device . getServices ( ) if uuid : gooduuids = ( uuid , ) else : ... | Searches the given IOBluetoothDevice using the specified parameters . Returns an empty list if the device has no services . |
33,343 | def reset ( self ) : self . model = pm . Model ( ) self . mu = None self . par_groups = { } | Reset PyMC3 model and all tracked distributions and parameters . |
33,344 | def _build_dist ( self , spec , label , dist , ** kwargs ) : if isinstance ( dist , string_types ) : if hasattr ( pm , dist ) : dist = getattr ( pm , dist ) elif dist in self . dists : dist = self . dists [ dist ] else : raise ValueError ( "The Distribution class '%s' was not " "found in PyMC3 or the PyMC3BackEnd." % d... | Build and return a PyMC3 Distribution . |
33,345 | def to_df ( self , varnames = None , ranefs = False , transformed = False , chains = None ) : names = self . _filter_names ( varnames , ranefs , transformed ) if chains is None : chains = list ( range ( self . n_chains ) ) chains = listify ( chains ) data = [ self . data [ : , i , : ] for i in chains ] data = np . conc... | Returns the MCMC samples in a nice neat pandas DataFrame with all MCMC chains concatenated . |
33,346 | def autocov ( x ) : acorr = autocorr ( x ) varx = np . var ( x , ddof = 1 ) * ( len ( x ) - 1 ) / len ( x ) acov = acorr * varx return acov | Compute autocovariance estimates for every lag for the input array . |
33,347 | def reset ( self ) : self . terms = OrderedDict ( ) self . y = None self . backend = None self . added_terms = [ ] self . _added_priors = { } self . completes = [ ] self . clean_data = None | Reset list of terms and y - variable . |
33,348 | def fit ( self , fixed = None , random = None , priors = None , family = 'gaussian' , link = None , run = True , categorical = None , backend = None , ** kwargs ) : if fixed is not None or random is not None : self . add ( fixed = fixed , random = random , priors = priors , family = family , link = link , categorical =... | Fit the model using the specified BackEnd . |
33,349 | def add ( self , fixed = None , random = None , priors = None , family = 'gaussian' , link = None , categorical = None , append = True ) : data = self . data if priors is None : priors = { } else : priors = deepcopy ( priors ) if not append : self . reset ( ) if categorical is not None : data = data . copy ( ) cats = l... | Adds one or more terms to the model via an R - like formula syntax . |
33,350 | def set_priors ( self , priors = None , fixed = None , random = None , match_derived_names = True ) : kwargs = dict ( zip ( [ 'priors' , 'fixed' , 'random' , 'match_derived_names' ] , [ priors , fixed , random , match_derived_names ] ) ) self . _added_priors . update ( kwargs ) self . built = False | Set priors for one or more existing terms . |
33,351 | def fixed_terms ( self ) : return { k : v for ( k , v ) in self . terms . items ( ) if not v . random } | Return dict of all and only fixed effects in model . |
33,352 | def random_terms ( self ) : return { k : v for ( k , v ) in self . terms . items ( ) if v . random } | Return dict of all and only random effects in model . |
33,353 | def update ( self , ** kwargs ) : kwargs = { k : ( np . array ( v ) if isinstance ( v , ( int , float ) ) else v ) for k , v in kwargs . items ( ) } self . args . update ( kwargs ) | Update the model arguments with additional arguments . |
33,354 | def get ( self , dist = None , term = None , family = None ) : if dist is not None : if dist not in self . dists : raise ValueError ( "'%s' is not a valid distribution name." % dist ) return self . _get_prior ( self . dists [ dist ] ) elif term is not None : if term not in self . terms : raise ValueError ( "'%s' is not... | Retrieve default prior for a named distribution term type or family . |
33,355 | def reset ( self ) : self . parameters = [ ] self . transformed_parameters = [ ] self . expressions = [ ] self . data = [ ] self . transformed_data = [ ] self . X = { } self . model = [ ] self . mu_cont = [ ] self . mu_cat = [ ] self . _original_names = { } self . _suppress_vars = [ 'yhat' , 'lp__' ] | Reset Stan model and all tracked distributions and parameters . |
33,356 | def reset_mode ( self ) : self . command ( 0x18 , b"\x01" , timeout = 0.1 ) self . transport . write ( Chipset . ACK ) time . sleep ( 0.010 ) | Send a Reset command to set the operation mode to 0 . |
33,357 | def sense_ttb ( self , target ) : return super ( Device , self ) . sense_ttb ( target , did = b'\x01' ) | Activate the RF field and probe for a Type B Target . |
33,358 | def sense_dep ( self , target ) : self . chipset . rf_configuration ( 0x02 , b"\x0B\x0B\x0A" ) return super ( Device , self ) . sense_dep ( target ) | Search for a DEP Target in active or passive communication mode . |
33,359 | def send ( self , message ) : log . debug ( "sending '{0}' message" . format ( message . type ) ) send_miu = self . socket . getsockopt ( nfc . llcp . SO_SNDMIU ) try : data = str ( message ) except nfc . llcp . EncodeError as e : log . error ( "message encoding failed: {0}" . format ( e ) ) else : return self . _send ... | Send a handover request message to the remote server . |
33,360 | def recv ( self , timeout = None ) : message = self . _recv ( timeout ) if message and message . type == "urn:nfc:wkt:Hs" : log . debug ( "received '{0}' message" . format ( message . type ) ) return nfc . ndef . HandoverSelectMessage ( message ) else : log . error ( "received invalid message type {0}" . format ( messa... | Receive a handover select message from the remote server . |
33,361 | def sense_ttb ( self , target ) : info = "{device} does not support sense for Type B Target" raise nfc . clf . UnsupportedTargetError ( info . format ( device = self ) ) | Sense for a Type B Target is not supported . |
33,362 | def sense_dep ( self , target ) : if target . atr_req [ 15 ] & 0x30 == 0x30 : self . log . warning ( "must reduce the max payload size in atr_req" ) target . atr_req [ 15 ] = ( target . atr_req [ 15 ] & 0xCF ) | 0x20 target = super ( Device , self ) . sense_dep ( target ) if target is None : return if target . atr_res ... | Search for a DEP Target in active communication mode . |
33,363 | def protect ( self , password = None , read_protect = False , protect_from = 0 ) : return super ( NTAG203 , self ) . protect ( password , read_protect , protect_from ) | Set lock bits to disable future memory modifications . |
33,364 | def signature ( self ) : log . debug ( "read tag signature" ) try : return bytes ( self . transceive ( b"\x3C\x00" ) ) except tt2 . Type2TagCommandError : return 32 * b"\0" | The 32 - byte ECC tag signature programmed at chip production . The signature is provided as a string and can only be read . |
33,365 | def protect ( self , password = None , read_protect = False , protect_from = 0 ) : args = ( password , read_protect , protect_from ) return super ( NTAG21x , self ) . protect ( * args ) | Set password protection or permanent lock bits . |
33,366 | def mute ( self ) : fname = "mute" cname = self . __class__ . __module__ + '.' + self . __class__ . __name__ raise NotImplementedError ( "%s.%s() is required" % ( cname , fname ) ) | Mutes all existing communication most notably the device will no longer generate a 13 . 56 MHz carrier signal when operating as Initiator . |
33,367 | def listen_tta ( self , target , timeout ) : fname = "listen_tta" cname = self . __class__ . __module__ + '.' + self . __class__ . __name__ raise NotImplementedError ( "%s.%s() is required" % ( cname , fname ) ) | Listen as Type A Target . |
33,368 | def send_cmd_recv_rsp ( self , target , data , timeout ) : fname = "send_cmd_recv_rsp" cname = self . __class__ . __module__ + '.' + self . __class__ . __name__ raise NotImplementedError ( "%s.%s() is required" % ( cname , fname ) ) | Exchange data with a remote Target |
33,369 | def get_max_recv_data_size ( self , target ) : fname = "get_max_recv_data_size" cname = self . __class__ . __module__ + '.' + self . __class__ . __name__ raise NotImplementedError ( "%s.%s() is required" % ( cname , fname ) ) | Returns the maximum number of data bytes for receiving . |
33,370 | def format ( self , version = None , wipe = None ) : return super ( Type2Tag , self ) . format ( version , wipe ) | Erase the NDEF message on a Type 2 Tag . |
33,371 | def protect ( self , password = None , read_protect = False , protect_from = 0 ) : return super ( Type2Tag , self ) . protect ( password , read_protect , protect_from ) | Protect the tag against write access i . e . make it read - only . |
33,372 | def read ( self , page ) : log . debug ( "read pages {0} to {1}" . format ( page , page + 3 ) ) data = self . transceive ( "\x30" + chr ( page % 256 ) , timeout = 0.005 ) if len ( data ) == 1 and data [ 0 ] & 0xFA == 0x00 : log . debug ( "received nak response" ) self . target . sel_req = self . target . sdd_res [ : ] ... | Send a READ command to retrieve data from the tag . |
33,373 | def write ( self , page , data ) : if len ( data ) != 4 : raise ValueError ( "data must be a four byte string or array" ) log . debug ( "write {0} to page {1}" . format ( hexlify ( data ) , page ) ) rsp = self . transceive ( "\xA2" + chr ( page % 256 ) + data ) if len ( rsp ) != 1 : log . debug ( "invalid response " + ... | Send a WRITE command to store data on the tag . |
33,374 | def sector_select ( self , sector ) : if sector != self . _current_sector : log . debug ( "select sector {0} (pages {1} to {2})" . format ( sector , sector << 10 , ( ( sector + 1 ) << 8 ) - 1 ) ) sector_select_1 = b'\xC2\xFF' sector_select_2 = pack ( 'Bxxx' , sector ) rsp = self . transceive ( sector_select_1 ) if len ... | Send a SECTOR_SELECT command to switch the 1K address sector . |
33,375 | def transceive ( self , data , timeout = 0.1 , retries = 2 ) : log . debug ( ">> {0} ({1:f}s)" . format ( hexlify ( data ) , timeout ) ) if not self . target : raise Type2TagCommandError ( nfc . tag . TIMEOUT_ERROR ) started = time . time ( ) for retry in range ( 1 + retries ) : try : data = self . clf . exchange ( dat... | Send a Type 2 Tag command and receive the response . |
33,376 | def setsockopt ( self , option , value ) : return self . llc . setsockopt ( self . _tco , option , value ) | Set the value of the given socket option and return the current value which may have been corrected if it was out of bounds . |
33,377 | def accept ( self ) : socket = Socket ( self . _llc , None ) socket . _tco = self . llc . accept ( self . _tco ) return socket | Accept a connection . The socket must be bound to an address and listening for connections . The return value is a new socket object usable to send and receive data on the connection . |
33,378 | def send ( self , data , flags = 0 ) : return self . llc . send ( self . _tco , data , flags ) | Send data to the socket . The socket must be connected to a remote socket . Returns a boolean value that indicates success or failure . A false value is typically an indication that the socket or connection was closed . |
33,379 | def sendto ( self , data , addr , flags = 0 ) : return self . llc . sendto ( self . _tco , data , addr , flags ) | Send data to the socket . The socket should not be connected to a remote socket since the destination socket is specified by addr . Returns a boolean value that indicates success or failure . Failure to send is generally an indication that the socket was closed . |
33,380 | def simple_pairing_hash ( self ) : try : if len ( self . eir [ 0x0E ] ) != 16 : raise DecodeError ( "wrong length of simple pairing hash" ) return bytearray ( self . eir [ 0x0E ] ) except KeyError : return None | Simple Pairing Hash C . Received and transmitted as EIR type 0x0E . Set to None if not received or not to be transmitted . Raises nfc . ndef . DecodeError if the received value or nfc . ndef . EncodeError if the assigned value is not a sequence of 16 octets . |
33,381 | def simple_pairing_rand ( self ) : try : if len ( self . eir [ 0x0F ] ) != 16 : raise DecodeError ( "wrong length of simple pairing hash" ) return bytearray ( self . eir [ 0x0F ] ) except KeyError : return None | Simple Pairing Randomizer R . Received and transmitted as EIR type 0x0F . Set to None if not received or not to be transmitted . Raises nfc . ndef . DecodeError if the received value or nfc . ndef . EncodeError if the assigned value is not a sequence of 16 octets . |
33,382 | def add_carrier ( self , carrier_record , power_state , aux_data_records = None ) : carrier = Carrier ( carrier_record , power_state ) if aux_data_records is not None : for aux in RecordList ( aux_data_records ) : carrier . auxiliary_data_records . append ( aux ) self . carriers . append ( carrier ) | Add a new carrier to the handover request message . |
33,383 | def pretty ( self , indent = 0 ) : indent = indent * ' ' lines = list ( ) version_string = "{v.major}.{v.minor}" . format ( v = self . version ) lines . append ( ( "handover version" , version_string ) ) if self . error . reason : lines . append ( ( "error reason" , self . error . reason ) ) lines . append ( ( "error v... | Returns a string with a formatted representation that might be considered pretty - printable . |
33,384 | def activate ( self , timeout = None , ** options ) : if timeout is None : timeout = 1.0 gbt = options . get ( 'gbt' , '' ) [ 0 : 47 ] lrt = min ( max ( 0 , options . get ( 'lrt' , 3 ) ) , 3 ) rwt = min ( max ( 0 , options . get ( 'rwt' , 8 ) ) , 14 ) pp = ( lrt << 4 ) | ( bool ( gbt ) << 1 ) | int ( bool ( self . nad ... | Activate DEP communication as a target . |
33,385 | def pretty ( self ) : lines = list ( ) for index , record in enumerate ( self . _records ) : lines . append ( ( "record {0}" . format ( index + 1 ) , ) ) lines . append ( ( " type" , repr ( record . type ) ) ) lines . append ( ( " name" , repr ( record . name ) ) ) lines . append ( ( " data" , repr ( record . data )... | Returns a message representation that might be considered pretty - printable . |
33,386 | def format ( self , version = None , wipe = None ) : return super ( Topaz , self ) . format ( version , wipe ) | Format a Topaz tag for NDEF use . |
33,387 | def format ( self , version = None , wipe = None ) : return super ( Topaz512 , self ) . format ( version , wipe ) | Format a Topaz - 512 tag for NDEF use . |
33,388 | def read_all ( self ) : log . debug ( "read all static memory" ) cmd = "\x00\x00\x00" + self . uid return self . transceive ( cmd ) | Returns the 2 byte Header ROM and all 120 byte static memory . |
33,389 | def listen_tta ( self , target , timeout ) : info = "{device} does not support listen as Type A Target" raise nfc . clf . UnsupportedTargetError ( info . format ( device = self ) ) | Listen as Type A Target is not supported . |
33,390 | def command ( self , cmd_code , cmd_data , timeout ) : log . log ( logging . DEBUG - 1 , self . CMD [ cmd_code ] + " " + hexlify ( cmd_data ) ) frame = bytearray ( [ 0xD4 , cmd_code ] ) + bytearray ( cmd_data ) frame = bytearray ( [ 0xFF , 0x00 , 0x00 , 0x00 , len ( frame ) ] ) + frame frame = self . ccid_xfr_block ( f... | Send a host command and return the chip response . |
33,391 | def format ( self , version = None , wipe = None ) : return super ( Type4Tag , self ) . format ( version , wipe ) | Erase the NDEF message on a Type 4 Tag . |
33,392 | def transceive ( self , data , timeout = None ) : log . debug ( ">> {0}" . format ( hexlify ( data ) ) ) data = self . _dep . exchange ( data , timeout ) log . debug ( "<< {0}" . format ( hexlify ( data ) if data else "None" ) ) return data | Transmit arbitrary data and receive the response . |
33,393 | def format ( self , version = None , wipe = None ) : if hasattr ( self , "_format" ) : args = "version={0!r}, wipe={1!r}" args = args . format ( version , wipe ) log . debug ( "format({0})" . format ( args ) ) status = self . _format ( version , wipe ) if status is True : self . _ndef = None return status else : log . ... | Format the tag to make it NDEF compatible or erase content . |
33,394 | def protect ( self , password = None , read_protect = False , protect_from = 0 ) : if hasattr ( self , "_protect" ) : args = "password={0!r}, read_protect={1!r}, protect_from={2!r}" args = args . format ( password , read_protect , protect_from ) log . debug ( "protect({0})" . format ( args ) ) status = self . _protect ... | Protect a tag against future write or read access . |
33,395 | def get_records ( self , records = None , timeout = 1.0 ) : octets = b'' . join ( ndef . message_encoder ( records ) ) if records else None octets = self . get_octets ( octets , timeout ) if octets and len ( octets ) >= 3 : return list ( ndef . message_decoder ( octets ) ) | Get NDEF message records from a SNEP Server . |
33,396 | def get_octets ( self , octets = None , timeout = 1.0 ) : if octets is None : octets = b'\xd0\x00\x00' if not self . socket : try : self . connect ( 'urn:nfc:sn:snep' ) except nfc . llcp . ConnectRefused : return None else : self . release_connection = True else : self . release_connection = False try : request = struc... | Get NDEF message octets from a SNEP Server . |
33,397 | def put ( self , ndef_message , timeout = 1.0 ) : if not self . socket : try : self . connect ( 'urn:nfc:sn:snep' ) except nfc . llcp . ConnectRefused : return False else : self . release_connection = True else : self . release_connection = False try : ndef_msgsize = struct . pack ( '>L' , len ( str ( ndef_message ) ) ... | Send an NDEF message to the server . Temporarily connects to the default SNEP server if the client is not yet connected . |
33,398 | def put_records ( self , records , timeout = 1.0 ) : octets = b'' . join ( ndef . message_encoder ( records ) ) return self . put_octets ( octets , timeout ) | Send NDEF message records to a SNEP Server . |
33,399 | def sense_ttb ( self , target ) : log . debug ( "polling for NFC-B technology" ) if target . brty not in ( "106B" , "212B" , "424B" ) : message = "unsupported bitrate {0}" . format ( target . brty ) raise nfc . clf . UnsupportedTargetError ( message ) self . chipset . in_set_rf ( target . brty ) self . chipset . in_set... | Sense for a Type B Target is supported for 106 212 and 424 kbps . However there may not be any target that understands the activation command in other than 106 kbps . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.