Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
EvaluationMaster._read_dataset_metadata
(self)
Reads dataset metadata. Returns: instance of DatasetMetadata
Reads dataset metadata.
def _read_dataset_metadata(self): """Reads dataset metadata. Returns: instance of DatasetMetadata """ blob = self.storage_client.get_blob( "dataset/" + self.dataset_name + "_dataset.csv" ) buf = BytesIO() blob.download_to_file(buf) b...
[ "def", "_read_dataset_metadata", "(", "self", ")", ":", "blob", "=", "self", ".", "storage_client", ".", "get_blob", "(", "\"dataset/\"", "+", "self", ".", "dataset_name", "+", "\"_dataset.csv\"", ")", "buf", "=", "BytesIO", "(", ")", "blob", ".", "download_...
[ 319, 4 ]
[ 331, 44 ]
python
en
['fr', 'jv', 'en']
False
EvaluationMaster.compute_results
(self)
Computes results (scores, stats, etc...) of competition evaluation. Results are saved into output directory (self.results_dir). Also this method saves all intermediate data into output directory as well, so it can resume computation if it was interrupted for some reason. This is useful ...
Computes results (scores, stats, etc...) of competition evaluation.
def compute_results(self): """Computes results (scores, stats, etc...) of competition evaluation. Results are saved into output directory (self.results_dir). Also this method saves all intermediate data into output directory as well, so it can resume computation if it was interrupted fo...
[ "def", "compute_results", "(", "self", ")", ":", "# read all data", "logging", ".", "info", "(", "\"Reading data from datastore\"", ")", "dataset_meta", "=", "self", ".", "_read_dataset_metadata", "(", ")", "self", ".", "submissions", ".", "init_from_datastore", "("...
[ 333, 4 ]
[ 557, 9 ]
python
en
['en', 'en', 'en']
True
EvaluationMaster._show_status_for_work
(self, work)
Shows status for given work pieces. Args: work: instance of either AttackWorkPieces or DefenseWorkPieces
Shows status for given work pieces.
def _show_status_for_work(self, work): """Shows status for given work pieces. Args: work: instance of either AttackWorkPieces or DefenseWorkPieces """ work_count = len(work.work) work_completed = {} work_completed_count = 0 for v in itervalues(work.work...
[ "def", "_show_status_for_work", "(", "self", ",", "work", ")", ":", "work_count", "=", "len", "(", "work", ".", "work", ")", "work_completed", "=", "{", "}", "work_completed_count", "=", "0", "for", "v", "in", "itervalues", "(", "work", ".", "work", ")",...
[ 559, 4 ]
[ 591, 13 ]
python
en
['en', 'en', 'en']
True
EvaluationMaster._export_work_errors
(self, work, output_file)
Saves errors for given work pieces into file. Args: work: instance of either AttackWorkPieces or DefenseWorkPieces output_file: name of the output file
Saves errors for given work pieces into file.
def _export_work_errors(self, work, output_file): """Saves errors for given work pieces into file. Args: work: instance of either AttackWorkPieces or DefenseWorkPieces output_file: name of the output file """ errors = set() for v in itervalues(work.work): ...
[ "def", "_export_work_errors", "(", "self", ",", "work", ",", "output_file", ")", ":", "errors", "=", "set", "(", ")", "for", "v", "in", "itervalues", "(", "work", ".", "work", ")", ":", "if", "v", "[", "\"is_completed\"", "]", "and", "v", "[", "\"err...
[ 593, 4 ]
[ 607, 29 ]
python
en
['en', 'en', 'en']
True
EvaluationMaster.show_status
(self)
Shows current status of competition evaluation. Also this method saves error messages generated by attacks and defenses into attack_errors.txt and defense_errors.txt.
Shows current status of competition evaluation.
def show_status(self): """Shows current status of competition evaluation. Also this method saves error messages generated by attacks and defenses into attack_errors.txt and defense_errors.txt. """ print_header("Attack work statistics") self.attack_work.read_all_from_data...
[ "def", "show_status", "(", "self", ")", ":", "print_header", "(", "\"Attack work statistics\"", ")", "self", ".", "attack_work", ".", "read_all_from_datastore", "(", ")", "self", ".", "_show_status_for_work", "(", "self", ".", "attack_work", ")", "self", ".", "_...
[ 609, 4 ]
[ 626, 9 ]
python
en
['en', 'en', 'en']
True
EvaluationMaster.cleanup_failed_attacks
(self)
Cleans up data of failed attacks.
Cleans up data of failed attacks.
def cleanup_failed_attacks(self): """Cleans up data of failed attacks.""" print_header("Cleaning up failed attacks") attacks_to_replace = {} self.attack_work.read_all_from_datastore() failed_submissions = set() error_msg = set() for k, v in iteritems(self.attack_w...
[ "def", "cleanup_failed_attacks", "(", "self", ")", ":", "print_header", "(", "\"Cleaning up failed attacks\"", ")", "attacks_to_replace", "=", "{", "}", "self", ".", "attack_work", ".", "read_all_from_datastore", "(", ")", "failed_submissions", "=", "set", "(", ")",...
[ 628, 4 ]
[ 659, 32 ]
python
en
['en', 'en', 'en']
True
EvaluationMaster.cleanup_attacks_with_zero_images
(self)
Cleans up data about attacks which generated zero images.
Cleans up data about attacks which generated zero images.
def cleanup_attacks_with_zero_images(self): """Cleans up data about attacks which generated zero images.""" print_header("Cleaning up attacks which generated 0 images.") # find out attack work to cleanup self.adv_batches.init_from_datastore() self.attack_work.read_all_from_datast...
[ "def", "cleanup_attacks_with_zero_images", "(", "self", ")", ":", "print_header", "(", "\"Cleaning up attacks which generated 0 images.\"", ")", "# find out attack work to cleanup", "self", ".", "adv_batches", ".", "init_from_datastore", "(", ")", "self", ".", "attack_work", ...
[ 661, 4 ]
[ 725, 22 ]
python
en
['en', 'en', 'en']
True
EvaluationMaster._cleanup_keys_with_confirmation
(self, keys_to_delete)
Asks confirmation and then deletes entries with keys. Args: keys_to_delete: list of datastore keys for which entries should be deleted
Asks confirmation and then deletes entries with keys.
def _cleanup_keys_with_confirmation(self, keys_to_delete): """Asks confirmation and then deletes entries with keys. Args: keys_to_delete: list of datastore keys for which entries should be deleted """ print("Round name: ", self.round_name) print("Number of entities to ...
[ "def", "_cleanup_keys_with_confirmation", "(", "self", ",", "keys_to_delete", ")", ":", "print", "(", "\"Round name: \"", ",", "self", ".", "round_name", ")", "print", "(", "\"Number of entities to be deleted: \"", ",", "len", "(", "keys_to_delete", ")", ")", "if", ...
[ 727, 4 ]
[ 768, 29 ]
python
en
['en', 'en', 'en']
True
EvaluationMaster.cleanup_defenses
(self)
Cleans up all data about defense work in current round.
Cleans up all data about defense work in current round.
def cleanup_defenses(self): """Cleans up all data about defense work in current round.""" print_header("CLEANING UP DEFENSES DATA") work_ancestor_key = self.datastore_client.key("WorkType", "AllDefenses") keys_to_delete = [ e.key for e in self.datastore_client.que...
[ "def", "cleanup_defenses", "(", "self", ")", ":", "print_header", "(", "\"CLEANING UP DEFENSES DATA\"", ")", "work_ancestor_key", "=", "self", ".", "datastore_client", ".", "key", "(", "\"WorkType\"", ",", "\"AllDefenses\"", ")", "keys_to_delete", "=", "[", "e", "...
[ 770, 4 ]
[ 783, 60 ]
python
en
['en', 'en', 'en']
True
EvaluationMaster.cleanup_datastore
(self)
Cleans up datastore and deletes all information about current round.
Cleans up datastore and deletes all information about current round.
def cleanup_datastore(self): """Cleans up datastore and deletes all information about current round.""" print_header("CLEANING UP ENTIRE DATASTORE") kinds_to_delete = [ u"Submission", u"SubmissionType", u"DatasetImage", u"DatasetBatch", ...
[ "def", "cleanup_datastore", "(", "self", ")", ":", "print_header", "(", "\"CLEANING UP ENTIRE DATASTORE\"", ")", "kinds_to_delete", "=", "[", "u\"Submission\"", ",", "u\"SubmissionType\"", ",", "u\"DatasetImage\"", ",", "u\"DatasetBatch\"", ",", "u\"AdversarialImage\"", "...
[ 785, 4 ]
[ 804, 60 ]
python
en
['en', 'en', 'en']
True
test_admin_may_bypass_min_period
(resource_with_opening_hours, user)
Admin users should be able to bypass min_period, and their minimum reservation time should be limited by slot_size
Admin users should be able to bypass min_period, and their minimum reservation time should be limited by slot_size
def test_admin_may_bypass_min_period(resource_with_opening_hours, user): """ Admin users should be able to bypass min_period, and their minimum reservation time should be limited by slot_size """ activate('en') # min_period is bypassed respecting slot_size restriction resource_with_opening_...
[ "def", "test_admin_may_bypass_min_period", "(", "resource_with_opening_hours", ",", "user", ")", ":", "activate", "(", "'en'", ")", "# min_period is bypassed respecting slot_size restriction", "resource_with_opening_hours", ".", "min_period", "=", "datetime", ".", "timedelta", ...
[ 155, 0 ]
[ 186, 50 ]
python
en
['en', 'error', 'th']
False
py_func_grad
(func, inp, Tout, stateful=True, name=None, grad=None)
Custom py_func with gradient support
Custom py_func with gradient support
def py_func_grad(func, inp, Tout, stateful=True, name=None, grad=None): """Custom py_func with gradient support""" # Need to generate a unique name to avoid duplicates: rnd_name = "PyFuncGrad" + str(np.random.randint(0, 1e8)) tf.RegisterGradient(rnd_name)(grad) g = tf.get_default_graph() with g...
[ "def", "py_func_grad", "(", "func", ",", "inp", ",", "Tout", ",", "stateful", "=", "True", ",", "name", "=", "None", ",", "grad", "=", "None", ")", ":", "# Need to generate a unique name to avoid duplicates:", "rnd_name", "=", "\"PyFuncGrad\"", "+", "str", "("...
[ 25, 0 ]
[ 33, 72 ]
python
en
['en', 'en', 'en']
True
SelectAndTextWidget._set_choices
(self, choices)
When choices are set for this widget, we want to pass those along to the Select widget
When choices are set for this widget, we want to pass those along to the Select widget
def _set_choices(self, choices): """ When choices are set for this widget, we want to pass those along to the Select widget """ self.widgets[0].choices = choices
[ "def", "_set_choices", "(", "self", ",", "choices", ")", ":", "self", ".", "widgets", "[", "0", "]", ".", "choices", "=", "choices" ]
[ 1090, 4 ]
[ 1094, 41 ]
python
en
['en', 'error', 'th']
False
SelectAndTextWidget._get_choices
(self)
The choices for this widget are the Select widget's choices
The choices for this widget are the Select widget's choices
def _get_choices(self): """ The choices for this widget are the Select widget's choices """ return self.widgets[0].choices
[ "def", "_get_choices", "(", "self", ")", ":", "return", "self", ".", "widgets", "[", "0", "]", ".", "choices" ]
[ 1096, 4 ]
[ 1100, 38 ]
python
en
['en', 'error', 'th']
False
ClearableFileInputTests.test_clear_input_renders
(self)
A ClearableFileInput with is_required False and rendered with an initial value that is a file renders a clear checkbox.
A ClearableFileInput with is_required False and rendered with an initial value that is a file renders a clear checkbox.
def test_clear_input_renders(self): """ A ClearableFileInput with is_required False and rendered with an initial value that is a file renders a clear checkbox. """ widget = ClearableFileInput() widget.is_required = False self.assertHTMLEqual(widget.render('myfile...
[ "def", "test_clear_input_renders", "(", "self", ")", ":", "widget", "=", "ClearableFileInput", "(", ")", "widget", ".", "is_required", "=", "False", "self", ".", "assertHTMLEqual", "(", "widget", ".", "render", "(", "'myfile'", ",", "FakeFieldFile", "(", ")", ...
[ 1169, 4 ]
[ 1178, 231 ]
python
en
['en', 'error', 'th']
False
ClearableFileInputTests.test_html_escaped
(self)
A ClearableFileInput should escape name, filename and URL when rendering HTML. Refs #15182.
A ClearableFileInput should escape name, filename and URL when rendering HTML. Refs #15182.
def test_html_escaped(self): """ A ClearableFileInput should escape name, filename and URL when rendering HTML. Refs #15182. """ @python_2_unicode_compatible class StrangeFieldFile(object): url = "something?chapter=1&sect=2&copy=3&lang=en" def __...
[ "def", "test_html_escaped", "(", "self", ")", ":", "@", "python_2_unicode_compatible", "class", "StrangeFieldFile", "(", "object", ")", ":", "url", "=", "\"something?chapter=1&sect=2&copy=3&lang=en\"", "def", "__str__", "(", "self", ")", ":", "return", "'''something<d...
[ 1180, 4 ]
[ 1201, 49 ]
python
en
['en', 'error', 'th']
False
ClearableFileInputTests.test_clear_input_renders_only_if_not_required
(self)
A ClearableFileInput with is_required=False does not render a clear checkbox.
A ClearableFileInput with is_required=False does not render a clear checkbox.
def test_clear_input_renders_only_if_not_required(self): """ A ClearableFileInput with is_required=False does not render a clear checkbox. """ widget = ClearableFileInput() widget.is_required = True self.assertHTMLEqual(widget.render('myfile', FakeFieldFile()), ...
[ "def", "test_clear_input_renders_only_if_not_required", "(", "self", ")", ":", "widget", "=", "ClearableFileInput", "(", ")", "widget", ".", "is_required", "=", "True", "self", ".", "assertHTMLEqual", "(", "widget", ".", "render", "(", "'myfile'", ",", "FakeFieldF...
[ 1203, 4 ]
[ 1212, 122 ]
python
en
['en', 'error', 'th']
False
ClearableFileInputTests.test_clear_input_renders_only_if_initial
(self)
A ClearableFileInput instantiated with no initial value does not render a clear checkbox.
A ClearableFileInput instantiated with no initial value does not render a clear checkbox.
def test_clear_input_renders_only_if_initial(self): """ A ClearableFileInput instantiated with no initial value does not render a clear checkbox. """ widget = ClearableFileInput() widget.is_required = False self.assertHTMLEqual(widget.render('myfile', None), ...
[ "def", "test_clear_input_renders_only_if_initial", "(", "self", ")", ":", "widget", "=", "ClearableFileInput", "(", ")", "widget", ".", "is_required", "=", "False", "self", ".", "assertHTMLEqual", "(", "widget", ".", "render", "(", "'myfile'", ",", "None", ")", ...
[ 1214, 4 ]
[ 1223, 63 ]
python
en
['en', 'error', 'th']
False
ClearableFileInputTests.test_clear_input_checked_returns_false
(self)
ClearableFileInput.value_from_datadict returns False if the clear checkbox is checked, if not required.
ClearableFileInput.value_from_datadict returns False if the clear checkbox is checked, if not required.
def test_clear_input_checked_returns_false(self): """ ClearableFileInput.value_from_datadict returns False if the clear checkbox is checked, if not required. """ widget = ClearableFileInput() widget.is_required = False self.assertEqual(widget.value_from_datadict(...
[ "def", "test_clear_input_checked_returns_false", "(", "self", ")", ":", "widget", "=", "ClearableFileInput", "(", ")", "widget", ".", "is_required", "=", "False", "self", ".", "assertEqual", "(", "widget", ".", "value_from_datadict", "(", "data", "=", "{", "'myf...
[ 1225, 4 ]
[ 1236, 34 ]
python
en
['en', 'error', 'th']
False
ClearableFileInputTests.test_clear_input_checked_returns_false_only_if_not_required
(self)
ClearableFileInput.value_from_datadict never returns False if the field is required.
ClearableFileInput.value_from_datadict never returns False if the field is required.
def test_clear_input_checked_returns_false_only_if_not_required(self): """ ClearableFileInput.value_from_datadict never returns False if the field is required. """ widget = ClearableFileInput() widget.is_required = True f = SimpleUploadedFile('something.txt', b'c...
[ "def", "test_clear_input_checked_returns_false_only_if_not_required", "(", "self", ")", ":", "widget", "=", "ClearableFileInput", "(", ")", "widget", ".", "is_required", "=", "True", "f", "=", "SimpleUploadedFile", "(", "'something.txt'", ",", "b'content'", ")", "self...
[ 1238, 4 ]
[ 1250, 30 ]
python
en
['en', 'error', 'th']
False
run
()
Run the script in sys.argv[1] as if it had been invoked naturally.
Run the script in sys.argv[1] as if it had been invoked naturally.
def run(): """ Run the script in sys.argv[1] as if it had been invoked naturally. """ __builtins__ script_name = sys.argv[1] namespace = dict( __file__=script_name, __name__='__main__', __doc__=None, ) sys.argv[:] = sys.argv[1:] open_ = getattr(tokenize, ...
[ "def", "run", "(", ")", ":", "__builtins__", "script_name", "=", "sys", ".", "argv", "[", "1", "]", "namespace", "=", "dict", "(", "__file__", "=", "script_name", ",", "__name__", "=", "'__main__'", ",", "__doc__", "=", "None", ",", ")", "sys", ".", ...
[ 12, 0 ]
[ 31, 25 ]
python
en
['en', 'error', 'th']
False
bin_constructor
(func)
Generates a prototype for binary construction (HEX, WKB) GEOS routines.
Generates a prototype for binary construction (HEX, WKB) GEOS routines.
def bin_constructor(func): "Generates a prototype for binary construction (HEX, WKB) GEOS routines." func.argtypes = [c_char_p, c_size_t] func.restype = GEOM_PTR func.errcheck = check_geom return func
[ "def", "bin_constructor", "(", "func", ")", ":", "func", ".", "argtypes", "=", "[", "c_char_p", ",", "c_size_t", "]", "func", ".", "restype", "=", "GEOM_PTR", "func", ".", "errcheck", "=", "check_geom", "return", "func" ]
[ 22, 0 ]
[ 27, 15 ]
python
en
['en', 'en', 'en']
True
bin_output
(func)
Generates a prototype for the routines that return a sized string.
Generates a prototype for the routines that return a sized string.
def bin_output(func): "Generates a prototype for the routines that return a sized string." func.argtypes = [GEOM_PTR, POINTER(c_size_t)] func.errcheck = check_sized_string func.restype = c_uchar_p return func
[ "def", "bin_output", "(", "func", ")", ":", "func", ".", "argtypes", "=", "[", "GEOM_PTR", ",", "POINTER", "(", "c_size_t", ")", "]", "func", ".", "errcheck", "=", "check_sized_string", "func", ".", "restype", "=", "c_uchar_p", "return", "func" ]
[ 31, 0 ]
[ 36, 15 ]
python
en
['en', 'en', 'en']
True
geom_output
(func, argtypes)
For GEOS routines that return a geometry.
For GEOS routines that return a geometry.
def geom_output(func, argtypes): "For GEOS routines that return a geometry." if argtypes: func.argtypes = argtypes func.restype = GEOM_PTR func.errcheck = check_geom return func
[ "def", "geom_output", "(", "func", ",", "argtypes", ")", ":", "if", "argtypes", ":", "func", ".", "argtypes", "=", "argtypes", "func", ".", "restype", "=", "GEOM_PTR", "func", ".", "errcheck", "=", "check_geom", "return", "func" ]
[ 39, 0 ]
[ 45, 15 ]
python
en
['en', 'en', 'en']
True
geom_index
(func)
For GEOS routines that return geometries from an index.
For GEOS routines that return geometries from an index.
def geom_index(func): "For GEOS routines that return geometries from an index." return geom_output(func, [GEOM_PTR, c_int])
[ "def", "geom_index", "(", "func", ")", ":", "return", "geom_output", "(", "func", ",", "[", "GEOM_PTR", ",", "c_int", "]", ")" ]
[ 48, 0 ]
[ 50, 47 ]
python
en
['en', 'en', 'en']
True
int_from_geom
(func, zero=False)
Argument is a geometry, return type is an integer.
Argument is a geometry, return type is an integer.
def int_from_geom(func, zero=False): "Argument is a geometry, return type is an integer." func.argtypes = [GEOM_PTR] func.restype = c_int if zero: func.errcheck = check_zero else: func.errcheck = check_minus_one return func
[ "def", "int_from_geom", "(", "func", ",", "zero", "=", "False", ")", ":", "func", ".", "argtypes", "=", "[", "GEOM_PTR", "]", "func", ".", "restype", "=", "c_int", "if", "zero", ":", "func", ".", "errcheck", "=", "check_zero", "else", ":", "func", "....
[ 53, 0 ]
[ 61, 15 ]
python
en
['en', 'en', 'en']
True
string_from_geom
(func)
Argument is a Geometry, return type is a string.
Argument is a Geometry, return type is a string.
def string_from_geom(func): "Argument is a Geometry, return type is a string." func.argtypes = [GEOM_PTR] func.restype = geos_char_p func.errcheck = check_string return func
[ "def", "string_from_geom", "(", "func", ")", ":", "func", ".", "argtypes", "=", "[", "GEOM_PTR", "]", "func", ".", "restype", "=", "geos_char_p", "func", ".", "errcheck", "=", "check_string", "return", "func" ]
[ 64, 0 ]
[ 69, 15 ]
python
en
['en', 'en', 'en']
True
register_handler
(handler)
Install application-specific WMF image handler. :param handler: Handler object.
Install application-specific WMF image handler.
def register_handler(handler): """ Install application-specific WMF image handler. :param handler: Handler object. """ global _handler _handler = handler
[ "def", "register_handler", "(", "handler", ")", ":", "global", "_handler", "_handler", "=", "handler" ]
[ 27, 0 ]
[ 34, 22 ]
python
en
['en', 'error', 'th']
False
shortcut
(request, content_type_id, object_id)
Redirect to an object's page based on a content-type ID and an object ID.
Redirect to an object's page based on a content-type ID and an object ID.
def shortcut(request, content_type_id, object_id): """ Redirect to an object's page based on a content-type ID and an object ID. """ # Look up the object, making sure it's got a get_absolute_url() function. try: content_type = ContentType.objects.get(pk=content_type_id) if not conten...
[ "def", "shortcut", "(", "request", ",", "content_type_id", ",", "object_id", ")", ":", "# Look up the object, making sure it's got a get_absolute_url() function.", "try", ":", "content_type", "=", "ContentType", ".", "objects", ".", "get", "(", "pk", "=", "content_type_...
[ 10, 0 ]
[ 89, 48 ]
python
en
['en', 'error', 'th']
False
AdminSite.register
(self, model_or_iterable, admin_class=None, **options)
Registers the given model(s) with the given admin class. The model(s) should be Model classes, not instances. If an admin class isn't given, it will use ModelAdmin (the default admin options). If keyword arguments are given -- e.g., list_display -- they'll be applied as option...
Registers the given model(s) with the given admin class.
def register(self, model_or_iterable, admin_class=None, **options): """ Registers the given model(s) with the given admin class. The model(s) should be Model classes, not instances. If an admin class isn't given, it will use ModelAdmin (the default admin options). If keyword ar...
[ "def", "register", "(", "self", ",", "model_or_iterable", ",", "admin_class", "=", "None", ",", "*", "*", "options", ")", ":", "if", "not", "admin_class", ":", "admin_class", "=", "ModelAdmin", "if", "isinstance", "(", "model_or_iterable", ",", "ModelBase", ...
[ 60, 4 ]
[ 103, 64 ]
python
en
['en', 'error', 'th']
False
AdminSite.unregister
(self, model_or_iterable)
Unregisters the given model(s). If a model isn't already registered, this will raise NotRegistered.
Unregisters the given model(s).
def unregister(self, model_or_iterable): """ Unregisters the given model(s). If a model isn't already registered, this will raise NotRegistered. """ if isinstance(model_or_iterable, ModelBase): model_or_iterable = [model_or_iterable] for model in model_or_ite...
[ "def", "unregister", "(", "self", ",", "model_or_iterable", ")", ":", "if", "isinstance", "(", "model_or_iterable", ",", "ModelBase", ")", ":", "model_or_iterable", "=", "[", "model_or_iterable", "]", "for", "model", "in", "model_or_iterable", ":", "if", "model"...
[ 105, 4 ]
[ 116, 37 ]
python
en
['en', 'error', 'th']
False
AdminSite.is_registered
(self, model)
Check if a model class is registered with this `AdminSite`.
Check if a model class is registered with this `AdminSite`.
def is_registered(self, model): """ Check if a model class is registered with this `AdminSite`. """ return model in self._registry
[ "def", "is_registered", "(", "self", ",", "model", ")", ":", "return", "model", "in", "self", ".", "_registry" ]
[ 118, 4 ]
[ 122, 38 ]
python
en
['en', 'error', 'th']
False
AdminSite.add_action
(self, action, name=None)
Register an action to be available globally.
Register an action to be available globally.
def add_action(self, action, name=None): """ Register an action to be available globally. """ name = name or action.__name__ self._actions[name] = action self._global_actions[name] = action
[ "def", "add_action", "(", "self", ",", "action", ",", "name", "=", "None", ")", ":", "name", "=", "name", "or", "action", ".", "__name__", "self", ".", "_actions", "[", "name", "]", "=", "action", "self", ".", "_global_actions", "[", "name", "]", "="...
[ 124, 4 ]
[ 130, 43 ]
python
en
['en', 'error', 'th']
False
AdminSite.disable_action
(self, name)
Disable a globally-registered action. Raises KeyError for invalid names.
Disable a globally-registered action. Raises KeyError for invalid names.
def disable_action(self, name): """ Disable a globally-registered action. Raises KeyError for invalid names. """ del self._actions[name]
[ "def", "disable_action", "(", "self", ",", "name", ")", ":", "del", "self", ".", "_actions", "[", "name", "]" ]
[ 132, 4 ]
[ 136, 31 ]
python
en
['en', 'error', 'th']
False
AdminSite.get_action
(self, name)
Explicitly get a registered global action whether it's enabled or not. Raises KeyError for invalid names.
Explicitly get a registered global action whether it's enabled or not. Raises KeyError for invalid names.
def get_action(self, name): """ Explicitly get a registered global action whether it's enabled or not. Raises KeyError for invalid names. """ return self._global_actions[name]
[ "def", "get_action", "(", "self", ",", "name", ")", ":", "return", "self", ".", "_global_actions", "[", "name", "]" ]
[ 138, 4 ]
[ 143, 41 ]
python
en
['en', 'error', 'th']
False
AdminSite.actions
(self)
Get all the enabled actions as an iterable of (name, func).
Get all the enabled actions as an iterable of (name, func).
def actions(self): """ Get all the enabled actions as an iterable of (name, func). """ return six.iteritems(self._actions)
[ "def", "actions", "(", "self", ")", ":", "return", "six", ".", "iteritems", "(", "self", ".", "_actions", ")" ]
[ 146, 4 ]
[ 150, 43 ]
python
en
['en', 'error', 'th']
False
AdminSite.has_permission
(self, request)
Returns True if the given HttpRequest has permission to view *at least one* page in the admin site.
Returns True if the given HttpRequest has permission to view *at least one* page in the admin site.
def has_permission(self, request): """ Returns True if the given HttpRequest has permission to view *at least one* page in the admin site. """ return request.user.is_active and request.user.is_staff
[ "def", "has_permission", "(", "self", ",", "request", ")", ":", "return", "request", ".", "user", ".", "is_active", "and", "request", ".", "user", ".", "is_staff" ]
[ 152, 4 ]
[ 157, 63 ]
python
en
['en', 'error', 'th']
False
AdminSite.check_dependencies
(self)
Check that all things needed to run the admin have been correctly installed. The default implementation checks that admin and contenttypes apps are installed, as well as the auth context processor.
Check that all things needed to run the admin have been correctly installed.
def check_dependencies(self): """ Check that all things needed to run the admin have been correctly installed. The default implementation checks that admin and contenttypes apps are installed, as well as the auth context processor. """ if not apps.is_installed('django.co...
[ "def", "check_dependencies", "(", "self", ")", ":", "if", "not", "apps", ".", "is_installed", "(", "'django.contrib.admin'", ")", ":", "raise", "ImproperlyConfigured", "(", "\"Put 'django.contrib.admin' in \"", "\"your INSTALLED_APPS setting in order to use the admin applicatio...
[ 159, 4 ]
[ 174, 101 ]
python
en
['en', 'error', 'th']
False
AdminSite.admin_view
(self, view, cacheable=False)
Decorator to create an admin view attached to this ``AdminSite``. This wraps the view and provides permission checking by calling ``self.has_permission``. You'll want to use this from within ``AdminSite.get_urls()``: class MyAdminSite(AdminSite): def get_u...
Decorator to create an admin view attached to this ``AdminSite``. This wraps the view and provides permission checking by calling ``self.has_permission``.
def admin_view(self, view, cacheable=False): """ Decorator to create an admin view attached to this ``AdminSite``. This wraps the view and provides permission checking by calling ``self.has_permission``. You'll want to use this from within ``AdminSite.get_urls()``: ...
[ "def", "admin_view", "(", "self", ",", "view", ",", "cacheable", "=", "False", ")", ":", "def", "inner", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "has_permission", "(", "request", ")", ":", "if"...
[ 176, 4 ]
[ 218, 42 ]
python
en
['en', 'error', 'th']
False
AdminSite.each_context
(self)
Returns a dictionary of variables to put in the template context for *every* page in the admin site.
Returns a dictionary of variables to put in the template context for *every* page in the admin site.
def each_context(self): """ Returns a dictionary of variables to put in the template context for *every* page in the admin site. """ return { 'site_title': self.site_title, 'site_header': self.site_header, 'site_url': self.site_url, }
[ "def", "each_context", "(", "self", ")", ":", "return", "{", "'site_title'", ":", "self", ".", "site_title", ",", "'site_header'", ":", "self", ".", "site_header", ",", "'site_url'", ":", "self", ".", "site_url", ",", "}" ]
[ 271, 4 ]
[ 280, 9 ]
python
en
['en', 'error', 'th']
False
AdminSite.password_change
(self, request)
Handles the "change password" task -- both form display and validation.
Handles the "change password" task -- both form display and validation.
def password_change(self, request): """ Handles the "change password" task -- both form display and validation. """ from django.contrib.admin.forms import AdminPasswordChangeForm from django.contrib.auth.views import password_change url = reverse('admin:password_change_do...
[ "def", "password_change", "(", "self", ",", "request", ")", ":", "from", "django", ".", "contrib", ".", "admin", ".", "forms", "import", "AdminPasswordChangeForm", "from", "django", ".", "contrib", ".", "auth", ".", "views", "import", "password_change", "url",...
[ 282, 4 ]
[ 297, 51 ]
python
en
['en', 'error', 'th']
False
AdminSite.password_change_done
(self, request, extra_context=None)
Displays the "success" page after a password change.
Displays the "success" page after a password change.
def password_change_done(self, request, extra_context=None): """ Displays the "success" page after a password change. """ from django.contrib.auth.views import password_change_done defaults = { 'current_app': self.name, 'extra_context': dict(self.each_cont...
[ "def", "password_change_done", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "from", "django", ".", "contrib", ".", "auth", ".", "views", "import", "password_change_done", "defaults", "=", "{", "'current_app'", ":", "self", ".", "...
[ 299, 4 ]
[ 310, 56 ]
python
en
['en', 'error', 'th']
False
AdminSite.i18n_javascript
(self, request)
Displays the i18n JavaScript that the Django admin requires. This takes into account the USE_I18N setting. If it's set to False, the generated JavaScript will be leaner and faster.
Displays the i18n JavaScript that the Django admin requires.
def i18n_javascript(self, request): """ Displays the i18n JavaScript that the Django admin requires. This takes into account the USE_I18N setting. If it's set to False, the generated JavaScript will be leaner and faster. """ if settings.USE_I18N: from django....
[ "def", "i18n_javascript", "(", "self", ",", "request", ")", ":", "if", "settings", ".", "USE_I18N", ":", "from", "django", ".", "views", ".", "i18n", "import", "javascript_catalog", "else", ":", "from", "django", ".", "views", ".", "i18n", "import", "null_...
[ 312, 4 ]
[ 323, 92 ]
python
en
['en', 'error', 'th']
False
AdminSite.logout
(self, request, extra_context=None)
Logs out the user for the given HttpRequest. This should *not* assume the user is already logged in.
Logs out the user for the given HttpRequest.
def logout(self, request, extra_context=None): """ Logs out the user for the given HttpRequest. This should *not* assume the user is already logged in. """ from django.contrib.auth.views import logout defaults = { 'current_app': self.name, 'extra_...
[ "def", "logout", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "from", "django", ".", "contrib", ".", "auth", ".", "views", "import", "logout", "defaults", "=", "{", "'current_app'", ":", "self", ".", "name", ",", "'extra_cont...
[ 326, 4 ]
[ 339, 42 ]
python
en
['en', 'error', 'th']
False
AdminSite.login
(self, request, extra_context=None)
Displays the login form for the given HttpRequest.
Displays the login form for the given HttpRequest.
def login(self, request, extra_context=None): """ Displays the login form for the given HttpRequest. """ if request.method == 'GET' and self.has_permission(request): # Already logged-in, redirect to admin index index_path = reverse('admin:index', current_app=self....
[ "def", "login", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "if", "request", ".", "method", "==", "'GET'", "and", "self", ".", "has_permission", "(", "request", ")", ":", "# Already logged-in, redirect to admin index", "index_path",...
[ 342, 4 ]
[ 371, 41 ]
python
en
['en', 'error', 'th']
False
AdminSite.index
(self, request, extra_context=None)
Displays the main admin index page, which lists all of the installed apps that have been registered in this site.
Displays the main admin index page, which lists all of the installed apps that have been registered in this site.
def index(self, request, extra_context=None): """ Displays the main admin index page, which lists all of the installed apps that have been registered in this site. """ app_dict = {} for model, model_admin in self._registry.items(): app_label = model._meta.app_...
[ "def", "index", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "app_dict", "=", "{", "}", "for", "model", ",", "model_admin", "in", "self", ".", "_registry", ".", "items", "(", ")", ":", "app_label", "=", "model", ".", "_me...
[ 374, 4 ]
[ 437, 54 ]
python
en
['en', 'error', 'th']
False
get_internal_wsgi_application
()
Load and return the WSGI application as configured by the user in ``settings.WSGI_APPLICATION``. With the default ``startproject`` layout, this will be the ``application`` object in ``projectname/wsgi.py``. This function, and the ``WSGI_APPLICATION`` setting itself, are only useful for Django's in...
Load and return the WSGI application as configured by the user in ``settings.WSGI_APPLICATION``. With the default ``startproject`` layout, this will be the ``application`` object in ``projectname/wsgi.py``.
def get_internal_wsgi_application(): """ Load and return the WSGI application as configured by the user in ``settings.WSGI_APPLICATION``. With the default ``startproject`` layout, this will be the ``application`` object in ``projectname/wsgi.py``. This function, and the ``WSGI_APPLICATION`` setting...
[ "def", "get_internal_wsgi_application", "(", ")", ":", "from", "django", ".", "conf", "import", "settings", "app_path", "=", "getattr", "(", "settings", ",", "'WSGI_APPLICATION'", ")", "if", "app_path", "is", "None", ":", "return", "get_wsgi_application", "(", "...
[ 25, 0 ]
[ 49, 18 ]
python
en
['en', 'error', 'th']
False
ServerHandler.__init__
(self, stdin, stdout, stderr, environ, **kwargs)
Use a LimitedStream so that unread request data will be ignored at the end of the request. WSGIRequest uses a LimitedStream but it shouldn't discard the data since the upstream servers usually do this. This fix applies only for testserver/runserver.
Use a LimitedStream so that unread request data will be ignored at the end of the request. WSGIRequest uses a LimitedStream but it shouldn't discard the data since the upstream servers usually do this. This fix applies only for testserver/runserver.
def __init__(self, stdin, stdout, stderr, environ, **kwargs): """ Use a LimitedStream so that unread request data will be ignored at the end of the request. WSGIRequest uses a LimitedStream but it shouldn't discard the data since the upstream servers usually do this. This fix app...
[ "def", "__init__", "(", "self", ",", "stdin", ",", "stdout", ",", "stderr", ",", "environ", ",", "*", "*", "kwargs", ")", ":", "try", ":", "content_length", "=", "int", "(", "environ", ".", "get", "(", "'CONTENT_LENGTH'", ")", ")", "except", "(", "Va...
[ 83, 4 ]
[ 94, 97 ]
python
en
['en', 'error', 'th']
False
WSGIRequestHandler.handle_one_request
(self)
Copy of WSGIRequestHandler.handle() but with different ServerHandler
Copy of WSGIRequestHandler.handle() but with different ServerHandler
def handle_one_request(self): """Copy of WSGIRequestHandler.handle() but with different ServerHandler""" self.raw_requestline = self.rfile.readline(65537) if len(self.raw_requestline) > 65536: self.requestline = '' self.request_version = '' self.command = '' ...
[ "def", "handle_one_request", "(", "self", ")", ":", "self", ".", "raw_requestline", "=", "self", ".", "rfile", ".", "readline", "(", "65537", ")", "if", "len", "(", "self", ".", "raw_requestline", ")", ">", "65536", ":", "self", ".", "requestline", "=", ...
[ 179, 4 ]
[ 196, 42 ]
python
en
['en', 'en', 'en']
True
DatabaseSchemaEditor._is_referenced_by_fk_constraint
(self, table_name, column_name=None, ignore_self=False)
Return whether or not the provided table name is referenced by another one. If `column_name` is specified, only references pointing to that column are considered. If `ignore_self` is True, self-referential constraints are ignored.
Return whether or not the provided table name is referenced by another one. If `column_name` is specified, only references pointing to that column are considered. If `ignore_self` is True, self-referential constraints are ignored.
def _is_referenced_by_fk_constraint(self, table_name, column_name=None, ignore_self=False): """ Return whether or not the provided table name is referenced by another one. If `column_name` is specified, only references pointing to that column are considered. If `ignore_self` is True, sel...
[ "def", "_is_referenced_by_fk_constraint", "(", "self", ",", "table_name", ",", "column_name", "=", "None", ",", "ignore_self", "=", "False", ")", ":", "with", "self", ".", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "for", "other_table", "in"...
[ 66, 4 ]
[ 83, 20 ]
python
en
['en', 'error', 'th']
False
DatabaseSchemaEditor._remake_table
(self, model, create_field=None, delete_field=None, alter_field=None)
Shortcut to transform a model from old_model into new_model This follows the correct procedure to perform non-rename or column addition operations based on SQLite's documentation https://www.sqlite.org/lang_altertable.html#caution The essential steps are: 1. Create ...
Shortcut to transform a model from old_model into new_model
def _remake_table(self, model, create_field=None, delete_field=None, alter_field=None): """ Shortcut to transform a model from old_model into new_model This follows the correct procedure to perform non-rename or column addition operations based on SQLite's documentation https:/...
[ "def", "_remake_table", "(", "self", ",", "model", ",", "create_field", "=", "None", ",", "delete_field", "=", "None", ",", "alter_field", "=", "None", ")", ":", "# Self-referential fields must be recreated rather than copied from", "# the old model to ensure their remote_f...
[ 139, 4 ]
[ 304, 47 ]
python
en
['en', 'error', 'th']
False
DatabaseSchemaEditor.add_field
(self, model, field)
Create a field on a model. Usually involves adding a column, but may involve adding a table instead (for M2M fields).
Create a field on a model. Usually involves adding a column, but may involve adding a table instead (for M2M fields).
def add_field(self, model, field): """ Create a field on a model. Usually involves adding a column, but may involve adding a table instead (for M2M fields). """ # Special-case implicit M2M tables if field.many_to_many and field.remote_field.through._meta.auto_created: ...
[ "def", "add_field", "(", "self", ",", "model", ",", "field", ")", ":", "# Special-case implicit M2M tables", "if", "field", ".", "many_to_many", "and", "field", ".", "remote_field", ".", "through", ".", "_meta", ".", "auto_created", ":", "return", "self", ".",...
[ 319, 4 ]
[ 327, 53 ]
python
en
['en', 'error', 'th']
False
DatabaseSchemaEditor.remove_field
(self, model, field)
Remove a field from a model. Usually involves deleting a column, but for M2Ms may involve deleting a table.
Remove a field from a model. Usually involves deleting a column, but for M2Ms may involve deleting a table.
def remove_field(self, model, field): """ Remove a field from a model. Usually involves deleting a column, but for M2Ms may involve deleting a table. """ # M2M fields are a special case if field.many_to_many: # For implicit M2M tables, delete the auto-created ...
[ "def", "remove_field", "(", "self", ",", "model", ",", "field", ")", ":", "# M2M fields are a special case", "if", "field", ".", "many_to_many", ":", "# For implicit M2M tables, delete the auto-created table", "if", "field", ".", "remote_field", ".", "through", ".", "...
[ 329, 4 ]
[ 345, 57 ]
python
en
['en', 'error', 'th']
False
DatabaseSchemaEditor._alter_field
(self, model, old_field, new_field, old_type, new_type, old_db_params, new_db_params, strict=False)
Perform a "physical" (non-ManyToMany) field update.
Perform a "physical" (non-ManyToMany) field update.
def _alter_field(self, model, old_field, new_field, old_type, new_type, old_db_params, new_db_params, strict=False): """Perform a "physical" (non-ManyToMany) field update.""" # Use "ALTER TABLE ... RENAME COLUMN" if only the column name # changed and there aren't any constra...
[ "def", "_alter_field", "(", "self", ",", "model", ",", "old_field", ",", "new_field", ",", "old_type", ",", "new_type", ",", "old_db_params", ",", "new_db_params", ",", "strict", "=", "False", ")", ":", "# Use \"ALTER TABLE ... RENAME COLUMN\" if only the column name"...
[ 347, 4 ]
[ 364, 57 ]
python
en
['en', 'en', 'en']
True
DatabaseSchemaEditor._alter_many_to_many
(self, model, old_field, new_field, strict)
Alter M2Ms to repoint their to= endpoints.
Alter M2Ms to repoint their to= endpoints.
def _alter_many_to_many(self, model, old_field, new_field, strict): """Alter M2Ms to repoint their to= endpoints.""" if old_field.remote_field.through._meta.db_table == new_field.remote_field.through._meta.db_table: # The field name didn't change, but some options did; we have to propagate t...
[ "def", "_alter_many_to_many", "(", "self", ",", "model", ",", "old_field", ",", "new_field", ",", "strict", ")", ":", "if", "old_field", ".", "remote_field", ".", "through", ".", "_meta", ".", "db_table", "==", "new_field", ".", "remote_field", ".", "through...
[ 366, 4 ]
[ 399, 57 ]
python
en
['en', 'en', 'en']
True
Container.__contains__
(self, field_name)
check if field_name is contained within tab.
check if field_name is contained within tab.
def __contains__(self, field_name): """ check if field_name is contained within tab. """ return field_name in map(lambda pointer: pointer[1], self.get_field_names())
[ "def", "__contains__", "(", "self", ",", "field_name", ")", ":", "return", "field_name", "in", "map", "(", "lambda", "pointer", ":", "pointer", "[", "1", "]", ",", "self", ".", "get_field_names", "(", ")", ")" ]
[ 226, 4 ]
[ 230, 84 ]
python
en
['en', 'ja', 'th']
False
ContainerHolder.first_container_with_errors
(self, errors)
Returns the first container with errors, otherwise returns None.
Returns the first container with errors, otherwise returns None.
def first_container_with_errors(self, errors): """ Returns the first container with errors, otherwise returns None. """ for tab in self.fields: errors_here = any(error in tab for error in errors) if errors_here: return tab return No...
[ "def", "first_container_with_errors", "(", "self", ",", "errors", ")", ":", "for", "tab", "in", "self", ".", "fields", ":", "errors_here", "=", "any", "(", "error", "in", "tab", "for", "error", "in", "errors", ")", "if", "errors_here", ":", "return", "ta...
[ 246, 4 ]
[ 254, 19 ]
python
en
['en', 'ja', 'th']
False
ContainerHolder.open_target_group_for_form
(self, form)
Makes sure that the first group that should be open is open. This is either the first group with errors or the first group in the container, unless that first group was originally set to active=False.
Makes sure that the first group that should be open is open. This is either the first group with errors or the first group in the container, unless that first group was originally set to active=False.
def open_target_group_for_form(self, form): """ Makes sure that the first group that should be open is open. This is either the first group with errors or the first group in the container, unless that first group was originally set to active=False. """ targ...
[ "def", "open_target_group_for_form", "(", "self", ",", "form", ")", ":", "target", "=", "self", ".", "first_container_with_errors", "(", "form", ".", "errors", ".", "keys", "(", ")", ")", "if", "target", "is", "None", ":", "target", "=", "self", ".", "fi...
[ 256, 4 ]
[ 271, 21 ]
python
en
['en', 'ja', 'th']
False
Tab.render_link
(self, template_pack=TEMPLATE_PACK, **kwargs)
Render the link for the tab-pane. It must be called after render so css_class is updated with active if needed.
Render the link for the tab-pane. It must be called after render so css_class is updated with active if needed.
def render_link(self, template_pack=TEMPLATE_PACK, **kwargs): """ Render the link for the tab-pane. It must be called after render so css_class is updated with active if needed. """ link_template = self.link_template % template_pack return render_to_string(link_temp...
[ "def", "render_link", "(", "self", ",", "template_pack", "=", "TEMPLATE_PACK", ",", "*", "*", "kwargs", ")", ":", "link_template", "=", "self", ".", "link_template", "%", "template_pack", "return", "render_to_string", "(", "link_template", ",", "{", "\"link\"", ...
[ 285, 4 ]
[ 291, 62 ]
python
en
['en', 'ja', 'th']
False
TestIsIterator.test_regression
(self)
This failed on Django 1.5/Py2.6 because category has a next method.
This failed on Django 1.5/Py2.6 because category has a next method.
def test_regression(self): """This failed on Django 1.5/Py2.6 because category has a next method.""" category = Category.objects.create(name='category') Thing.objects.create(category=category) Thing.objects.filter(category=category)
[ "def", "test_regression", "(", "self", ")", ":", "category", "=", "Category", ".", "objects", ".", "create", "(", "name", "=", "'category'", ")", "Thing", ".", "objects", ".", "create", "(", "category", "=", "category", ")", "Thing", ".", "objects", ".",...
[ 6, 4 ]
[ 10, 47 ]
python
en
['en', 'en', 'en']
True
FormPreview.unused_name
(self, name)
Given a first-choice name, adds an underscore to the name until it reaches a name that isn't claimed by any field in the form. This is calculated rather than being hard-coded so that no field names are off-limits for use in the form.
Given a first-choice name, adds an underscore to the name until it reaches a name that isn't claimed by any field in the form.
def unused_name(self, name): """ Given a first-choice name, adds an underscore to the name until it reaches a name that isn't claimed by any field in the form. This is calculated rather than being hard-coded so that no field names are off-limits for use in the form. """ ...
[ "def", "unused_name", "(", "self", ",", "name", ")", ":", "while", "1", ":", "try", ":", "self", ".", "form", ".", "base_fields", "[", "name", "]", "except", "KeyError", ":", "break", "# This field name isn't being used by the form.", "name", "+=", "'_'", "r...
[ 32, 4 ]
[ 46, 19 ]
python
en
['en', 'error', 'th']
False
FormPreview.preview_get
(self, request)
Displays the form
Displays the form
def preview_get(self, request): "Displays the form" f = self.form(auto_id=self.get_auto_id(), initial=self.get_initial(request)) return render_to_response(self.form_template, self.get_context(request, f), context_instance=RequestContext(request))
[ "def", "preview_get", "(", "self", ",", "request", ")", ":", "f", "=", "self", ".", "form", "(", "auto_id", "=", "self", ".", "get_auto_id", "(", ")", ",", "initial", "=", "self", ".", "get_initial", "(", "request", ")", ")", "return", "render_to_respo...
[ 48, 4 ]
[ 53, 53 ]
python
en
['en', 'en', 'en']
True
FormPreview.preview_post
(self, request)
Validates the POST data. If valid, displays the preview page. Else, redisplays form.
Validates the POST data. If valid, displays the preview page. Else, redisplays form.
def preview_post(self, request): "Validates the POST data. If valid, displays the preview page. Else, redisplays form." f = self.form(request.POST, auto_id=self.get_auto_id()) context = self.get_context(request, f) if f.is_valid(): self.process_preview(request, f, context) ...
[ "def", "preview_post", "(", "self", ",", "request", ")", ":", "f", "=", "self", ".", "form", "(", "request", ".", "POST", ",", "auto_id", "=", "self", ".", "get_auto_id", "(", ")", ")", "context", "=", "self", ".", "get_context", "(", "request", ",",...
[ 55, 4 ]
[ 65, 108 ]
python
en
['en', 'en', 'en']
True
FormPreview.post_post
(self, request)
Validates the POST data. If valid, calls done(). Else, redisplays form.
Validates the POST data. If valid, calls done(). Else, redisplays form.
def post_post(self, request): "Validates the POST data. If valid, calls done(). Else, redisplays form." f = self.form(request.POST, auto_id=self.get_auto_id()) if f.is_valid(): if not self._check_security_hash(request.POST.get(self.unused_name('hash'), ''), ...
[ "def", "post_post", "(", "self", ",", "request", ")", ":", "f", "=", "self", ".", "form", "(", "request", ".", "POST", ",", "auto_id", "=", "self", ".", "get_auto_id", "(", ")", ")", "if", "f", ".", "is_valid", "(", ")", ":", "if", "not", "self",...
[ 71, 4 ]
[ 82, 57 ]
python
en
['en', 'en', 'en']
True
FormPreview.get_auto_id
(self)
Hook to override the ``auto_id`` kwarg for the form. Needed when rendering two form previews in the same template.
Hook to override the ``auto_id`` kwarg for the form. Needed when rendering two form previews in the same template.
def get_auto_id(self): """ Hook to override the ``auto_id`` kwarg for the form. Needed when rendering two form previews in the same template. """ return AUTO_ID
[ "def", "get_auto_id", "(", "self", ")", ":", "return", "AUTO_ID" ]
[ 86, 4 ]
[ 91, 22 ]
python
en
['en', 'error', 'th']
False
FormPreview.get_initial
(self, request)
Takes a request argument and returns a dictionary to pass to the form's ``initial`` kwarg when the form is being created from an HTTP get.
Takes a request argument and returns a dictionary to pass to the form's ``initial`` kwarg when the form is being created from an HTTP get.
def get_initial(self, request): """ Takes a request argument and returns a dictionary to pass to the form's ``initial`` kwarg when the form is being created from an HTTP get. """ return {}
[ "def", "get_initial", "(", "self", ",", "request", ")", ":", "return", "{", "}" ]
[ 93, 4 ]
[ 98, 17 ]
python
en
['en', 'error', 'th']
False
FormPreview.get_context
(self, request, form)
Context for template rendering.
Context for template rendering.
def get_context(self, request, form): "Context for template rendering." return {'form': form, 'stage_field': self.unused_name('stage'), 'state': self.state}
[ "def", "get_context", "(", "self", ",", "request", ",", "form", ")", ":", "return", "{", "'form'", ":", "form", ",", "'stage_field'", ":", "self", ".", "unused_name", "(", "'stage'", ")", ",", "'state'", ":", "self", ".", "state", "}" ]
[ 100, 4 ]
[ 102, 92 ]
python
en
['da', 'en', 'en']
True
FormPreview.parse_params
(self, *args, **kwargs)
Given captured args and kwargs from the URLconf, saves something in self.state and/or raises Http404 if necessary. For example, this URLconf captures a user_id variable: (r'^contact/(?P<user_id>\d{1,6})/$', MyFormPreview(MyForm)), In this case, the kwargs variable in pars...
Given captured args and kwargs from the URLconf, saves something in self.state and/or raises Http404 if necessary.
def parse_params(self, *args, **kwargs): """ Given captured args and kwargs from the URLconf, saves something in self.state and/or raises Http404 if necessary. For example, this URLconf captures a user_id variable: (r'^contact/(?P<user_id>\d{1,6})/$', MyFormPreview(MyForm))...
[ "def", "parse_params", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "pass" ]
[ 104, 4 ]
[ 118, 12 ]
python
en
['en', 'error', 'th']
False
FormPreview.process_preview
(self, request, form, context)
Given a validated form, performs any extra processing before displaying the preview page, and saves any extra data in context.
Given a validated form, performs any extra processing before displaying the preview page, and saves any extra data in context.
def process_preview(self, request, form, context): """ Given a validated form, performs any extra processing before displaying the preview page, and saves any extra data in context. """ pass
[ "def", "process_preview", "(", "self", ",", "request", ",", "form", ",", "context", ")", ":", "pass" ]
[ 120, 4 ]
[ 125, 12 ]
python
en
['en', 'error', 'th']
False
FormPreview.security_hash
(self, request, form)
Calculates the security hash for the given HttpRequest and Form instances. Subclasses may want to take into account request-specific information, such as the IP address.
Calculates the security hash for the given HttpRequest and Form instances.
def security_hash(self, request, form): """ Calculates the security hash for the given HttpRequest and Form instances. Subclasses may want to take into account request-specific information, such as the IP address. """ return form_hmac(form)
[ "def", "security_hash", "(", "self", ",", "request", ",", "form", ")", ":", "return", "form_hmac", "(", "form", ")" ]
[ 127, 4 ]
[ 134, 30 ]
python
en
['en', 'error', 'th']
False
FormPreview.failed_hash
(self, request)
Returns an HttpResponse in the case of an invalid security hash.
Returns an HttpResponse in the case of an invalid security hash.
def failed_hash(self, request): "Returns an HttpResponse in the case of an invalid security hash." return self.preview_post(request)
[ "def", "failed_hash", "(", "self", ",", "request", ")", ":", "return", "self", ".", "preview_post", "(", "request", ")" ]
[ 136, 4 ]
[ 138, 41 ]
python
en
['en', 'en', 'en']
True
FormPreview.done
(self, request, cleaned_data)
Does something with the cleaned_data and returns an HttpResponseRedirect.
Does something with the cleaned_data and returns an HttpResponseRedirect.
def done(self, request, cleaned_data): """ Does something with the cleaned_data and returns an HttpResponseRedirect. """ raise NotImplementedError('You must define a done() method on your %s subclass.' % self.__class__.__name__)
[ "def", "done", "(", "self", ",", "request", ",", "cleaned_data", ")", ":", "raise", "NotImplementedError", "(", "'You must define a done() method on your %s subclass.'", "%", "self", ".", "__class__", ".", "__name__", ")" ]
[ 142, 4 ]
[ 147, 115 ]
python
en
['en', 'error', 'th']
False
CookieStorage._get
(self, *args, **kwargs)
Retrieves a list of messages from the messages cookie. If the not_finished sentinel value is found at the end of the message list, remove it and return a result indicating that not all messages were retrieved by this storage.
Retrieves a list of messages from the messages cookie. If the not_finished sentinel value is found at the end of the message list, remove it and return a result indicating that not all messages were retrieved by this storage.
def _get(self, *args, **kwargs): """ Retrieves a list of messages from the messages cookie. If the not_finished sentinel value is found at the end of the message list, remove it and return a result indicating that not all messages were retrieved by this storage. """ ...
[ "def", "_get", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "data", "=", "self", ".", "request", ".", "COOKIES", ".", "get", "(", "self", ".", "cookie_name", ")", "messages", "=", "self", ".", "_decode", "(", "data", ")", "al...
[ 63, 4 ]
[ 76, 38 ]
python
en
['en', 'error', 'th']
False
CookieStorage._update_cookie
(self, encoded_data, response)
Either sets the cookie with the encoded data if there is any data to store, or deletes the cookie.
Either sets the cookie with the encoded data if there is any data to store, or deletes the cookie.
def _update_cookie(self, encoded_data, response): """ Either sets the cookie with the encoded data if there is any data to store, or deletes the cookie. """ if encoded_data: response.set_cookie(self.cookie_name, encoded_data, domain=settings.SESSION_CO...
[ "def", "_update_cookie", "(", "self", ",", "encoded_data", ",", "response", ")", ":", "if", "encoded_data", ":", "response", ".", "set_cookie", "(", "self", ".", "cookie_name", ",", "encoded_data", ",", "domain", "=", "settings", ".", "SESSION_COOKIE_DOMAIN", ...
[ 78, 4 ]
[ 90, 54 ]
python
en
['en', 'error', 'th']
False
CookieStorage._store
(self, messages, response, remove_oldest=True, *args, **kwargs)
Stores the messages to a cookie, returning a list of any messages which could not be stored. If the encoded data is larger than ``max_cookie_size``, removes messages until the data fits (these are the messages which are returned), and add the not_finished sentinel value to indi...
Stores the messages to a cookie, returning a list of any messages which could not be stored.
def _store(self, messages, response, remove_oldest=True, *args, **kwargs): """ Stores the messages to a cookie, returning a list of any messages which could not be stored. If the encoded data is larger than ``max_cookie_size``, removes messages until the data fits (these are the...
[ "def", "_store", "(", "self", ",", "messages", ",", "response", ",", "remove_oldest", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "unstored_messages", "=", "[", "]", "encoded_data", "=", "self", ".", "_encode", "(", "messages", ")...
[ 92, 4 ]
[ 119, 32 ]
python
en
['en', 'error', 'th']
False
CookieStorage._hash
(self, value)
Creates an HMAC/SHA1 hash based on the value and the project setting's SECRET_KEY, modified to make it unique for the present purpose.
Creates an HMAC/SHA1 hash based on the value and the project setting's SECRET_KEY, modified to make it unique for the present purpose.
def _hash(self, value): """ Creates an HMAC/SHA1 hash based on the value and the project setting's SECRET_KEY, modified to make it unique for the present purpose. """ key_salt = 'django.contrib.messages' return salted_hmac(key_salt, value).hexdigest()
[ "def", "_hash", "(", "self", ",", "value", ")", ":", "key_salt", "=", "'django.contrib.messages'", "return", "salted_hmac", "(", "key_salt", ",", "value", ")", ".", "hexdigest", "(", ")" ]
[ 121, 4 ]
[ 127, 55 ]
python
en
['en', 'error', 'th']
False
CookieStorage._encode
(self, messages, encode_empty=False)
Returns an encoded version of the messages list which can be stored as plain text. Since the data will be retrieved from the client-side, the encoded data also contains a hash to ensure that the data was not tampered with.
Returns an encoded version of the messages list which can be stored as plain text.
def _encode(self, messages, encode_empty=False): """ Returns an encoded version of the messages list which can be stored as plain text. Since the data will be retrieved from the client-side, the encoded data also contains a hash to ensure that the data was not tampered with. ...
[ "def", "_encode", "(", "self", ",", "messages", ",", "encode_empty", "=", "False", ")", ":", "if", "messages", "or", "encode_empty", ":", "encoder", "=", "MessageEncoder", "(", "separators", "=", "(", "','", ",", "':'", ")", ")", "value", "=", "encoder",...
[ 129, 4 ]
[ 140, 55 ]
python
en
['en', 'error', 'th']
False
CookieStorage._decode
(self, data)
Safely decodes an encoded text stream back into a list of messages. If the encoded text stream contained an invalid hash or was in an invalid format, ``None`` is returned.
Safely decodes an encoded text stream back into a list of messages.
def _decode(self, data): """ Safely decodes an encoded text stream back into a list of messages. If the encoded text stream contained an invalid hash or was in an invalid format, ``None`` is returned. """ if not data: return None bits = data.split('$'...
[ "def", "_decode", "(", "self", ",", "data", ")", ":", "if", "not", "data", ":", "return", "None", "bits", "=", "data", ".", "split", "(", "'$'", ",", "1", ")", "if", "len", "(", "bits", ")", "==", "2", ":", "hash", ",", "value", "=", "bits", ...
[ 142, 4 ]
[ 164, 19 ]
python
en
['en', 'error', 'th']
False
__init__
(self, context, ec2, targetgroup, cloudwatch)
Initialize the module-wide variables and register configuration keys and associated documentation. NOTE: This function must be calleable from the cs-format-documentation tool so dependencies must be kept light.
Initialize the module-wide variables and register configuration keys and associated documentation. NOTE: This function must be calleable from the cs-format-documentation tool so dependencies must be kept light.
def __init__(self, context, ec2, targetgroup, cloudwatch): """ Initialize the module-wide variables and register configuration keys and associated documentation. NOTE: This function must be calleable from the cs-format-documentation tool so dependencies must be kept light. """ s...
[ "def", "__init__", "(", "self", ",", "context", ",", "ec2", ",", "targetgroup", ",", "cloudwatch", ")", ":", "self", ".", "context", "=", "context", "self", ".", "ec2", "=", "ec2", "self", ".", "o_state", "=", "self", ".", "context", "[", "\"o_state\""...
[ 64, 4 ]
[ 467, 14 ]
python
en
['en', 'en', 'en']
True
get_prerequisites
(self)
This method loads, gathers and prepares data needed by all others methods in this module.
This method loads, gathers and prepares data needed by all others methods in this module.
def get_prerequisites(self): """ This method loads, gathers and prepares data needed by all others methods in this module. """ self.cpu_credits = yaml.safe_load(str(misc.get_url("internal:cpu-credits.yaml"),"utf-8")) self.ec2_alarmstate_table = kvtable.KVTable(self.context, self...
[ "def", "get_prerequisites", "(", "self", ")", ":", "self", ".", "cpu_credits", "=", "yaml", ".", "safe_load", "(", "str", "(", "misc", ".", "get_url", "(", "\"internal:cpu-credits.yaml\"", ")", ",", "\"utf-8\"", ")", ")", "self", ".", "ec2_alarmstate_table", ...
[ 471, 4 ]
[ 626, 22 ]
python
en
['en', 'en', 'en']
True
generate_instance_transition_events
(self)
Generate events on instance state transition. On instance state change (ex: stopped => pending), an event 'instance_transitions' is generated that can be intercepted by users (through a Lambda function, a SNS or a SQS message).
Generate events on instance state transition.
def generate_instance_transition_events(self): """ Generate events on instance state transition. On instance state change (ex: stopped => pending), an event 'instance_transitions' is generated that can be intercepted by users (through a Lambda function, a SNS or a SQS message). """ ...
[ "def", "generate_instance_transition_events", "(", "self", ")", ":", "transitions", "=", "[", "]", "for", "instance", "in", "self", ".", "instances_wo_excluded", ":", "instance_id", "=", "instance", "[", "\"InstanceId\"", "]", "previous_state", "=", "self", ".", ...
[ 635, 4 ]
[ 656, 71 ]
python
en
['en', 'en', 'en']
True
instance_transitions
(self, Transitions=None)
This method is only for its signature will be reflected in the generated event.
This method is only for its signature will be reflected in the generated event.
def instance_transitions(self, Transitions=None): """ This method is only for its signature will be reflected in the generated event. """ return {}
[ "def", "instance_transitions", "(", "self", ",", "Transitions", "=", "None", ")", ":", "return", "{", "}" ]
[ 658, 4 ]
[ 661, 17 ]
python
en
['en', 'en', 'en']
True
get_min_instance_count
(self)
Return the minimum instance count linked to 'ec2.schedule.min_instance_count'. Especially, it converts percentage into an absolute number. :return An integer (number of instances)
Return the minimum instance count linked to 'ec2.schedule.min_instance_count'. Especially, it converts percentage into an absolute number.
def get_min_instance_count(self): """ Return the minimum instance count linked to 'ec2.schedule.min_instance_count'. Especially, it converts percentage into an absolute number. :return An integer (number of instances) """ instances = self.all_main_fleet_instances return...
[ "def", "get_min_instance_count", "(", "self", ")", ":", "instances", "=", "self", ".", "all_main_fleet_instances", "return", "max", "(", "0", ",", "Cfg", ".", "get_abs_or_percent", "(", "\"ec2.schedule.min_instance_count\"", ",", "-", "1", ",", "len", "(", "inst...
[ 669, 4 ]
[ 676, 100 ]
python
en
['en', 'en', 'en']
True
desired_instance_count
(self)
Return the desired instance count linked in 'ec2.schedule.desired_instance_count'. Especially, it converts percentage into an absolute number. :return An integer (number of instances
Return the desired instance count linked in 'ec2.schedule.desired_instance_count'. Especially, it converts percentage into an absolute number.
def desired_instance_count(self): """ Return the desired instance count linked in 'ec2.schedule.desired_instance_count'. Especially, it converts percentage into an absolute number. :return An integer (number of instances """ instances = self.all_main_fleet_instances ret...
[ "def", "desired_instance_count", "(", "self", ")", ":", "instances", "=", "self", ".", "all_main_fleet_instances", "return", "Cfg", ".", "get_abs_or_percent", "(", "\"ec2.schedule.desired_instance_count\"", ",", "-", "1", ",", "len", "(", "instances", ")", ")" ]
[ 678, 4 ]
[ 685, 96 ]
python
en
['en', 'en', 'en']
True
get_ready_for_operation_timeouted_instances
(self)
Return a list of instance ids that spent too much time in 'initializing' time.
Return a list of instance ids that spent too much time in 'initializing' time.
def get_ready_for_operation_timeouted_instances(self): """ Return a list of instance ids that spent too much time in 'initializing' time. """ if not self.ssm.is_feature_enabled("events.ec2.instance_ready_for_operation"): return [] ids = [] max_initializing_delay = Cfg...
[ "def", "get_ready_for_operation_timeouted_instances", "(", "self", ")", ":", "if", "not", "self", ".", "ssm", ".", "is_feature_enabled", "(", "\"events.ec2.instance_ready_for_operation\"", ")", ":", "return", "[", "]", "ids", "=", "[", "]", "max_initializing_delay", ...
[ 687, 4 ]
[ 698, 18 ]
python
en
['en', 'en', 'en']
True
get_ready_for_shutdown_timeouted_instances
(self)
Return a list of instance ids that spent too much time in 'draining' time.
Return a list of instance ids that spent too much time in 'draining' time.
def get_ready_for_shutdown_timeouted_instances(self): """ Return a list of instance ids that spent too much time in 'draining' time. """ if not self.ssm.is_feature_enabled("events.ec2.instance_ready_for_shutdown"): return [] max_shutdown_delay = Cfg.get_duration_secs("ssm.fea...
[ "def", "get_ready_for_shutdown_timeouted_instances", "(", "self", ")", ":", "if", "not", "self", ".", "ssm", ".", "is_feature_enabled", "(", "\"events.ec2.instance_ready_for_shutdown\"", ")", ":", "return", "[", "]", "max_shutdown_delay", "=", "Cfg", ".", "get_duratio...
[ 700, 4 ]
[ 721, 18 ]
python
en
['en', 'en', 'en']
True
get_instances_with_issues
(self)
Return a list of Instance Id of faulty instances. A faulty instance can be any of: - Instances that are part of one or more TargetGroups and reported 'unavail' or 'unhealth', - Instances that have EC2 status as 'impaired' or 'unhealthy', - Instances that have been AZ evicte...
Return a list of Instance Id of faulty instances.
def get_instances_with_issues(self): """ Return a list of Instance Id of faulty instances. A faulty instance can be any of: - Instances that are part of one or more TargetGroups and reported 'unavail' or 'unhealth', - Instances that have EC2 status as 'impaired' or 'unhealthy', ...
[ "def", "get_instances_with_issues", "(", "self", ")", ":", "active_instances", "=", "self", ".", "pending_running_instances", "instances_with_issue_ids", "=", "[", "]", "# TargetGroup related issues", "instances_with_issue_ids", ".", "extend", "(", "self", ".", "unhealthy...
[ 723, 4 ]
[ 770, 39 ]
python
en
['en', 'en', 'en']
True
get_useable_instances
(self, instances=None, State="pending,running", ScalingState=None, exclude_problematic_instances=True, exclude_bounced_instances=True, exclude_initializing_instances=False, initializing_only=False)
Return a list of Instance full structures according to supplied data selectors. :param instances: List of instances to filter (if 'None', all instances are considered) :param State: Instance state selector ("stopped", "pending", "running"...) :pa...
Return a list of Instance full structures according to supplied data selectors.
def get_useable_instances(self, instances=None, State="pending,running", ScalingState=None, exclude_problematic_instances=True, exclude_bounced_instances=True, exclude_initializing_instances=False, initializing_only=False): """ Return a list of Instance full structures according to supp...
[ "def", "get_useable_instances", "(", "self", ",", "instances", "=", "None", ",", "State", "=", "\"pending,running\"", ",", "ScalingState", "=", "None", ",", "exclude_problematic_instances", "=", "True", ",", "exclude_bounced_instances", "=", "True", ",", "exclude_in...
[ 772, 4 ]
[ 801, 31 ]
python
en
['en', 'en', 'en']
True
get_useable_instance_count
(self, exclude_problematic_instances=True, exclude_bounced_instances=True, exclude_initializing_instances=False, initializing_only=False)
Return a number of usueable instance. :param exclude_problematic_instances: Filter out instances that have issues ("unhealthy", "impaired" etc...) :param exclude_bounced_instances: Filter out instances marked with scaling state "bounced" :param exclude_initializing_instances: Filter o...
Return a number of usueable instance.
def get_useable_instance_count(self, exclude_problematic_instances=True, exclude_bounced_instances=True, exclude_initializing_instances=False, initializing_only=False): """ Return a number of usueable instance. :param exclude_problematic_instances: Filter out instances that have issues (...
[ "def", "get_useable_instance_count", "(", "self", ",", "exclude_problematic_instances", "=", "True", ",", "exclude_bounced_instances", "=", "True", ",", "exclude_initializing_instances", "=", "False", ",", "initializing_only", "=", "False", ")", ":", "return", "len", ...
[ 803, 4 ]
[ 816, 53 ]
python
en
['en', 'en', 'en']
True
get_cpu_exhausted_instances
(self, threshold=5)
Return list of instances that have their CPU exhausted below the specified threshold :param threshold: A pourcentage of CPU Credit to consider the minimum required :return A list of instance structures
Return list of instances that have their CPU exhausted below the specified threshold
def get_cpu_exhausted_instances(self, threshold=5): """ Return list of instances that have their CPU exhausted below the specified threshold :param threshold: A pourcentage of CPU Credit to consider the minimum required :return A list of instance structures """ #max_cpu_credit_u...
[ "def", "get_cpu_exhausted_instances", "(", "self", ",", "threshold", "=", "5", ")", ":", "#max_cpu_credit_unhealthy = Cfg.get_int(\"ec2.schedule.burstable_instance.max_cpu_credit_unhealthy_instances\")", "instances_exhausted", "=", "[", "]", "for", "i", "in", "self", ".", ...
[ 818, 4 ]
[ 833, 34 ]
python
en
['en', 'en', 'en']
True
get_young_instance_ids
(self, instances=None)
Return a list of instance that are considered young based on their running time. Instances that are running for less than duration specified in 'ec2.schedule.start.warmup_delay'. :return A list of instances.
Return a list of instance that are considered young based on their running time.
def get_young_instance_ids(self, instances=None): """ Return a list of instance that are considered young based on their running time. Instances that are running for less than duration specified in 'ec2.schedule.start.warmup_delay'. :return A list of instances. """ now ...
[ "def", "get_young_instance_ids", "(", "self", ",", "instances", "=", "None", ")", ":", "now", "=", "self", ".", "context", "[", "\"now\"", "]", "warmup_delay", "=", "Cfg", ".", "get_duration_secs", "(", "\"ec2.schedule.start.warmup_delay\"", ")", "active_instances...
[ 835, 4 ]
[ 845, 117 ]
python
en
['en', 'en', 'en']
True
get_initial_instances
(self, instances=None)
Return list of instances in 'initializing' state. 'Initializing' status is aither: - Marked as such at EC2 level, - At least on TargetGroup is currently initializing the instance, - Running not longer enough. :param A list of instance structures.
Return list of instances in 'initializing' state.
def get_initial_instances(self, instances=None): """ Return list of instances in 'initializing' state. 'Initializing' status is aither: - Marked as such at EC2 level, - At least on TargetGroup is currently initializing the instance, - Running not longer enough. ...
[ "def", "get_initial_instances", "(", "self", ",", "instances", "=", "None", ")", ":", "active_instances", "=", "self", ".", "pending_running_instances_wo_excluded", "if", "instances", "is", "None", "else", "instances", "active_instance_ids", "=", "[", "i", "[", "\...
[ 847, 4 ]
[ 864, 136 ]
python
en
['en', 'en', 'en']
True
get_initial_instances_ids
(self)
Return the list of 'initializing' instance ids.
Return the list of 'initializing' instance ids.
def get_initial_instances_ids(self): """ Return the list of 'initializing' instance ids. """ return [i["InstanceId"] for i in self.initializing_instances]
[ "def", "get_initial_instances_ids", "(", "self", ")", ":", "return", "[", "i", "[", "\"InstanceId\"", "]", "for", "i", "in", "self", ".", "initializing_instances", "]" ]
[ 866, 4 ]
[ 869, 69 ]
python
en
['en', 'en', 'en']
True
get_disabled_azs
(self)
Return the list of AZ names that must not be scheduled.
Return the list of AZ names that must not be scheduled.
def get_disabled_azs(self): """ Return the list of AZ names that must not be scheduled. """ return self.ec2.get_azs_with_issues()
[ "def", "get_disabled_azs", "(", "self", ")", ":", "return", "self", ".", "ec2", ".", "get_azs_with_issues", "(", ")" ]
[ 871, 4 ]
[ 874, 45 ]
python
en
['en', 'en', 'en']
True
set_state
(self, key, value, TTL=None)
Helper method to set state with the default module TTL.
Helper method to set state with the default module TTL.
def set_state(self, key, value, TTL=None): """ Helper method to set state with the default module TTL. """ if TTL is None: TTL=self.state_ttl self.ec2.set_state(key, value, TTL=TTL)
[ "def", "set_state", "(", "self", ",", "key", ",", "value", ",", "TTL", "=", "None", ")", ":", "if", "TTL", "is", "None", ":", "TTL", "=", "self", ".", "state_ttl", "self", ".", "ec2", ".", "set_state", "(", "key", ",", "value", ",", "TTL", "=", ...
[ 876, 4 ]
[ 880, 47 ]
python
en
['en', 'en', 'en']
True
schedule_instances
(self)
This is the function that manage all decisions related to scaling
This is the function that manage all decisions related to scaling
def schedule_instances(self): """ This is the function that manage all decisions related to scaling """ self.generate_instance_transition_events() self.manage_spot_events() if not Cfg.get_int("ec2.schedule.disable"): self.shelve_extra_lighthouse_instances() ...
[ "def", "schedule_instances", "(", "self", ")", ":", "self", ".", "generate_instance_transition_events", "(", ")", "self", ".", "manage_spot_events", "(", ")", "if", "not", "Cfg", ".", "get_int", "(", "\"ec2.schedule.disable\"", ")", ":", "self", ".", "shelve_ext...
[ 888, 4 ]
[ 904, 37 ]
python
en
['en', 'error', 'th']
False
send_events
(self)
Send SSM Events linked to instance state changes.
Send SSM Events linked to instance state changes.
def send_events(self): """ Send SSM Events linked to instance state changes. """ o_ssm = self.context["o_ssm"] if o_ssm.is_feature_enabled("events.ec2.scaling_state_changes"): ids_per_new_state = {} for instance_id in self.scaling_state_snapshots: ...
[ "def", "send_events", "(", "self", ")", ":", "o_ssm", "=", "self", ".", "context", "[", "\"o_ssm\"", "]", "if", "o_ssm", ".", "is_feature_enabled", "(", "\"events.ec2.scaling_state_changes\"", ")", ":", "ids_per_new_state", "=", "{", "}", "for", "instance_id", ...
[ 907, 4 ]
[ 968, 116 ]
python
en
['en', 'en', 'en']
True
prepare_metrics
(self)
Compute all module CloudWatch metrics and Synthetic metrics available through the API Gateway.
Compute all module CloudWatch metrics and Synthetic metrics available through the API Gateway.
def prepare_metrics(self): """ Compute all module CloudWatch metrics and Synthetic metrics available through the API Gateway. """ cw = self.cloudwatch fleet_instances = self.all_main_fleet_instances draining_instances = self.pending_running_instances_draining...
[ "def", "prepare_metrics", "(", "self", ")", ":", "cw", "=", "self", ".", "cloudwatch", "fleet_instances", "=", "self", ".", "all_main_fleet_instances", "draining_instances", "=", "self", ".", "pending_running_instances_draining_wo_excluded", "running_instances", "=", "s...
[ 971, 4 ]
[ 1102, 42 ]
python
en
['en', 'en', 'en']
True
get_synthetic_metrics
(self)
Return synthetics metrics (used by the API Gateway statistic methods.
Return synthetics metrics (used by the API Gateway statistic methods.
def get_synthetic_metrics(self): """ Return synthetics metrics (used by the API Gateway statistic methods. """ return self.synthetic_metrics
[ "def", "get_synthetic_metrics", "(", "self", ")", ":", "return", "self", ".", "synthetic_metrics" ]
[ 1104, 4 ]
[ 1107, 37 ]
python
en
['en', 'en', 'en']
True
sort_and_filter_stopped_instance_candidates
(self, active_instances, stopped_instances)
This method is used to sort and filter instances according to horizontal and vertical scaling algorithms. This method is used both for Main and Subfleets to define the "best" order to start instances when needed. - It filters out instances that are notified with Spot 'rebalance_recommended' and 'i...
This method is used to sort and filter instances according to horizontal and vertical scaling algorithms.
def sort_and_filter_stopped_instance_candidates(self, active_instances, stopped_instances): """ This method is used to sort and filter instances according to horizontal and vertical scaling algorithms. This method is used both for Main and Subfleets to define the "best" order to start instances when ne...
[ "def", "sort_and_filter_stopped_instance_candidates", "(", "self", ",", "active_instances", ",", "stopped_instances", ")", ":", "# Filter out instances that are not startable", "stopped_instances", "=", "list", "(", "filter", "(", "lambda", "i", ":", "i", "[", "\"Instance...
[ 1114, 4 ]
[ 1148, 32 ]
python
en
['en', 'en', 'en']
True