query stringlengths 5 1.23k | positive stringlengths 53 15.2k | id_ int64 0 252k | task_name stringlengths 87 242 | negative listlengths 20 553 |
|---|---|---|---|---|
This function calls the a trous algorithm code to recompose the input into a single array . This is the implementation of the isotropic undecimated wavelet transform recomposition for a GPU . | def gpu_iuwt_recomposition ( in1 , scale_adjust , store_on_gpu , smoothed_array ) : wavelet_filter = ( 1. / 16 ) * np . array ( [ 1 , 4 , 6 , 4 , 1 ] , dtype = np . float32 ) # Filter-bank for use in the a trous algorithm. wavelet_filter = gpuarray . to_gpu_async ( wavelet_filter ) # Determines scale with adjustment an... | 900 | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt.py#L501-L581 | [
"def",
"set_end_date",
"(",
"self",
",",
"lifetime",
")",
":",
"self",
".",
"end_date",
"=",
"(",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"+",
"datetime",
".",
"timedelta",
"(",
"0",
",",
"lifetime",
")",
")"
] |
logout and remove all session data | def unauth ( request ) : if check_key ( request ) : api = get_api ( request ) request . session . clear ( ) logout ( request ) return HttpResponseRedirect ( reverse ( 'main' ) ) | 901 | https://github.com/marcelcaraciolo/foursquare/blob/a8bda33cc2d61e25aa8df72011246269fd98aa13/examples/django/example/djfoursquare/views.py#L22-L30 | [
"def",
"create_or_update_group_alias",
"(",
"self",
",",
"name",
",",
"alias_id",
"=",
"None",
",",
"mount_accessor",
"=",
"None",
",",
"canonical_id",
"=",
"None",
",",
"mount_point",
"=",
"DEFAULT_MOUNT_POINT",
")",
":",
"params",
"=",
"{",
"'name'",
":",
... |
display some user info to show we have authenticated successfully | def info ( request ) : if check_key ( request ) : api = get_api ( request ) user = api . users ( id = 'self' ) print dir ( user ) return render_to_response ( 'djfoursquare/info.html' , { 'user' : user } ) else : return HttpResponseRedirect ( reverse ( 'main' ) ) | 902 | https://github.com/marcelcaraciolo/foursquare/blob/a8bda33cc2d61e25aa8df72011246269fd98aa13/examples/django/example/djfoursquare/views.py#L33-L43 | [
"def",
"comment",
"(",
"self",
",",
"text",
",",
"comment_prefix",
"=",
"'#'",
")",
":",
"comment",
"=",
"Comment",
"(",
"self",
".",
"_container",
")",
"if",
"not",
"text",
".",
"startswith",
"(",
"comment_prefix",
")",
":",
"text",
"=",
"\"{} {}\"",
... |
Check to see if we already have an access_key stored if we do then we have already gone through OAuth . If not then we haven t and we probably need to . | def check_key ( request ) : try : access_key = request . session . get ( 'oauth_token' , None ) if not access_key : return False except KeyError : return False return True | 903 | https://github.com/marcelcaraciolo/foursquare/blob/a8bda33cc2d61e25aa8df72011246269fd98aa13/examples/django/example/djfoursquare/views.py#L73-L85 | [
"def",
"statistic_recommend",
"(",
"classes",
",",
"P",
")",
":",
"if",
"imbalance_check",
"(",
"P",
")",
":",
"return",
"IMBALANCED_RECOMMEND",
"if",
"binary_check",
"(",
"classes",
")",
":",
"return",
"BINARY_RECOMMEND",
"return",
"MULTICLASS_RECOMMEND"
] |
Iterate over items in a streaming response from the Docker client within a timeout . | def stream_timeout ( stream , timeout , timeout_msg = None ) : timed_out = threading . Event ( ) def timeout_func ( ) : timed_out . set ( ) stream . close ( ) timer = threading . Timer ( timeout , timeout_func ) try : timer . start ( ) for item in stream : yield item # A timeout looks the same as the loop ending. So we... | 904 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/stream/_timeout.py#L4-L41 | [
"def",
"guess_extension",
"(",
"amimetype",
",",
"normalize",
"=",
"False",
")",
":",
"ext",
"=",
"_mimes",
".",
"guess_extension",
"(",
"amimetype",
")",
"if",
"ext",
"and",
"normalize",
":",
"# Normalize some common magic mis-interpreation",
"ext",
"=",
"{",
"... |
Get per - program state . | def get_state ( self , caller ) : if caller in self . state : return self . state [ caller ] else : rv = self . state [ caller ] = DictObject ( ) return rv | 905 | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/callable.py#L74-L83 | [
"def",
"removeAllChildrenAtIndex",
"(",
"self",
",",
"parentIndex",
")",
":",
"if",
"not",
"parentIndex",
".",
"isValid",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"No valid item selected for deletion (ignored).\"",
")",
"return",
"parentItem",
"=",
"self",
".... |
Return object for given name registered in System namespace . | def name_to_system_object ( self , value ) : if not self . system : raise SystemNotReady if isinstance ( value , ( str , Object ) ) : rv = self . system . name_to_system_object ( value ) return rv if rv else value else : return value | 906 | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/callable.py#L250-L261 | [
"def",
"write_index",
"(",
"self",
",",
"overwrite",
":",
"bool",
"=",
"False",
",",
"mock",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"write_if_allowed",
"(",
"self",
".",
"index_filename",
",",
"self",
".",
"index_content",
"(",
")",
",",
"o... |
Recursively cancel all threaded background processes of this Callable . This is called automatically for actions if program deactivates . | def cancel ( self , caller ) : for o in { i for i in self . children if isinstance ( i , AbstractCallable ) } : o . cancel ( caller ) | 907 | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/callable.py#L311-L317 | [
"def",
"getPositionNearType",
"(",
"self",
",",
"tagSet",
",",
"idx",
")",
":",
"try",
":",
"return",
"idx",
"+",
"self",
".",
"__ambiguousTypes",
"[",
"idx",
"]",
".",
"getPositionByType",
"(",
"tagSet",
")",
"except",
"KeyError",
":",
"raise",
"error",
... |
Give string representation of the callable . | def give_str ( self ) : args = self . _args [ : ] kwargs = self . _kwargs return self . _give_str ( args , kwargs ) | 908 | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/callable.py#L333-L339 | [
"def",
"_intersection",
"(",
"self",
",",
"keys",
",",
"rows",
")",
":",
"# If there are no other keys with start and end date (i.e. nothing to merge) return immediately.",
"if",
"not",
"keys",
":",
"return",
"rows",
"ret",
"=",
"list",
"(",
")",
"for",
"row",
"in",
... |
Prepares the request and catches common errors and returns tuple of data and the request response . | def _make_request ( self , endpoint , params ) : # params = { # **self._base_params, # Mind order to allow params to overwrite base params # **params # } full_params = self . _base_params . copy ( ) full_params . update ( params ) try : r = requests . get ( endpoint , full_params ) data = r . json ( ) if r . s... | 909 | https://github.com/fauskanger/mypolr/blob/46eb4fc5ba0f65412634a37e30e05de79fc9db4c/mypolr/polr_api.py#L42-L74 | [
"def",
"batch_update",
"(",
"self",
",",
"values",
",",
"w",
"=",
"1",
")",
":",
"for",
"x",
"in",
"values",
":",
"self",
".",
"update",
"(",
"x",
",",
"w",
")",
"self",
".",
"compress",
"(",
")",
"return"
] |
Creates a short url if valid | def shorten ( self , long_url , custom_ending = None , is_secret = False ) : params = { 'url' : long_url , 'is_secret' : 'true' if is_secret else 'false' , 'custom_ending' : custom_ending } data , r = self . _make_request ( self . api_shorten_endpoint , params ) if r . status_code == 400 : if custom_ending is not None ... | 910 | https://github.com/fauskanger/mypolr/blob/46eb4fc5ba0f65412634a37e30e05de79fc9db4c/mypolr/polr_api.py#L76-L103 | [
"def",
"get_rng",
"(",
"obj",
"=",
"None",
")",
":",
"seed",
"=",
"(",
"id",
"(",
"obj",
")",
"+",
"os",
".",
"getpid",
"(",
")",
"+",
"int",
"(",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"\"%Y%m%d%H%M%S%f\"",
")",
")",
")",
"%",... |
Returns the short url ending from a short url or an short url ending . | def _get_ending ( self , lookup_url ) : if lookup_url . startswith ( self . api_server ) : return lookup_url [ len ( self . api_server ) + 1 : ] return lookup_url | 911 | https://github.com/fauskanger/mypolr/blob/46eb4fc5ba0f65412634a37e30e05de79fc9db4c/mypolr/polr_api.py#L105-L120 | [
"def",
"run",
"(",
"self",
")",
":",
"for",
"cellindex",
"in",
"self",
".",
"RANK_CELLINDICES",
":",
"self",
".",
"cellsim",
"(",
"cellindex",
")",
"COMM",
".",
"Barrier",
"(",
")"
] |
Looks up the url_ending to obtain information about the short url . | def lookup ( self , lookup_url , url_key = None ) : url_ending = self . _get_ending ( lookup_url ) params = { 'url_ending' : url_ending , 'url_key' : url_key } data , r = self . _make_request ( self . api_lookup_endpoint , params ) if r . status_code == 401 : if url_key is not None : raise exceptions . UnauthorizedKeyE... | 912 | https://github.com/fauskanger/mypolr/blob/46eb4fc5ba0f65412634a37e30e05de79fc9db4c/mypolr/polr_api.py#L122-L173 | [
"def",
"ignore_directories",
"(",
"self",
",",
"project",
")",
":",
"project_list",
"=",
"False",
"try",
":",
"ignore_directories",
"=",
"il",
"[",
"'ignore_directories'",
"]",
"except",
"KeyError",
":",
"logger",
".",
"error",
"(",
"'Key Error processing ignore_d... |
Setup argparse arguments . | def make_argparser ( ) : parser = argparse . ArgumentParser ( prog = 'mypolr' , description = "Interacts with the Polr Project's API.\n\n" "User Guide and documentation: https://mypolr.readthedocs.io" , formatter_class = argparse . ArgumentDefaultsHelpFormatter , epilog = "NOTE: if configurations are saved, they are st... | 913 | https://github.com/fauskanger/mypolr/blob/46eb4fc5ba0f65412634a37e30e05de79fc9db4c/mypolr/cli.py#L18-L61 | [
"def",
"restore",
"(",
"self",
")",
":",
"clean_beam",
",",
"beam_params",
"=",
"beam_fit",
"(",
"self",
".",
"psf_data",
",",
"self",
".",
"cdelt1",
",",
"self",
".",
"cdelt2",
")",
"if",
"np",
".",
"all",
"(",
"np",
".",
"array",
"(",
"self",
"."... |
This function estimates the noise using the MAD estimator . | def estimate_threshold ( in1 , edge_excl = 0 , int_excl = 0 ) : out1 = np . empty ( [ in1 . shape [ 0 ] ] ) mid = in1 . shape [ 1 ] / 2 if ( edge_excl != 0 ) | ( int_excl != 0 ) : if edge_excl != 0 : mask = np . zeros ( [ in1 . shape [ 1 ] , in1 . shape [ 2 ] ] ) mask [ edge_excl : - edge_excl , edge_excl : - edge_excl... | 914 | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_toolbox.py#L17-L48 | [
"def",
"_replace_path",
"(",
"self",
",",
"path",
")",
":",
"if",
"path",
"in",
"self",
".",
"_field_to_key",
":",
"return",
"self",
".",
"_field_to_key",
"[",
"path",
"]",
"next_key",
"=",
"\"#f%d\"",
"%",
"self",
".",
"_next_field",
"self",
".",
"_next... |
Convenience function for allocating work to cpu or gpu depending on the selected mode . | def source_extraction ( in1 , tolerance , mode = "cpu" , store_on_gpu = False , neg_comp = False ) : if mode == "cpu" : return cpu_source_extraction ( in1 , tolerance , neg_comp ) elif mode == "gpu" : return gpu_source_extraction ( in1 , tolerance , store_on_gpu , neg_comp ) | 915 | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_toolbox.py#L77-L94 | [
"def",
"generate_version_file",
"(",
"self",
",",
"schema_filename",
",",
"binding_filename",
")",
":",
"version_filename",
"=",
"binding_filename",
"+",
"'_version.txt'",
"version_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"binding_dir",
",",
... |
The following function determines connectivity within a given wavelet decomposition . These connected and labelled structures are thresholded to within some tolerance of the maximum coefficient at the scale . This determines whether on not an object is to be considered as significant . Significant objects are extracted... | def cpu_source_extraction ( in1 , tolerance , neg_comp ) : # The following initialises some variables for storing the labelled image and the number of labels. The per scale # maxima are also initialised here. scale_maxima = np . empty ( [ in1 . shape [ 0 ] , 1 ] ) objects = np . empty_like ( in1 , dtype = np . int32 ) ... | 916 | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_toolbox.py#L97-L154 | [
"def",
"_get_variant_silent",
"(",
"parser",
",",
"variant",
")",
":",
"prev_log",
"=",
"config",
".",
"LOG_NOT_FOUND",
"config",
".",
"LOG_NOT_FOUND",
"=",
"False",
"results",
"=",
"parser",
".",
"get_variant_genotypes",
"(",
"variant",
")",
"config",
".",
"L... |
The following function simply calculates the signal to noise ratio between two signals . | def snr_ratio ( in1 , in2 ) : out1 = 20 * ( np . log10 ( np . linalg . norm ( in1 ) / np . linalg . norm ( in1 - in2 ) ) ) return out1 | 917 | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_toolbox.py#L292-L306 | [
"def",
"cache_url_config",
"(",
"cls",
",",
"url",
",",
"backend",
"=",
"None",
")",
":",
"url",
"=",
"urlparse",
"(",
"url",
")",
"if",
"not",
"isinstance",
"(",
"url",
",",
"cls",
".",
"URL_CLASS",
")",
"else",
"url",
"location",
"=",
"url",
".",
... |
Wait for the RabbitMQ process to be come up . | def wait_for_start ( self ) : er = self . exec_rabbitmqctl ( 'wait' , [ '--pid' , '1' , '--timeout' , str ( int ( self . wait_timeout ) ) ] ) output_lines ( er , error_exc = TimeoutError ) | 918 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/rabbitmq.py#L56-L62 | [
"def",
"_clear",
"(",
"self",
",",
"fully",
"=",
"True",
")",
":",
"pages",
"=",
"self",
".",
"pages",
"if",
"not",
"pages",
":",
"return",
"self",
".",
"_keyframe",
"=",
"pages",
"[",
"0",
"]",
"if",
"fully",
":",
"# delete all but first TiffPage/TiffFr... |
Execute a rabbitmqctl command inside a running container . | def exec_rabbitmqctl ( self , command , args = [ ] , rabbitmqctl_opts = [ '-q' ] ) : cmd = [ 'rabbitmqctl' ] + rabbitmqctl_opts + [ command ] + args return self . inner ( ) . exec_run ( cmd ) | 919 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/rabbitmq.py#L87-L98 | [
"def",
"delete",
"(",
"self",
",",
"object_type",
",",
"object_id",
")",
":",
"tag_names",
"=",
"request",
".",
"get_json",
"(",
"force",
"=",
"True",
")",
"if",
"not",
"tag_names",
":",
"return",
"Response",
"(",
"status",
"=",
"403",
")",
"db",
".",
... |
Execute a rabbitmqctl command to list the given resources . | def exec_rabbitmqctl_list ( self , resources , args = [ ] , rabbitmq_opts = [ '-q' , '--no-table-headers' ] ) : command = 'list_{}' . format ( resources ) return self . exec_rabbitmqctl ( command , args , rabbitmq_opts ) | 920 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/rabbitmq.py#L100-L112 | [
"def",
"dump_webdriver_cookies_into_requestdriver",
"(",
"requestdriver",
",",
"webdriverwrapper",
")",
":",
"for",
"cookie",
"in",
"webdriverwrapper",
".",
"get_cookies",
"(",
")",
":",
"# Wedbriver uses \"expiry\"; requests uses \"expires\", adjust for this",
"expires",
"=",
... |
Run the list_users command and return a list of tuples describing the users . | def list_users ( self ) : lines = output_lines ( self . exec_rabbitmqctl_list ( 'users' ) ) return [ _parse_rabbitmq_user ( line ) for line in lines ] | 921 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/rabbitmq.py#L133-L143 | [
"def",
"_set_cdn_access",
"(",
"self",
",",
"container",
",",
"public",
",",
"ttl",
"=",
"None",
")",
":",
"headers",
"=",
"{",
"\"X-Cdn-Enabled\"",
":",
"\"%s\"",
"%",
"public",
"}",
"if",
"public",
"and",
"ttl",
":",
"headers",
"[",
"\"X-Ttl\"",
"]",
... |
Returns a broker URL for use with Celery . | def broker_url ( self ) : return 'amqp://{}:{}@{}/{}' . format ( self . user , self . password , self . name , self . vhost ) | 922 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/rabbitmq.py#L145-L148 | [
"def",
"weld_replace",
"(",
"array",
",",
"weld_type",
",",
"this",
",",
"to",
")",
":",
"if",
"not",
"isinstance",
"(",
"this",
",",
"str",
")",
":",
"this",
"=",
"to_weld_literal",
"(",
"this",
",",
"weld_type",
")",
"to",
"=",
"to_weld_literal",
"("... |
Execute a command inside a running container as the postgres user asserting success . | def exec_pg_success ( self , cmd ) : result = self . inner ( ) . exec_run ( cmd , user = 'postgres' ) assert result . exit_code == 0 , result . output . decode ( 'utf-8' ) return result | 923 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/postgresql.py#L63-L70 | [
"def",
"ticker",
"(",
"ctx",
",",
"market",
")",
":",
"market",
"=",
"Market",
"(",
"market",
",",
"bitshares_instance",
"=",
"ctx",
".",
"bitshares",
")",
"ticker",
"=",
"market",
".",
"ticker",
"(",
")",
"t",
"=",
"[",
"[",
"\"key\"",
",",
"\"value... |
Remove all data by dropping and recreating the configured database . | def clean ( self ) : self . exec_pg_success ( [ 'dropdb' , '-U' , self . user , self . database ] ) self . exec_pg_success ( [ 'createdb' , '-U' , self . user , self . database ] ) | 924 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/postgresql.py#L72-L82 | [
"def",
"confirmation",
"(",
"self",
",",
"apdu",
")",
":",
"if",
"_debug",
":",
"ClientSSM",
".",
"_debug",
"(",
"\"confirmation %r\"",
",",
"apdu",
")",
"if",
"self",
".",
"state",
"==",
"SEGMENTED_REQUEST",
":",
"self",
".",
"segmented_request",
"(",
"ap... |
Execute a psql command inside a running container . By default the container s database is connected to . | def exec_psql ( self , command , psql_opts = [ '-qtA' ] ) : cmd = [ 'psql' ] + psql_opts + [ '--dbname' , self . database , '-U' , self . user , '-c' , command , ] return self . inner ( ) . exec_run ( cmd , user = 'postgres' ) | 925 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/postgresql.py#L84-L98 | [
"def",
"setOverlayTexelAspect",
"(",
"self",
",",
"ulOverlayHandle",
",",
"fTexelAspect",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"setOverlayTexelAspect",
"result",
"=",
"fn",
"(",
"ulOverlayHandle",
",",
"fTexelAspect",
")",
"return",
"result"
] |
Runs the \\ list command and returns a list of column values with information about all databases . | def list_databases ( self ) : lines = output_lines ( self . exec_psql ( '\\list' ) ) return [ line . split ( '|' ) for line in lines ] | 926 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/postgresql.py#L100-L106 | [
"def",
"market_if_touched_replace",
"(",
"self",
",",
"accountID",
",",
"orderID",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"replace",
"(",
"accountID",
",",
"orderID",
",",
"order",
"=",
"MarketIfTouchedOrderRequest",
"(",
"*",
"*",
"kwargs... |
Runs the \\ dt command and returns a list of column values with information about all tables in the database . | def list_tables ( self ) : lines = output_lines ( self . exec_psql ( '\\dt' ) ) return [ line . split ( '|' ) for line in lines ] | 927 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/postgresql.py#L108-L114 | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"super",
"(",
"ImageMemberManager",
",",
"self",
")",
".",
"create",
"(",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"... |
Runs the \\ du command and returns a list of column values with information about all user roles . | def list_users ( self ) : lines = output_lines ( self . exec_psql ( '\\du' ) ) return [ line . split ( '|' ) for line in lines ] | 928 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/postgresql.py#L116-L122 | [
"def",
"disassociate_public_ip",
"(",
"self",
",",
"public_ip_id",
")",
":",
"floating_ip",
"=",
"self",
".",
"client",
".",
"floating_ips",
".",
"get",
"(",
"public_ip_id",
")",
"floating_ip",
"=",
"floating_ip",
".",
"to_dict",
"(",
")",
"instance_id",
"=",
... |
Returns a database URL for use with DJ - Database - URL and similar libraries . | def database_url ( self ) : return 'postgres://{}:{}@{}/{}' . format ( self . user , self . password , self . name , self . database ) | 929 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/postgresql.py#L124-L130 | [
"def",
"wait_for_compactions",
"(",
"self",
",",
"timeout",
"=",
"120",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"\"pending tasks: 0\"",
")",
"start",
"=",
"time",
".",
"time",
"(",
")",
"while",
"time",
".",
"time",
"(",
")",
"-",
"start",... |
Generate a matrix from a configuration dictionary . | def from_config ( config ) : matrix = { } variables = config . keys ( ) for entries in product ( * config . values ( ) ) : combination = dict ( zip ( variables , entries ) ) include = True for value in combination . values ( ) : for reducer in value . reducers : if reducer . pattern == '-' : match = not combination [ r... | 930 | https://github.com/ionelmc/python-matrix/blob/e1a63879a6c94c37c3883386f1d86eb7c2179a5b/src/matrix/__init__.py#L131-L156 | [
"def",
"_try_free_lease",
"(",
"self",
",",
"shard_state",
",",
"slice_retry",
"=",
"False",
")",
":",
"@",
"db",
".",
"transactional",
"def",
"_tx",
"(",
")",
":",
"fresh_state",
"=",
"model",
".",
"ShardState",
".",
"get_by_shard_id",
"(",
"shard_state",
... |
This only needs to be called manually from unit tests | def flush ( self ) : self . logger . debug ( 'Flush joining' ) self . queue . join ( ) self . logger . debug ( 'Flush joining ready' ) | 931 | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/worker.py#L112-L119 | [
"def",
"_get_api_id",
"(",
"self",
",",
"event_properties",
")",
":",
"api_id",
"=",
"event_properties",
".",
"get",
"(",
"\"RestApiId\"",
")",
"if",
"isinstance",
"(",
"api_id",
",",
"dict",
")",
"and",
"\"Ref\"",
"in",
"api_id",
":",
"api_id",
"=",
"api_... |
Convert bytestring container output or the result of a container exec command into a sequence of unicode lines . | def output_lines ( output , encoding = 'utf-8' , error_exc = None ) : if isinstance ( output , ExecResult ) : exit_code , output = output if exit_code != 0 and error_exc is not None : raise error_exc ( output . decode ( encoding ) ) return output . decode ( encoding ) . splitlines ( ) | 932 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/utils.py#L4-L27 | [
"def",
"exclude_types",
"(",
"self",
",",
"*",
"objs",
")",
":",
"for",
"o",
"in",
"objs",
":",
"for",
"t",
"in",
"_keytuple",
"(",
"o",
")",
":",
"if",
"t",
"and",
"t",
"not",
"in",
"self",
".",
"_excl_d",
":",
"self",
".",
"_excl_d",
"[",
"t"... |
Get file from WeedFS . | def get_file ( self , fid ) : url = self . get_file_url ( fid ) return self . conn . get_raw_data ( url ) | 933 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L50-L66 | [
"def",
"extract",
"(",
"self",
",",
"content",
",",
"output",
")",
":",
"for",
"table",
"in",
"self",
"[",
"'tables'",
"]",
":",
"# First apply default options.",
"plugin_settings",
"=",
"DEFAULT_OPTIONS",
".",
"copy",
"(",
")",
"plugin_settings",
".",
"update... |
Get url for the file | def get_file_url ( self , fid , public = None ) : try : volume_id , rest = fid . strip ( ) . split ( "," ) except ValueError : raise BadFidFormat ( "fid must be in format: <volume_id>,<file_name_hash>" ) file_location = self . get_file_location ( volume_id ) if public is None : public = self . use_public_url volume_url... | 934 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L68-L87 | [
"def",
"handlePortfolio",
"(",
"self",
",",
"msg",
")",
":",
"# log handler msg",
"self",
".",
"log_msg",
"(",
"\"portfolio\"",
",",
"msg",
")",
"# contract identifier",
"contract_tuple",
"=",
"self",
".",
"contract_to_tuple",
"(",
"msg",
".",
"contract",
")",
... |
Get location for the file WeedFS volume is choosed randomly | def get_file_location ( self , volume_id ) : url = ( "http://{master_addr}:{master_port}/" "dir/lookup?volumeId={volume_id}" ) . format ( master_addr = self . master_addr , master_port = self . master_port , volume_id = volume_id ) data = json . loads ( self . conn . get_data ( url ) ) _file_location = random . choice ... | 935 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L89-L105 | [
"def",
"_on_stream_update",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_streams",
"[",
"data",
".",
"get",
"(",
"'id'",
")",
"]",
".",
"update",
"(",
"data",
".",
"get",
"(",
"'stream'",
")",
")",
"_LOGGER",
".",
"info",
"(",
"'stream %s updat... |
Gets size of uploaded file Or None if file doesn t exist . | def get_file_size ( self , fid ) : url = self . get_file_url ( fid ) res = self . conn . head ( url ) if res is not None : size = res . headers . get ( "content-length" , None ) if size is not None : return int ( size ) return None | 936 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L107-L124 | [
"def",
"cmd_oreoled",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"<",
"4",
":",
"print",
"(",
"\"Usage: oreoled LEDNUM RED GREEN BLUE <RATE>\"",
")",
"return",
"lednum",
"=",
"int",
"(",
"args",
"[",
"0",
"]",
")",
"pattern",
"=",... |
Checks if file with provided fid exists | def file_exists ( self , fid ) : res = self . get_file_size ( fid ) if res is not None : return True return False | 937 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L126-L138 | [
"def",
"extract_name_from_path",
"(",
"path",
")",
":",
"base_path",
",",
"query_string",
"=",
"path",
".",
"split",
"(",
"'?'",
")",
"infos",
"=",
"base_path",
".",
"strip",
"(",
"'/'",
")",
".",
"split",
"(",
"'/'",
")",
"[",
"2",
":",
"]",
"# Remo... |
Delete file from WeedFS | def delete_file ( self , fid ) : url = self . get_file_url ( fid ) return self . conn . delete_data ( url ) | 938 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L140-L147 | [
"def",
"extract",
"(",
"self",
",",
"content",
",",
"output",
")",
":",
"for",
"table",
"in",
"self",
"[",
"'tables'",
"]",
":",
"# First apply default options.",
"plugin_settings",
"=",
"DEFAULT_OPTIONS",
".",
"copy",
"(",
")",
"plugin_settings",
".",
"update... |
Uploads file to WeedFS | def upload_file ( self , path = None , stream = None , name = None , * * kwargs ) : params = "&" . join ( [ "%s=%s" % ( k , v ) for k , v in kwargs . items ( ) ] ) url = "http://{master_addr}:{master_port}/dir/assign{params}" . format ( master_addr = self . master_addr , master_port = self . master_port , params = "?" ... | 939 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L149-L192 | [
"def",
"alter",
"(",
"self",
",",
"operation",
",",
"timeout",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"credentials",
"=",
"None",
")",
":",
"new_metadata",
"=",
"self",
".",
"add_login_metadata",
"(",
"metadata",
")",
"try",
":",
"return",
"self... |
Force garbage collection | def vacuum ( self , threshold = 0.3 ) : url = ( "http://{master_addr}:{master_port}/" "vol/vacuum?garbageThreshold={threshold}" ) . format ( master_addr = self . master_addr , master_port = self . master_port , threshold = threshold ) res = self . conn . get_data ( url ) if res is not None : return True return False | 940 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L194-L211 | [
"def",
"_redis_watcher",
"(",
"state",
")",
":",
"conf",
"=",
"state",
".",
"app",
".",
"config",
"r",
"=",
"redis",
".",
"client",
".",
"StrictRedis",
"(",
"host",
"=",
"conf",
".",
"get",
"(",
"'WAFFLE_REDIS_HOST'",
",",
"'localhost'",
")",
",",
"por... |
Returns Weed - FS master version | def version ( self ) : url = "http://{master_addr}:{master_port}/dir/status" . format ( master_addr = self . master_addr , master_port = self . master_port ) data = self . conn . get_data ( url ) response_data = json . loads ( data ) return response_data . get ( "Version" ) | 941 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L214-L225 | [
"def",
"list_conversions",
"(",
"api_key",
",",
"api_secret",
",",
"video_key",
",",
"*",
"*",
"kwargs",
")",
":",
"jwplatform_client",
"=",
"jwplatform",
".",
"Client",
"(",
"api_key",
",",
"api_secret",
")",
"logging",
".",
"info",
"(",
"\"Querying for video... |
This function determines the convolution of two inputs using the FFT . Contains an implementation for both CPU and GPU . | def fft_convolve ( in1 , in2 , conv_device = "cpu" , conv_mode = "linear" , store_on_gpu = False ) : # NOTE: Circular convolution assumes a periodic repetition of the input. This can cause edge effects. Linear # convolution pads the input with zeros to avoid this problem but is consequently heavier on computation and #... | 942 | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_convolution.py#L18-L73 | [
"def",
"generation",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"self",
".",
"state",
"is",
"not",
"MemberState",
".",
"STABLE",
":",
"return",
"None",
"return",
"self",
".",
"_generation"
] |
This function makes use of the scikits implementation of the FFT for GPUs to take the real to complex FFT . | def gpu_r2c_fft ( in1 , is_gpuarray = False , store_on_gpu = False ) : if is_gpuarray : gpu_in1 = in1 else : gpu_in1 = gpuarray . to_gpu_async ( in1 . astype ( np . float32 ) ) output_size = np . array ( in1 . shape ) output_size [ 1 ] = 0.5 * output_size [ 1 ] + 1 gpu_out1 = gpuarray . empty ( [ output_size [ 0 ] , ou... | 943 | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_convolution.py#L76-L106 | [
"def",
"release",
"(",
"self",
")",
":",
"if",
"self",
".",
"_subscription",
"and",
"self",
".",
"_subscription",
".",
"subscribed",
":",
"self",
".",
"_subscription",
".",
"unsubscribe",
"(",
")",
"self",
".",
"_subscription",
".",
"reset",
"(",
")"
] |
This function makes use of the scikits implementation of the FFT for GPUs to take the complex to real IFFT . | def gpu_c2r_ifft ( in1 , is_gpuarray = False , store_on_gpu = False ) : if is_gpuarray : gpu_in1 = in1 else : gpu_in1 = gpuarray . to_gpu_async ( in1 . astype ( np . complex64 ) ) output_size = np . array ( in1 . shape ) output_size [ 1 ] = 2 * ( output_size [ 1 ] - 1 ) gpu_out1 = gpuarray . empty ( [ output_size [ 0 ]... | 944 | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_convolution.py#L108-L139 | [
"def",
"_remove_player",
"(",
"self",
",",
"player_id",
")",
":",
"player",
"=",
"self",
".",
"_mpris_players",
".",
"get",
"(",
"player_id",
")",
"if",
"player",
":",
"if",
"player",
".",
"get",
"(",
"\"subscription\"",
")",
":",
"player",
"[",
"\"subsc... |
Simple convenience function to pad arrays for linear convolution . | def pad_array ( in1 ) : padded_size = 2 * np . array ( in1 . shape ) out1 = np . zeros ( [ padded_size [ 0 ] , padded_size [ 1 ] ] ) out1 [ padded_size [ 0 ] / 4 : 3 * padded_size [ 0 ] / 4 , padded_size [ 1 ] / 4 : 3 * padded_size [ 1 ] / 4 ] = in1 return out1 | 945 | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt_convolution.py#L142-L158 | [
"def",
"numRegisteredForRole",
"(",
"self",
",",
"role",
",",
"includeTemporaryRegs",
"=",
"False",
")",
":",
"count",
"=",
"self",
".",
"eventregistration_set",
".",
"filter",
"(",
"cancelled",
"=",
"False",
",",
"dropIn",
"=",
"False",
",",
"role",
"=",
... |
Check if host is a dragon . | def is_dragon ( host , timeout = 1 ) : try : r = requests . get ( 'http://{}/' . format ( host ) , timeout = timeout ) if r . status_code == 200 : if '<title>DragonMint</title>' in r . text or '<title>AsicMiner</title>' in r . text : return True except requests . exceptions . RequestException : pass return False | 946 | https://github.com/brndnmtthws/dragon-rest/blob/10ea09a6203c0cbfeeeb854702764bd778769887/dragon_rest/dragons.py#L49-L65 | [
"def",
"encrypt",
"(",
"self",
",",
"plaintext_data_key",
",",
"encryption_context",
")",
":",
"if",
"self",
".",
"wrapping_algorithm",
".",
"encryption_type",
"is",
"EncryptionType",
".",
"ASYMMETRIC",
":",
"if",
"self",
".",
"wrapping_key_type",
"is",
"Encryptio... |
Change the pools of the miner . This call will restart cgminer . | def updatePools ( self , pool1 , username1 , password1 , pool2 = None , username2 = None , password2 = None , pool3 = None , username3 = None , password3 = None ) : return self . __post ( '/api/updatePools' , data = { 'Pool1' : pool1 , 'UserName1' : username1 , 'Password1' : password1 , 'Pool2' : pool2 , 'UserName2' : ... | 947 | https://github.com/brndnmtthws/dragon-rest/blob/10ea09a6203c0cbfeeeb854702764bd778769887/dragon_rest/dragons.py#L148-L170 | [
"def",
"WriteArtifactsFile",
"(",
"self",
",",
"artifacts",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"file_object",
":",
"file_object",
".",
"write",
"(",
"self",
".",
"FormatArtifacts",
"(",
"artifacts",
")",
")"
... |
Change the password of a user . | def updatePassword ( self , user , currentPassword , newPassword ) : return self . __post ( '/api/updatePassword' , data = { 'user' : user , 'currentPassword' : currentPassword , 'newPassword' : newPassword } ) | 948 | https://github.com/brndnmtthws/dragon-rest/blob/10ea09a6203c0cbfeeeb854702764bd778769887/dragon_rest/dragons.py#L172-L182 | [
"def",
"write",
"(",
"self",
",",
"path",
",",
"wrap_ttl",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
"=",
"sanitize_mount",
"(",
"path",
")",
"val",
"=",
"None",
"if",
"path",
".",
"startswith",
"(",
"'cubbyhole'",
")",
":",
"self",
"... |
Change the current network settings . | def updateNetwork ( self , dhcp = 'dhcp' , ipaddress = None , netmask = None , gateway = None , dns = None ) : return self . __post ( '/api/updateNetwork' , data = { 'dhcp' : dhcp , 'ipaddress' : ipaddress , 'netmask' : netmask , 'gateway' : gateway , 'dns' : json . dumps ( dns ) } ) | 949 | https://github.com/brndnmtthws/dragon-rest/blob/10ea09a6203c0cbfeeeb854702764bd778769887/dragon_rest/dragons.py#L188-L202 | [
"def",
"revoke_session",
"(",
"self",
",",
"sid",
"=",
"''",
",",
"token",
"=",
"''",
")",
":",
"if",
"not",
"sid",
":",
"if",
"token",
":",
"sid",
"=",
"self",
".",
"handler",
".",
"sid",
"(",
"token",
")",
"else",
":",
"raise",
"ValueError",
"(... |
Upgrade the firmware of the miner . | def upgradeUpload ( self , file ) : files = { 'upfile' : open ( file , 'rb' ) } return self . __post_files ( '/upgrade/upload' , files = files ) | 950 | https://github.com/brndnmtthws/dragon-rest/blob/10ea09a6203c0cbfeeeb854702764bd778769887/dragon_rest/dragons.py#L237-L241 | [
"def",
"user_deleted_from_site_event",
"(",
"event",
")",
":",
"userid",
"=",
"event",
".",
"principal",
"catalog",
"=",
"api",
".",
"portal",
".",
"get_tool",
"(",
"'portal_catalog'",
")",
"query",
"=",
"{",
"'object_provides'",
":",
"WORKSPACE_INTERFACE",
"}",... |
A property which can be used to check if StatusObject uses program features or not . | def is_program ( self ) : from automate . callables import Empty return not ( isinstance ( self . on_activate , Empty ) and isinstance ( self . on_deactivate , Empty ) and isinstance ( self . on_update , Empty ) ) | 951 | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/statusobject.py#L208-L215 | [
"def",
"insert",
"(",
"self",
",",
"storagemodel",
")",
"->",
"StorageTableModel",
":",
"modeldefinition",
"=",
"self",
".",
"getmodeldefinition",
"(",
"storagemodel",
",",
"True",
")",
"try",
":",
"modeldefinition",
"[",
"'tableservice'",
"]",
".",
"insert_or_r... |
Get data of this object as a data dictionary . Used by websocket service . | def get_as_datadict ( self ) : d = super ( ) . get_as_datadict ( ) d . update ( dict ( status = self . status , data_type = self . data_type , editable = self . editable ) ) return d | 952 | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/statusobject.py#L238-L244 | [
"def",
"setOverlayTextureColorSpace",
"(",
"self",
",",
"ulOverlayHandle",
",",
"eTextureColorSpace",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"setOverlayTextureColorSpace",
"result",
"=",
"fn",
"(",
"ulOverlayHandle",
",",
"eTextureColorSpace",
")",
... |
This function is called by - set_status - _update_program_stack if active program is being changed - thia may be launched by sensor status change . status lock is necessary because these happen from different threads . | def _do_change_status ( self , status , force = False ) : self . system . worker_thread . put ( DummyStatusWorkerTask ( self . _request_status_change_in_queue , status , force = force ) ) | 953 | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/statusobject.py#L354-L366 | [
"def",
"create_pattern",
"(",
"cls",
",",
"userdata",
")",
":",
"empty",
"=",
"cls",
".",
"create_empty",
"(",
"None",
")",
"userdata_dict",
"=",
"cls",
".",
"normalize",
"(",
"empty",
",",
"userdata",
")",
"return",
"Userdata",
"(",
"userdata_dict",
")"
] |
Called by program which desires to manipulate this actuator when it is activated . | def activate_program ( self , program ) : self . logger . debug ( "activate_program %s" , program ) if program in self . program_stack : return with self . _program_lock : self . logger . debug ( "activate_program got through %s" , program ) self . program_stack . append ( program ) self . _update_program_stack ( ) | 954 | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/statusobject.py#L578-L589 | [
"def",
"get_resource_form",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Implemented from kitosid template for -",
"# osid.resource.ResourceAdminSession.get_resource_form_for_update",
"# This method might be a bit sketchy. Time will tell.",
"if",
"isinstance... |
Called by program when it is deactivated . | def deactivate_program ( self , program ) : self . logger . debug ( "deactivate_program %s" , program ) with self . _program_lock : self . logger . debug ( "deactivate_program got through %s" , program ) if program not in self . program_stack : import ipdb ipdb . set_trace ( ) self . program_stack . remove ( program ) ... | 955 | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/statusobject.py#L591-L605 | [
"def",
"create_resource_quota",
"(",
"self",
",",
"name",
",",
"quota_json",
")",
":",
"url",
"=",
"self",
".",
"_build_k8s_url",
"(",
"\"resourcequotas/\"",
")",
"response",
"=",
"self",
".",
"_post",
"(",
"url",
",",
"data",
"=",
"json",
".",
"dumps",
... |
Stream logs from a Docker container within a timeout . | def stream_logs ( container , timeout = 10.0 , * * logs_kwargs ) : stream = container . logs ( stream = True , * * logs_kwargs ) return stream_timeout ( stream , timeout , 'Timeout waiting for container logs.' ) | 956 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/stream/logs.py#L8-L26 | [
"def",
"save_html",
"(",
"self",
",",
"name",
",",
"address",
"=",
"True",
",",
"overall_param",
"=",
"None",
",",
"class_param",
"=",
"None",
",",
"class_name",
"=",
"None",
",",
"color",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
",",
"normalize",
"... |
Fetch an image if it isn t already present . | def fetch_image ( client , name ) : try : image = client . images . get ( name ) except docker . errors . ImageNotFound : name , tag = _parse_image_tag ( name ) tag = 'latest' if tag is None else tag log . info ( "Pulling tag '{}' for image '{}'..." . format ( tag , name ) ) image = client . images . pull ( name , tag ... | 957 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L27-L44 | [
"def",
"session",
"(",
"self",
",",
"request",
":",
"Request",
")",
"->",
"WebSession",
":",
"return",
"WebSession",
"(",
"request",
",",
"http_client",
"=",
"self",
".",
"_http_client",
",",
"redirect_tracker",
"=",
"self",
".",
"_redirect_tracker_factory",
"... |
Get both the model and ID of an object that could be an ID or a model . | def _get_id_and_model ( self , id_or_model ) : if isinstance ( id_or_model , self . collection . model ) : model = id_or_model elif isinstance ( id_or_model , str ) : # Assume we have an ID string model = self . collection . get ( id_or_model ) else : raise TypeError ( 'Unexpected type {}, expected {} or {}' . format (... | 958 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L82-L100 | [
"def",
"GetCovariance",
"(",
"kernel",
",",
"kernel_params",
",",
"time",
",",
"errors",
")",
":",
"# NOTE: We purposefully compute the covariance matrix",
"# *without* the GP white noise term",
"K",
"=",
"np",
".",
"diag",
"(",
"errors",
"**",
"2",
")",
"K",
"+=",
... |
Create an instance of this resource type . | def create ( self , name , * args , * * kwargs ) : resource_name = self . _resource_name ( name ) log . info ( "Creating {} '{}'..." . format ( self . _model_name , resource_name ) ) resource = self . collection . create ( * args , name = resource_name , * * kwargs ) self . _ids . add ( resource . id ) return resource | 959 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L102-L111 | [
"def",
"_create_auth",
"(",
"team",
",",
"timeout",
"=",
"None",
")",
":",
"url",
"=",
"get_registry_url",
"(",
"team",
")",
"contents",
"=",
"_load_auth",
"(",
")",
"auth",
"=",
"contents",
".",
"get",
"(",
"url",
")",
"if",
"auth",
"is",
"not",
"No... |
Remove an instance of this resource type . | def remove ( self , resource , * * kwargs ) : log . info ( "Removing {} '{}'..." . format ( self . _model_name , resource . name ) ) resource . remove ( * * kwargs ) self . _ids . remove ( resource . id ) | 960 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L113-L120 | [
"def",
"_create_auth",
"(",
"team",
",",
"timeout",
"=",
"None",
")",
":",
"url",
"=",
"get_registry_url",
"(",
"team",
")",
"contents",
"=",
"_load_auth",
"(",
")",
"auth",
"=",
"contents",
".",
"get",
"(",
"url",
")",
"if",
"auth",
"is",
"not",
"No... |
Remove a container . | def remove ( self , container , force = True , volumes = True ) : super ( ) . remove ( container , force = force , v = volumes ) | 961 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L266-L283 | [
"def",
"disable_avatar",
"(",
"self",
")",
":",
"with",
"(",
"yield",
"from",
"self",
".",
"_publish_lock",
")",
":",
"todo",
"=",
"[",
"]",
"if",
"self",
".",
"_synchronize_vcard",
":",
"todo",
".",
"append",
"(",
"self",
".",
"_disable_vcard_avatar",
"... |
Get the default bridge network that containers are connected to if no other network options are specified . | def get_default ( self , create = True ) : if self . _default_network is None and create : log . debug ( "Creating default network..." ) self . _default_network = self . create ( 'default' , driver = 'bridge' ) return self . _default_network | 962 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L326-L338 | [
"def",
"createRPYText",
"(",
"self",
")",
":",
"self",
".",
"rollText",
"=",
"self",
".",
"axes",
".",
"text",
"(",
"self",
".",
"leftPos",
"+",
"(",
"self",
".",
"vertSize",
"/",
"10.0",
")",
",",
"-",
"0.97",
"+",
"(",
"2",
"*",
"self",
".",
... |
Get the helper for a given type of Docker model . For use by resource definitions . | def _helper_for_model ( self , model_type ) : if model_type is models . containers . Container : return self . containers if model_type is models . images . Image : return self . images if model_type is models . networks . Network : return self . networks if model_type is models . volumes . Volume : return self . volum... | 963 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L398-L412 | [
"def",
"_quantiles",
"(",
"self",
")",
":",
"trials",
"=",
"[",
"]",
"for",
"trial",
",",
"state",
"in",
"self",
".",
"_trial_state",
".",
"items",
"(",
")",
":",
"if",
"state",
".",
"last_score",
"is",
"not",
"None",
"and",
"not",
"trial",
".",
"i... |
Clean up all resources when we re done with them . | def teardown ( self ) : self . containers . _teardown ( ) self . networks . _teardown ( ) self . volumes . _teardown ( ) # We need to close the underlying APIClient explicitly to avoid # ResourceWarnings from unclosed HTTP connections. self . _client . api . close ( ) | 964 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/helpers.py#L414-L424 | [
"def",
"_bsecurate_cli_compare_basis_sets",
"(",
"args",
")",
":",
"ret",
"=",
"curate",
".",
"compare_basis_sets",
"(",
"args",
".",
"basis1",
",",
"args",
".",
"basis2",
",",
"args",
".",
"version1",
",",
"args",
".",
"version2",
",",
"args",
".",
"uncon... |
Execute a redis - cli command inside a running container . | def exec_redis_cli ( self , command , args = [ ] , db = 0 , redis_cli_opts = [ ] ) : cli_opts = [ '-n' , str ( db ) ] + redis_cli_opts cmd = [ 'redis-cli' ] + cli_opts + [ command ] + [ str ( a ) for a in args ] return self . inner ( ) . exec_run ( cmd ) | 965 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/redis.py#L40-L52 | [
"def",
"orderbook",
"(",
"ctx",
",",
"market",
")",
":",
"market",
"=",
"Market",
"(",
"market",
",",
"bitshares_instance",
"=",
"ctx",
".",
"bitshares",
")",
"orderbook",
"=",
"market",
".",
"orderbook",
"(",
")",
"ta",
"=",
"{",
"}",
"ta",
"[",
"\"... |
Run the KEYS command and return the list of matching keys . | def list_keys ( self , pattern = '*' , db = 0 ) : lines = output_lines ( self . exec_redis_cli ( 'KEYS' , [ pattern ] , db = db ) ) return [ ] if lines == [ '' ] else lines | 966 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/containers/redis.py#L54-L62 | [
"def",
"commit",
"(",
"self",
")",
":",
"if",
"self",
".",
"session",
"is",
"not",
"None",
":",
"logger",
".",
"info",
"(",
"\"committing transaction in %s\"",
"%",
"self",
")",
"tmp",
"=",
"self",
".",
"stable",
"self",
".",
"stable",
",",
"self",
"."... |
uses thread_init as a decorator - style | def threaded ( system , func , * args , * * kwargs ) : @ wraps ( func ) def wrapper ( * args , * * kwargs ) : try : return func ( * args , * * kwargs ) except Exception as e : if system . raven_client : system . raven_client . captureException ( ) logger . exception ( 'Exception occurred in thread: %s' , e ) return Fal... | 967 | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/common.py#L96-L108 | [
"def",
"decode",
"(",
"self",
",",
"data",
")",
":",
"file_name",
"=",
"self",
".",
"_filename_decoder",
".",
"decode",
"(",
"data",
"[",
"'filename'",
"]",
")",
"file_data",
"=",
"data",
"[",
"'contents'",
"]",
"i",
"=",
"0",
"max_size",
"=",
"len",
... |
Return True if the expected matchers are matched in the expected order otherwise False . | def match ( self , item ) : if self . _position == len ( self . _matchers ) : raise RuntimeError ( 'Matcher exhausted, no more matchers to use' ) matcher = self . _matchers [ self . _position ] if matcher ( item ) : self . _position += 1 if self . _position == len ( self . _matchers ) : # All patterns have been matched... | 968 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/stream/matchers.py#L81-L97 | [
"def",
"win32_refresh_window",
"(",
"cls",
")",
":",
"# Get console handle",
"handle",
"=",
"windll",
".",
"kernel32",
".",
"GetConsoleWindow",
"(",
")",
"RDW_INVALIDATE",
"=",
"0x0001",
"windll",
".",
"user32",
".",
"RedrawWindow",
"(",
"handle",
",",
"None",
... |
Return True if the expected matchers are matched in any order otherwise False . | def match ( self , item ) : if not self . _unused_matchers : raise RuntimeError ( 'Matcher exhausted, no more matchers to use' ) for matcher in self . _unused_matchers : if matcher ( item ) : self . _used_matchers . append ( matcher ) break if not self . _unused_matchers : # All patterns have been matched return True r... | 969 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/stream/matchers.py#L129-L146 | [
"def",
"win32_refresh_window",
"(",
"cls",
")",
":",
"# Get console handle",
"handle",
"=",
"windll",
".",
"kernel32",
".",
"GetConsoleWindow",
"(",
")",
"RDW_INVALIDATE",
"=",
"0x0001",
"windll",
".",
"user32",
".",
"RedrawWindow",
"(",
"handle",
",",
"None",
... |
Extension of the MORESANE algorithm . This takes a scale - by - scale approach attempting to remove all sources at the lower scales before moving onto the higher ones . At each step the algorithm may return to previous scales to remove the sources uncovered by the deconvolution . | def moresane_by_scale ( self , start_scale = 1 , stop_scale = 20 , subregion = None , sigma_level = 4 , loop_gain = 0.1 , tolerance = 0.75 , accuracy = 1e-6 , major_loop_miter = 100 , minor_loop_miter = 30 , all_on_gpu = False , decom_mode = "ser" , core_count = 1 , conv_device = 'cpu' , conv_mode = 'linear' , extracti... | 970 | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/main.py#L523-L599 | [
"def",
"set_global_feedback",
"(",
"feedback",
",",
"append",
"=",
"False",
")",
":",
"rdict",
"=",
"load_feedback",
"(",
")",
"rdict",
"[",
"'text'",
"]",
"=",
"rdict",
".",
"get",
"(",
"'text'",
",",
"''",
")",
"+",
"feedback",
"if",
"append",
"else"... |
This method constructs the restoring beam and then adds the convolution to the residual . | def restore ( self ) : clean_beam , beam_params = beam_fit ( self . psf_data , self . cdelt1 , self . cdelt2 ) if np . all ( np . array ( self . psf_data_shape ) == 2 * np . array ( self . dirty_data_shape ) ) : self . restored = np . fft . fftshift ( np . fft . irfft2 ( np . fft . rfft2 ( conv . pad_array ( self . mod... | 971 | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/main.py#L601-L616 | [
"def",
"component_doi",
"(",
"soup",
")",
":",
"component_doi",
"=",
"[",
"]",
"object_id_tags",
"=",
"raw_parser",
".",
"object_id",
"(",
"soup",
",",
"pub_id_type",
"=",
"\"doi\"",
")",
"# Get components too for later",
"component_list",
"=",
"components",
"(",
... |
This method tries to ensure that the input data has the correct dimensions . | def handle_input ( self , input_hdr ) : input_slice = input_hdr [ 'NAXIS' ] * [ 0 ] for i in range ( input_hdr [ 'NAXIS' ] ) : if input_hdr [ 'CTYPE%d' % ( i + 1 ) ] . startswith ( "RA" ) : input_slice [ - 1 ] = slice ( None ) if input_hdr [ 'CTYPE%d' % ( i + 1 ) ] . startswith ( "DEC" ) : input_slice [ - 2 ] = slice (... | 972 | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/main.py#L618-L634 | [
"def",
"authorize_url",
"(",
"self",
")",
":",
"url",
",",
"self",
".",
"state",
"=",
"self",
".",
"oauth",
".",
"authorization_url",
"(",
"'%sauthorize'",
"%",
"OAUTH_URL",
")",
"return",
"url"
] |
This method simply saves the model components and the residual . | def save_fits ( self , data , name ) : data = data . reshape ( 1 , 1 , data . shape [ 0 ] , data . shape [ 0 ] ) new_file = pyfits . PrimaryHDU ( data , self . img_hdu_list [ 0 ] . header ) new_file . writeto ( "{}" . format ( name ) , overwrite = True ) | 973 | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/main.py#L636-L646 | [
"def",
"quote",
"(",
"text",
")",
":",
"text",
"=",
"unicode",
"(",
"text",
")",
"return",
"text",
".",
"translate",
"(",
"{",
"ord",
"(",
"'&'",
")",
":",
"u'&'",
",",
"ord",
"(",
"'<'",
")",
":",
"u'<'",
",",
"ord",
"(",
"'\"'",
")",
"... |
Convenience function which creates a logger for the module . | def make_logger ( self , level = "INFO" ) : level = getattr ( logging , level . upper ( ) ) logger = logging . getLogger ( __name__ ) logger . setLevel ( logging . DEBUG ) fh = logging . FileHandler ( 'PyMORESANE.log' , mode = 'w' ) fh . setLevel ( level ) ch = logging . StreamHandler ( ) ch . setLevel ( level ) format... | 974 | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/main.py#L648-L676 | [
"def",
"_get_port_speed_price_id",
"(",
"items",
",",
"port_speed",
",",
"no_public",
",",
"location",
")",
":",
"for",
"item",
"in",
"items",
":",
"if",
"utils",
".",
"lookup",
"(",
"item",
",",
"'itemCategory'",
",",
"'categoryCode'",
")",
"!=",
"'port_spe... |
Start Text UI main loop | def text_ui ( self ) : self . logger . info ( "Starting command line interface" ) self . help ( ) try : self . ipython_ui ( ) except ImportError : self . fallback_ui ( ) self . system . cleanup ( ) | 975 | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/services/textui.py#L96-L106 | [
"def",
"scan",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"pos",
"=",
"0",
"self",
".",
"text",
"=",
"text",
"while",
"self",
".",
"pos",
"<",
"len",
"(",
"text",
")",
":",
"m",
"=",
"self",
".",
"wsregexp",
".",
"match",
"(",
"text",
"... |
Prepare headers for http communication . | def _prepare_headers ( self , additional_headers = None , * * kwargs ) : user_agent = "pyseaweed/{version}" . format ( version = __version__ ) headers = { "User-Agent" : user_agent } if additional_headers is not None : headers . update ( additional_headers ) return headers | 976 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/utils.py#L21-L39 | [
"def",
"get_tracks_from_album",
"(",
"album_name",
")",
":",
"spotify",
"=",
"spotipy",
".",
"Spotify",
"(",
")",
"album",
"=",
"spotify",
".",
"search",
"(",
"q",
"=",
"'album:'",
"+",
"album_name",
",",
"limit",
"=",
"1",
")",
"album_id",
"=",
"album",... |
Returns response to http HEAD on provided url | def head ( self , url , * args , * * kwargs ) : res = self . _conn . head ( url , headers = self . _prepare_headers ( * * kwargs ) ) if res . status_code == 200 : return res return None | 977 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/utils.py#L41-L48 | [
"def",
"_SeparateTypes",
"(",
"self",
",",
"metadata_value_pairs",
")",
":",
"registry_pairs",
"=",
"[",
"]",
"file_pairs",
"=",
"[",
"]",
"match_pairs",
"=",
"[",
"]",
"for",
"metadata",
",",
"result",
"in",
"metadata_value_pairs",
":",
"if",
"(",
"result",... |
Gets data from url as text | def get_data ( self , url , * args , * * kwargs ) : res = self . _conn . get ( url , headers = self . _prepare_headers ( * * kwargs ) ) if res . status_code == 200 : return res . text else : return None | 978 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/utils.py#L50-L70 | [
"def",
"find_signature",
"(",
"self",
",",
"data_stream",
",",
"msg_signature",
")",
":",
"signature_match_index",
"=",
"None",
"# The message that will be returned if it matches the signature",
"msg_signature",
"=",
"msg_signature",
".",
"split",
"(",
")",
"# Split into li... |
Gets data from url as bytes | def get_raw_data ( self , url , * args , * * kwargs ) : res = self . _conn . get ( url , headers = self . _prepare_headers ( * * kwargs ) ) if res . status_code == 200 : return res . content else : return None | 979 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/utils.py#L72-L93 | [
"def",
"group_experiments_greedy",
"(",
"tomo_expt",
":",
"TomographyExperiment",
")",
":",
"diag_sets",
"=",
"_max_tpb_overlap",
"(",
"tomo_expt",
")",
"grouped_expt_settings_list",
"=",
"list",
"(",
"diag_sets",
".",
"values",
"(",
")",
")",
"grouped_tomo_expt",
"... |
Uploads file to provided url . | def post_file ( self , url , filename , file_stream , * args , * * kwargs ) : res = self . _conn . post ( url , files = { filename : file_stream } , headers = self . _prepare_headers ( * * kwargs ) ) if res . status_code == 200 or res . status_code == 201 : return res . text else : return None | 980 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/utils.py#L95-L119 | [
"def",
"get_records",
"(",
"self",
")",
":",
"form",
"=",
"self",
".",
"request",
".",
"form",
"ar_count",
"=",
"self",
".",
"get_ar_count",
"(",
")",
"records",
"=",
"[",
"]",
"# Group belonging AR fields together",
"for",
"arnum",
"in",
"range",
"(",
"ar... |
Deletes data under provided url | def delete_data ( self , url , * args , * * kwargs ) : res = self . _conn . delete ( url , headers = self . _prepare_headers ( * * kwargs ) ) if res . status_code == 200 or res . status_code == 202 : return True else : return False | 981 | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/utils.py#L121-L140 | [
"def",
"record",
"(",
"self",
")",
":",
"while",
"True",
":",
"frames",
"=",
"[",
"]",
"self",
".",
"stream",
".",
"start_stream",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"num_frames",
")",
":",
"data",
"=",
"self",
".",
"stream",
... |
Given a collection of Unicode diacritics return a function that takes a string and returns the string without those diacritics . | def remove_diacritic ( * diacritics ) : def _ ( text ) : return unicodedata . normalize ( "NFC" , "" . join ( ch for ch in unicodedata . normalize ( "NFD" , text ) if ch not in diacritics ) ) return _ | 982 | https://github.com/jtauber/greek-accentuation/blob/330796cd97f7c7adcbecbd05bd91be984f9b9f67/greek_accentuation/characters.py#L42-L53 | [
"def",
"MapFile",
"(",
"self",
",",
"key_path_prefix",
",",
"registry_file",
")",
":",
"self",
".",
"_registry_files",
"[",
"key_path_prefix",
".",
"upper",
"(",
")",
"]",
"=",
"registry_file",
"registry_file",
".",
"SetKeyPathPrefix",
"(",
"key_path_prefix",
")... |
Recursively merge all input dicts into a single dict . | def deep_merge ( * dicts ) : result = { } for d in dicts : if not isinstance ( d , dict ) : raise Exception ( 'Can only deep_merge dicts, got {}' . format ( d ) ) for k , v in d . items ( ) : # Whenever the value is a dict, we deep_merge it. This ensures that # (a) we only ever merge dicts with dicts and (b) we always ... | 983 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L21-L37 | [
"def",
"checkIfAvailable",
"(",
"self",
",",
"dateTime",
"=",
"timezone",
".",
"now",
"(",
")",
")",
":",
"return",
"(",
"self",
".",
"startTime",
">=",
"dateTime",
"+",
"timedelta",
"(",
"days",
"=",
"getConstant",
"(",
"'privateLessons__closeBookingDays'",
... |
Create an instance of this resource definition . | def create ( self , * * kwargs ) : if self . created : raise RuntimeError ( '{} already created.' . format ( self . __model_type__ . __name__ ) ) kwargs = self . merge_kwargs ( self . _create_kwargs , kwargs ) self . _inner = self . helper . create ( self . name , * self . _create_args , * * kwargs ) | 984 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L54-L67 | [
"def",
"readAnnotations",
"(",
"self",
")",
":",
"annot",
"=",
"self",
".",
"read_annotation",
"(",
")",
"annot",
"=",
"np",
".",
"array",
"(",
"annot",
")",
"if",
"(",
"annot",
".",
"shape",
"[",
"0",
"]",
"==",
"0",
")",
":",
"return",
"np",
".... |
Remove an instance of this resource definition . | def remove ( self , * * kwargs ) : self . helper . remove ( self . inner ( ) , * * kwargs ) self . _inner = None | 985 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L69-L74 | [
"def",
"readAnnotations",
"(",
"self",
")",
":",
"annot",
"=",
"self",
".",
"read_annotation",
"(",
")",
"annot",
"=",
"np",
".",
"array",
"(",
"annot",
")",
"if",
"(",
"annot",
".",
"shape",
"[",
"0",
"]",
"==",
"0",
")",
":",
"return",
"np",
".... |
Setup this resource so that is ready to be used in a test . If the resource has already been created this call does nothing . | def setup ( self , helper = None , * * create_kwargs ) : if self . created : return self . set_helper ( helper ) self . create ( * * create_kwargs ) return self | 986 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L76-L99 | [
"def",
"files_comments_delete",
"(",
"self",
",",
"*",
",",
"file",
":",
"str",
",",
"id",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
"->",
"SlackResponse",
":",
"kwargs",
".",
"update",
"(",
"{",
"\"file\"",
":",
"file",
",",
"\"id\"",
":",
"id",
"... |
A decorator to inject this container into a function as a test fixture . | def as_fixture ( self , name = None ) : if name is None : name = self . name def deco ( f ) : @ functools . wraps ( f ) def wrapper ( * args , * * kw ) : with self : kw [ name ] = self return f ( * args , * * kw ) return wrapper return deco | 987 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L147-L161 | [
"def",
"_GetKeyFromRegistry",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_registry",
":",
"return",
"try",
":",
"self",
".",
"_registry_key",
"=",
"self",
".",
"_registry",
".",
"GetKeyByPath",
"(",
"self",
".",
"_key_path",
")",
"except",
"RuntimeE... |
Creates the container starts it and waits for it to completely start . | def setup ( self , helper = None , * * run_kwargs ) : if self . created : return self . set_helper ( helper ) self . run ( * * run_kwargs ) self . wait_for_start ( ) return self | 988 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L246-L267 | [
"def",
"read_avro",
"(",
"file_path_or_buffer",
",",
"schema",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"file_path_or_buffer",
",",
"six",
".",
"string_types",
")",
":",
"with",
"open",
"(",
"file_path_or_buffer",
",",
"'rb'",... |
Stop and remove the container if it exists . | def teardown ( self ) : while self . _http_clients : self . _http_clients . pop ( ) . close ( ) if self . created : self . halt ( ) | 989 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L269-L276 | [
"def",
"_handle_fetch_response",
"(",
"self",
",",
"request",
",",
"send_time",
",",
"response",
")",
":",
"fetch_offsets",
"=",
"{",
"}",
"for",
"topic",
",",
"partitions",
"in",
"request",
".",
"topics",
":",
"for",
"partition_data",
"in",
"partitions",
":... |
Get the container s current status from Docker . | def status ( self ) : if not self . created : return None self . inner ( ) . reload ( ) return self . inner ( ) . status | 990 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L278-L288 | [
"def",
"_openResources",
"(",
"self",
")",
":",
"try",
":",
"rate",
",",
"data",
"=",
"scipy",
".",
"io",
".",
"wavfile",
".",
"read",
"(",
"self",
".",
"_fileName",
",",
"mmap",
"=",
"True",
")",
"except",
"Exception",
"as",
"ex",
":",
"logger",
"... |
Stop the container . The container must have been created . | def stop ( self , timeout = 5 ) : self . inner ( ) . stop ( timeout = timeout ) self . inner ( ) . reload ( ) | 991 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L297-L306 | [
"def",
"_retrieve_offsets",
"(",
"self",
",",
"timestamps",
",",
"timeout_ms",
"=",
"float",
"(",
"\"inf\"",
")",
")",
":",
"if",
"not",
"timestamps",
":",
"return",
"{",
"}",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"remaining_ms",
"=",
"timeou... |
Create the container and start it . Similar to docker run . | def run ( self , fetch_image = True , * * kwargs ) : self . create ( fetch_image = fetch_image , * * kwargs ) self . start ( ) | 992 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L308-L319 | [
"def",
"_adapt_WSDateTime",
"(",
"dt",
")",
":",
"try",
":",
"ts",
"=",
"int",
"(",
"(",
"dt",
".",
"replace",
"(",
"tzinfo",
"=",
"pytz",
".",
"utc",
")",
"-",
"datetime",
"(",
"1970",
",",
"1",
",",
"1",
",",
"tzinfo",
"=",
"pytz",
".",
"utc"... |
Wait for the container to start . | def wait_for_start ( self ) : if self . wait_matchers : matcher = UnorderedMatcher ( * self . wait_matchers ) self . wait_for_logs_matching ( matcher , timeout = self . wait_timeout ) | 993 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L321-L332 | [
"def",
"hicexplorer_basic_statistics",
"(",
"self",
")",
":",
"data",
"=",
"{",
"}",
"for",
"file",
"in",
"self",
".",
"mod_data",
":",
"max_distance_key",
"=",
"'Max rest. site distance'",
"total_pairs",
"=",
"self",
".",
"mod_data",
"[",
"file",
"]",
"[",
... |
Get container logs . | def get_logs ( self , stdout = True , stderr = True , timestamps = False , tail = 'all' , since = None ) : return self . inner ( ) . logs ( stdout = stdout , stderr = stderr , timestamps = timestamps , tail = tail , since = since ) | 994 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L400-L410 | [
"def",
"has_uncacheable_headers",
"(",
"self",
",",
"response",
")",
":",
"cc_dict",
"=",
"get_header_dict",
"(",
"response",
",",
"'Cache-Control'",
")",
"if",
"cc_dict",
":",
"if",
"'max-age'",
"in",
"cc_dict",
"and",
"cc_dict",
"[",
"'max-age'",
"]",
"==",
... |
Stream container output . | def stream_logs ( self , stdout = True , stderr = True , tail = 'all' , timeout = 10.0 ) : return stream_logs ( self . inner ( ) , stdout = stdout , stderr = stderr , tail = tail , timeout = timeout ) | 995 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L412-L418 | [
"def",
"delete_entity",
"(",
"self",
",",
"entity_id",
",",
"mount_point",
"=",
"DEFAULT_MOUNT_POINT",
")",
":",
"api_path",
"=",
"'/v1/{mount_point}/entity/id/{id}'",
".",
"format",
"(",
"mount_point",
"=",
"mount_point",
",",
"id",
"=",
"entity_id",
",",
")",
... |
Wait for logs matching the given matcher . | def wait_for_logs_matching ( self , matcher , timeout = 10 , encoding = 'utf-8' , * * logs_kwargs ) : wait_for_logs_matching ( self . inner ( ) , matcher , timeout = timeout , encoding = encoding , * * logs_kwargs ) | 996 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L420-L427 | [
"def",
"aux",
"(",
"self",
",",
"aux",
")",
":",
"if",
"aux",
"==",
"self",
".",
"_aux",
":",
"return",
"if",
"self",
".",
"_aux",
":",
"self",
".",
"_manager",
".",
"port_manager",
".",
"release_tcp_port",
"(",
"self",
".",
"_aux",
",",
"self",
".... |
Construct an HTTP client for this container . | def http_client ( self , port = None ) : # Local import to avoid potential circularity. from seaworthy . client import ContainerHttpClient client = ContainerHttpClient . for_container ( self , container_port = port ) self . _http_clients . append ( client ) return client | 997 | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/definitions.py#L429-L437 | [
"def",
"noise",
"(",
"mesh",
",",
"magnitude",
"=",
"None",
")",
":",
"if",
"magnitude",
"is",
"None",
":",
"magnitude",
"=",
"mesh",
".",
"scale",
"/",
"100.0",
"random",
"=",
"(",
"np",
".",
"random",
".",
"random",
"(",
"mesh",
".",
"vertices",
... |
Prepare and dispatch a trait change event to a listener . | def _dispatch_change_event ( self , object , trait_name , old , new , handler ) : # Extract the arguments needed from the handler. args = self . argument_transform ( object , trait_name , old , new ) # Send a description of the event to the change event tracer. if tnotifier . _pre_change_event_tracer is not None : tnot... | 998 | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/traits_fixes.py#L59-L85 | [
"async",
"def",
"load_cache",
"(",
"self",
",",
"archive",
":",
"bool",
"=",
"False",
")",
"->",
"int",
":",
"LOGGER",
".",
"debug",
"(",
"'Verifier.load_cache >>> archive: %s'",
",",
"archive",
")",
"rv",
"=",
"int",
"(",
"time",
"(",
")",
")",
"for",
... |
Split value into value and exponent - of - 10 where exponent - of - 10 is a multiple of 3 . This corresponds to SI prefixes . | def split ( value , precision = 1 ) : negative = False digits = precision + 1 if value < 0. : value = - value negative = True elif value == 0. : return 0. , 0 expof10 = int ( math . log10 ( value ) ) if expof10 > 0 : expof10 = ( expof10 // 3 ) * 3 else : expof10 = ( - expof10 + 3 ) // 3 * ( - 3 ) value *= 10 ** ( - exp... | 999 | https://github.com/cfobel/si-prefix/blob/274fdf47f65d87d0b7a2e3c80f267db63d042c59/si_prefix/__init__.py#L47-L106 | [
"def",
"load_cert_chain",
"(",
"self",
",",
"certfile",
",",
"keyfile",
"=",
"None",
")",
":",
"self",
".",
"_certfile",
"=",
"certfile",
"self",
".",
"_keyfile",
"=",
"keyfile"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.