repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
mozilla/python_moztelemetry | moztelemetry/standards.py | get_last_month_range | def get_last_month_range():
""" Gets the date for the first and the last day of the previous complete month.
:returns: A tuple containing two date objects, for the first and the last day of the month
respectively.
"""
today = date.today()
# Get the last day for the previous month.
... | python | def get_last_month_range():
""" Gets the date for the first and the last day of the previous complete month.
:returns: A tuple containing two date objects, for the first and the last day of the month
respectively.
"""
today = date.today()
# Get the last day for the previous month.
... | Gets the date for the first and the last day of the previous complete month.
:returns: A tuple containing two date objects, for the first and the last day of the month
respectively. | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/standards.py#L130-L140 |
mozilla/python_moztelemetry | moztelemetry/standards.py | read_main_summary | def read_main_summary(spark,
submission_date_s3=None,
sample_id=None,
mergeSchema=True,
path='s3://telemetry-parquet/main_summary/v4'):
""" Efficiently read main_summary parquet data.
Read data from the given path, optional... | python | def read_main_summary(spark,
submission_date_s3=None,
sample_id=None,
mergeSchema=True,
path='s3://telemetry-parquet/main_summary/v4'):
""" Efficiently read main_summary parquet data.
Read data from the given path, optional... | Efficiently read main_summary parquet data.
Read data from the given path, optionally filtering to a
specified set of partition values first. This can save a
time, particularly if `mergeSchema` is True.
Args:
spark: Spark session
submission_date_s3: Optional list of values to filter th... | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/standards.py#L143-L202 |
mozilla/python_moztelemetry | moztelemetry/standards.py | sampler | def sampler(dataframe, modulo, column="client_id", sample_id=42):
""" Collect a sample of clients given an input column
Filter dataframe based on the modulus of the CRC32 of a given string
column matching a given sample_id. if dataframe has already been filtered
by sample_id, then modulo should be a mu... | python | def sampler(dataframe, modulo, column="client_id", sample_id=42):
""" Collect a sample of clients given an input column
Filter dataframe based on the modulus of the CRC32 of a given string
column matching a given sample_id. if dataframe has already been filtered
by sample_id, then modulo should be a mu... | Collect a sample of clients given an input column
Filter dataframe based on the modulus of the CRC32 of a given string
column matching a given sample_id. if dataframe has already been filtered
by sample_id, then modulo should be a multiple of 100, column should be
"client_id", and the given sample_id s... | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/standards.py#L205-L227 |
Karaage-Cluster/karaage | karaage/plugins/kgusage/views.py | progress | def progress(request):
""" Check status of task. """
if 'delete' in request.GET:
models.MachineCache.objects.all().delete()
models.InstituteCache.objects.all().delete()
models.PersonCache.objects.all().delete()
models.ProjectCache.objects.all().delete()
return render(
... | python | def progress(request):
""" Check status of task. """
if 'delete' in request.GET:
models.MachineCache.objects.all().delete()
models.InstituteCache.objects.all().delete()
models.PersonCache.objects.all().delete()
models.ProjectCache.objects.all().delete()
return render(
... | Check status of task. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/views.py#L56-L83 |
Karaage-Cluster/karaage | karaage/plugins/kgusage/views.py | synchronise | def synchronise(func):
""" If task already queued, running, or finished, don't restart. """
def inner(request, *args):
lock_id = '%s-%s-built-%s' % (
datetime.date.today(), func.__name__,
",".join([str(a) for a in args]))
if cache.add(lock_id, 'true', LOCK_EXPIRE):
... | python | def synchronise(func):
""" If task already queued, running, or finished, don't restart. """
def inner(request, *args):
lock_id = '%s-%s-built-%s' % (
datetime.date.today(), func.__name__,
",".join([str(a) for a in args]))
if cache.add(lock_id, 'true', LOCK_EXPIRE):
... | If task already queued, running, or finished, don't restart. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/views.py#L86-L107 |
mozilla/python_moztelemetry | moztelemetry/dataset.py | _group_by_size_greedy | def _group_by_size_greedy(obj_list, tot_groups):
"""Partition a list of objects in even buckets
The idea is to choose the bucket for an object in a round-robin fashion.
The list of objects is sorted to also try to keep the total size in bytes
as balanced as possible.
:param obj_list: a list of dict... | python | def _group_by_size_greedy(obj_list, tot_groups):
"""Partition a list of objects in even buckets
The idea is to choose the bucket for an object in a round-robin fashion.
The list of objects is sorted to also try to keep the total size in bytes
as balanced as possible.
:param obj_list: a list of dict... | Partition a list of objects in even buckets
The idea is to choose the bucket for an object in a round-robin fashion.
The list of objects is sorted to also try to keep the total size in bytes
as balanced as possible.
:param obj_list: a list of dict-like objects with a 'size' property
:param tot_grou... | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/dataset.py#L27-L42 |
mozilla/python_moztelemetry | moztelemetry/dataset.py | _group_by_equal_size | def _group_by_equal_size(obj_list, tot_groups, threshold=pow(2, 32)):
"""Partition a list of objects evenly and by file size
Files are placed according to largest file in the smallest bucket. If the
file is larger than the given threshold, then it is placed in a new bucket
by itself.
:param obj_lis... | python | def _group_by_equal_size(obj_list, tot_groups, threshold=pow(2, 32)):
"""Partition a list of objects evenly and by file size
Files are placed according to largest file in the smallest bucket. If the
file is larger than the given threshold, then it is placed in a new bucket
by itself.
:param obj_lis... | Partition a list of objects evenly and by file size
Files are placed according to largest file in the smallest bucket. If the
file is larger than the given threshold, then it is placed in a new bucket
by itself.
:param obj_list: a list of dict-like objects with a 'size' property
:param tot_groups: ... | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/dataset.py#L45-L72 |
mozilla/python_moztelemetry | moztelemetry/dataset.py | Dataset.select | def select(self, *properties, **aliased_properties):
"""Specify which properties of the dataset must be returned
Property extraction is based on `JMESPath <http://jmespath.org>`_ expressions.
This method returns a new Dataset narrowed down by the given selection.
:param properties: JME... | python | def select(self, *properties, **aliased_properties):
"""Specify which properties of the dataset must be returned
Property extraction is based on `JMESPath <http://jmespath.org>`_ expressions.
This method returns a new Dataset narrowed down by the given selection.
:param properties: JME... | Specify which properties of the dataset must be returned
Property extraction is based on `JMESPath <http://jmespath.org>`_ expressions.
This method returns a new Dataset narrowed down by the given selection.
:param properties: JMESPath to use for the property extraction.
... | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/dataset.py#L174-L197 |
mozilla/python_moztelemetry | moztelemetry/dataset.py | Dataset.where | def where(self, **kwargs):
"""Return a new Dataset refined using the given condition
:param kwargs: a map of `dimension` => `condition` to filter the elements
of the dataset. `condition` can either be an exact value or a
callable returning a boolean value. If `condition` is a va... | python | def where(self, **kwargs):
"""Return a new Dataset refined using the given condition
:param kwargs: a map of `dimension` => `condition` to filter the elements
of the dataset. `condition` can either be an exact value or a
callable returning a boolean value. If `condition` is a va... | Return a new Dataset refined using the given condition
:param kwargs: a map of `dimension` => `condition` to filter the elements
of the dataset. `condition` can either be an exact value or a
callable returning a boolean value. If `condition` is a value, it is
converted to a ... | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/dataset.py#L231-L251 |
mozilla/python_moztelemetry | moztelemetry/dataset.py | Dataset.summaries | def summaries(self, sc, limit=None):
"""Summary of the files contained in the current dataset
Every item in the summary is a dict containing a key name and the corresponding size of
the key item in bytes, e.g.::
{'key': 'full/path/to/my/key', 'size': 200}
:param limit: Max numb... | python | def summaries(self, sc, limit=None):
"""Summary of the files contained in the current dataset
Every item in the summary is a dict containing a key name and the corresponding size of
the key item in bytes, e.g.::
{'key': 'full/path/to/my/key', 'size': 200}
:param limit: Max numb... | Summary of the files contained in the current dataset
Every item in the summary is a dict containing a key name and the corresponding size of
the key item in bytes, e.g.::
{'key': 'full/path/to/my/key', 'size': 200}
:param limit: Max number of objects to retrieve
:return: An it... | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/dataset.py#L268-L291 |
mozilla/python_moztelemetry | moztelemetry/dataset.py | Dataset.records | def records(self, sc, group_by='greedy', limit=None, sample=1, seed=42, decode=None, summaries=None):
"""Retrieve the elements of a Dataset
:param sc: a SparkContext object
:param group_by: specifies a partition strategy for the objects
:param limit: maximum number of objects to retriev... | python | def records(self, sc, group_by='greedy', limit=None, sample=1, seed=42, decode=None, summaries=None):
"""Retrieve the elements of a Dataset
:param sc: a SparkContext object
:param group_by: specifies a partition strategy for the objects
:param limit: maximum number of objects to retriev... | Retrieve the elements of a Dataset
:param sc: a SparkContext object
:param group_by: specifies a partition strategy for the objects
:param limit: maximum number of objects to retrieve
:param decode: an optional transformation to apply to the objects retrieved
:param sample: perc... | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/dataset.py#L293-L357 |
mozilla/python_moztelemetry | moztelemetry/dataset.py | Dataset.dataframe | def dataframe(self, spark, group_by='greedy', limit=None, sample=1, seed=42, decode=None, summaries=None, schema=None, table_name=None):
"""Convert RDD returned from records function to a dataframe
:param spark: a SparkSession object
:param group_by: specifies a paritition strategy for the obje... | python | def dataframe(self, spark, group_by='greedy', limit=None, sample=1, seed=42, decode=None, summaries=None, schema=None, table_name=None):
"""Convert RDD returned from records function to a dataframe
:param spark: a SparkSession object
:param group_by: specifies a paritition strategy for the obje... | Convert RDD returned from records function to a dataframe
:param spark: a SparkSession object
:param group_by: specifies a paritition strategy for the objects
:param limit: maximum number of objects to retrieve
:param decode: an optional transformation to apply to the objects retrieved
... | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/dataset.py#L359-L385 |
mozilla/python_moztelemetry | moztelemetry/dataset.py | Dataset.from_source | def from_source(source_name):
"""Create a Dataset configured for the given source_name
This is particularly convenient when the user doesn't know
the list of dimensions or the bucket name, but only the source name.
Usage example::
records = Dataset.from_source('telemetry')... | python | def from_source(source_name):
"""Create a Dataset configured for the given source_name
This is particularly convenient when the user doesn't know
the list of dimensions or the bucket name, but only the source name.
Usage example::
records = Dataset.from_source('telemetry')... | Create a Dataset configured for the given source_name
This is particularly convenient when the user doesn't know
the list of dimensions or the bucket name, but only the source name.
Usage example::
records = Dataset.from_source('telemetry').where(
docType='main',
... | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/dataset.py#L388-L412 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/transitions.py | TransitionOpen.get_next_action | def get_next_action(self, request, application, roles):
""" Retrieve the next state. """
application.reopen()
link, is_secret = base.get_email_link(application)
emails.send_invite_email(application, link, is_secret)
messages.success(
request,
"Sent an invi... | python | def get_next_action(self, request, application, roles):
""" Retrieve the next state. """
application.reopen()
link, is_secret = base.get_email_link(application)
emails.send_invite_email(application, link, is_secret)
messages.success(
request,
"Sent an invi... | Retrieve the next state. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/transitions.py#L11-L20 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/transitions.py | TransitionSubmit.get_next_action | def get_next_action(self, request, application, roles):
""" Retrieve the next state. """
# Check for serious errors in submission.
# Should only happen in rare circumstances.
errors = application.check_valid()
if len(errors) > 0:
for error in errors:
... | python | def get_next_action(self, request, application, roles):
""" Retrieve the next state. """
# Check for serious errors in submission.
# Should only happen in rare circumstances.
errors = application.check_valid()
if len(errors) > 0:
for error in errors:
... | Retrieve the next state. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/transitions.py#L27-L41 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/transitions.py | TransitionApprove.get_next_action | def get_next_action(self, request, application, roles):
""" Retrieve the next state. """
# Check for serious errors in submission.
# Should only happen in rare circumstances.
errors = application.check_valid()
if len(errors) > 0:
for error in errors:
m... | python | def get_next_action(self, request, application, roles):
""" Retrieve the next state. """
# Check for serious errors in submission.
# Should only happen in rare circumstances.
errors = application.check_valid()
if len(errors) > 0:
for error in errors:
m... | Retrieve the next state. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/transitions.py#L48-L71 |
Karaage-Cluster/karaage | karaage/people/emails.py | send_bounced_warning | def send_bounced_warning(person, leader_list):
"""Sends an email to each project leader for person
informing them that person's email has bounced"""
context = CONTEXT.copy()
context['person'] = person
for lp in leader_list:
leader = lp['leader']
context['project'] = lp['project']
... | python | def send_bounced_warning(person, leader_list):
"""Sends an email to each project leader for person
informing them that person's email has bounced"""
context = CONTEXT.copy()
context['person'] = person
for lp in leader_list:
leader = lp['leader']
context['project'] = lp['project']
... | Sends an email to each project leader for person
informing them that person's email has bounced | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/emails.py#L42-L64 |
Karaage-Cluster/karaage | karaage/people/emails.py | send_reset_password_email | def send_reset_password_email(person):
"""Sends an email to user allowing them to set their password."""
uid = urlsafe_base64_encode(force_bytes(person.pk)).decode("ascii")
token = default_token_generator.make_token(person)
url = '%s/persons/reset/%s/%s/' % (
settings.REGISTRATION_BASE_URL, uid,... | python | def send_reset_password_email(person):
"""Sends an email to user allowing them to set their password."""
uid = urlsafe_base64_encode(force_bytes(person.pk)).decode("ascii")
token = default_token_generator.make_token(person)
url = '%s/persons/reset/%s/%s/' % (
settings.REGISTRATION_BASE_URL, uid,... | Sends an email to user allowing them to set their password. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/emails.py#L67-L83 |
Karaage-Cluster/karaage | karaage/people/emails.py | send_confirm_password_email | def send_confirm_password_email(person):
"""Sends an email to user allowing them to confirm their password."""
url = '%s/profile/login/%s/' % (
settings.REGISTRATION_BASE_URL, person.username)
context = CONTEXT.copy()
context.update({
'url': url,
'receiver': person,
})
... | python | def send_confirm_password_email(person):
"""Sends an email to user allowing them to confirm their password."""
url = '%s/profile/login/%s/' % (
settings.REGISTRATION_BASE_URL, person.username)
context = CONTEXT.copy()
context.update({
'url': url,
'receiver': person,
})
... | Sends an email to user allowing them to confirm their password. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/emails.py#L86-L100 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/states.py | StateWaitingForApproval.check_can_approve | def check_can_approve(self, request, application, roles):
""" Check the person's authorization. """
try:
authorised_persons = self.get_authorised_persons(application)
authorised_persons.get(pk=request.user.pk)
return True
except Person.DoesNotExist:
... | python | def check_can_approve(self, request, application, roles):
""" Check the person's authorization. """
try:
authorised_persons = self.get_authorised_persons(application)
authorised_persons.get(pk=request.user.pk)
return True
except Person.DoesNotExist:
... | Check the person's authorization. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/states.py#L57-L64 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/states.py | StateWaitingForApproval.enter_state | def enter_state(self, request, application):
""" This is becoming the new current state. """
authorised_persons = self.get_email_persons(application)
link, is_secret = self.get_request_email_link(application)
emails.send_request_email(
self.authorised_text,
self.a... | python | def enter_state(self, request, application):
""" This is becoming the new current state. """
authorised_persons = self.get_email_persons(application)
link, is_secret = self.get_request_email_link(application)
emails.send_request_email(
self.authorised_text,
self.a... | This is becoming the new current state. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/states.py#L73-L82 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/states.py | StateWaitingForApproval.get_next_action | def get_next_action(self, request, application, label, roles):
""" Django view method. """
actions = self.get_actions(request, application, roles)
if label == "approve" and 'approve' in actions:
application_form = self.get_approve_form(
request, application, roles)
... | python | def get_next_action(self, request, application, label, roles):
""" Django view method. """
actions = self.get_actions(request, application, roles)
if label == "approve" and 'approve' in actions:
application_form = self.get_approve_form(
request, application, roles)
... | Django view method. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/states.py#L88-L160 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/states.py | StatePassword.get_next_action | def get_next_action(self, request, application, label, roles):
""" Django view method. """
actions = self.get_actions(request, application, roles)
if label is None and 'is_applicant' in roles:
assert application.content_type.model == 'person'
if application.applicant.has_... | python | def get_next_action(self, request, application, label, roles):
""" Django view method. """
actions = self.get_actions(request, application, roles)
if label is None and 'is_applicant' in roles:
assert application.content_type.model == 'person'
if application.applicant.has_... | Django view method. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/states.py#L168-L202 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/states.py | StateDeclined.get_next_action | def get_next_action(self, request, application, label, roles):
""" Django view method. """
actions = self.get_actions(request, application, roles)
if label is None and \
'is_applicant' in roles and 'is_admin' not in roles:
# applicant, admin, leader can reopen an appl... | python | def get_next_action(self, request, application, label, roles):
""" Django view method. """
actions = self.get_actions(request, application, roles)
if label is None and \
'is_applicant' in roles and 'is_admin' not in roles:
# applicant, admin, leader can reopen an appl... | Django view method. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/states.py#L232-L250 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/states.py | StateWithSteps.add_step | def add_step(self, step, step_id):
""" Add a step to the list. The first step added becomes the initial
step. """
assert step_id not in self._steps
assert step_id not in self._order
assert isinstance(step, Step)
self._steps[step_id] = step
self._order.append(step... | python | def add_step(self, step, step_id):
""" Add a step to the list. The first step added becomes the initial
step. """
assert step_id not in self._steps
assert step_id not in self._order
assert isinstance(step, Step)
self._steps[step_id] = step
self._order.append(step... | Add a step to the list. The first step added becomes the initial
step. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/states.py#L381-L389 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/states.py | StateWithSteps.get_next_action | def get_next_action(self, request, application, label, roles):
""" Process the get_next_action request at the current step. """
actions = self.get_actions(request, application, roles)
# if the user is not the applicant, the steps don't apply.
if 'is_applicant' not in roles:
... | python | def get_next_action(self, request, application, label, roles):
""" Process the get_next_action request at the current step. """
actions = self.get_actions(request, application, roles)
# if the user is not the applicant, the steps don't apply.
if 'is_applicant' not in roles:
... | Process the get_next_action request at the current step. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/states.py#L391-L459 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/states.py | StateIntroduction.get_next_action | def get_next_action(self, request, application, label, roles):
""" Django get_next_action method. """
actions = self.get_actions(request, application, roles)
if label is None and \
'is_applicant' in roles and 'is_admin' not in roles:
for action in actions:
... | python | def get_next_action(self, request, application, label, roles):
""" Django get_next_action method. """
actions = self.get_actions(request, application, roles)
if label is None and \
'is_applicant' in roles and 'is_admin' not in roles:
for action in actions:
... | Django get_next_action method. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/states.py#L482-L502 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | _init_datastores | def _init_datastores():
""" Initialize all datastores. """
global _DATASTORES
array = settings.DATASTORES
for config in array:
cls = _lookup(config['ENGINE'])
ds = _get_datastore(cls, DataStore, config)
_DATASTORES.append(ds)
legacy_settings = getattr(settings, 'MACHINE_CATEG... | python | def _init_datastores():
""" Initialize all datastores. """
global _DATASTORES
array = settings.DATASTORES
for config in array:
cls = _lookup(config['ENGINE'])
ds = _get_datastore(cls, DataStore, config)
_DATASTORES.append(ds)
legacy_settings = getattr(settings, 'MACHINE_CATEG... | Initialize all datastores. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L52-L71 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | set_account_username | def set_account_username(account, old_username, new_username):
""" Account's username was changed. """
for datastore in _get_datastores():
datastore.set_account_username(account, old_username, new_username) | python | def set_account_username(account, old_username, new_username):
""" Account's username was changed. """
for datastore in _get_datastores():
datastore.set_account_username(account, old_username, new_username) | Account's username was changed. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L110-L113 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | get_account_details | def get_account_details(account):
""" Get the account details. """
result = []
for datastore in _get_datastores():
value = datastore.get_account_details(account)
value['datastore'] = datastore.config['DESCRIPTION']
result.append(value)
return result | python | def get_account_details(account):
""" Get the account details. """
result = []
for datastore in _get_datastores():
value = datastore.get_account_details(account)
value['datastore'] = datastore.config['DESCRIPTION']
result.append(value)
return result | Get the account details. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L160-L167 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | set_group_name | def set_group_name(group, old_name, new_name):
""" Group was renamed. """
for datastore in _get_datastores():
datastore.set_group_name(group, old_name, new_name) | python | def set_group_name(group, old_name, new_name):
""" Group was renamed. """
for datastore in _get_datastores():
datastore.set_group_name(group, old_name, new_name) | Group was renamed. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L186-L189 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | get_group_details | def get_group_details(group):
""" Get group details. """
result = []
for datastore in _get_datastores():
value = datastore.get_group_details(group)
value['datastore'] = datastore.config['DESCRIPTION']
result.append(value)
return result | python | def get_group_details(group):
""" Get group details. """
result = []
for datastore in _get_datastores():
value = datastore.get_group_details(group)
value['datastore'] = datastore.config['DESCRIPTION']
result.append(value)
return result | Get group details. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L192-L199 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | get_project_details | def get_project_details(project):
""" Get details for this user. """
result = []
for datastore in _get_datastores():
value = datastore.get_project_details(project)
value['datastore'] = datastore.config['DESCRIPTION']
result.append(value)
return result | python | def get_project_details(project):
""" Get details for this user. """
result = []
for datastore in _get_datastores():
value = datastore.get_project_details(project)
value['datastore'] = datastore.config['DESCRIPTION']
result.append(value)
return result | Get details for this user. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L218-L225 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | set_project_pid | def set_project_pid(project, old_pid, new_pid):
""" Project's PID was changed. """
for datastore in _get_datastores():
datastore.save_project(project)
datastore.set_project_pid(project, old_pid, new_pid) | python | def set_project_pid(project, old_pid, new_pid):
""" Project's PID was changed. """
for datastore in _get_datastores():
datastore.save_project(project)
datastore.set_project_pid(project, old_pid, new_pid) | Project's PID was changed. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L228-L232 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | get_institute_details | def get_institute_details(institute):
""" Get details for this user. """
result = []
for datastore in _get_datastores():
value = datastore.get_institute_details(institute)
value['datastore'] = datastore.config['DESCRIPTION']
result.append(value)
return result | python | def get_institute_details(institute):
""" Get details for this user. """
result = []
for datastore in _get_datastores():
value = datastore.get_institute_details(institute)
value['datastore'] = datastore.config['DESCRIPTION']
result.append(value)
return result | Get details for this user. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L251-L258 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | add_accounts_to_group | def add_accounts_to_group(accounts_query, group):
""" Add accounts to group. """
query = accounts_query.filter(date_deleted__isnull=True)
for account in query:
add_account_to_group(account, group) | python | def add_accounts_to_group(accounts_query, group):
""" Add accounts to group. """
query = accounts_query.filter(date_deleted__isnull=True)
for account in query:
add_account_to_group(account, group) | Add accounts to group. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L265-L271 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | remove_accounts_from_group | def remove_accounts_from_group(accounts_query, group):
""" Remove accounts from group. """
query = accounts_query.filter(date_deleted__isnull=True)
for account in query:
remove_account_from_group(account, group) | python | def remove_accounts_from_group(accounts_query, group):
""" Remove accounts from group. """
query = accounts_query.filter(date_deleted__isnull=True)
for account in query:
remove_account_from_group(account, group) | Remove accounts from group. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L274-L280 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | add_accounts_to_project | def add_accounts_to_project(accounts_query, project):
""" Add accounts to project. """
query = accounts_query.filter(date_deleted__isnull=True)
for account in query:
add_account_to_project(account, project) | python | def add_accounts_to_project(accounts_query, project):
""" Add accounts to project. """
query = accounts_query.filter(date_deleted__isnull=True)
for account in query:
add_account_to_project(account, project) | Add accounts to project. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L283-L289 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | remove_accounts_from_project | def remove_accounts_from_project(accounts_query, project):
""" Remove accounts from project. """
query = accounts_query.filter(date_deleted__isnull=True)
for account in query:
remove_account_from_project(account, project) | python | def remove_accounts_from_project(accounts_query, project):
""" Remove accounts from project. """
query = accounts_query.filter(date_deleted__isnull=True)
for account in query:
remove_account_from_project(account, project) | Remove accounts from project. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L292-L298 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | add_accounts_to_institute | def add_accounts_to_institute(accounts_query, institute):
""" Add accounts to institute. """
query = accounts_query.filter(date_deleted__isnull=True)
for account in query:
add_account_to_institute(account, institute) | python | def add_accounts_to_institute(accounts_query, institute):
""" Add accounts to institute. """
query = accounts_query.filter(date_deleted__isnull=True)
for account in query:
add_account_to_institute(account, institute) | Add accounts to institute. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L301-L307 |
Karaage-Cluster/karaage | karaage/datastores/__init__.py | remove_accounts_from_institute | def remove_accounts_from_institute(accounts_query, institute):
""" Remove accounts from institute. """
query = accounts_query.filter(date_deleted__isnull=True)
for account in query:
remove_account_from_institute(account, institute) | python | def remove_accounts_from_institute(accounts_query, institute):
""" Remove accounts from institute. """
query = accounts_query.filter(date_deleted__isnull=True)
for account in query:
remove_account_from_institute(account, institute) | Remove accounts from institute. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/__init__.py#L310-L316 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/aed.py | StateStepShibboleth.view | def view(self, request, application, label, roles, actions):
""" Django view method. """
status = None
applicant = application.applicant
attrs = []
saml_session = saml.is_saml_session(request)
# certain actions are supported regardless of what else happens
if 'c... | python | def view(self, request, application, label, roles, actions):
""" Django view method. """
status = None
applicant = application.applicant
attrs = []
saml_session = saml.is_saml_session(request)
# certain actions are supported regardless of what else happens
if 'c... | Django view method. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/aed.py#L45-L168 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/aed.py | StateStepApplicant.view | def view(self, request, application, label, roles, actions):
""" Django view method. """
# Get the appropriate form
status = None
form = None
if application.content_type.model != 'applicant':
status = "You are already registered in the system."
elif applicati... | python | def view(self, request, application, label, roles, actions):
""" Django view method. """
# Get the appropriate form
status = None
form = None
if application.content_type.model != 'applicant':
status = "You are already registered in the system."
elif applicati... | Django view method. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/aed.py#L176-L224 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/aed.py | StateStepProject.view | def view(self, request, application, label, roles, actions):
""" Django view method. """
if 'ajax' in request.POST:
resp = self.handle_ajax(request, application)
return HttpResponse(
json.dumps(resp), content_type="application/json")
form_models = {
... | python | def view(self, request, application, label, roles, actions):
""" Django view method. """
if 'ajax' in request.POST:
resp = self.handle_ajax(request, application)
return HttpResponse(
json.dumps(resp), content_type="application/json")
form_models = {
... | Django view method. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/aed.py#L269-L384 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/aed.py | StateStepIntroduction.view | def view(self, request, application, label, roles, actions):
""" Django get_next_action method. """
if application.content_type.model == 'applicant':
if not application.applicant.email_verified:
application.applicant.email_verified = True
application.applicant... | python | def view(self, request, application, label, roles, actions):
""" Django get_next_action method. """
if application.content_type.model == 'applicant':
if not application.applicant.email_verified:
application.applicant.email_verified = True
application.applicant... | Django get_next_action method. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/aed.py#L392-L409 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/aed.py | StateApplicantEnteringDetails.get_next_action | def get_next_action(self, request, application, label, roles):
""" Process the get_next_action request at the current step. """
# if user is logged and and not applicant, steal the
# application
if 'is_applicant' in roles:
# if we got this far, then we either we are logged i... | python | def get_next_action(self, request, application, label, roles):
""" Process the get_next_action request at the current step. """
# if user is logged and and not applicant, steal the
# application
if 'is_applicant' in roles:
# if we got this far, then we either we are logged i... | Process the get_next_action request at the current step. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/aed.py#L431-L511 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase._filter_string | def _filter_string(value):
""" Filter the string so MAM doesn't have heart failure."""
if value is None:
value = ""
# replace whitespace with space
value = value.replace("\n", " ")
value = value.replace("\t", " ")
# CSV seperator
value = value.replac... | python | def _filter_string(value):
""" Filter the string so MAM doesn't have heart failure."""
if value is None:
value = ""
# replace whitespace with space
value = value.replace("\n", " ")
value = value.replace("\t", " ")
# CSV seperator
value = value.replac... | Filter the string so MAM doesn't have heart failure. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L57-L78 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase._truncate | def _truncate(value, arg):
"""
Truncates a string after a given number of chars
Argument: Number of chars to _truncate after
"""
length = int(arg)
if value is None:
value = ""
if len(value) > length:
return value[:length] + "..."
el... | python | def _truncate(value, arg):
"""
Truncates a string after a given number of chars
Argument: Number of chars to _truncate after
"""
length = int(arg)
if value is None:
value = ""
if len(value) > length:
return value[:length] + "..."
el... | Truncates a string after a given number of chars
Argument: Number of chars to _truncate after | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L81-L92 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase._call | def _call(self, command, ignore_errors=None):
""" Call remote command with logging. """
if ignore_errors is None:
ignore_errors = []
command = self._get_command(command)
logger.debug("Cmd %s" % command)
null = open('/dev/null', 'w')
retcode = subprocess.call(... | python | def _call(self, command, ignore_errors=None):
""" Call remote command with logging. """
if ignore_errors is None:
ignore_errors = []
command = self._get_command(command)
logger.debug("Cmd %s" % command)
null = open('/dev/null', 'w')
retcode = subprocess.call(... | Call remote command with logging. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L125-L147 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase.get_user | def get_user(self, username):
""" Get the user details from MAM. """
cmd = ["glsuser", "-u", username, "--raw"]
results = self._read_output(cmd)
if len(results) == 0:
return None
elif len(results) > 1:
logger.error(
"Command returned multi... | python | def get_user(self, username):
""" Get the user details from MAM. """
cmd = ["glsuser", "-u", username, "--raw"]
results = self._read_output(cmd)
if len(results) == 0:
return None
elif len(results) > 1:
logger.error(
"Command returned multi... | Get the user details from MAM. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L208-L231 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase.get_user_balance | def get_user_balance(self, username):
""" Get the user balance details from MAM. """
cmd = ["gbalance", "-u", username, "--raw"]
results = self._read_output(cmd)
if len(results) == 0:
return None
return results | python | def get_user_balance(self, username):
""" Get the user balance details from MAM. """
cmd = ["gbalance", "-u", username, "--raw"]
results = self._read_output(cmd)
if len(results) == 0:
return None
return results | Get the user balance details from MAM. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L233-L241 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase.get_users_in_project | def get_users_in_project(self, projectname):
""" Get list of users in project from MAM. """
ds_project = self.get_project(projectname)
if ds_project is None:
logger.error(
"Project '%s' does not exist in MAM" % projectname)
raise RuntimeError(
... | python | def get_users_in_project(self, projectname):
""" Get list of users in project from MAM. """
ds_project = self.get_project(projectname)
if ds_project is None:
logger.error(
"Project '%s' does not exist in MAM" % projectname)
raise RuntimeError(
... | Get list of users in project from MAM. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L271-L283 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase.get_projects_in_user | def get_projects_in_user(self, username):
""" Get list of projects in user from MAM. """
ds_balance = self.get_user_balance(username)
if ds_balance is None:
return []
project_list = []
for bal in ds_balance:
project_list.append(bal["Name"])
return... | python | def get_projects_in_user(self, username):
""" Get list of projects in user from MAM. """
ds_balance = self.get_user_balance(username)
if ds_balance is None:
return []
project_list = []
for bal in ds_balance:
project_list.append(bal["Name"])
return... | Get list of projects in user from MAM. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L285-L294 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase._save_account | def _save_account(self, account, username):
""" Called when account is created/updated. With username override. """
# retrieve default project, or use null project if none
default_project_name = self._null_project
if account.default_project is not None:
default_project_name ... | python | def _save_account(self, account, username):
""" Called when account is created/updated. With username override. """
# retrieve default project, or use null project if none
default_project_name = self._null_project
if account.default_project is not None:
default_project_name ... | Called when account is created/updated. With username override. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L302-L347 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase._delete_account | def _delete_account(self, account, username):
""" Called when account is deleted. With username override. """
# account deleted
ds_user = self.get_user(username)
if ds_user is not None:
self._call(["grmuser", "-u", username], ignore_errors=[8])
return | python | def _delete_account(self, account, username):
""" Called when account is deleted. With username override. """
# account deleted
ds_user = self.get_user(username)
if ds_user is not None:
self._call(["grmuser", "-u", username], ignore_errors=[8])
return | Called when account is deleted. With username override. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L353-L362 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase.set_account_username | def set_account_username(self, account, old_username, new_username):
""" Account's username was changed. """
self._delete_account(account, old_username)
self._save_account(account, new_username) | python | def set_account_username(self, account, old_username, new_username):
""" Account's username was changed. """
self._delete_account(account, old_username)
self._save_account(account, new_username) | Account's username was changed. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L372-L375 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase.get_account_details | def get_account_details(self, account):
""" Get the account details """
result = self.get_user(account.username)
if result is None:
result = {}
return result | python | def get_account_details(self, account):
""" Get the account details """
result = self.get_user(account.username)
if result is None:
result = {}
return result | Get the account details | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L390-L395 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase.save_project | def save_project(self, project):
""" Called when project is saved/updated. """
pid = project.pid
# project created
# project updated
if project.is_active:
# project is not deleted
logger.debug("project is active")
ds_project = self.get_projec... | python | def save_project(self, project):
""" Called when project is saved/updated. """
pid = project.pid
# project created
# project updated
if project.is_active:
# project is not deleted
logger.debug("project is active")
ds_project = self.get_projec... | Called when project is saved/updated. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L418-L442 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase.delete_project | def delete_project(self, project):
""" Called when project is deleted. """
pid = project.pid
# project deleted
ds_project = self.get_project(pid)
if ds_project is not None:
self._delete_project(pid)
return | python | def delete_project(self, project):
""" Called when project is deleted. """
pid = project.pid
# project deleted
ds_project = self.get_project(pid)
if ds_project is not None:
self._delete_project(pid)
return | Called when project is deleted. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L444-L454 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase.get_project_details | def get_project_details(self, project):
""" Get the project details. """
result = self.get_project(project.pid)
if result is None:
result = {}
return result | python | def get_project_details(self, project):
""" Get the project details. """
result = self.get_project(project.pid)
if result is None:
result = {}
return result | Get the project details. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L456-L461 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase.save_institute | def save_institute(self, institute):
""" Called when institute is created/updated. """
name = institute.name
logger.debug("save_institute '%s'" % name)
# institute created
# institute updated
if institute.is_active:
# date_deleted is not set, user should exi... | python | def save_institute(self, institute):
""" Called when institute is created/updated. """
name = institute.name
logger.debug("save_institute '%s'" % name)
# institute created
# institute updated
if institute.is_active:
# date_deleted is not set, user should exi... | Called when institute is created/updated. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L468-L490 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStoreBase.delete_institute | def delete_institute(self, institute):
""" Called when institute is deleted. """
name = institute.name
logger.debug("institute_deleted '%s'" % name)
# institute deleted
self._call(["goldsh", "Organization", "Delete", "Name==%s" % name])
logger.debug("returning")
... | python | def delete_institute(self, institute):
""" Called when institute is deleted. """
name = institute.name
logger.debug("institute_deleted '%s'" % name)
# institute deleted
self._call(["goldsh", "Organization", "Delete", "Name==%s" % name])
logger.debug("returning")
... | Called when institute is deleted. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L492-L501 |
Karaage-Cluster/karaage | karaage/datastores/mam.py | MamDataStore71.add_account_to_project | def add_account_to_project(self, account, project):
""" Add account to project. """
username = account.username
projectname = project.pid
self._call([
"gchproject",
"--add-user", username,
"-p", projectname],
ignore_errors=[74]) | python | def add_account_to_project(self, account, project):
""" Add account to project. """
username = account.username
projectname = project.pid
self._call([
"gchproject",
"--add-user", username,
"-p", projectname],
ignore_errors=[74]) | Add account to project. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L523-L531 |
mozilla/python_moztelemetry | moztelemetry/zeppelin.py | show | def show(fig, width=600):
""" Renders a Matplotlib figure in Zeppelin.
:param fig: a Matplotlib figure
:param width: the width in pixel of the rendered figure, defaults to 600
Usage example::
import matplotlib.pyplot as plt
from moztelemetry.zeppelin import show
fig = plt.fig... | python | def show(fig, width=600):
""" Renders a Matplotlib figure in Zeppelin.
:param fig: a Matplotlib figure
:param width: the width in pixel of the rendered figure, defaults to 600
Usage example::
import matplotlib.pyplot as plt
from moztelemetry.zeppelin import show
fig = plt.fig... | Renders a Matplotlib figure in Zeppelin.
:param fig: a Matplotlib figure
:param width: the width in pixel of the rendered figure, defaults to 600
Usage example::
import matplotlib.pyplot as plt
from moztelemetry.zeppelin import show
fig = plt.figure()
plt.plot([1, 2, 3])
... | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/zeppelin.py#L8-L26 |
daler/trackhub | trackhub/__init__.py | default_hub | def default_hub(hub_name, genome, email, short_label=None, long_label=None):
"""
Returns a fully-connected set of hub components using default filenames.
Parameters
----------
hub_name : str
Name of the hub
genome : str
Assembly name (hg38, dm6, etc)
email : str
E... | python | def default_hub(hub_name, genome, email, short_label=None, long_label=None):
"""
Returns a fully-connected set of hub components using default filenames.
Parameters
----------
hub_name : str
Name of the hub
genome : str
Assembly name (hg38, dm6, etc)
email : str
E... | Returns a fully-connected set of hub components using default filenames.
Parameters
----------
hub_name : str
Name of the hub
genome : str
Assembly name (hg38, dm6, etc)
email : str
Email to include with hub.
short_label : str
Short label for the hub. If None... | https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/__init__.py#L18-L57 |
Karaage-Cluster/karaage | karaage/plugins/kgusage/xmlrpc.py | parse_usage | def parse_usage(machine, usage, date, machine_name, log_type):
"""
Parses usage
"""
assert machine.name == machine_name
year, month, day = date.split('-')
date = datetime.date(int(year), int(month), int(day))
return parse_logs(usage, date, machine_name, log_type) | python | def parse_usage(machine, usage, date, machine_name, log_type):
"""
Parses usage
"""
assert machine.name == machine_name
year, month, day = date.split('-')
date = datetime.date(int(year), int(month), int(day))
return parse_logs(usage, date, machine_name, log_type) | Parses usage | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/xmlrpc.py#L31-L40 |
mozilla/python_moztelemetry | moztelemetry/parse_histograms.py | from_files | def from_files(filenames, strict_type_checks=True):
"""Return an iterator that provides a sequence of Histograms for
the histograms defined in filenames.
"""
if strict_type_checks:
load_whitelist()
all_histograms = OrderedDict()
for filename in filenames:
parser = FILENAME_PARSERS[o... | python | def from_files(filenames, strict_type_checks=True):
"""Return an iterator that provides a sequence of Histograms for
the histograms defined in filenames.
"""
if strict_type_checks:
load_whitelist()
all_histograms = OrderedDict()
for filename in filenames:
parser = FILENAME_PARSERS[o... | Return an iterator that provides a sequence of Histograms for
the histograms defined in filenames. | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/parse_histograms.py#L598-L644 |
mozilla/python_moztelemetry | moztelemetry/parse_histograms.py | Histogram.ranges | def ranges(self):
"""Return an array of lower bounds for each bucket in the histogram."""
bucket_fns = {
'boolean': linear_buckets,
'flag': linear_buckets,
'count': linear_buckets,
'enumerated': linear_buckets,
'categorical': linear_buckets,
... | python | def ranges(self):
"""Return an array of lower bounds for each bucket in the histogram."""
bucket_fns = {
'boolean': linear_buckets,
'flag': linear_buckets,
'count': linear_buckets,
'enumerated': linear_buckets,
'categorical': linear_buckets,
... | Return an array of lower bounds for each bucket in the histogram. | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/parse_histograms.py#L193-L209 |
Karaage-Cluster/karaage | karaage/projects/utils.py | get_new_pid | def get_new_pid(institute):
""" Return a new Project ID
Keyword arguments:
institute_id -- Institute id
"""
number = '0001'
prefix = 'p%s' % institute.name.replace(' ', '')[:4]
found = True
while found:
try:
Project.objects.get(pid=prefix + number)
number... | python | def get_new_pid(institute):
""" Return a new Project ID
Keyword arguments:
institute_id -- Institute id
"""
number = '0001'
prefix = 'p%s' % institute.name.replace(' ', '')[:4]
found = True
while found:
try:
Project.objects.get(pid=prefix + number)
number... | Return a new Project ID
Keyword arguments:
institute_id -- Institute id | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/projects/utils.py#L33-L55 |
Karaage-Cluster/karaage | karaage/common/create_update.py | apply_extra_context | def apply_extra_context(extra_context, context):
"""
Adds items from extra_context dict to context. If a value in extra_context
is callable, then it is called and the result is added to context.
"""
for key, value in six.iteritems(extra_context):
if callable(value):
context[key]... | python | def apply_extra_context(extra_context, context):
"""
Adds items from extra_context dict to context. If a value in extra_context
is callable, then it is called and the result is added to context.
"""
for key, value in six.iteritems(extra_context):
if callable(value):
context[key]... | Adds items from extra_context dict to context. If a value in extra_context
is callable, then it is called and the result is added to context. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/create_update.py#L12-L21 |
Karaage-Cluster/karaage | karaage/common/create_update.py | get_model_and_form_class | def get_model_and_form_class(model, form_class):
"""
Returns a model and form class based on the model and form_class
parameters that were passed to the generic view.
If ``form_class`` is given then its associated model will be returned along
with ``form_class`` itself. Otherwise, if ``model`` is ... | python | def get_model_and_form_class(model, form_class):
"""
Returns a model and form class based on the model and form_class
parameters that were passed to the generic view.
If ``form_class`` is given then its associated model will be returned along
with ``form_class`` itself. Otherwise, if ``model`` is ... | Returns a model and form class based on the model and form_class
parameters that were passed to the generic view.
If ``form_class`` is given then its associated model will be returned along
with ``form_class`` itself. Otherwise, if ``model`` is given, ``model``
itself will be returned along with a ``M... | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/create_update.py#L24-L50 |
Karaage-Cluster/karaage | karaage/common/create_update.py | redirect | def redirect(post_save_redirect, obj):
"""
Returns a HttpResponseRedirect to ``post_save_redirect``.
``post_save_redirect`` should be a string, and can contain named string-
substitution place holders of ``obj`` field names.
If ``post_save_redirect`` is None, then redirect to ``obj``'s URL returne... | python | def redirect(post_save_redirect, obj):
"""
Returns a HttpResponseRedirect to ``post_save_redirect``.
``post_save_redirect`` should be a string, and can contain named string-
substitution place holders of ``obj`` field names.
If ``post_save_redirect`` is None, then redirect to ``obj``'s URL returne... | Returns a HttpResponseRedirect to ``post_save_redirect``.
``post_save_redirect`` should be a string, and can contain named string-
substitution place holders of ``obj`` field names.
If ``post_save_redirect`` is None, then redirect to ``obj``'s URL returned
by ``get_absolute_url()``. If ``obj`` has no... | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/create_update.py#L53-L75 |
Karaage-Cluster/karaage | karaage/common/create_update.py | lookup_object | def lookup_object(model, object_id, slug, slug_field):
"""
Return the ``model`` object with the passed ``object_id``. If
``object_id`` is None, then return the object whose ``slug_field``
equals the passed ``slug``. If ``slug`` and ``slug_field`` are not passed,
then raise Http404 exception.
"... | python | def lookup_object(model, object_id, slug, slug_field):
"""
Return the ``model`` object with the passed ``object_id``. If
``object_id`` is None, then return the object whose ``slug_field``
equals the passed ``slug``. If ``slug`` and ``slug_field`` are not passed,
then raise Http404 exception.
"... | Return the ``model`` object with the passed ``object_id``. If
``object_id`` is None, then return the object whose ``slug_field``
equals the passed ``slug``. If ``slug`` and ``slug_field`` are not passed,
then raise Http404 exception. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/create_update.py#L78-L98 |
Karaage-Cluster/karaage | karaage/common/create_update.py | create_object | def create_object(
request, model=None, template_name=None,
template_loader=loader, extra_context=None, post_save_redirect=None,
login_required=False, context_processors=None, form_class=None):
"""
Generic object-creation function.
Templates: ``<app_label>/<model_name>_form.html``
... | python | def create_object(
request, model=None, template_name=None,
template_loader=loader, extra_context=None, post_save_redirect=None,
login_required=False, context_processors=None, form_class=None):
"""
Generic object-creation function.
Templates: ``<app_label>/<model_name>_form.html``
... | Generic object-creation function.
Templates: ``<app_label>/<model_name>_form.html``
Context:
form
the form for the object | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/create_update.py#L101-L140 |
Karaage-Cluster/karaage | karaage/common/create_update.py | update_object | def update_object(
request, model=None, object_id=None, slug=None,
slug_field='slug', template_name=None, template_loader=loader,
extra_context=None, post_save_redirect=None, login_required=False,
context_processors=None, template_object_name='object',
form_class=None):
"""
... | python | def update_object(
request, model=None, object_id=None, slug=None,
slug_field='slug', template_name=None, template_loader=loader,
extra_context=None, post_save_redirect=None, login_required=False,
context_processors=None, template_object_name='object',
form_class=None):
"""
... | Generic object-update function.
Templates: ``<app_label>/<model_name>_form.html``
Context:
form
the form for the object
object
the original object being edited | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/create_update.py#L143-L188 |
Karaage-Cluster/karaage | karaage/common/create_update.py | delete_object | def delete_object(
request, model, post_delete_redirect, object_id=None,
slug=None, slug_field='slug', template_name=None,
template_loader=loader, extra_context=None, login_required=False,
context_processors=None, template_object_name='object'):
"""
Generic object-delete function... | python | def delete_object(
request, model, post_delete_redirect, object_id=None,
slug=None, slug_field='slug', template_name=None,
template_loader=loader, extra_context=None, login_required=False,
context_processors=None, template_object_name='object'):
"""
Generic object-delete function... | Generic object-delete function.
The given template will be used to confirm deletetion if this view is
fetched using GET; for safty, deletion will only be performed if this
view is POSTed.
Templates: ``<app_label>/<model_name>_confirm_delete.html``
Context:
object
the original o... | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/create_update.py#L191-L231 |
daler/trackhub | trackhub/assembly.py | Assembly.add_params | def add_params(self, **kw):
"""
Add [possibly many] parameters to the Assembly.
Parameters will be checked against known UCSC parameters and their
supported formats.
"""
for k, v in kw.items():
if k not in self.params:
raise ValidationError(
... | python | def add_params(self, **kw):
"""
Add [possibly many] parameters to the Assembly.
Parameters will be checked against known UCSC parameters and their
supported formats.
"""
for k, v in kw.items():
if k not in self.params:
raise ValidationError(
... | Add [possibly many] parameters to the Assembly.
Parameters will be checked against known UCSC parameters and their
supported formats. | https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/assembly.py#L138-L153 |
daler/trackhub | trackhub/assembly.py | Assembly.remove_params | def remove_params(self, *args):
"""
Remove [possibly many] parameters from the Assembly.
E.g.,
remove_params('color', 'visibility')
"""
for a in args:
self._orig_kwargs.pop(a)
self.kwargs = self._orig_kwargs.copy() | python | def remove_params(self, *args):
"""
Remove [possibly many] parameters from the Assembly.
E.g.,
remove_params('color', 'visibility')
"""
for a in args:
self._orig_kwargs.pop(a)
self.kwargs = self._orig_kwargs.copy() | Remove [possibly many] parameters from the Assembly.
E.g.,
remove_params('color', 'visibility') | https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/assembly.py#L155-L165 |
Karaage-Cluster/karaage | karaage/machines/models.py | _members_changed | def _members_changed(
sender, instance, action, reverse, model, pk_set, **kwargs):
"""
Hook that executes whenever the group members are changed.
"""
if action == "post_remove":
if not reverse:
group = instance
for person in model.objects.filter(pk__in=pk_set):
... | python | def _members_changed(
sender, instance, action, reverse, model, pk_set, **kwargs):
"""
Hook that executes whenever the group members are changed.
"""
if action == "post_remove":
if not reverse:
group = instance
for person in model.objects.filter(pk__in=pk_set):
... | Hook that executes whenever the group members are changed. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/machines/models.py#L319-L344 |
Karaage-Cluster/karaage | karaage/people/utils.py | validate_username | def validate_username(username):
""" Validate the new username. If the username is invalid, raises
:py:exc:`UsernameInvalid`.
:param username: Username to validate.
"""
# Check username looks ok
if not username.islower():
raise UsernameInvalid(six.u('Username must be all lowercase'))
... | python | def validate_username(username):
""" Validate the new username. If the username is invalid, raises
:py:exc:`UsernameInvalid`.
:param username: Username to validate.
"""
# Check username looks ok
if not username.islower():
raise UsernameInvalid(six.u('Username must be all lowercase'))
... | Validate the new username. If the username is invalid, raises
:py:exc:`UsernameInvalid`.
:param username: Username to validate. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/utils.py#L44-L60 |
Karaage-Cluster/karaage | karaage/people/utils.py | validate_username_for_new_person | def validate_username_for_new_person(username):
""" Validate the new username for a new person. If the username is invalid
or in use, raises :py:exc:`UsernameInvalid` or :py:exc:`UsernameTaken`.
:param username: Username to validate.
"""
# is the username valid?
validate_username(username)
... | python | def validate_username_for_new_person(username):
""" Validate the new username for a new person. If the username is invalid
or in use, raises :py:exc:`UsernameInvalid` or :py:exc:`UsernameTaken`.
:param username: Username to validate.
"""
# is the username valid?
validate_username(username)
... | Validate the new username for a new person. If the username is invalid
or in use, raises :py:exc:`UsernameInvalid` or :py:exc:`UsernameTaken`.
:param username: Username to validate. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/utils.py#L63-L98 |
Karaage-Cluster/karaage | karaage/people/utils.py | validate_username_for_new_account | def validate_username_for_new_account(person, username):
""" Validate the new username for a new account. If the username is invalid
or in use, raises :py:exc:`UsernameInvalid` or :py:exc:`UsernameTaken`.
:param person: Owner of new account.
:param username: Username to validate.
"""
# This is... | python | def validate_username_for_new_account(person, username):
""" Validate the new username for a new account. If the username is invalid
or in use, raises :py:exc:`UsernameInvalid` or :py:exc:`UsernameTaken`.
:param person: Owner of new account.
:param username: Username to validate.
"""
# This is... | Validate the new username for a new account. If the username is invalid
or in use, raises :py:exc:`UsernameInvalid` or :py:exc:`UsernameTaken`.
:param person: Owner of new account.
:param username: Username to validate. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/utils.py#L101-L143 |
Karaage-Cluster/karaage | karaage/people/utils.py | check_username_for_new_account | def check_username_for_new_account(person, username):
""" Check the new username for a new account. If the username is
in use, raises :py:exc:`UsernameTaken`.
:param person: Owner of new account.
:param username: Username to validate.
"""
query = Account.objects.filter(
username__exac... | python | def check_username_for_new_account(person, username):
""" Check the new username for a new account. If the username is
in use, raises :py:exc:`UsernameTaken`.
:param person: Owner of new account.
:param username: Username to validate.
"""
query = Account.objects.filter(
username__exac... | Check the new username for a new account. If the username is
in use, raises :py:exc:`UsernameTaken`.
:param person: Owner of new account.
:param username: Username to validate. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/utils.py#L146-L168 |
Karaage-Cluster/karaage | karaage/people/utils.py | validate_username_for_rename_person | def validate_username_for_rename_person(username, person):
""" Validate the new username to rename a person. If the username is
invalid or in use, raises :py:exc:`UsernameInvalid` or
:py:exc:`UsernameTaken`.
:param username: Username to validate.
:param person: We exclude this person when checking ... | python | def validate_username_for_rename_person(username, person):
""" Validate the new username to rename a person. If the username is
invalid or in use, raises :py:exc:`UsernameInvalid` or
:py:exc:`UsernameTaken`.
:param username: Username to validate.
:param person: We exclude this person when checking ... | Validate the new username to rename a person. If the username is
invalid or in use, raises :py:exc:`UsernameInvalid` or
:py:exc:`UsernameTaken`.
:param username: Username to validate.
:param person: We exclude this person when checking for duplicates. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/utils.py#L171-L209 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/base.py | get_url | def get_url(request, application, roles, label=None):
""" Retrieve a link that will work for the current user. """
args = []
if label is not None:
args.append(label)
# don't use secret_token unless we have to
if 'is_admin' in roles:
# Administrators can access anything without secre... | python | def get_url(request, application, roles, label=None):
""" Retrieve a link that will work for the current user. """
args = []
if label is not None:
args.append(label)
# don't use secret_token unless we have to
if 'is_admin' in roles:
# Administrators can access anything without secre... | Retrieve a link that will work for the current user. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/base.py#L69-L103 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/base.py | get_admin_email_link | def get_admin_email_link(application):
""" Retrieve a link that can be emailed to the administrator. """
url = '%s/applications/%d/' % (settings.ADMIN_BASE_URL, application.pk)
is_secret = False
return url, is_secret | python | def get_admin_email_link(application):
""" Retrieve a link that can be emailed to the administrator. """
url = '%s/applications/%d/' % (settings.ADMIN_BASE_URL, application.pk)
is_secret = False
return url, is_secret | Retrieve a link that can be emailed to the administrator. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/base.py#L106-L110 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/base.py | get_registration_email_link | def get_registration_email_link(application):
""" Retrieve a link that can be emailed to the logged other users. """
url = '%s/applications/%d/' % (
settings.REGISTRATION_BASE_URL, application.pk)
is_secret = False
return url, is_secret | python | def get_registration_email_link(application):
""" Retrieve a link that can be emailed to the logged other users. """
url = '%s/applications/%d/' % (
settings.REGISTRATION_BASE_URL, application.pk)
is_secret = False
return url, is_secret | Retrieve a link that can be emailed to the logged other users. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/base.py#L113-L118 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/base.py | get_email_link | def get_email_link(application):
""" Retrieve a link that can be emailed to the applicant. """
# don't use secret_token unless we have to
if (application.content_type.model == 'person'
and application.applicant.has_usable_password()):
url = '%s/applications/%d/' % (
settings.... | python | def get_email_link(application):
""" Retrieve a link that can be emailed to the applicant. """
# don't use secret_token unless we have to
if (application.content_type.model == 'person'
and application.applicant.has_usable_password()):
url = '%s/applications/%d/' % (
settings.... | Retrieve a link that can be emailed to the applicant. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/base.py#L121-L133 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/base.py | StateMachine.start | def start(self, request, application, extra_roles=None):
""" Continue the state machine at first state. """
# Get the authentication of the current user
roles = self._get_roles_for_request(request, application)
if extra_roles is not None:
roles.update(extra_roles)
# ... | python | def start(self, request, application, extra_roles=None):
""" Continue the state machine at first state. """
# Get the authentication of the current user
roles = self._get_roles_for_request(request, application)
if extra_roles is not None:
roles.update(extra_roles)
# ... | Continue the state machine at first state. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/base.py#L158-L171 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/base.py | StateMachine.process | def process(
self, request, application,
expected_state, label, extra_roles=None):
""" Process the view request at the current state. """
# Get the authentication of the current user
roles = self._get_roles_for_request(request, application)
if extra_roles is not ... | python | def process(
self, request, application,
expected_state, label, extra_roles=None):
""" Process the view request at the current state. """
# Get the authentication of the current user
roles = self._get_roles_for_request(request, application)
if extra_roles is not ... | Process the view request at the current state. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/base.py#L173-L237 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/base.py | StateMachine._get_roles_for_request | def _get_roles_for_request(request, application):
""" Check the authentication of the current user. """
roles = application.get_roles_for_person(request.user)
if common.is_admin(request):
roles.add("is_admin")
roles.add('is_authorised')
return roles | python | def _get_roles_for_request(request, application):
""" Check the authentication of the current user. """
roles = application.get_roles_for_person(request.user)
if common.is_admin(request):
roles.add("is_admin")
roles.add('is_authorised')
return roles | Check the authentication of the current user. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/base.py#L243-L251 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/base.py | StateMachine._next | def _next(self, request, application, roles, next_config):
""" Continue the state machine at given state. """
# we only support state changes for POST requests
if request.method == "POST":
key = None
# If next state is a transition, process it
while True:
... | python | def _next(self, request, application, roles, next_config):
""" Continue the state machine at given state. """
# we only support state changes for POST requests
if request.method == "POST":
key = None
# If next state is a transition, process it
while True:
... | Continue the state machine at given state. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/base.py#L253-L291 |
Karaage-Cluster/karaage | karaage/plugins/kgapplications/views/base.py | State.get_next_action | def get_next_action(self, request, application, label, roles):
""" Django view method. We provide a default detail view for
applications. """
# We only provide a view for when no label provided
if label is not None:
return HttpResponseBadRequest("<h1>Bad Request</h1>")
... | python | def get_next_action(self, request, application, label, roles):
""" Django view method. We provide a default detail view for
applications. """
# We only provide a view for when no label provided
if label is not None:
return HttpResponseBadRequest("<h1>Bad Request</h1>")
... | Django view method. We provide a default detail view for
applications. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/base.py#L326-L355 |
Karaage-Cluster/karaage | karaage/institutes/lookups.py | LookupChannel.check_auth | def check_auth(self, request):
"""
to ensure that nobody can get your data via json simply by knowing the
URL. public facing forms should write a custom LookupChannel to
implement as you wish. also you could choose to return
HttpResponseForbidden("who are you?") instead of rais... | python | def check_auth(self, request):
"""
to ensure that nobody can get your data via json simply by knowing the
URL. public facing forms should write a custom LookupChannel to
implement as you wish. also you could choose to return
HttpResponseForbidden("who are you?") instead of rais... | to ensure that nobody can get your data via json simply by knowing the
URL. public facing forms should write a custom LookupChannel to
implement as you wish. also you could choose to return
HttpResponseForbidden("who are you?") instead of raising
PermissionDenied (401 response) | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/institutes/lookups.py#L32-L43 |
Karaage-Cluster/karaage | karaage/institutes/lookups.py | InstituteLookup.get_query | def get_query(self, q, request):
""" return a query set searching for the query string q
either implement this method yourself or set the search_field
in the LookupChannel class definition
"""
return Institute.objects.filter(
Q(name__icontains=q)
) | python | def get_query(self, q, request):
""" return a query set searching for the query string q
either implement this method yourself or set the search_field
in the LookupChannel class definition
"""
return Institute.objects.filter(
Q(name__icontains=q)
) | return a query set searching for the query string q
either implement this method yourself or set the search_field
in the LookupChannel class definition | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/institutes/lookups.py#L49-L56 |
mozilla/python_moztelemetry | moztelemetry/histogram.py | Histogram.get_value | def get_value(self, only_median=False, autocast=True):
"""
Returns a scalar for flag and count histograms. Otherwise it returns either the
raw histogram represented as a pandas Series or just the median if only_median
is True.
If autocast is disabled the underlying pandas series ... | python | def get_value(self, only_median=False, autocast=True):
"""
Returns a scalar for flag and count histograms. Otherwise it returns either the
raw histogram represented as a pandas Series or just the median if only_median
is True.
If autocast is disabled the underlying pandas series ... | Returns a scalar for flag and count histograms. Otherwise it returns either the
raw histogram represented as a pandas Series or just the median if only_median
is True.
If autocast is disabled the underlying pandas series is always returned as is. | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/histogram.py#L178-L198 |
mozilla/python_moztelemetry | moztelemetry/histogram.py | Histogram.percentile | def percentile(self, percentile):
""" Returns the nth percentile of the histogram. """
assert(percentile >= 0 and percentile <= 100)
assert(self.kind in ["exponential", "linear", "enumerated", "boolean"])
fraction = percentile / 100
to_count = fraction * self.buckets.sum()
... | python | def percentile(self, percentile):
""" Returns the nth percentile of the histogram. """
assert(percentile >= 0 and percentile <= 100)
assert(self.kind in ["exponential", "linear", "enumerated", "boolean"])
fraction = percentile / 100
to_count = fraction * self.buckets.sum()
... | Returns the nth percentile of the histogram. | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/histogram.py#L204-L226 |
daler/trackhub | trackhub/track.py | BaseTrack.tracktype | def tracktype(self, tracktype):
"""
When setting the track type, the valid parameters for this track type
need to be set as well.
"""
self._tracktype = tracktype
if tracktype is not None:
if 'bed' in tracktype.lower():
tracktype = 'bigBed'
... | python | def tracktype(self, tracktype):
"""
When setting the track type, the valid parameters for this track type
need to be set as well.
"""
self._tracktype = tracktype
if tracktype is not None:
if 'bed' in tracktype.lower():
tracktype = 'bigBed'
... | When setting the track type, the valid parameters for this track type
need to be set as well. | https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/track.py#L245-L256 |
daler/trackhub | trackhub/track.py | BaseTrack.add_params | def add_params(self, **kw):
"""
Add [possibly many] parameters to the track.
Parameters will be checked against known UCSC parameters and their
supported formats.
E.g.::
add_params(color='128,0,0', visibility='dense')
"""
for k, v in kw.items():
... | python | def add_params(self, **kw):
"""
Add [possibly many] parameters to the track.
Parameters will be checked against known UCSC parameters and their
supported formats.
E.g.::
add_params(color='128,0,0', visibility='dense')
"""
for k, v in kw.items():
... | Add [possibly many] parameters to the track.
Parameters will be checked against known UCSC parameters and their
supported formats.
E.g.::
add_params(color='128,0,0', visibility='dense') | https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/track.py#L264-L286 |
daler/trackhub | trackhub/track.py | BaseTrack.add_subgroups | def add_subgroups(self, subgroups):
"""
Update the subgroups for this track.
Note that in contrast to :meth:`CompositeTrack`, which takes a list of
:class:`SubGroupDefinition` objects representing the allowed subgroups,
this method takes a single dictionary indicating the partic... | python | def add_subgroups(self, subgroups):
"""
Update the subgroups for this track.
Note that in contrast to :meth:`CompositeTrack`, which takes a list of
:class:`SubGroupDefinition` objects representing the allowed subgroups,
this method takes a single dictionary indicating the partic... | Update the subgroups for this track.
Note that in contrast to :meth:`CompositeTrack`, which takes a list of
:class:`SubGroupDefinition` objects representing the allowed subgroups,
this method takes a single dictionary indicating the particular
subgroups for this track.
Paramete... | https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/track.py#L300-L321 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.