idx int64 0 252k | question stringlengths 48 5.28k | target stringlengths 5 1.23k |
|---|---|---|
6,400 | def crashlog_clean ( name , timestamp , size , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'crashlog:clean' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , 'size' : size , 'timestamp' : timestamp , } ) | For application NAME leave SIZE crashlogs or remove all crashlogs with timestamp > TIMESTAMP . |
6,401 | def crashlog_cleanrange ( from_day , up_to_day , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'crashlog:cleanwhen' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'from_day' : from_day , 'to_day' : up_to_day , } ) | Remove all crashlogs from one date up to another . |
6,402 | def group_list ( ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'group:list' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , } ) | Show available routing groups . |
6,403 | def group_view ( name , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'group:view' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , } ) | Show specified routing group . |
6,404 | def group_create ( name , content , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'group:create' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , 'content' : content , } ) | Create routing group . |
6,405 | def group_remove ( name , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'group:remove' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , } ) | Remove routing group from the storage . |
6,406 | def group_copy ( name , copyname , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'group:copy' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , 'copyname' : copyname , } ) | Copy routing group . |
6,407 | def group_refresh ( name , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'group:refresh' , ** { 'locator' : ctx . locator , 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , } ) | Refresh routing group . |
6,408 | def group_push ( name , app , weight , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'group:app:add' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , 'app' : app , 'weight' : weight , } ) | Add application with its weight into the routing group . |
6,409 | def group_pop ( name , app , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'group:app:remove' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , 'app' : app , } ) | Remove application from the specified routing group . |
6,410 | def unicorn_edit ( path , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . timeout = None ctx . execute_action ( 'unicorn:edit' , ** { 'unicorn' : ctx . repo . create_secure_service ( 'unicorn' ) , 'path' : path , } ) | Edit Unicorn node interactively . |
6,411 | def logging_list_loggers ( ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'logging:list_loggers' , ** { 'logging_service' : ctx . repo . create_secure_service ( 'logging' ) , } ) | List all registered logger names . |
6,412 | def logging_set_filter ( name , filter_def , ttl , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'logging:set_filter' , ** { 'logging_service' : ctx . repo . create_secure_service ( 'logging' ) , 'logger_name' : name , 'filter_def' : filter_def , 'ttl' : ttl , } ) | Set local filter . |
6,413 | def logging_remove_filter ( filter_id , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'logging:remove_filter' , ** { 'logging_service' : ctx . repo . create_secure_service ( 'logging' ) , 'filter_id' : filter_id , } ) | Remove filter by filter id . |
6,414 | def logging_list_filters ( ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'logging:list_filters' , ** { 'logging_service' : ctx . repo . create_secure_service ( 'logging' ) , } ) | List all available filters . |
6,415 | def auth_list ( ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'auth:group:list' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , } ) | Shows available authorization groups . |
6,416 | def auth_create ( name , token , force , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'auth:group:create' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , 'token' : token , 'force' : force , } ) | Creates an authorization group . |
6,417 | def auth_edit ( name , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . timeout = None ctx . execute_action ( 'auth:group:edit' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , } ) | Interactively edits an authorization group . |
6,418 | def auth_remove ( name , drop , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'auth:group:remove' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , 'drop' : drop , } ) | Removes an authorization group . |
6,419 | def auth_view ( name , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'auth:group:view' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , } ) | Shows an authorization group s content . |
6,420 | def auth_add ( name , service , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'auth:group:members:add' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , 'service' : service , } ) | Adds a member of an authorization group . |
6,421 | def access_storage_list ( ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'access:storage:list' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , } ) | Shows collections with ACL . |
6,422 | def access_storage_view ( name , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'access:storage:view' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , } ) | Shows ACL for the specified collection . |
6,423 | def access_storage_create ( name , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'access:storage:create' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , } ) | Creates new ACL for the specified collection . |
6,424 | def access_storage_edit ( name , cid , uid , perm , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'access:storage:edit' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , 'cids' : cid , 'uids' : uid , 'perm' : perm , } ) | Edits ACL for the specified collection . |
6,425 | def access_storage_rm ( name , yes , ** kwargs ) : if name is None : if not yes : click . confirm ( 'Are you sure you want to remove all ACL?' , abort = True ) ctx = Context ( ** kwargs ) ctx . execute_action ( 'access:storage:rm' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , 'name' : name , } ) | Remove ACL for the specified collection . |
6,426 | def access_list ( ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'access:list' , ** { 'unicorn' : ctx . repo . create_secure_service ( 'unicorn' ) , } ) | Shows services for which there are ACL specified . |
6,427 | def access_view ( name , ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'access:view' , ** { 'unicorn' : ctx . repo . create_secure_service ( 'unicorn' ) , 'service' : name , } ) | Shows ACL for the specified service . |
6,428 | def keyring_view ( ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'keyring:view' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , } ) | View saved public keys . |
6,429 | def keyring_remove ( key , yes , ** kwargs ) : if key is None : if not yes : click . confirm ( 'Are you sure you want to remove all keys?' , abort = True ) ctx = Context ( ** kwargs ) ctx . execute_action ( 'keyring:remove' , ** { 'key' : key , 'storage' : ctx . repo . create_secure_service ( 'storage' ) , } ) | Removes a public key from the keyring . |
6,430 | def keyring_edit ( ** kwargs ) : ctx = Context ( ** kwargs ) ctx . timeout = None ctx . execute_action ( 'keyring:edit' , ** { 'storage' : ctx . repo . create_secure_service ( 'storage' ) , } ) | Edits interactively the keyring . |
6,431 | def keyring_refresh ( ** kwargs ) : ctx = Context ( ** kwargs ) ctx . execute_action ( 'keyring:refresh' , ** { 'tvm' : ctx . repo . create_secure_service ( 'tvm' ) , } ) | Refresh the keyring in the cocaine - runtime . |
6,432 | def evaluate_parameter_sets ( self ) : self . parameter_interpreter = LcoptParameterSet ( self . modelInstance ) self . modelInstance . evaluated_parameter_sets = self . parameter_interpreter . evaluated_parameter_sets self . modelInstance . bw2_export_params = self . parameter_interpreter . bw2_export_params | This takes the parameter sets of the model instance and evaluates any formulas using the parameter values to create a fixed full set of parameters for each parameter set in the model |
6,433 | def create_parameter_map ( self ) : names = self . modelInstance . names db = self . modelInstance . database [ 'items' ] parameter_map = { } def get_names_index ( my_thing ) : return [ i for i , x in enumerate ( names ) if x == my_thing ] [ 0 ] for k , this_item in db . items ( ) : if this_item [ 'type' ] == 'process'... | Creates a parameter map which takes a tuple of the exchange from and exchange to codes and returns the parameter name for that exchange |
6,434 | def get_config ( override = None ) : config_path = os . path . expanduser ( '~' ) + '/.dbschema.yml' if override : config_path = override check_exists ( config_path ) with open ( config_path ) as f : config = yaml . safe_load ( f ) return config | Get config file |
6,435 | def check_exists ( path , type = 'file' ) : if type == 'file' : if not os . path . isfile ( path ) : raise RuntimeError ( 'The file `%s` does not exist.' % path ) else : if not os . path . isdir ( path ) : raise RuntimeError ( 'The folder `%s` does not exist.' % path ) return True | Check if a file or a folder exists |
6,436 | def get_connection ( engine , host , user , port , password , database , ssl = { } ) : if engine == 'mysql' : return get_mysql_connection ( host , user , port , password , database , ssl ) elif engine == 'postgresql' : return get_pg_connection ( host , user , port , password , database , ssl ) else : raise RuntimeError... | Returns a PostgreSQL or MySQL connection |
6,437 | def parse_statements ( queries_input , engine ) : queries = [ ] query = '' sql_delimiter = ';' postgres_func_delimiters = [ '$$' , '##' ] lines = queries_input . strip ( ) . split ( '\n' ) for k , line in enumerate ( lines ) : line = line . strip ( ) if not line or line . startswith ( '--' ) : continue if engine == 'my... | Parse input and return a list of SQL statements |
6,438 | def run_migration ( connection , queries , engine ) : with connection . cursor ( ) as cursorMig : queries = parse_statements ( queries , engine ) for query in queries : cursorMig . execute ( query ) connection . commit ( ) return True | Apply a migration to the SQL server |
6,439 | def save_migration ( connection , basename ) : sql = "INSERT INTO migrations_applied (name, date) VALUES (%s, NOW())" with connection . cursor ( ) as cursor : cursor . execute ( sql , ( basename , ) ) connection . commit ( ) return True | Save a migration in migrations_applied table |
6,440 | def delete_migration ( connection , basename ) : sql = "DELETE FROM migrations_applied WHERE name = %s" with connection . cursor ( ) as cursor : cursor . execute ( sql , ( basename , ) ) connection . commit ( ) return True | Delete a migration in migrations_applied table |
6,441 | def get_migrations_applied ( engine , connection ) : try : if engine == 'postgresql' : cursor = connection . cursor ( cursor_factory = psycopg2 . extras . RealDictCursor ) else : cursor = connection . cursor ( ) sql = "SELECT id, name, date FROM migrations_applied" cursor . execute ( sql ) rows = cursor . fetchall ( ) ... | Get list of migrations already applied |
6,442 | def apply_migrations ( engine , connection , path ) : migrations_applied = get_migrations_applied ( engine , connection ) for file in get_migrations_files ( path ) : basename = os . path . basename ( os . path . dirname ( file ) ) if is_applied ( migrations_applied , basename ) : continue source = get_migration_source ... | Apply all migrations in a chronological order |
6,443 | def rollback_migration ( engine , connection , path , migration_to_rollback ) : migrations_applied = get_migrations_applied ( engine , connection ) if not is_applied ( migrations_applied , migration_to_rollback ) : raise RuntimeError ( '`%s` is not in the list of previously applied migrations.' % ( migration_to_rollbac... | Rollback a migration |
6,444 | def get_ssl ( database ) : if database [ 'engine' ] == 'postgresql' : keys = [ 'sslmode' , 'sslcert' , 'sslkey' , 'sslrootcert' , 'sslcrl' , 'sslcompression' ] else : keys = [ 'ssl_ca' , 'ssl_capath' , 'ssl_cert' , 'ssl_key' , 'ssl_cipher' , 'ssl_check_hostname' ] ssl = { } for key in keys : value = database . get ( ke... | Returns SSL options for the selected engine |
6,445 | def apply ( config_override = None , tag_override = None , rollback = None , skip_missing = None ) : config = get_config ( config_override ) databases = config [ 'databases' ] if rollback and not tag_override : raise RuntimeError ( 'To rollback a migration you need to specify the database tag with `--tag`' ) for tag in... | Look thru migrations and apply them |
6,446 | def resolve ( self , authorization : http . Header ) : if authorization is None : return None scheme , token = authorization . split ( ) if scheme . lower ( ) != 'basic' : return None username , password = base64 . b64decode ( token ) . decode ( 'utf-8' ) . split ( ':' ) user = authenticate ( username = username , pass... | Determine the user associated with a request using HTTP Basic Authentication . |
6,447 | def resolve ( self , authorization : http . Header ) : from django_apistar . authentication . models import Token if authorization is None : return None scheme , token = authorization . split ( ) if scheme . lower ( ) != 'bearer' : return None try : user = Token . objects . get ( key = token ) . user except Token . Doe... | Determine the user associated with a request using Token Authentication . |
6,448 | def loop ( self ) : if not self . _loop : self . _loop = IOLoop . current ( ) return self . _loop return self . _loop | Lazy event loop initialization |
6,449 | def execute_action ( self , action_name , ** options ) : assert action_name in NG_ACTIONS , 'wrong action - {0}' . format ( action_name ) action = NG_ACTIONS [ action_name ] self . loop . run_sync ( lambda : action . execute ( ** options ) , timeout = self . timeout ) | Execute action with specified options . |
6,450 | def json2excel ( items , keys , filename , page_size = 60000 ) : wb = xlwt . Workbook ( ) rowindex = 0 sheetindex = 0 for item in items : if rowindex % page_size == 0 : sheetname = "%02d" % sheetindex ws = wb . add_sheet ( sheetname ) rowindex = 0 sheetindex += 1 colindex = 0 for key in keys : ws . write ( rowindex , c... | max_page_size is 65000 because we output old excel . xls format |
6,451 | def check_production_parameters_exist ( self ) : for k , v in self . modelInstance . parameter_sets . items ( ) : for p_id in self . modelInstance . production_params . keys ( ) : if v . get ( p_id ) : pass else : v [ p_id ] = 1.0 for p_id in self . modelInstance . allocation_params . keys ( ) : if v . get ( p_id ) : p... | old versions of models won t have produciton parameters leading to ZeroDivision errors and breaking things |
6,452 | def _create_symbol ( self , id , symbolobj ) : result = { 'id' : symbolobj . name , 'isPoint' : False , 'isStroke' : False , 'isFill' : False } matcher = Mapfile . _SYMBOL_NAME_REGEXP . match ( symbolobj . name ) if matcher : result [ 'name' ] = matcher . group ( 2 ) for c in matcher . group ( 1 ) : field = Mapfile . _... | Creates the JSON representation of a symbol |
6,453 | def translate ( pua , composed = True ) : from . encoder import PUAComposedEncoder from . encoder import PUADecomposedEncoder if composed : JamoEncoder = PUAComposedEncoder else : JamoEncoder = PUADecomposedEncoder encoder = JamoEncoder ( ) return encoder . encode ( pua , final = True ) | Convert a unicode string with Hanyang - PUA codes to a Syllable - Initial - Peak - Final encoded unicode string . |
6,454 | def codes2unicode ( codes , composed = True ) : pua = u'' . join ( unichr ( code ) for code in codes ) return translate ( pua , composed = composed ) | Convert Hanyang - PUA code iterable to Syllable - Initial - Peak - Final encoded unicode string . |
6,455 | def read ( self , len = 1024 ) : 'read up to len bytes and return them, or empty string on EOF' return self . _with_retry ( functools . partial ( self . _read_attempt , len ) , self . gettimeout ( ) ) | read up to len bytes and return them or empty string on EOF |
6,456 | def connect ( self , address ) : 'connects to the address and wraps the connection in an SSL context' tout = _timeout ( self . gettimeout ( ) ) while 1 : self . _wait_event ( tout . now , write = True ) err = self . _connect ( address , tout . now ) if err in ( errno . EINPROGRESS , errno . EALREADY , errno . EWOULDBLO... | connects to the address and wraps the connection in an SSL context |
6,457 | def accept ( self ) : while 1 : try : sock , addr = self . _sock . accept ( ) return ( type ( self ) ( sock , keyfile = self . keyfile , certfile = self . certfile , server_side = True , cert_reqs = self . cert_reqs , ssl_version = self . ssl_version , ca_certs = self . ca_certs , do_handshake_on_connect = self . do_ha... | accept a connection attempt from a remote client |
6,458 | def makefile ( self , mode = 'r' , bufsize = - 1 ) : 'return a file-like object that operates on the ssl connection' sockfile = gsock . SocketFile . __new__ ( gsock . SocketFile ) gfiles . FileBase . __init__ ( sockfile ) sockfile . _sock = self sockfile . mode = mode if bufsize > 0 : sockfile . CHUNKSIZE = bufsize ret... | return a file - like object that operates on the ssl connection |
6,459 | def run ( cont , util , shell , argv = None ) : cont . fetch_and_import ( "setup/python/setup.py" ) . run ( cont , util , shell , argv ) cmake_cont = cont . fetch_and_import ( "setup/cmake/setup.py" ) . run ( cont , util , shell , argv ) with cont . in_temp_cache_dir ( ) : with open ( "cmroot.cmake" , "w" ) as root_scr... | Set up language runtimes and pass control to python project script . |
6,460 | def get_content ( pattern , string , tag = 'content' ) : output = [ ] for match in re . finditer ( pattern , string ) : output . append ( match . group ( tag ) ) return output | Finds the content tag from a pattern in the provided string |
6,461 | def extract ( pattern , string , * , assert_equal = False , one = False , condense = False , default = None , default_if_multiple = True , default_if_none = True ) : if isinstance ( pattern , str ) : output = get_content ( pattern , string ) else : output = [ ] for p in pattern : output += get_content ( p , string ) ou... | Used to extract a given regex pattern from a string given several options |
6,462 | def extractRuntime ( runtime_dirs ) : names = [ str ( item ) for name in runtime_dirs for item in os . listdir ( name ) ] string = '\n' . join ( names ) result = extract ( RUNTIME_PATTERN , string , condense = True ) return result | Used to find the correct static lib name to pass to gcc |
6,463 | def extractVersion ( string , default = '?' ) : return extract ( VERSION_PATTERN , string , condense = True , default = default , one = True ) | Extracts a three digit standard format version number |
6,464 | def render_secrets ( config_path , secret_path , ) : with open ( secret_path , 'r' ) as s_fh : secret_ini = anyconfig . load ( s_fh , ac_parser = 'ini' ) with open ( config_path , 'r' ) as c_fh : raw_cfg = c_fh . read ( ) rendered_cfg = anytemplate . renders ( raw_cfg , secret_ini , at_engine = 'jinja2' ) p_config = Pr... | combine a jinja template with a secret . ini file |
6,465 | def check_value ( config , section , option , jinja_pattern = JINJA_PATTERN , ) : value = config [ section ] [ option ] if re . match ( jinja_pattern , value ) : return None return value | try to figure out if value is valid or jinja2 template value |
6,466 | def read_config ( config_filepath , logger = logging . getLogger ( 'ProsperCommon' ) , ) : config_parser = configparser . ConfigParser ( interpolation = ExtendedInterpolation ( ) , allow_no_value = True , delimiters = ( '=' ) , inline_comment_prefixes = ( '#' ) ) logger . debug ( 'config_filepath=%s' , config_filepath ... | fetch and parse config file |
6,467 | def get_local_config_filepath ( config_filepath , force_local = False , ) : local_config_name = path . basename ( config_filepath ) . split ( '.' ) [ 0 ] + '_local.cfg' local_config_filepath = path . join ( path . split ( config_filepath ) [ 0 ] , local_config_name ) real_config_filepath = '' if path . isfile ( local_c... | helper for finding local filepath for config |
6,468 | def get_option ( self , section_name , key_name , args_option = None , args_default = None , ) : if args_option != args_default and args_option is not None : self . logger . debug ( '-- using function args' ) return args_option section_info = section_name + '.' + key_name option = None try : option = check_value ( self... | evaluates the requested option and returns the correct value |
6,469 | def SetCredentials ( api_username , api_passwd ) : global V2_API_USERNAME global V2_API_PASSWD global _V2_ENABLED _V2_ENABLED = True V2_API_USERNAME = api_username V2_API_PASSWD = api_passwd | Establish API username and password associated with APIv2 commands . |
6,470 | def get_session ( username , password , default_endpoints = clc . defaults , cert = None ) : if cert is None : cert = API . _ResourcePath ( 'clc/cacert.pem' ) session = requests . Session ( ) request = session . request ( "POST" , "{}/v2/authentication/login" . format ( default_endpoints . ENDPOINT_URL_V2 ) , data = { ... | Start a session with the given parameters |
6,471 | def set_id ( self , pid ) : if self . type == 'KAF' : return self . node . set ( 'pid' , pid ) elif self . type == 'NAF' : return self . node . set ( 'id' , pid ) | Set the property identifier |
6,472 | def to_kaf ( self ) : if self . type == 'NAF' : for node in self . node . findall ( 'properties/property' ) : node . set ( 'pid' , node . get ( 'id' ) ) del node . attrib [ 'id' ] | Converts the element to NAF |
6,473 | def to_naf ( self ) : if self . type == 'KAF' : for node in self . node . findall ( 'properties/property' ) : node . set ( 'id' , node . get ( 'pid' ) ) del node . attrib [ 'pid' ] | Converts the element to KAF |
6,474 | def get_properties ( self ) : node_prop = self . node . find ( 'properties' ) if node_prop is not None : obj_properties = Cproperties ( node_prop , self . type ) for prop in obj_properties : yield prop | Iterator that returns all the properties of the layuer |
6,475 | def remove_properties ( self ) : node_prop = self . node . find ( 'properties' ) if node_prop is not None : self . node . remove ( node_prop ) | Removes the property layer if exists |
6,476 | def get_id ( self ) : if self . type == 'NAF' : return self . node . get ( 'id' ) elif self . type == 'KAF' : return self . node . get ( 'mid' ) | Returns the term identifier |
6,477 | def set_id ( self , i ) : if self . type == 'NAF' : self . node . set ( 'id' , i ) elif self . type == 'KAF' : self . node . set ( 'mid' , i ) | Sets the identifier for the term |
6,478 | def add_external_reference ( self , ext_ref ) : ext_refs_node = self . node . find ( 'externalReferences' ) if ext_refs_node is None : ext_refs_obj = CexternalReferences ( ) self . node . append ( ext_refs_obj . get_node ( ) ) else : ext_refs_obj = CexternalReferences ( ext_refs_node ) ext_refs_obj . add_external_refer... | Adds an external reference object to the markable |
6,479 | def get_external_references ( self ) : for ext_ref_node in self . node . findall ( 'externalReferences' ) : ext_refs_obj = CexternalReferences ( ext_ref_node ) for ref in ext_refs_obj : yield ref | Iterator that returns all the external references of the markable |
6,480 | def add_external_reference ( self , markable_id , external_ref ) : if markable_id in self . idx : markable_obj = Cterm ( self . idx [ markable_id ] , self . type ) markable_obj . add_external_reference ( external_ref ) else : print ( '{markable_id} not in self.idx' . format ( ** locals ( ) ) ) | Adds an external reference for the given markable |
6,481 | def remove_markables ( self , list_mark_ids ) : nodes_to_remove = set ( ) for markable in self : if markable . get_id ( ) in list_mark_ids : nodes_to_remove . add ( markable . get_node ( ) ) prv = markable . get_node ( ) . getprevious ( ) if prv is not None : nodes_to_remove . add ( prv ) for node in nodes_to_remove : ... | Removes a list of markables from the layer |
6,482 | def getinfo ( ee_obj , n = 4 ) : output = None for i in range ( 1 , n ) : try : output = ee_obj . getInfo ( ) except ee . ee_exception . EEException as e : if 'Earth Engine memory capacity exceeded' in str ( e ) : logging . info ( ' Resending query ({}/10)' . format ( i ) ) logging . debug ( ' {}' . format ( e ) ... | Make an exponential back off getInfo call on an Earth Engine object |
6,483 | def constant_image_value ( image , crs = 'EPSG:32613' , scale = 1 ) : return getinfo ( ee . Image ( image ) . reduceRegion ( reducer = ee . Reducer . first ( ) , scale = scale , geometry = ee . Geometry . Rectangle ( [ 0 , 0 , 10 , 10 ] , crs , False ) ) ) | Extract the output value from a calculation done with constant images |
6,484 | def date_0utc ( date ) : return ee . Date . fromYMD ( date . get ( 'year' ) , date . get ( 'month' ) , date . get ( 'day' ) ) | Get the 0 UTC date for a date |
6,485 | def get_version ( here_path , default_version = DEFAULT_VERSION , ) : if 'site-packages' in here_path : return _version_from_file ( here_path ) if os . environ . get ( 'TRAVIS_TAG' ) : if not TEST_MODE : return os . environ . get ( 'TRAVIS_TAG' ) . replace ( 'v' , '' ) else : warnings . warn ( 'Travis detected, but TES... | tries to resolve version number |
6,486 | def _read_git_tags ( default_version = DEFAULT_VERSION , git_command = ( 'git' , 'tag' ) , ) : try : current_tags = check_output ( git_command ) . splitlines ( ) except Exception : raise if not current_tags [ 0 ] : warnings . warn ( 'Unable to resolve current version' , exceptions . ProsperDefaultVersionWarning ) retur... | tries to find current git tag |
6,487 | def _version_from_file ( path_to_version , default_version = DEFAULT_VERSION , ) : version_filepath = os . path . join ( path_to_version , 'version.txt' ) if not os . path . isfile ( version_filepath ) : warnings . warn ( 'Unable to resolve current version' , exceptions . ProsperDefaultVersionWarning ) return default_v... | for PyPI installed versions just get data from file |
6,488 | def _configure_common ( self , prefix , fallback_level , fallback_format , handler_name , handler , custom_args = '' ) : log_level = self . config . get_option ( 'LOGGING' , prefix + 'log_level' , None , fallback_level ) log_format_name = self . config . get_option ( 'LOGGING' , prefix + 'log_format' , None , None ) lo... | commom configuration code |
6,489 | def configure_default_logger ( self , log_freq = 'midnight' , log_total = 30 , log_level = 'INFO' , log_format = ReportingFormats . DEFAULT . value , custom_args = '' ) : log_freq = self . config . get_option ( 'LOGGING' , 'log_freq' , None , log_freq ) log_total = self . config . get_option ( 'LOGGING' , 'log_total' ,... | default logger that every Prosper script should use!! |
6,490 | def configure_discord_logger ( self , discord_webhook = None , discord_recipient = None , log_level = 'ERROR' , log_format = ReportingFormats . PRETTY_PRINT . value , custom_args = '' ) : discord_webhook = self . config . get_option ( 'LOGGING' , 'discord_webhook' , None , discord_webhook ) discord_recipient = self . c... | logger for sending messages to Discord . Easy way to alert humans of issues |
6,491 | def configure_slack_logger ( self , slack_webhook = None , log_level = 'ERROR' , log_format = ReportingFormats . SLACK_PRINT . value , custom_args = '' ) : slack_webhook = self . config . get_option ( 'LOGGING' , 'slack_webhook' , None , slack_webhook ) log_level = self . config . get_option ( 'LOGGING' , 'slack_level'... | logger for sending messages to Slack . Easy way to alert humans of issues |
6,492 | def configure_hipchat_logger ( self , hipchat_webhook = None , log_level = 'ERROR' , log_format = ReportingFormats . PRETTY_PRINT . value , custom_args = '' ) : hipchat_webhook = self . config . get_option ( 'LOGGING' , 'hipchat_webhook' , None , hipchat_webhook ) log_level = self . config . get_option ( 'LOGGING' , 'h... | logger for sending messages to HipChat . Easy way to alert humans of issues |
6,493 | def webhook ( self , webhook_url ) : if not webhook_url : raise Exception ( 'Url can not be None' ) matcher = re . match ( self . __webhook_url_format , webhook_url ) if not matcher : raise Exception ( 'Invalid url format, looking for: ' + self . __webhook_url_format ) self . api_keys ( int ( matcher . group ( 1 ) ) , ... | Load object with webhook_url |
6,494 | def emit ( self , record ) : if record . exc_text : record . exc_text = '```python\n{0}\n```' . format ( record . exc_text ) log_msg = self . format ( record ) if len ( log_msg ) + self . alert_length > DISCORD_MESSAGE_LIMIT : log_msg = log_msg [ : ( DISCORD_MESSAGE_LIMIT - DISCORD_PAD_SIZE ) ] if self . alert_recipien... | required classmethod for logging to execute logging message |
6,495 | def send_msg_to_webhook ( self , message ) : payload = { 'content' : message } header = { 'Content-Type' : 'application/json' } try : request = requests . post ( self . api_url , headers = header , json = payload ) request . raise_for_status ( ) except Exception as error_msg : warning_msg = ( 'EXCEPTION: UNABLE TO COMM... | separated Requests logic for easier testing |
6,496 | def decorate ( self , record ) : attachments = { } if record . levelno >= logging . ERROR : attachments [ 'color' ] = 'warning' if record . levelno >= logging . CRITICAL : attachments [ 'color' ] = 'danger' attach_text = '{levelname}: {name} {module}.{funcName}:{lineno}' . format ( levelname = record . levelname , name... | add slack - specific flourishes to responses |
6,497 | def send_msg_to_webhook ( self , json_payload , log_msg ) : if SILENCE_OVERRIDE : return payload = { 'text' : log_msg , 'attachments' : [ json_payload ] } header = { 'Content-Type' : 'application/json' } try : request = requests . post ( self . webhook_url , headers = header , json = payload ) request . raise_for_statu... | push message out to webhook |
6,498 | def decorate ( self , record ) : color = 'gray' if record . levelno == logging . WARNING : color = 'yellow' if record . levelno == logging . INFO : color = 'green' if record . levelno == logging . DEBUG : color = 'gray' if record . levelno >= logging . ERROR : color = 'red' notify = False if record . levelno >= logging... | Build up HipChat specific values for log record |
6,499 | def GetNetworks ( alias = None , location = None ) : if alias is None : alias = clc . v1 . Account . GetAlias ( ) if location is None : location = clc . v1 . Account . GetLocation ( ) r = clc . v1 . API . Call ( 'post' , 'Network/GetAccountNetworks' , { 'AccountAlias' : alias , 'Location' : location } ) if int ( r [ 'S... | Gets the list of Networks mapped to the account in the specified datacenter . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.