idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
40,500 | def _GetEnableOsLoginValue ( self , metadata_dict ) : instance_data , project_data = self . _GetInstanceAndProjectAttributes ( metadata_dict ) instance_value = instance_data . get ( 'enable-oslogin' ) project_value = project_data . get ( 'enable-oslogin' ) value = instance_value or project_value or '' return value . lo... | Get the value of the enable - oslogin metadata key . |
40,501 | def HandleAccounts ( self , result ) : self . logger . debug ( 'Checking for changes to user accounts.' ) configured_users = self . utils . GetConfiguredUsers ( ) enable_oslogin = self . _GetEnableOsLoginValue ( result ) enable_two_factor = self . _GetEnableTwoFactorValue ( result ) if enable_oslogin : desired_users = ... | Called when there are changes to the contents of the metadata server . |
40,502 | def _SetSELinuxContext ( path ) : restorecon = '/sbin/restorecon' if os . path . isfile ( restorecon ) and os . access ( restorecon , os . X_OK ) : subprocess . call ( [ restorecon , path ] ) | Set the appropriate SELinux context if SELinux tools are installed . |
40,503 | def SetPermissions ( path , mode = None , uid = None , gid = None , mkdir = False ) : if mkdir and not os . path . exists ( path ) : os . mkdir ( path , mode or 0o777 ) elif mode : os . chmod ( path , mode ) if uid and gid : os . chown ( path , uid , gid ) _SetSELinuxContext ( path ) | Set the permissions and ownership of a path . |
40,504 | def Lock ( fd , path , blocking ) : operation = fcntl . LOCK_EX if blocking else fcntl . LOCK_EX | fcntl . LOCK_NB try : fcntl . flock ( fd , operation ) except IOError as e : if e . errno == errno . EWOULDBLOCK : raise IOError ( 'Exception locking %s. File already locked.' % path ) else : raise IOError ( 'Exception lo... | Lock the provided file descriptor . |
40,505 | def Unlock ( fd , path ) : try : fcntl . flock ( fd , fcntl . LOCK_UN | fcntl . LOCK_NB ) except IOError as e : if e . errno == errno . EWOULDBLOCK : raise IOError ( 'Exception unlocking %s. Locked by another process.' % path ) else : raise IOError ( 'Exception unlocking %s. %s.' % ( path , str ( e ) ) ) | Release the lock on the file . |
40,506 | def LockFile ( path , blocking = False ) : fd = os . open ( path , os . O_CREAT ) try : Lock ( fd , path , blocking ) yield finally : try : Unlock ( fd , path ) finally : os . close ( fd ) | Interface to flock - based file locking to prevent concurrent executions . |
40,507 | def RetryOnUnavailable ( func ) : @ functools . wraps ( func ) def Wrapper ( * args , ** kwargs ) : while True : try : response = func ( * args , ** kwargs ) except ( httpclient . HTTPException , socket . error , urlerror . URLError ) as e : time . sleep ( 5 ) if ( isinstance ( e , urlerror . HTTPError ) and e . getcod... | Function decorator to retry on a service unavailable exception . |
40,508 | def _GetMetadataRequest ( self , metadata_url , params = None , timeout = None ) : headers = { 'Metadata-Flavor' : 'Google' } params = urlparse . urlencode ( params or { } ) url = '%s?%s' % ( metadata_url , params ) request = urlrequest . Request ( url , headers = headers ) request_opener = urlrequest . build_opener ( ... | Performs a GET request with the metadata headers . |
40,509 | def _UpdateEtag ( self , response ) : etag = response . headers . get ( 'etag' , self . etag ) etag_updated = self . etag != etag self . etag = etag return etag_updated | Update the etag from an API response . |
40,510 | def _GetMetadataUpdate ( self , metadata_key = '' , recursive = True , wait = True , timeout = None ) : metadata_key = os . path . join ( metadata_key , '' ) if recursive else metadata_key metadata_url = os . path . join ( METADATA_SERVER , metadata_key ) params = { 'alt' : 'json' , 'last_etag' : self . etag , 'recursi... | Request the contents of metadata server and deserialize the response . |
40,511 | def _HandleMetadataUpdate ( self , metadata_key = '' , recursive = True , wait = True , timeout = None , retry = True ) : exception = None while True : try : return self . _GetMetadataUpdate ( metadata_key = metadata_key , recursive = recursive , wait = wait , timeout = timeout ) except ( httpclient . HTTPException , s... | Wait for a successful metadata response . |
40,512 | def WatchMetadata ( self , handler , metadata_key = '' , recursive = True , timeout = None ) : while True : response = self . _HandleMetadataUpdate ( metadata_key = metadata_key , recursive = recursive , wait = True , timeout = timeout ) try : handler ( response ) except Exception as e : self . logger . exception ( 'Ex... | Watch for changes to the contents of the metadata server . |
40,513 | def GetMetadata ( self , metadata_key = '' , recursive = True , timeout = None , retry = True ) : return self . _HandleMetadataUpdate ( metadata_key = metadata_key , recursive = recursive , wait = False , timeout = timeout , retry = retry ) | Retrieve the contents of metadata server for a metadata key . |
40,514 | def _LogForwardedIpChanges ( self , configured , desired , to_add , to_remove , interface ) : if not to_add and not to_remove : return self . logger . info ( 'Changing %s IPs from %s to %s by adding %s and removing %s.' , interface , configured or None , desired or None , to_add or None , to_remove or None ) | Log the planned IP address changes . |
40,515 | def _AddForwardedIps ( self , forwarded_ips , interface ) : for address in forwarded_ips : self . ip_forwarding_utils . AddForwardedIp ( address , interface ) | Configure the forwarded IP address on the network interface . |
40,516 | def _RemoveForwardedIps ( self , forwarded_ips , interface ) : for address in forwarded_ips : self . ip_forwarding_utils . RemoveForwardedIp ( address , interface ) | Remove the forwarded IP addresses from the network interface . |
40,517 | def HandleForwardedIps ( self , interface , forwarded_ips , interface_ip = None ) : desired = self . ip_forwarding_utils . ParseForwardedIps ( forwarded_ips ) configured = self . ip_forwarding_utils . GetForwardedIps ( interface , interface_ip ) to_add = sorted ( set ( desired ) - set ( configured ) ) to_remove = sorte... | Handle changes to the forwarded IPs on a network interface . |
40,518 | def _WriteIfcfg ( self , interfaces , logger ) : for interface in interfaces : interface_config = os . path . join ( self . network_path , 'ifcfg-%s' % interface ) interface_content = [ '# Added by Google.' , 'STARTMODE=hotplug' , 'BOOTPROTO=dhcp' , 'DHCLIENT_SET_DEFAULT_ROUTE=yes' , 'DHCLIENT_ROUTE_PRIORITY=10%s00' % ... | Write ifcfg files for multi - NIC support . |
40,519 | def _Ifup ( self , interfaces , logger ) : ifup = [ '/usr/sbin/wicked' , 'ifup' , '--timeout' , '1' ] try : subprocess . check_call ( ifup + interfaces ) except subprocess . CalledProcessError : logger . warning ( 'Could not activate interfaces %s.' , interfaces ) | Activate network interfaces . |
40,520 | def HandleNetworkInterfaces ( self , result ) : network_interfaces = self . _ExtractInterfaceMetadata ( result ) if self . network_setup_enabled : self . network_setup . EnableNetworkInterfaces ( [ interface . name for interface in network_interfaces [ 1 : ] ] ) for interface in network_interfaces : if self . ip_forwar... | Called when network interface metadata changes . |
40,521 | def _ExtractInterfaceMetadata ( self , metadata ) : interfaces = [ ] for network_interface in metadata : mac_address = network_interface . get ( 'mac' ) interface = self . network_utils . GetNetworkInterface ( mac_address ) ip_addresses = [ ] if interface : ip_addresses . extend ( network_interface . get ( 'forwardedIp... | Extracts network interface metadata . |
40,522 | def _build_url ( self , query_params ) : url = '' count = 0 while count < len ( self . _url_path ) : url += '/{}' . format ( self . _url_path [ count ] ) count += 1 if self . append_slash : url += '/' if query_params : url_values = urlencode ( sorted ( query_params . items ( ) ) , True ) url = '{}?{}' . format ( url , ... | Build the final URL to be passed to urllib |
40,523 | def _build_client ( self , name = None ) : url_path = self . _url_path + [ name ] if name else self . _url_path return Client ( host = self . host , version = self . _version , request_headers = self . request_headers , url_path = url_path , append_slash = self . append_slash , timeout = self . timeout ) | Make a new Client object |
40,524 | def _make_request ( self , opener , request , timeout = None ) : timeout = timeout or self . timeout try : return opener . open ( request , timeout = timeout ) except HTTPError as err : exc = handle_error ( err ) exc . __cause__ = None raise exc | Make the API call and return the response . This is separated into it s own function so we can mock it easily for testing . |
40,525 | def category ( msg ) : if common . typecode ( msg ) < 1 or common . typecode ( msg ) > 4 : raise RuntimeError ( "%s: Not a identification message" % msg ) msgbin = common . hex2bin ( msg ) return common . bin2int ( msgbin [ 5 : 8 ] ) | Aircraft category number |
40,526 | def airborne_position ( msg0 , msg1 , t0 , t1 ) : mb0 = common . hex2bin ( msg0 ) [ 32 : ] mb1 = common . hex2bin ( msg1 ) [ 32 : ] cprlat_even = common . bin2int ( mb0 [ 22 : 39 ] ) / 131072.0 cprlon_even = common . bin2int ( mb0 [ 39 : 56 ] ) / 131072.0 cprlat_odd = common . bin2int ( mb1 [ 22 : 39 ] ) / 131072.0 cpr... | Decode airborn position from a pair of even and odd position message |
40,527 | def airborne_position_with_ref ( msg , lat_ref , lon_ref ) : mb = common . hex2bin ( msg ) [ 32 : ] cprlat = common . bin2int ( mb [ 22 : 39 ] ) / 131072.0 cprlon = common . bin2int ( mb [ 39 : 56 ] ) / 131072.0 i = int ( mb [ 21 ] ) d_lat = 360.0 / 59 if i else 360.0 / 60 j = common . floor ( lat_ref / d_lat ) + commo... | Decode airborne position with only one message knowing reference nearby location such as previously calculated location ground station or airport location etc . The reference position shall be with in 180NM of the true position . |
40,528 | def hex2bin ( hexstr ) : num_of_bits = len ( hexstr ) * 4 binstr = bin ( int ( hexstr , 16 ) ) [ 2 : ] . zfill ( int ( num_of_bits ) ) return binstr | Convert a hexdecimal string to binary string with zero fillings . |
40,529 | def icao ( msg ) : DF = df ( msg ) if DF in ( 11 , 17 , 18 ) : addr = msg [ 2 : 8 ] elif DF in ( 0 , 4 , 5 , 16 , 20 , 21 ) : c0 = bin2int ( crc ( msg , encode = True ) ) c1 = hex2int ( msg [ - 6 : ] ) addr = '%06X' % ( c0 ^ c1 ) else : addr = None return addr | Calculate the ICAO address from an Mode - S message with DF4 DF5 DF20 DF21 |
40,530 | def gray2int ( graystr ) : num = bin2int ( graystr ) num ^= ( num >> 8 ) num ^= ( num >> 4 ) num ^= ( num >> 2 ) num ^= ( num >> 1 ) return num | Convert greycode to binary |
40,531 | def allzeros ( msg ) : d = hex2bin ( data ( msg ) ) if bin2int ( d ) > 0 : return False else : return True | check if the data bits are all zeros |
40,532 | def wrongstatus ( data , sb , msb , lsb ) : status = int ( data [ sb - 1 ] ) value = bin2int ( data [ msb - 1 : lsb ] ) if not status : if value != 0 : return True return False | Check if the status bit and field bits are consistency . This Function is used for checking BDS code versions . |
40,533 | def version ( msg ) : tc = typecode ( msg ) if tc != 31 : raise RuntimeError ( "%s: Not a status operation message, expecting TC = 31" % msg ) msgbin = common . hex2bin ( msg ) version = common . bin2int ( msgbin [ 72 : 75 ] ) return version | ADS - B Version |
40,534 | def nic_v1 ( msg , NICs ) : if typecode ( msg ) < 5 or typecode ( msg ) > 22 : raise RuntimeError ( "%s: Not a surface position message (5<TC<8), \ airborne position message (8<TC<19), \ or airborne position with GNSS height (20<TC<22)" % msg ) tc = typecode ( msg ) NIC = uncertainty . TC_NICv1_lo... | Calculate NIC navigation integrity category for ADS - B version 1 |
40,535 | def nic_v2 ( msg , NICa , NICbc ) : if typecode ( msg ) < 5 or typecode ( msg ) > 22 : raise RuntimeError ( "%s: Not a surface position message (5<TC<8), \ airborne position message (8<TC<19), \ or airborne position with GNSS height (20<TC<22)" % msg ) tc = typecode ( msg ) NIC = uncertainty . TC_... | Calculate NIC navigation integrity category for ADS - B version 2 |
40,536 | def nic_s ( msg ) : tc = typecode ( msg ) if tc != 31 : raise RuntimeError ( "%s: Not a status operation message, expecting TC = 31" % msg ) msgbin = common . hex2bin ( msg ) nic_s = int ( msgbin [ 75 ] ) return nic_s | Obtain NIC supplement bit TC = 31 message |
40,537 | def nic_b ( msg ) : tc = typecode ( msg ) if tc < 9 or tc > 18 : raise RuntimeError ( "%s: Not a airborne position message, expecting 8<TC<19" % msg ) msgbin = common . hex2bin ( msg ) nic_b = int ( msgbin [ 39 ] ) return nic_b | Obtain NICb navigation integrity category supplement - b |
40,538 | def nac_p ( msg ) : tc = typecode ( msg ) if tc not in [ 29 , 31 ] : raise RuntimeError ( "%s: Not a target state and status message, \ or operation status message, expecting TC = 29 or 31" % msg ) msgbin = common . hex2bin ( msg ) if tc == 29 : NACp = common . bin2int ( msgbin [ 71 : 75 ] ) e... | Calculate NACp Navigation Accuracy Category - Position |
40,539 | def nac_v ( msg ) : tc = typecode ( msg ) if tc != 19 : raise RuntimeError ( "%s: Not an airborne velocity message, expecting TC = 19" % msg ) msgbin = common . hex2bin ( msg ) NACv = common . bin2int ( msgbin [ 42 : 45 ] ) try : HFOMr = uncertainty . NACv [ NACv ] [ 'HFOMr' ] VFOMr = uncertainty . NACv [ NACv ] [ 'VFO... | Calculate NACv Navigation Accuracy Category - Velocity |
40,540 | def sil ( msg , version ) : tc = typecode ( msg ) if tc not in [ 29 , 31 ] : raise RuntimeError ( "%s: Not a target state and status messag, \ or operation status message, expecting TC = 29 or 31" % msg ) msgbin = common . hex2bin ( msg ) if tc == 29 : SIL = common . bin2int ( msgbin [ 76 : 78... | Calculate SIL Surveillance Integrity Level |
40,541 | def roll50 ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 0 ] == '0' : return None sign = int ( d [ 1 ] ) value = bin2int ( d [ 2 : 11 ] ) if sign : value = value - 512 angle = value * 45.0 / 256.0 return round ( angle , 1 ) | Roll angle BDS 5 0 message |
40,542 | def trk50 ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 11 ] == '0' : return None sign = int ( d [ 12 ] ) value = bin2int ( d [ 13 : 23 ] ) if sign : value = value - 1024 trk = value * 90.0 / 512.0 if trk < 0 : trk = 360 + trk return round ( trk , 3 ) | True track angle BDS 5 0 message |
40,543 | def gs50 ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 23 ] == '0' : return None spd = bin2int ( d [ 24 : 34 ] ) * 2 return spd | Ground speed BDS 5 0 message |
40,544 | def tas50 ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 45 ] == '0' : return None tas = bin2int ( d [ 46 : 56 ] ) * 2 return tas | Aircraft true airspeed BDS 5 0 message |
40,545 | def ias53 ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 12 ] == '0' : return None ias = bin2int ( d [ 13 : 23 ] ) return ias | Indicated airspeed DBS 5 3 message |
40,546 | def mach53 ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 23 ] == '0' : return None mach = bin2int ( d [ 24 : 33 ] ) * 0.008 return round ( mach , 3 ) | MACH number DBS 5 3 message |
40,547 | def tas53 ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 33 ] == '0' : return None tas = bin2int ( d [ 34 : 46 ] ) * 0.5 return round ( tas , 1 ) | Aircraft true airspeed BDS 5 3 message |
40,548 | def read_skysense_buffer ( self ) : SS_MSGLENGTH = 24 SS_STARTCHAR = 0x24 if len ( self . buffer ) <= SS_MSGLENGTH : return None messages = [ ] while len ( self . buffer ) > SS_MSGLENGTH : i = 0 if self . buffer [ i ] == SS_STARTCHAR and self . buffer [ i + SS_MSGLENGTH ] == SS_STARTCHAR : i += 1 if ( self . buffer [ i... | Skysense stream format . |
40,549 | def is10 ( msg ) : if allzeros ( msg ) : return False d = hex2bin ( data ( msg ) ) if d [ 0 : 8 ] != '00010000' : return False if bin2int ( d [ 9 : 14 ] ) != 0 : return False if d [ 14 ] == '1' and bin2int ( d [ 16 : 23 ] ) < 5 : return False if d [ 14 ] == '0' and bin2int ( d [ 16 : 23 ] ) > 4 : return False return Tr... | Check if a message is likely to be BDS code 1 0 |
40,550 | def is17 ( msg ) : if allzeros ( msg ) : return False d = hex2bin ( data ( msg ) ) if bin2int ( d [ 28 : 56 ] ) != 0 : return False caps = cap17 ( msg ) if 'BDS20' not in caps : return False return True | Check if a message is likely to be BDS code 1 7 |
40,551 | def cap17 ( msg ) : allbds = [ '05' , '06' , '07' , '08' , '09' , '0A' , '20' , '21' , '40' , '41' , '42' , '43' , '44' , '45' , '48' , '50' , '51' , '52' , '53' , '54' , '55' , '56' , '5F' , '60' , 'NA' , 'NA' , 'E1' , 'E2' ] d = hex2bin ( data ( msg ) ) idx = [ i for i , v in enumerate ( d [ : 28 ] ) if v == '1' ] ca... | Extract capacities from BDS 1 7 message |
40,552 | def get_aircraft ( self ) : acs = self . acs icaos = list ( acs . keys ( ) ) for icao in icaos : if acs [ icao ] [ 'lat' ] is None : acs . pop ( icao ) return acs | all aircraft that are stored in memeory |
40,553 | def altitude_diff ( msg ) : tc = common . typecode ( msg ) if tc != 19 : raise RuntimeError ( "%s: Not a airborne velocity message, expecting TC=19" % msg ) msgbin = common . hex2bin ( msg ) sign = - 1 if int ( msgbin [ 80 ] ) else 1 value = common . bin2int ( msgbin [ 81 : 88 ] ) if value == 0 or value == 127 : return... | Decode the differece between GNSS and barometric altitude |
40,554 | def is50or60 ( msg , spd_ref , trk_ref , alt_ref ) : def vxy ( v , angle ) : vx = v * np . sin ( np . radians ( angle ) ) vy = v * np . cos ( np . radians ( angle ) ) return vx , vy if not ( bds50 . is50 ( msg ) and bds60 . is60 ( msg ) ) : return None h50 = bds50 . trk50 ( msg ) v50 = bds50 . gs50 ( msg ) if h50 is No... | Use reference ground speed and trk to determine BDS50 and DBS60 . |
40,555 | def infer ( msg , mrar = False ) : df = common . df ( msg ) if common . allzeros ( msg ) : return 'EMPTY' if df == 17 : tc = common . typecode ( msg ) if 1 <= tc <= 4 : return 'BDS08' if 5 <= tc <= 8 : return 'BDS06' if 9 <= tc <= 18 : return 'BDS05' if tc == 19 : return 'BDS09' if 20 <= tc <= 22 : return 'BDS05' if tc... | Estimate the most likely BDS code of an message . |
40,556 | def is40 ( msg ) : if allzeros ( msg ) : return False d = hex2bin ( data ( msg ) ) if wrongstatus ( d , 1 , 2 , 13 ) : return False if wrongstatus ( d , 14 , 15 , 26 ) : return False if wrongstatus ( d , 27 , 28 , 39 ) : return False if wrongstatus ( d , 48 , 49 , 51 ) : return False if wrongstatus ( d , 54 , 55 , 56 )... | Check if a message is likely to be BDS code 4 0 |
40,557 | def alt40fms ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 13 ] == '0' : return None alt = bin2int ( d [ 14 : 26 ] ) * 16 return alt | Selected altitude FMS |
40,558 | def p40baro ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 26 ] == '0' : return None p = bin2int ( d [ 27 : 39 ] ) * 0.1 + 800 return p | Barometric pressure setting |
40,559 | def is44 ( msg ) : if allzeros ( msg ) : return False d = hex2bin ( data ( msg ) ) if wrongstatus ( d , 5 , 6 , 23 ) : return False if wrongstatus ( d , 35 , 36 , 46 ) : return False if wrongstatus ( d , 47 , 48 , 49 ) : return False if wrongstatus ( d , 50 , 51 , 56 ) : return False if bin2int ( d [ 0 : 4 ] ) > 4 : re... | Check if a message is likely to be BDS code 4 4 . |
40,560 | def wind44 ( msg ) : d = hex2bin ( data ( msg ) ) status = int ( d [ 4 ] ) if not status : return None speed = bin2int ( d [ 5 : 14 ] ) direction = bin2int ( d [ 14 : 23 ] ) * 180.0 / 256.0 return round ( speed , 0 ) , round ( direction , 1 ) | Wind speed and direction . |
40,561 | def p44 ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 34 ] == '0' : return None p = bin2int ( d [ 35 : 46 ] ) return p | Static pressure . |
40,562 | def is60 ( msg ) : if allzeros ( msg ) : return False d = hex2bin ( data ( msg ) ) if wrongstatus ( d , 1 , 2 , 12 ) : return False if wrongstatus ( d , 13 , 14 , 23 ) : return False if wrongstatus ( d , 24 , 25 , 34 ) : return False if wrongstatus ( d , 35 , 36 , 45 ) : return False if wrongstatus ( d , 46 , 47 , 56 )... | Check if a message is likely to be BDS code 6 0 |
40,563 | def hdg60 ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 0 ] == '0' : return None sign = int ( d [ 1 ] ) value = bin2int ( d [ 2 : 12 ] ) if sign : value = value - 1024 hdg = value * 90 / 512.0 if hdg < 0 : hdg = 360 + hdg return round ( hdg , 3 ) | Megnetic heading of aircraft |
40,564 | def mach60 ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 23 ] == '0' : return None mach = bin2int ( d [ 24 : 34 ] ) * 2.048 / 512.0 return round ( mach , 3 ) | Aircraft MACH number |
40,565 | def vr60baro ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 34 ] == '0' : return None sign = int ( d [ 35 ] ) value = bin2int ( d [ 36 : 45 ] ) if value == 0 or value == 511 : return 0 value = value - 512 if sign else value roc = value * 32 return roc | Vertical rate from barometric measurement this value may be very noisy . |
40,566 | def is45 ( msg ) : if allzeros ( msg ) : return False d = hex2bin ( data ( msg ) ) if wrongstatus ( d , 1 , 2 , 3 ) : return False if wrongstatus ( d , 4 , 5 , 6 ) : return False if wrongstatus ( d , 7 , 8 , 9 ) : return False if wrongstatus ( d , 10 , 11 , 12 ) : return False if wrongstatus ( d , 13 , 14 , 15 ) : retu... | Check if a message is likely to be BDS code 4 5 . |
40,567 | def ws45 ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 3 ] == '0' : return None ws = bin2int ( d [ 4 : 6 ] ) return ws | Wind shear . |
40,568 | def wv45 ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 12 ] == '0' : return None ws = bin2int ( d [ 13 : 15 ] ) return ws | Wake vortex . |
40,569 | def p45 ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 26 ] == '0' : return None p = bin2int ( d [ 27 : 38 ] ) return p | Average static pressure . |
40,570 | def rh45 ( msg ) : d = hex2bin ( data ( msg ) ) if d [ 38 ] == '0' : return None rh = bin2int ( d [ 39 : 51 ] ) * 16 return rh | Radio height . |
40,571 | def vsound ( H ) : T = temperature ( H ) a = np . sqrt ( gamma * R * T ) return a | Speed of sound |
40,572 | def distance ( lat1 , lon1 , lat2 , lon2 , H = 0 ) : phi1 = np . radians ( 90.0 - lat1 ) phi2 = np . radians ( 90.0 - lat2 ) theta1 = np . radians ( lon1 ) theta2 = np . radians ( lon2 ) cos = np . sin ( phi1 ) * np . sin ( phi2 ) * np . cos ( theta1 - theta2 ) + np . cos ( phi1 ) * np . cos ( phi2 ) cos = np . where (... | Compute spherical distance from spherical coordinates . |
40,573 | def tas2mach ( Vtas , H ) : a = vsound ( H ) Mach = Vtas / a return Mach | True Airspeed to Mach number |
40,574 | def mach2tas ( Mach , H ) : a = vsound ( H ) Vtas = Mach * a return Vtas | Mach number to True Airspeed |
40,575 | def tas2eas ( Vtas , H ) : rho = density ( H ) Veas = Vtas * np . sqrt ( rho / rho0 ) return Veas | True Airspeed to Equivalent Airspeed |
40,576 | def cas2tas ( Vcas , H ) : p , rho , T = atmos ( H ) qdyn = p0 * ( ( 1. + rho0 * Vcas * Vcas / ( 7. * p0 ) ) ** 3.5 - 1. ) Vtas = np . sqrt ( 7. * p / rho * ( ( 1. + qdyn / p ) ** ( 2. / 7. ) - 1. ) ) return Vtas | Calibrated Airspeed to True Airspeed |
40,577 | def mach2cas ( Mach , H ) : Vtas = mach2tas ( Mach , H ) Vcas = tas2cas ( Vtas , H ) return Vcas | Mach number to Calibrated Airspeed |
40,578 | def cas2mach ( Vcas , H ) : Vtas = cas2tas ( Vcas , H ) Mach = tas2mach ( Vtas , H ) return Mach | Calibrated Airspeed to Mach number |
40,579 | def markdown_search_user ( request ) : data = { } username = request . GET . get ( 'username' ) if username is not None and username != '' and ' ' not in username : users = User . objects . filter ( Q ( username__icontains = username ) ) . filter ( is_active = True ) if users . exists ( ) : data . update ( { 'status' :... | Json usernames of the users registered & actived . |
40,580 | def handleMatch ( self , m ) : username = self . unescape ( m . group ( 2 ) ) if MARTOR_ENABLE_CONFIGS [ 'mention' ] == 'true' : if username in [ u . username for u in User . objects . exclude ( is_active = False ) ] : url = '{0}{1}/' . format ( MARTOR_MARKDOWN_BASE_MENTION_URL , username ) el = markdown . util . etree... | Makesure username is registered and actived . |
40,581 | def markdownify ( markdown_content ) : try : return markdown . markdown ( markdown_content , safe_mode = MARTOR_MARKDOWN_SAFE_MODE , extensions = MARTOR_MARKDOWN_EXTENSIONS , extension_configs = MARTOR_MARKDOWN_EXTENSION_CONFIGS ) except Exception : raise VersionNotCompatible ( "The markdown isn't compatible, please re... | Render the markdown content to HTML . |
40,582 | def get_entry_url ( entry , blog_page , root_page ) : if root_page == blog_page : return reverse ( 'entry_page_serve' , kwargs = { 'year' : entry . date . strftime ( '%Y' ) , 'month' : entry . date . strftime ( '%m' ) , 'day' : entry . date . strftime ( '%d' ) , 'slug' : entry . slug } ) else : blog_path = strip_prefix... | Get the entry url given and entry page a blog page instances . It will use an url or another depending if blog_page is the root page . |
40,583 | def get_feeds_url ( blog_page , root_page ) : if root_page == blog_page : return reverse ( 'blog_page_feed' ) else : blog_path = strip_prefix_and_ending_slash ( blog_page . specific . last_url_part ) return reverse ( 'blog_page_feed_slug' , kwargs = { 'blog_path' : blog_path } ) | Get the feeds urls a blog page instance . It will use an url or another depending if blog_page is the root page . |
40,584 | def install_dependencies ( dependencies , verbose = False ) : if not dependencies : return stdout = stderr = None if verbose else subprocess . DEVNULL with tempfile . TemporaryDirectory ( ) as req_dir : req_file = Path ( req_dir ) / "requirements.txt" with open ( req_file , "w" ) as f : for dependency in dependencies :... | Install all packages in dependency list via pip . |
40,585 | def install_translations ( config ) : if not config : return from . import _translation checks_translation = gettext . translation ( domain = config [ "domain" ] , localedir = internal . check_dir / config [ "localedir" ] , fallback = True ) _translation . add_fallback ( checks_translation ) | Add check translations according to config as a fallback to existing translations |
40,586 | def hash ( file ) : exists ( file ) log ( _ ( "hashing {}..." ) . format ( file ) ) with open ( file , "rb" ) as f : sha256 = hashlib . sha256 ( ) for block in iter ( lambda : f . read ( 65536 ) , b"" ) : sha256 . update ( block ) return sha256 . hexdigest ( ) | Hashes file using SHA - 256 . |
40,587 | def exists ( * paths ) : for path in paths : log ( _ ( "checking that {} exists..." ) . format ( path ) ) if not os . path . exists ( path ) : raise Failure ( _ ( "{} not found" ) . format ( path ) ) | Assert that all given paths exist . |
40,588 | def import_checks ( path ) : dir = internal . check_dir / path file = internal . load_config ( dir ) [ "checks" ] mod = internal . import_file ( dir . name , ( dir / file ) . resolve ( ) ) sys . modules [ dir . name ] = mod return mod | Import checks module given relative path . |
40,589 | def _raw ( s ) : if isinstance ( s , list ) : s = "\n" . join ( _raw ( item ) for item in s ) if s == EOF : return "EOF" s = repr ( s ) s = s [ 1 : - 1 ] if len ( s ) > 15 : s = s [ : 15 ] + "..." return s | Get raw representation of s truncating if too long . |
40,590 | def _copy ( src , dst ) : try : shutil . copy ( src , dst ) except IsADirectoryError : if os . path . isdir ( dst ) : dst = os . path . join ( dst , os . path . basename ( src ) ) shutil . copytree ( src , dst ) | Copy src to dst copying recursively if src is a directory . |
40,591 | def stdin ( self , line , prompt = True , timeout = 3 ) : if line == EOF : log ( "sending EOF..." ) else : log ( _ ( "sending input {}..." ) . format ( line ) ) if prompt : try : self . process . expect ( ".+" , timeout = timeout ) except ( TIMEOUT , EOF ) : raise Failure ( _ ( "expected prompt for input, found none" )... | Send line to stdin optionally expect a prompt . |
40,592 | def reject ( self , timeout = 1 ) : log ( _ ( "checking that input was rejected..." ) ) try : self . _wait ( timeout ) except Failure as e : if not isinstance ( e . __cause__ , TIMEOUT ) : raise else : raise Failure ( _ ( "expected program to reject input, but it did not" ) ) return self | Check that the process survives for timeout . Useful for checking whether program is waiting on input . |
40,593 | def import_file ( name , path ) : spec = importlib . util . spec_from_file_location ( name , path ) mod = importlib . util . module_from_spec ( spec ) spec . loader . exec_module ( mod ) return mod | Import a file given a raw file path . |
40,594 | def compile ( * files , exe_name = None , cc = CC , ** cflags ) : if not files : raise RuntimeError ( _ ( "compile requires at least one file" ) ) if exe_name is None and files [ 0 ] . endswith ( ".c" ) : exe_name = Path ( files [ 0 ] ) . stem files = " " . join ( files ) flags = CFLAGS . copy ( ) flags . update ( cfla... | Compile C source files . |
40,595 | def valgrind ( command , env = { } ) : xml_file = tempfile . NamedTemporaryFile ( ) internal . register . after_check ( lambda : _check_valgrind ( xml_file ) ) return run ( f"valgrind --show-leak-kinds=all --xml=yes --xml-file={xml_file.name} -- {command}" , env = env ) | Run a command with valgrind . |
40,596 | def _check_valgrind ( xml_file ) : log ( _ ( "checking for valgrind errors..." ) ) xml = ET . ElementTree ( file = xml_file ) reported = set ( ) for error in xml . iterfind ( "error" ) : kind = error . find ( "kind" ) . text what = error . find ( "xwhat/text" if kind . startswith ( "Leak_" ) else "what" ) . text msg = ... | Log and report any errors encountered by valgrind . |
40,597 | def _timeout ( seconds ) : def _handle_timeout ( * args ) : raise Timeout ( seconds ) signal . signal ( signal . SIGALRM , _handle_timeout ) signal . alarm ( seconds ) try : yield finally : signal . alarm ( 0 ) signal . signal ( signal . SIGALRM , signal . SIG_DFL ) | Context manager that runs code block until timeout is reached . |
40,598 | def run ( self , files , working_area ) : results = { name : None for name in self . check_names } checks_root = working_area . parent with futures . ProcessPoolExecutor ( ) as executor : not_done = set ( executor . submit ( run_check ( name , self . checks_spec , checks_root ) ) for name , _ in self . child_map [ None... | Run checks concurrently . Returns a list of CheckResults ordered by declaration order of the checks in the imported module |
40,599 | def append_code ( original , codefile ) : with open ( codefile ) as code , open ( original , "a" ) as o : o . write ( "\n" ) o . writelines ( code ) | Append the contents of one file to another . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.