id
int64 0
843k
| repository_name
stringlengths 7
55
| file_path
stringlengths 9
332
| class_name
stringlengths 3
290
| human_written_code
stringlengths 12
4.36M
| class_skeleton
stringlengths 19
2.2M
| total_program_units
int64 1
9.57k
| total_doc_str
int64 0
4.2k
| AvgCountLine
float64 0
7.89k
| AvgCountLineBlank
float64 0
300
| AvgCountLineCode
float64 0
7.89k
| AvgCountLineComment
float64 0
7.89k
| AvgCyclomatic
float64 0
130
| CommentToCodeRatio
float64 0
176
| CountClassBase
float64 0
48
| CountClassCoupled
float64 0
589
| CountClassCoupledModified
float64 0
581
| CountClassDerived
float64 0
5.37k
| CountDeclInstanceMethod
float64 0
4.2k
| CountDeclInstanceVariable
float64 0
299
| CountDeclMethod
float64 0
4.2k
| CountDeclMethodAll
float64 0
4.2k
| CountLine
float64 1
115k
| CountLineBlank
float64 0
9.01k
| CountLineCode
float64 0
94.4k
| CountLineCodeDecl
float64 0
46.1k
| CountLineCodeExe
float64 0
91.3k
| CountLineComment
float64 0
27k
| CountStmt
float64 1
93.2k
| CountStmtDecl
float64 0
46.1k
| CountStmtExe
float64 0
90.2k
| MaxCyclomatic
float64 0
759
| MaxInheritanceTree
float64 0
16
| MaxNesting
float64 0
34
| SumCyclomatic
float64 0
6k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
145,948 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0098_blank_annotation.py
|
squad.core.migrations.0098_blank_annotation.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0097_build_placeholder'),
]
operations = [
migrations.AlterField(
model_name='annotation',
name='description',
field=models.CharField(blank=True, max_length=1024, null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,949 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0099_metricthreshold.py
|
squad.core.migrations.0099_metricthreshold.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0098_blank_annotation'),
]
operations = [
migrations.CreateModel(
name='MetricThreshold',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=1024)),
('value', models.FloatField()),
('is_higher_better', models.BooleanField(default=False)),
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Project')),
],
),
migrations.AlterUniqueTogether(
name='metricthreshold',
unique_together=set([('project', 'name')]),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 22 | 2 | 20 | 3 | 19 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,950 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0100_metric_is_outlier.py
|
squad.core.migrations.0100_metric_is_outlier.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0099_metricthreshold'),
]
operations = [
migrations.AddField(
model_name='metric',
name='is_outlier',
field=models.BooleanField(default=False),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,951 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0101_project_project_settings.py
|
squad.core.migrations.0101_project_project_settings.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0100_metric_is_outlier'),
]
operations = [
migrations.AddField(
model_name='project',
name='project_settings',
field=models.TextField(blank=True, null=True, validators=[squad.core.utils.yaml_validator]),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,952 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0102_projectstatus_null_metric_summary.py
|
squad.core.migrations.0102_projectstatus_null_metric_summary.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0101_project_project_settings'),
]
operations = [
migrations.AlterField(
model_name='projectstatus',
name='metrics_summary',
field=models.FloatField(null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,953 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0125_fix_missing_status_has_metrics_for_testruns.py
|
squad.core.migrations.0125_fix_missing_status_has_metrics_for_testruns.Migration
|
class Migration(migrations.Migration):
dependencies = [('core', '0124_set_default_expected_test_runs_to_zero')]
operations = [
migrations.RunPython(
update_testrun_has_metrics_entry,
reverse_code=migrations.RunPython.noop
)
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 8 | 3 | 7 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,954 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0103_populate_project_status.py
|
squad.core.migrations.0103_populate_project_status.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0102_projectstatus_null_metric_summary'),
]
operations = [
migrations.RunPython(
create_missing_project_status,
reverse_code=migrations.RunPython.noop,
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 12 | 2 | 10 | 3 | 9 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,955 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0105_delayed_report_error_message.py
|
squad.core.migrations.0105_delayed_report_error_message.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0104_delayedreport'),
]
operations = [
migrations.AlterField(
model_name='delayedreport',
name='error_message',
field=models.TextField(blank=True, null=True, validators=[squad.core.utils.yaml_validator]),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,956 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0106_delayedreport_output_subject.py
|
squad.core.migrations.0106_delayedreport_output_subject.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0105_delayed_report_error_message'),
]
operations = [
migrations.AddField(
model_name='delayedreport',
name='output_subject',
field=models.TextField(blank=True, null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,957 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0107_move_notification_strategy.py
|
squad.core.migrations.0107_move_notification_strategy.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0106_delayedreport_output_subject'),
]
operations = [
migrations.AddField(
model_name='subscription',
name='notification_strategy',
field=models.CharField(choices=[('all', 'All builds'), ('change', 'Only on change'), ('regression', 'Only on regression')], default='all', max_length=32),
),
migrations.RunPython(
set_notification_strategy,
reverse_code=migrations.RunPython.noop,
),
migrations.RemoveField(
model_name='project',
name='notification_strategy',
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 21 | 2 | 19 | 3 | 18 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,958 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0108_add_email_template_validator.py
|
squad.core.migrations.0108_add_email_template_validator.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0107_move_notification_strategy'),
]
operations = [
migrations.AlterField(
model_name='emailtemplate',
name='html',
field=models.TextField(blank=True, help_text='Jinja2 template for text/html content', null=True, validators=[squad.core.utils.jinja2_validator]),
),
migrations.AlterField(
model_name='emailtemplate',
name='plain_text',
field=models.TextField(help_text='Jinja2 template for text/plain content', validators=[squad.core.utils.jinja2_validator]),
),
migrations.AlterField(
model_name='emailtemplate',
name='subject',
field=models.CharField(blank=True, help_text='Jinja2 template for subject (single line)', max_length=1024, null=True, validators=[squad.core.utils.jinja2_validator]),
),
migrations.AlterField(
model_name='historicalemailtemplate',
name='html',
field=models.TextField(blank=True, help_text='Jinja2 template for text/html content', null=True, validators=[squad.core.utils.jinja2_validator]),
),
migrations.AlterField(
model_name='historicalemailtemplate',
name='plain_text',
field=models.TextField(help_text='Jinja2 template for text/plain content', validators=[squad.core.utils.jinja2_validator]),
),
migrations.AlterField(
model_name='historicalemailtemplate',
name='subject',
field=models.CharField(blank=True, help_text='Jinja2 template for subject (single line)', max_length=1024, null=True, validators=[squad.core.utils.jinja2_validator]),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 38 | 2 | 36 | 3 | 35 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,959 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0109_group_member.py
|
squad.core.migrations.0109_group_member.Migration
|
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('core', '0108_add_email_template_validator'),
]
operations = [
migrations.CreateModel(
name='GroupMember',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('access', models.CharField(choices=[('member', 'Member'), ('submitter', 'Result submitter'), ('admin', 'Administrator')], default='member', max_length=10)),
('member_since', models.DateField(auto_now_add=True)),
('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Group')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'Group member',
'verbose_name_plural': 'Group members',
},
),
migrations.AddField(
model_name='group',
name='members',
field=models.ManyToManyField(through='core.GroupMember', to=settings.AUTH_USER_MODEL),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 28 | 2 | 26 | 3 | 25 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,960 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0110_move_users_from_django_groups_to_squad_groups.py
|
squad.core.migrations.0110_move_users_from_django_groups_to_squad_groups.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0109_group_member'),
]
operations = [
migrations.RunPython(
move_users_to_squad_groups,
reverse_code=migrations.RunPython.noop,
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 12 | 2 | 10 | 3 | 9 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,961 |
Linaro/squad
|
Linaro_squad/test/__init__.py
|
test.Runner
|
class Runner(DiscoverRunner):
def get_resultclass(self):
return TestResult
def suite_result(self, suite, result, **kwargs):
write_results(result)
return super(Runner, self).suite_result(suite, result, **kwargs)
|
class Runner(DiscoverRunner):
def get_resultclass(self):
pass
def suite_result(self, suite, result, **kwargs):
pass
| 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 2 | 0 | 2 | 2 | 8 | 2 | 6 | 3 | 3 | 0 | 6 | 3 | 3 | 1 | 1 | 0 | 2 |
145,962 |
Linaro/squad
|
Linaro_squad/squad/socialaccount.py
|
squad.socialaccount.CustomSocialAccountAdapter
|
class CustomSocialAccountAdapter(DefaultSocialAccountAdapter):
def populate_user(self, request, sociallogin, data):
user = super().populate_user(request, sociallogin, data)
user.username = user.email
return user
def pre_social_login(self, request, sociallogin):
user = sociallogin.user
if user.id:
return
try:
existing_user = User.objects.get(username=user.username)
sociallogin.state['process'] = 'connect'
perform_login(request, existing_user, request.GET.get('next', '/'))
except User.DoesNotExist:
pass
|
class CustomSocialAccountAdapter(DefaultSocialAccountAdapter):
def populate_user(self, request, sociallogin, data):
pass
def pre_social_login(self, request, sociallogin):
pass
| 3 | 0 | 7 | 0 | 7 | 0 | 2 | 0 | 1 | 1 | 0 | 0 | 2 | 0 | 2 | 2 | 17 | 2 | 15 | 6 | 12 | 0 | 15 | 6 | 12 | 3 | 1 | 1 | 4 |
145,963 |
Linaro/squad
|
Linaro_squad/squad/plugins/linux_log_parser.py
|
squad.plugins.linux_log_parser.Plugin
|
class Plugin(BasePlugin):
def __compile_regexes(self, regexes):
combined = [r'(%s)' % r[REGEX_BODY] for r in regexes]
return re.compile(r'|'.join(combined), re.S | re.M)
def __cutoff_boot_log(self, log):
# Attempt to split the log in " login:"
logs = log.split(' login:', 1)
# 1 string means no split was done, consider all logs as test log
if len(logs) == 1:
return '', log
boot_log = logs[0]
test_log = logs[1]
return boot_log, test_log
def __kernel_msgs_only(self, log):
kernel_msgs = re.findall(r'(\[[ \d]+\.[ \d]+\] .*?)$', log, re.S | re.M)
return '\n'.join(kernel_msgs)
def __join_matches(self, matches, regexes):
"""
group regex in python are returned as a list of tuples which each
group match in one of the positions in the tuple. Example:
regex = r'(a)|(b)|(c)'
matches = [
('match a', '', ''),
('', 'match b', ''),
('match a', '', ''),
('', '', 'match c')
]
"""
snippets = {regex_id: [] for regex_id in range(len(regexes))}
for match in matches:
for regex_id in range(len(regexes)):
if len(match[regex_id]) > 0:
snippets[regex_id].append(match[regex_id])
return snippets
def __create_tests(self, testrun, suite, test_name, lines, test_regex=None):
"""
There will be at least one test per regex. If there were any match for a given
regex, then a new test will be generated using test_name + shasum. This helps
comparing kernel logs accross different builds
"""
# Run the REGEX_EXTRACT_NAME regex over the log lines to sort them by
# extracted name. If no name is extracted or the log parser did not
# have any output for a particular regex, just use the default name
# (for example "check-kernel-oops").
tests_to_create = defaultdict(set)
shas = defaultdict(set)
# If there are no lines, use the default name and create a passing
# test. For example "check-kernel-oops"
if not lines:
tests_to_create[test_name] = []
# If there are lines, then create the tests for these.
for line in lines:
extracted_name = self.__create_name(line, test_regex)
if extracted_name:
extended_test_name = f"{test_name}-{extracted_name}"
else:
extended_test_name = test_name
tests_to_create[extended_test_name].add(line)
for name, lines in tests_to_create.items():
metadata, _ = SuiteMetadata.objects.get_or_create(suite=suite.slug, name=name, kind='test')
testrun.tests.create(
suite=suite,
result=(len(lines) == 0),
log='\n'.join(lines),
metadata=metadata,
build=testrun.build,
environment=testrun.environment,
)
# Some lines of the matched regex might be the same, and we don't want to create
# multiple tests like test1-sha1, test1-sha1, etc, so we'll create a set of sha1sums
# then create only new tests for unique sha's
for line in lines:
sha = self.__create_shasum(line)
name_with_sha = f"{name}-{sha}"
shas[name_with_sha].add(line)
for name_with_sha, lines in shas.items():
metadata, _ = SuiteMetadata.objects.get_or_create(suite=suite.slug, name=name_with_sha, kind='test')
testrun.tests.create(
suite=suite,
result=False,
log='\n---\n'.join(lines),
metadata=metadata,
build=testrun.build,
environment=testrun.environment,
)
def __remove_numbers_and_time(self, snippet):
without_numbers = re.sub(r"(0x[a-f0-9]+|[<\[][0-9a-f]+?[>\]]|\d+)", "", snippet)
without_time = re.sub(r"^\[[^\]]+\]", "", without_numbers)
return without_time
def __create_name(self, snippet, regex=None):
matches = None
if regex:
matches = regex.findall(snippet)
if not matches:
return None
snippet = matches[0]
without_numbers_and_time = self.__remove_numbers_and_time(snippet)
# Limit the name length to 191 characters, since the max name length
# for SuiteMetadata in SQUAD is 256 characters. The SHA and "-" take 65
# characters: 256-65=191
return slugify(without_numbers_and_time)[:191]
def __create_shasum(self, snippet):
sha = hashlib.sha256()
without_numbers_and_time = self.__remove_numbers_and_time(snippet)
sha.update(without_numbers_and_time.encode())
return sha.hexdigest()
def postprocess_testrun(self, testrun):
if testrun.log_file is None:
return
boot_log, test_log = self.__cutoff_boot_log(testrun.log_file)
logs = {
'boot': boot_log,
'test': test_log,
}
for log_type, log in logs.items():
log = self.__kernel_msgs_only(log)
suite, _ = testrun.build.project.suites.get_or_create(slug=f'log-parser-{log_type}')
regex = self.__compile_regexes(REGEXES)
matches = regex.findall(log)
snippets = self.__join_matches(matches, REGEXES)
for regex_id in range(len(REGEXES)):
test_name = REGEXES[regex_id][REGEX_NAME]
regex_pattern = REGEXES[regex_id][REGEX_EXTRACT_NAME]
test_name_regex = None
if regex_pattern:
test_name_regex = re.compile(regex_pattern, re.S | re.M)
self.__create_tests(testrun, suite, test_name, snippets[regex_id], test_name_regex)
|
class Plugin(BasePlugin):
def __compile_regexes(self, regexes):
pass
def __cutoff_boot_log(self, log):
pass
def __kernel_msgs_only(self, log):
pass
def __join_matches(self, matches, regexes):
'''
group regex in python are returned as a list of tuples which each
group match in one of the positions in the tuple. Example:
regex = r'(a)|(b)|(c)'
matches = [
('match a', '', ''),
('', 'match b', ''),
('match a', '', ''),
('', '', 'match c')
]
'''
pass
def __create_tests(self, testrun, suite, test_name, lines, test_regex=None):
'''
There will be at least one test per regex. If there were any match for a given
regex, then a new test will be generated using test_name + shasum. This helps
comparing kernel logs accross different builds
'''
pass
def __remove_numbers_and_time(self, snippet):
pass
def __create_name(self, snippet, regex=None):
pass
def __create_shasum(self, snippet):
pass
def postprocess_testrun(self, testrun):
pass
| 10 | 2 | 16 | 2 | 11 | 3 | 3 | 0.32 | 1 | 3 | 1 | 0 | 9 | 0 | 9 | 9 | 149 | 22 | 96 | 43 | 86 | 31 | 78 | 43 | 68 | 7 | 1 | 3 | 25 |
145,964 |
Linaro/squad
|
Linaro_squad/squad/plugins/github.py
|
squad.plugins.github.Plugin
|
class Plugin(BasePlugin):
@staticmethod
def __github_post__(build, endpoint, payload):
api_url = build.patch_source.url
api_token = build.patch_source.token
owner, repository, commit = re.split(r'[:/]', build.patch_id)
headers = {
"Authorization": "token %s" % api_token,
}
url = urljoin(
api_url, endpoint.format(
owner=owner,
repository=repository,
commit=commit)
)
return requests.post(url, headers=headers, json=payload)
def notify_patch_build_created(self, build):
payload = {
"state": "pending",
"target_url": build_url(build),
"description": "This build is being tested",
"context": "continuous-integration/squad"
}
endpoint = '/repos/{owner}/{repository}/statuses/{commit}'
return Plugin.__github_post__(build, endpoint, payload)
@staticmethod
def __get_finished_state__(build):
try:
if (build.status.tests_fail == 0):
return ("success", "All tests passed")
else:
return ("failure", "Some tests failed")
except ProjectStatus.DoesNotExist:
return ("error", "An error occurred")
def notify_patch_build_finished(self, build):
state, description = self.__get_finished_state__(build)
payload = {
"state": state,
"target_url": build_url(build),
"description": description,
"context": "continuous-integration/squad"
}
endpoint = '/repos/{owner}/{repository}/statuses/{commit}'
return Plugin.__github_post__(build, endpoint, payload)
def get_url(self, build):
api_url = build.patch_source.url
owner, repository, commit = re.split(r'[:/]', build.patch_id)
endpoint = "/repos/{owner}/{repository}/commits/{commit}".format(
owner=owner,
repository=repository,
commit=commit
)
return urljoin(api_url, endpoint)
|
class Plugin(BasePlugin):
@staticmethod
def __github_post__(build, endpoint, payload):
pass
def notify_patch_build_created(self, build):
pass
@staticmethod
def __get_finished_state__(build):
pass
def notify_patch_build_finished(self, build):
pass
def get_url(self, build):
pass
| 8 | 0 | 11 | 1 | 10 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 3 | 0 | 5 | 11 | 61 | 8 | 53 | 21 | 45 | 0 | 29 | 19 | 23 | 3 | 2 | 2 | 7 |
145,965 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0104_delayedreport.py
|
squad.core.migrations.0104_delayedreport.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0103_populate_project_status'),
]
operations = [
migrations.CreateModel(
name='DelayedReport',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('output_format', models.CharField(choices=[('text/plain', 'text/plain'), ('text/html', 'text/html')], max_length=32)),
('email_recipient', models.EmailField(blank=True, max_length=254, null=True)),
('email_recipient_notified', models.BooleanField(default=False)),
('callback', models.URLField(blank=True, null=True)),
('callback_token', models.CharField(blank=True, max_length=128, null=True)),
('callback_notified', models.BooleanField(default=False)),
('data_retention_days', models.PositiveSmallIntegerField(default=5, validators=[django.core.validators.MaxValueValidator(30)])),
('output_text', models.TextField(blank=True, null=True)),
('output_html', models.TextField(blank=True, null=True)),
('error_message', models.CharField(blank=True, max_length=1024, null=True, validators=[squad.core.utils.yaml_validator])),
('status_code', models.PositiveSmallIntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(511), django.core.validators.MinValueValidator(100)])),
('created_at', models.DateTimeField(auto_now_add=True)),
('baseline', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='delayed_report_baselines', to='core.ProjectStatus')),
('build', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='delayed_reports', to='core.Build')),
('template', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.EmailTemplate')),
],
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 29 | 2 | 27 | 3 | 26 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,966 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0126_metricthreshold_environment.py
|
squad.core.migrations.0126_metricthreshold_environment.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0125_fix_missing_status_has_metrics_for_testruns'),
]
operations = [
migrations.AddField(
model_name='metricthreshold',
name='environment',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Environment'),
),
migrations.AlterUniqueTogether(
name='metricthreshold',
unique_together=set(),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 17 | 2 | 15 | 3 | 14 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,967 |
Linaro/squad
|
Linaro_squad/squad/core/admin.py
|
squad.core.admin.BuildAdmin
|
class BuildAdmin(NoDeleteListingModelAdmin):
model = models.Build
ordering = ['-id']
list_display = ['__str__', 'project']
list_filter = ['project', 'datetime']
def has_add_permission(self, request):
return False
|
class BuildAdmin(NoDeleteListingModelAdmin):
def has_add_permission(self, request):
pass
| 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 2 | 8 | 1 | 7 | 6 | 5 | 0 | 7 | 6 | 5 | 1 | 2 | 0 | 1 |
145,968 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0128_metric_thresholds_remove_proj_col.py
|
squad.core.migrations.0128_metric_thresholds_remove_proj_col.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0127_metric_thresholds_migrate_data'),
]
operations = [
migrations.AlterField(
model_name='metricthreshold',
name='environment',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Environment'),
),
migrations.AlterUniqueTogether(
name='metricthreshold',
unique_together={('environment', 'name')},
),
migrations.RemoveField(
model_name='metricthreshold',
name='project',
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 21 | 2 | 19 | 3 | 18 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,969 |
Linaro/squad
|
Linaro_squad/test/ci/test_models.py
|
test.ci.test_models.BackendPollTest
|
class BackendPollTest(BackendTestBase):
def test_poll(self):
test_job = self.create_test_job(submitted=True)
jobs = list(self.backend.poll())
self.assertEqual([test_job], jobs)
def test_poll_enabled(self):
self.create_test_job(submitted=True)
self.backend.poll_enabled = False
jobs = list(self.backend.poll())
self.assertEqual([], jobs)
def test_poll_wont_fetch_non_submitted_job(self):
self.create_test_job(submitted=False)
jobs = list(self.backend.poll())
self.assertEqual(jobs, [])
def test_poll_wont_fetch_job_previouly_fetched(self):
self.create_test_job(submitted=True, fetched=True)
jobs = list(self.backend.poll())
self.assertEqual(jobs, [])
def test_poll_wont_fetch_before_poll_interval(self):
self.create_test_job(submitted=True, last_fetch_attempt=NOW)
jobs = list(self.backend.poll())
self.assertEqual(jobs, [])
def test_poll_will_fetch_after_poll_interval(self):
past = timezone.now() - relativedelta(minutes=self.backend.poll_interval + 1)
test_job = self.create_test_job(submitted=True, last_fetch_attempt=past)
jobs = list(self.backend.poll())
self.assertEqual([test_job], jobs)
def test_poll_gives_up_eventually(self):
self.create_test_job(submitted=True, fetch_attempts=self.backend.max_fetch_attempts + 1)
jobs = list(self.backend.poll())
self.assertEqual([], jobs)
|
class BackendPollTest(BackendTestBase):
def test_poll(self):
pass
def test_poll_enabled(self):
pass
def test_poll_wont_fetch_non_submitted_job(self):
pass
def test_poll_wont_fetch_job_previouly_fetched(self):
pass
def test_poll_wont_fetch_before_poll_interval(self):
pass
def test_poll_will_fetch_after_poll_interval(self):
pass
def test_poll_gives_up_eventually(self):
pass
| 8 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 7 | 0 | 7 | 9 | 38 | 7 | 31 | 18 | 23 | 0 | 31 | 18 | 23 | 1 | 2 | 0 | 7 |
145,970 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0137_patchsource_token_null.py
|
squad.core.migrations.0137_patchsource_token_null.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0136_migrate_submitters_to_privileged'),
]
operations = [
migrations.AlterField(
model_name='patchsource',
name='token',
field=models.CharField(blank=True, max_length=1024, null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,971 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0138_metric_unit.py
|
squad.core.migrations.0138_metric_unit.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0137_patchsource_token_null'),
]
operations = [
migrations.AddField(
model_name='metric',
name='unit',
field=models.CharField(max_length=30, null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,972 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0139_nullable_test_name.py
|
squad.core.migrations.0139_nullable_test_name.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0138_metric_unit'),
]
operations = [
migrations.AlterModelOptions(
name='test',
options={'ordering': ['metadata__name']},
),
migrations.AlterField(
model_name='test',
name='name',
field=models.CharField(max_length=256, db_index=True, null=True, default=None, blank=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 17 | 2 | 15 | 3 | 14 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,973 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0127_metric_thresholds_migrate_data.py
|
squad.core.migrations.0127_metric_thresholds_migrate_data.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0126_metricthreshold_environment'),
]
operations = [
migrations.RunPython(
populate_env_in_thresholds_and_migrate_olddata,
reverse_code=migrations.RunPython.noop
)
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 12 | 2 | 10 | 3 | 9 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,974 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0141_remove_test_name.py
|
squad.core.migrations.0141_remove_test_name.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0140_increase_gerrit_password_length'),
]
operations = [
migrations.RemoveField(
model_name='test',
name='name',
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 12 | 2 | 10 | 3 | 9 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,975 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0142_add_testrun_file_storage.py
|
squad.core.migrations.0142_add_testrun_file_storage.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0141_remove_test_name'),
]
operations = [
migrations.AddField(
model_name='testrun',
name='log_file_storage',
field=models.FileField(null=True, upload_to=''),
),
migrations.AddField(
model_name='testrun',
name='metrics_file_storage',
field=models.FileField(null=True, upload_to=''),
),
migrations.AddField(
model_name='testrun',
name='tests_file_storage',
field=models.FileField(null=True, upload_to=''),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 23 | 2 | 21 | 3 | 20 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,976 |
Linaro/squad
|
Linaro_squad/squad/api/rest.py
|
squad.api.rest.HyperlinkedMetricsIdentityField
|
class HyperlinkedMetricsIdentityField(serializers.HyperlinkedIdentityField):
def get_url(self, *args):
testrun = args[0]
statuses = testrun.status.all()
if len(statuses) > 0:
if testrun.status.all()[0].has_metrics:
return super().get_url(*args)
else:
return None
|
class HyperlinkedMetricsIdentityField(serializers.HyperlinkedIdentityField):
def get_url(self, *args):
pass
| 2 | 0 | 8 | 0 | 8 | 0 | 3 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 9 | 0 | 9 | 4 | 7 | 0 | 8 | 4 | 6 | 3 | 1 | 2 | 3 |
145,977 |
Linaro/squad
|
Linaro_squad/squad/api/rest.py
|
squad.api.rest.GroupViewSet
|
class GroupViewSet(viewsets.ModelViewSet):
"""
List of groups. Includes public groups and groups that the current
user has access to.
"""
queryset = Group.objects
serializer_class = GroupSerializer
filterset_fields = ('slug', 'name')
filter_fields = filterset_fields # TODO: remove when django-filters 1.x is not supported anymore
filterset_class = GroupFilter
filter_class = filterset_class # TODO: remove when django-filters 1.x is not supported anymore
filter_backends = (ComplexFilterBackend, )
search_fields = ('slug', 'name')
ordering_fields = ('slug', 'name')
def get_queryset(self):
return self.queryset.accessible_to(self.request.user)
|
class GroupViewSet(viewsets.ModelViewSet):
'''
List of groups. Includes public groups and groups that the current
user has access to.
'''
def get_queryset(self):
pass
| 2 | 1 | 2 | 0 | 2 | 0 | 1 | 0.5 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 17 | 1 | 12 | 11 | 10 | 6 | 12 | 11 | 10 | 1 | 1 | 0 | 1 |
145,978 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0143_attachment_storage.py
|
squad.core.migrations.0143_attachment_storage.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0142_add_testrun_file_storage'),
]
operations = [
migrations.AddField(
model_name='attachment',
name='storage',
field=models.FileField(null=True, upload_to=''),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,979 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0144_attachment_data_null.py
|
squad.core.migrations.0144_attachment_data_null.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0143_attachment_storage'),
]
operations = [
migrations.AlterField(
model_name='attachment',
name='data',
field=models.BinaryField(default=None, null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,980 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0145_pluginscratch.py
|
squad.core.migrations.0145_pluginscratch.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0144_attachment_data_null'),
]
operations = [
migrations.CreateModel(
name='PluginScratch',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('storage', models.TextField(blank=True, null=True)),
('build', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Build')),
],
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 16 | 2 | 14 | 3 | 13 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,981 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0146_deprecate_testrun_and_attachment_data_fields.py
|
squad.core.migrations.0146_deprecate_testrun_and_attachment_data_fields.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0145_pluginscratch'),
]
operations = [
migrations.RenameField(
model_name='testrun',
old_name='log_file',
new_name='old_log_file',
),
migrations.RenameField(
model_name='testrun',
old_name='metrics_file',
new_name='old_metrics_file',
),
migrations.RenameField(
model_name='testrun',
old_name='tests_file',
new_name='old_tests_file',
),
migrations.RenameField(
model_name='attachment',
old_name='data',
new_name='old_data',
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 28 | 2 | 26 | 3 | 25 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,982 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0147_add_build_and_environment_to_test.py
|
squad.core.migrations.0147_add_build_and_environment_to_test.Migration
|
class Migration(migrations.Migration):
atomic = False
dependencies = [
('core', '0146_deprecate_testrun_and_attachment_data_fields'),
]
operations = [
migrations.AddField(
model_name='test',
name='build',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tests', to='core.Build'),
),
migrations.AddField(
model_name='test',
name='environment',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tests', to='core.Environment'),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 20 | 3 | 17 | 4 | 16 | 0 | 4 | 4 | 3 | 0 | 1 | 0 | 0 |
145,983 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0148_remove_legacy_storage_fields.py
|
squad.core.migrations.0148_remove_legacy_storage_fields.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0147_add_build_and_environment_to_test'),
]
operations = [
migrations.RemoveField(
model_name='attachment',
name='old_data',
),
migrations.RemoveField(
model_name='testrun',
name='old_log_file',
),
migrations.RemoveField(
model_name='testrun',
name='old_metrics_file',
),
migrations.RemoveField(
model_name='testrun',
name='old_tests_file',
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 24 | 2 | 22 | 3 | 21 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,984 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0149_build_patch_url.py
|
squad.core.migrations.0149_build_patch_url.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0148_remove_legacy_storage_fields'),
]
operations = [
migrations.AddField(
model_name='build',
name='patch_url',
field=models.URLField(blank=True, null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,985 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0150_add_new_notification_strategy.py
|
squad.core.migrations.0150_add_new_notification_strategy.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0149_build_patch_url'),
]
operations = [
migrations.AlterField(
model_name='subscription',
name='notification_strategy',
field=models.CharField(choices=[('all', 'All builds'), ('change', 'Only on change'), ('regression', 'Only on regression'), ('error', 'Only on infrastructure error')], default='all', max_length=32),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,986 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0151_callback.py
|
squad.core.migrations.0151_callback.Migration
|
class Migration(migrations.Migration):
dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('core', '0150_add_new_notification_strategy'),
]
operations = [
migrations.CreateModel(
name='Callback',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('url', models.URLField(blank=True, default=None, max_length=1024, null=True)),
('method', models.CharField(default='post', max_length=10, validators=[squad.core.callback.callback_methods.validator])),
('event', models.CharField(max_length=64, validators=[squad.core.callback.callback_events.validator])),
('headers', models.TextField(blank=True, default=None, null=True, validators=[squad.core.utils.yaml_validator], verbose_name='HTTP headers (JSON-formatted) to be sent in this callback')),
('payload', models.TextField(blank=True, default=None, null=True, validators=[squad.core.utils.yaml_validator], verbose_name='Payload (JSON-formatted) to be sent in this callback')),
('payload_is_json', models.BooleanField(default=True)),
('is_sent', models.BooleanField(default=False)),
('record_response', models.BooleanField(default=False, verbose_name='Should this callback response be recorded?')),
('response_code', models.IntegerField(blank=True, default=None, null=True)),
('response_content', models.CharField(blank=True, default=None, max_length=1024, null=True)),
('object_reference_id', models.PositiveIntegerField()),
('object_reference_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
],
options={
'unique_together': {('object_reference_type', 'object_reference_id', 'url', 'event')},
},
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 30 | 2 | 28 | 3 | 27 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,987 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0152_add_build_patch_notified.py
|
squad.core.migrations.0152_add_build_patch_notified.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0151_callback'),
]
operations = [
migrations.AddField(
model_name='build',
name='patch_notified',
field=models.BooleanField(default=False),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,988 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0153_callback_make_response_content_blob.py
|
squad.core.migrations.0153_callback_make_response_content_blob.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0152_add_build_patch_notified'),
]
operations = [
migrations.AlterField(
model_name='callback',
name='response_content',
field=models.TextField(blank=True, default=None, null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,989 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0154_project_add_force_finishing_builds_field.py
|
squad.core.migrations.0154_project_add_force_finishing_builds_field.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0153_callback_make_response_content_blob'),
]
operations = [
migrations.AddField(
model_name='project',
name='force_finishing_builds_on_timeout',
field=models.BooleanField(default=False, help_text='Forces builds to finish when "Notification timeout" is reached'),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,990 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0155_add_build_and_environment_to_metric.py
|
squad.core.migrations.0155_add_build_and_environment_to_metric.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0154_project_add_force_finishing_builds_field'),
]
operations = [
migrations.AddField(
model_name='metric',
name='build',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='metrics', to='core.Build'),
),
migrations.AddField(
model_name='metric',
name='environment',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='metrics', to='core.Environment'),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 18 | 2 | 16 | 3 | 15 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,991 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0156_nullable_metric_name.py
|
squad.core.migrations.0156_nullable_metric_name.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0155_add_build_and_environment_to_metric'),
]
operations = [
migrations.AlterField(
model_name='metric',
name='name',
field=models.CharField(blank=True, default=None, max_length=256, null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,992 |
Linaro/squad
|
Linaro_squad/test/ci/test_listen.py
|
test.ci.test_listen.TestListener
|
class TestListener(TestCase):
def test_run(self):
backend = MagicMock()
listener = Listener(backend)
listener.run()
backend.get_implementation.return_value.listen.assert_called_once()
|
class TestListener(TestCase):
def test_run(self):
pass
| 2 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 1 | 0 | 1 | 1 | 7 | 1 | 6 | 4 | 4 | 0 | 6 | 4 | 4 | 1 | 1 | 0 | 1 |
145,993 |
Linaro/squad
|
Linaro_squad/test/ci/backend/test_real_lava.py
|
test.ci.backend.test_real_lava.RealLavaRPC2Test
|
class RealLavaRPC2Test(TestCase):
def setUp(self):
self.backend = Backend.objects.create(
url='http://localhost:8000/RPC2/',
username='squadtest',
token='kz8wyxmldwahe4w4086ceadedfwd0z7tadr87i60u1z30xymq38xy35ji98f0h6fgqmpwr3161zq87dytza70iqyhx5ab6xrzgh5lp1ghbcbrb0q650x8tpkgrm0a9n7',
implementation_type='lava',
backend_settings='{"CI_LAVA_HANDLE_SUITE": True, "CI_LAVA_CLONE_MEASUREMENTS": True}',
)
self.group = Group.objects.create(
name="group_foo"
)
self.project = Project.objects.create(
name="project_foo",
group=self.group,
)
self.build = self.project.builds.create(version='1')
@lava_test
def test_submit(self):
testjob = TestJob(
definition=QEMU_JOB_DEFINITION,
target=self.project,
target_build=self.build,
environment="qemu",
backend=self.backend)
testjob.save()
self.backend.submit(testjob)
testjob.refresh_from_db()
self.assertEqual('bar', testjob.name)
self.assertIsNotNone(testjob.job_id)
@lava_test
def test_submit_multinode(self):
testjob = TestJob(
definition=QEMU_JOB_DEFINITION,
target=self.project,
target_build=self.build,
environment="qemu",
backend=self.backend)
testjob.save()
self.backend.submit(testjob)
testjob.refresh_from_db()
self.assertEqual('bar', testjob.name)
self.assertIsNotNone(testjob.job_id)
@lava_test
def test_fetch_basics(self):
testjob = TestJob(
job_id='3',
target=self.project,
target_build=self.build,
environment="qemu",
backend=self.backend)
testjob.save()
self.backend.fetch(testjob.id)
testjob.refresh_from_db()
self.assertEqual(True, testjob.fetched)
@lava_test
def test_fetch_not_finished(self):
testjob = TestJob(
definition=QEMU_JOB_DEFINITION,
target=self.project,
target_build=self.build,
environment="qemu",
backend=self.backend)
testjob.save()
self.backend.submit(testjob)
testjob.refresh_from_db()
self.backend.fetch(testjob.id)
testjob.refresh_from_db()
self.assertEqual(False, testjob.fetched)
self.assertEqual(0, testjob.fetch_attempts)
@lava_test
def test_listen(self):
url = self.backend.get_implementation().get_listener_url()
self.assertEqual(url, "tcp://localhost:5500")
@lava_test
def test_start_listener(self):
lava_backend_listen = self.backend.get_implementation().listen
listener_process = Process(target=lava_backend_listen)
listener_process.start()
sleep(3)
listener_process.terminate()
while listener_process.is_alive():
sleep(1)
self.assertEqual(-signal.SIGTERM, listener_process.exitcode)
|
class RealLavaRPC2Test(TestCase):
def setUp(self):
pass
@lava_test
def test_submit(self):
pass
@lava_test
def test_submit_multinode(self):
pass
@lava_test
def test_fetch_basics(self):
pass
@lava_test
def test_fetch_not_finished(self):
pass
@lava_test
def test_listen(self):
pass
@lava_test
def test_start_listener(self):
pass
| 14 | 0 | 11 | 0 | 11 | 0 | 1 | 0 | 1 | 3 | 3 | 0 | 7 | 4 | 7 | 7 | 92 | 8 | 84 | 25 | 70 | 0 | 47 | 19 | 39 | 2 | 1 | 1 | 8 |
145,994 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0140_increase_gerrit_password_length.py
|
squad.core.migrations.0140_increase_gerrit_password_length.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0139_nullable_test_name'),
]
operations = [
migrations.AlterField(
model_name='patchsource',
name='_password',
field=models.CharField(blank=True, db_column='password', max_length=256, null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,995 |
Linaro/squad
|
Linaro_squad/test/ci/backend/test_fake.py
|
test.ci.backend.test_fake.FakeBackendTest
|
class FakeBackendTest(TestCase):
def setUp(self):
self.backend = Backend.objects.create(
url='http://example.com/',
username='myuser',
token='mypassword',
implementation_type='fake',
)
self.group = Group.objects.create(
name="group_foo"
)
self.project = Project.objects.create(
name="project_foo",
group=self.group,
)
def test_impl(self):
self.assertIsInstance(self.backend.get_implementation(), FakeBackend)
def test_submit(self):
job = TestJob.objects.create(backend=self.backend, target=self.project)
impl = FakeBackend(self.backend)
jid = impl.submit(job)
self.assertEqual([str(job.id)], jid)
def test_resubmit(self):
job = TestJob.objects.create(backend=self.backend, target=self.project, job_id='22')
impl = FakeBackend(self.backend)
new_job = impl.resubmit(job)
self.assertIsInstance(new_job, TestJob)
self.assertIsNot(job, new_job)
self.assertEqual('22.1', new_job.job_id)
self.assertEqual(job, new_job.parent_job)
def test_resubmit_resubmitted(self):
job = TestJob.objects.create(backend=self.backend, target=self.project, job_id='22.1')
impl = FakeBackend(self.backend)
new_job = impl.resubmit(job)
self.assertEqual('22.1.1', new_job.job_id)
def test_fetch(self):
job = TestJob.objects.create(backend=self.backend, target=self.project)
impl = FakeBackend(self.backend)
(status, completed, metadata, tests, metrics, logs) = impl.fetch(job)
self.assertIsInstance(status, str)
self.assertIsInstance(completed, bool)
self.assertIsInstance(metadata, dict)
self.assertIsInstance(tests, dict)
self.assertIsInstance(metrics, dict)
self.assertIsInstance(logs, str)
def test_job_url(self):
job = TestJob(job_id='123')
impl = FakeBackend(self.backend)
self.assertIsInstance(impl.job_url(job), str)
|
class FakeBackendTest(TestCase):
def setUp(self):
pass
def test_impl(self):
pass
def test_submit(self):
pass
def test_resubmit(self):
pass
def test_resubmit_resubmitted(self):
pass
def test_fetch(self):
pass
def test_job_url(self):
pass
| 8 | 0 | 7 | 0 | 7 | 0 | 1 | 0 | 1 | 6 | 3 | 0 | 7 | 3 | 7 | 7 | 56 | 7 | 49 | 25 | 41 | 0 | 39 | 25 | 31 | 1 | 1 | 0 | 7 |
145,996 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0129_projectstatus_nullable_notified_on_timeout.py
|
squad.core.migrations.0129_projectstatus_nullable_notified_on_timeout.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0128_metric_thresholds_remove_proj_col'),
]
operations = [
migrations.AlterField(
model_name='projectstatus',
name='notified_on_timeout',
field=models.NullBooleanField(default=None),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,997 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0130_project_status_baseline_next.py
|
squad.core.migrations.0130_project_status_baseline_next.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0129_projectstatus_nullable_notified_on_timeout'),
]
operations = [
migrations.AddField(
model_name='projectstatus',
name='baseline',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='next_statuses', to='core.Build'),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,998 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0131_create_squad_auth_group_and_add_users.py
|
squad.core.migrations.0131_create_squad_auth_group_and_add_users.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0130_project_status_baseline_next'),
]
operations = [
migrations.RunPython(
create_squad_group_and_add_users,
reverse_code=migrations.RunPython.noop
)
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 12 | 2 | 10 | 3 | 9 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,999 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0132_attachment_mimetype.py
|
squad.core.migrations.0132_attachment_mimetype.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0131_create_squad_auth_group_and_add_users'),
]
operations = [
migrations.AddField(
model_name='attachment',
name='mimetype',
field=models.CharField(default='application/octet-stream', max_length=128),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
146,000 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0133_append_project_permissions_to_squad_auth_group.py
|
squad.core.migrations.0133_append_project_permissions_to_squad_auth_group.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0132_attachment_mimetype'),
]
operations = [
migrations.RunPython(
append_project_permissions_to_squad_auth_group,
reverse_code=migrations.RunPython.noop
)
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 12 | 2 | 10 | 3 | 9 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
146,001 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0134_longer_metric_name.py
|
squad.core.migrations.0134_longer_metric_name.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0133_append_project_permissions_to_squad_auth_group'),
]
operations = [
migrations.AlterField(
model_name='metric',
name='name',
field=models.CharField(max_length=256),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
146,002 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0135_add_privileged_access_level.py
|
squad.core.migrations.0135_add_privileged_access_level.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0134_longer_metric_name'),
]
operations = [
migrations.AlterField(
model_name='groupmember',
name='access',
field=models.CharField(choices=[('member', 'Member'), ('submitter', 'Result submitter'), ('privileged', 'Privileged'), ('admin', 'Administrator')], default='member', max_length=10),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
146,003 |
Linaro/squad
|
Linaro_squad/test/ci/backend/test_real_lava.py
|
test.ci.backend.test_real_lava.RealLavaRESTTest
|
class RealLavaRESTTest(TestCase):
def setUp(self):
self.backend = Backend.objects.create(
url='http://localhost:8000/api/v0.2',
username='squadtest',
token='kz8wyxmldwahe4w4086ceadedfwd0z7tadr87i60u1z30xymq38xy35ji98f0h6fgqmpwr3161zq87dytza70iqyhx5ab6xrzgh5lp1ghbcbrb0q650x8tpkgrm0a9n7',
implementation_type='lava',
backend_settings='{"CI_LAVA_HANDLE_SUITE": True, "CI_LAVA_CLONE_MEASUREMENTS": True}',
)
self.group = Group.objects.create(
name="group_foo"
)
self.project = Project.objects.create(
name="project_foo",
group=self.group,
)
self.build = self.project.builds.create(version='1')
def test_final_url(self):
# make sure LAVA url ends with /
self.assertEqual("http://localhost:8000/api/v0.2/", self.backend.get_implementation().api_url_base)
@lava_test
def test_submit(self):
testjob = TestJob(
definition=QEMU_JOB_DEFINITION,
target=self.project,
target_build=self.build,
environment="qemu",
backend=self.backend)
testjob.save()
self.backend.submit(testjob)
testjob.refresh_from_db()
self.assertEqual('bar', testjob.name)
self.assertIsNotNone(testjob.job_id)
@lava_test
def test_submit_multinode(self):
testjob = TestJob(
definition=QEMU_JOB_DEFINITION,
target=self.project,
target_build=self.build,
environment="qemu",
backend=self.backend)
testjob.save()
self.backend.submit(testjob)
testjob.refresh_from_db()
self.assertEqual('bar', testjob.name)
self.assertIsNotNone(testjob.job_id)
@lava_test
def test_fetch_basics(self):
testjob = TestJob(
job_id='2',
target=self.project,
target_build=self.build,
environment="qemu",
backend=self.backend)
testjob.save()
self.backend.fetch(testjob.id)
testjob.refresh_from_db()
self.assertEqual(True, testjob.fetched)
@lava_test
def test_fetch_not_finished(self):
testjob = TestJob(
definition=QEMU_JOB_DEFINITION,
target=self.project,
target_build=self.build,
environment="qemu",
backend=self.backend)
testjob.save()
self.backend.submit(testjob)
testjob.refresh_from_db()
self.backend.fetch(testjob.id)
testjob.refresh_from_db()
self.assertEqual(False, testjob.fetched)
self.assertEqual(0, testjob.fetch_attempts)
@lava_test
def test_cancel(self):
testjob = TestJob(
definition=QEMU_JOB_DEFINITION,
target=self.project,
target_build=self.build,
environment="qemu",
backend=self.backend)
testjob.save()
self.backend.submit(testjob)
testjob.refresh_from_db()
testjob.cancel()
self.backend.fetch(testjob.id)
testjob.refresh_from_db()
self.assertEqual(True, testjob.fetched)
self.assertEqual(0, testjob.fetch_attempts)
@lava_test
def test_listen(self):
url = self.backend.get_implementation().get_listener_url()
self.assertEqual(url, "tcp://localhost:5500")
@lava_test
def test_start_listener(self):
lava_backend_listen = self.backend.get_implementation().listen
listener_process = Process(target=lava_backend_listen)
listener_process.start()
sleep(3)
listener_process.terminate()
while listener_process.is_alive():
sleep(1)
self.assertEqual(-signal.SIGTERM, listener_process.exitcode)
|
class RealLavaRESTTest(TestCase):
def setUp(self):
pass
def test_final_url(self):
pass
@lava_test
def test_submit(self):
pass
@lava_test
def test_submit_multinode(self):
pass
@lava_test
def test_fetch_basics(self):
pass
@lava_test
def test_fetch_not_finished(self):
pass
@lava_test
def test_cancel(self):
pass
@lava_test
def test_listen(self):
pass
@lava_test
def test_start_listener(self):
pass
| 17 | 0 | 11 | 0 | 10 | 0 | 1 | 0.01 | 1 | 3 | 3 | 0 | 9 | 4 | 9 | 9 | 114 | 11 | 102 | 29 | 85 | 1 | 59 | 22 | 49 | 2 | 1 | 1 | 10 |
146,004 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0136_migrate_submitters_to_privileged.py
|
squad.core.migrations.0136_migrate_submitters_to_privileged.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0135_add_privileged_access_level'),
]
operations = [
migrations.RunPython(
migrate_existing_submitters_to_privliged,
reverse_code=migrations.RunPython.noop
)
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 12 | 2 | 10 | 3 | 9 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
146,005 |
Linaro/squad
|
Linaro_squad/test/api/tests.py
|
test.api.tests.CreateTestRunApiTest
|
class CreateTestRunApiTest(ApiTest):
def test_create_object_hierarchy(self):
response = self.client.post('/api/submit/mygroup/myproject/1.0.0/myenvironment')
self.assertEqual(response.status_code, 201)
build = self.project.builds.get(version='1.0.0')
environment = self.project.environments.get(slug='myenvironment')
testrun = build.test_runs.get(environment=environment)
logentry_queryset = LogEntry.objects.filter(
user_id=self.project_submission_admin_user.pk,
object_id=testrun.pk,
object_repr=force_text(testrun),
)
self.assertEqual(str(response.content.decode()), str(testrun.id))
self.assertEqual(
1,
logentry_queryset.count()
)
self.assertEqual(
ADDITION,
logentry_queryset.last().action_flag
)
def test_create_object_hierarchy_private(self):
response = self.client.post('/api/submit/~project-user/userproject/1.0.0/myenvironment')
self.assertEqual(response.status_code, 201)
self.userproject.builds.get(version='1.0.0')
self.userproject.environments.get(slug='myenvironment')
def test_create_test_run(self):
test_runs = models.TestRun.objects.count()
self.client.post('/api/submit/mygroup/myproject/1.0.22/myenvironment')
self.submitter_client.post('/api/submit/mygroup/myproject/1.0.23/myenvironment2')
self.assertEqual(test_runs + 2, models.TestRun.objects.count())
def test_receives_tests_file(self):
with open(tests_file) as f:
self.client.post(
'/api/submit/mygroup/myproject/1.0.1/myenvironment',
{'tests': f}
)
self.assertIsNotNone(models.TestRun.objects.last().tests_file)
self.assertIsNotNone(models.TestRun.objects.last().tests_file_storage)
self.assertNotEqual(0, models.Test.objects.count())
self.assertIsNone(models.Test.objects.last().log)
with open(tests_two_file) as f:
self.submitter_client.post(
'/api/submit/mygroup/myproject/1.1.5/myenvironment3',
{'tests': f}
)
self.assertIsNotNone(models.TestRun.objects.last().tests_file)
self.assertIsNotNone(models.TestRun.objects.last().tests_file_storage)
self.assertNotEqual(0, models.Test.objects.count())
self.assertIsNone(models.Test.objects.last().log)
def test_receives_tests_file_with_logs(self):
with open(tests_log_file) as f:
self.client.post(
'/api/submit/mygroup/myproject/1.0.2/myenvironment',
{'tests': f}
)
self.assertIsNotNone(models.TestRun.objects.last().tests_file)
self.assertIsNotNone(models.TestRun.objects.last().tests_file_storage)
self.assertNotEqual(0, models.Test.objects.count())
test_one = models.Test.objects.filter(metadata__name="test_one").first()
test_two = models.Test.objects.filter(metadata__name="test_two").first()
self.assertTrue(test_one.result)
self.assertFalse(test_two.result)
self.assertEqual("test one log", test_one.log)
self.assertEqual("test two log", test_two.log)
def test_receives_tests_file_as_POST_param(self):
self.client.post(
'/api/submit/mygroup/myproject/1.0.3/myenvironment',
{'tests': '{"test1": "pass"}'}
)
self.assertIsNotNone(models.TestRun.objects.last().tests_file)
self.assertIsNotNone(models.TestRun.objects.last().tests_file_storage)
self.assertNotEqual(0, models.Test.objects.count())
self.assertIsNone(models.Test.objects.last().log)
self.submitter_client.post(
'/api/submit/mygroup/myproject/1.1.3/myenvironment3',
{'tests': '{"submitterTest": "pass"}'}
)
self.assertIsNotNone(models.TestRun.objects.last().tests_file)
self.assertIsNotNone(models.TestRun.objects.last().tests_file_storage)
self.assertNotEqual(0, models.Test.objects.count())
self.assertIsNone(models.Test.objects.last().log)
def test_receives_tests_file_as_POST_param_with_logs(self):
self.client.post(
'/api/submit/mygroup/myproject/1.0.4/myenvironment',
{'tests': '{"test1": {"result": "pass", "log": "test log"}}'}
)
self.assertIsNotNone(models.TestRun.objects.last().tests_file)
self.assertIsNotNone(models.TestRun.objects.last().tests_file_storage)
self.assertNotEqual(0, models.Test.objects.count())
self.assertIsNotNone(models.Test.objects.last().log)
test1 = models.Test.objects.filter(metadata__name="test1").first()
self.assertTrue(test1.result)
self.assertEqual("test log", test1.log)
def test_receives_metrics_file(self):
with open(metrics_file) as f:
self.client.post(
'/api/submit/mygroup/myproject/1.0.5/myenvironment',
{'metrics': f}
)
self.assertIsNotNone(models.TestRun.objects.last().metrics_file)
self.assertIsNotNone(models.TestRun.objects.last().metrics_file_storage)
self.assertNotEqual(0, models.Metric.objects.count())
def test_receives_metrics_file_as_POST_param_with_no_metric_unit(self):
self.client.post(
'/api/submit/mygroup/myproject/1.0.6/myenvironment',
{'metrics': '{"metric1": 10}'}
)
self.assertIsNotNone(models.TestRun.objects.last().metrics_file)
self.assertIsNotNone(models.TestRun.objects.last().metrics_file_storage)
self.assertNotEqual(0, models.Metric.objects.count())
def test_receives_metrics_file_as_POST_param(self):
self.client.post(
'/api/submit/mygroup/myproject/1.0.6/myenvironment',
{'metrics': '{"metric1": {"value": 10, "unit": ""}}'}
)
self.assertIsNotNone(models.TestRun.objects.last().metrics_file)
self.assertIsNotNone(models.TestRun.objects.last().metrics_file_storage)
self.assertNotEqual(0, models.Metric.objects.count())
def test_receives_log_file(self):
with open(log_file) as f:
self.client.post('/api/submit/mygroup/myproject/1.0.7/myenvironment',
{'log': f})
self.assertIsNotNone(models.TestRun.objects.last().log_file)
self.assertIsNotNone(models.TestRun.objects.last().log_file_storage)
def test_receives_log_file_as_POST_param(self):
self.client.post('/api/submit/mygroup/myproject/1.0.8/myenvironment',
{'log': "THIS IS THE LOG"})
self.assertIsNotNone(models.TestRun.objects.last().log_file)
self.assertIsNotNone(models.TestRun.objects.last().log_file_storage)
def test_process_data_on_submission(self):
self.client.post(
'/api/submit/mygroup/myproject/1.0.9/myenvironment',
{
'tests': open(tests_file),
'metrics': open(metrics_file),
}
)
self.assertNotEqual(0, models.Test.objects.count())
self.assertNotEqual(0, models.Metric.objects.count())
self.assertNotEqual(0, models.Status.objects.count())
def test_receives_metadata_file(self):
self.client.post(
'/api/submit/mygroup/myproject/1.0.10/myenvironment',
{
'metadata': open(metadata_file),
}
)
t = models.TestRun.objects.last()
self.assertEqual("2016-09-01T00:00:00+00:00", t.datetime.isoformat())
def test_receives_metadata_file_as_POST_param(self):
self.client.post(
'/api/submit/mygroup/myproject/1.0.11/myenvironment',
{
'metadata': '{"job_id": "123", "datetime": "2016-09-01T00:00:00+00:00"}',
}
)
t = models.TestRun.objects.last()
self.assertEqual("2016-09-01T00:00:00+00:00", t.datetime.isoformat())
def test_receives_metadata_fields_as_POST_params(self):
self.client.post(
'/api/submit/mygroup/myproject/1.0.12/myenvironment',
{
"build_url": "http://example.com/build/1",
"datetime": "2016-09-01T00:00:00+00:00",
"job_id": "123",
"job_status": "Complete",
"job_url": "http://example.com/build/1/jobs/1",
"resubmit_url": "http://example.com/build/1/jobs/1/resubmit",
}
)
t = models.TestRun.objects.last()
self.assertEqual("2016-09-01T00:00:00+00:00", t.datetime.isoformat())
self.assertIsNotNone(t.build_url)
self.assertIsNotNone(t.job_id)
self.assertIsNotNone(t.job_status)
self.assertIsNotNone(t.job_url)
self.assertIsNotNone(t.resubmit_url)
def test_stores_metadata_file(self):
self.client.post(
'/api/submit/mygroup/myproject/1.0.13/myenvironment',
{
'metadata': open(metadata_file),
}
)
t = models.TestRun.objects.last()
self.assertEqual(open(metadata_file).read(), t.metadata_file)
def test_attachment(self):
self.client.post(
'/api/submit/mygroup/myproject/1.0.14/myenvironment',
{
'attachment': open(metadata_file),
}
)
t = models.TestRun.objects.last()
attachment = t.attachments.first()
self.assertEqual(open(metadata_file, mode='rb').read(), bytes(attachment.data))
self.assertEqual(open(metadata_file, mode='rb').read(), attachment.storage.read())
def test_multiple_attachments(self):
self.client.post(
'/api/submit/mygroup/myproject/1.0.15/myenvironment',
{
'attachment': [
open(metadata_file),
open(log_file),
]
}
)
t = models.TestRun.objects.last()
attachment_metadata = t.attachments.get(filename=os.path.basename(metadata_file))
attachment_log = t.attachments.get(filename=os.path.basename(log_file))
self.assertIsNotNone(attachment_metadata)
self.assertIsNotNone(attachment_metadata.storage)
self.assertIsNotNone(attachment_log)
self.assertIsNotNone(attachment_log.storage)
def test_unauthorized(self):
client = Client() # regular client without auth support
response = client.post('/api/submit/mygroup/myproject/1.0.0/myenvironment')
self.assertEqual(response.status_code, 403)
self.assertEqual(models.TestRun.objects.count(), 0)
def test_wrong_token(self):
self.client.token = 'wrongtoken'
response = self.client.post('/api/submit/mygroup/myproject/1.0.0/myenv')
self.assertEqual(response.status_code, 403)
self.assertEqual(models.TestRun.objects.count(), 0)
def test_good_token_but_non_member_on_private_project(self):
non_member = User.objects.create(username='nonmember')
Token.objects.create(user=non_member, key='nonmemberkey')
self.project.is_public = False
self.project.save()
client = APIClient('nonmemberkey')
response = client.post('/api/submit/mygroup/myproject/1.0.0/myenvironment')
self.assertEqual(response.status_code, 401)
self.assertEqual(models.TestRun.objects.count(), 0)
def test_good_token_but_non_member(self):
non_member = User.objects.create(username='nonmember')
Token.objects.create(user=non_member, key='nonmemberkey')
client = APIClient('nonmemberkey')
response = client.post('/api/submit/mygroup/myproject/1.0.0/myenvironment')
self.assertEqual(response.status_code, 403)
self.assertEqual(models.TestRun.objects.count(), 0)
def test_good_token_but_member_without_submit_access(self):
member = User.objects.create(username='member')
self.group.add_user(member)
Token.objects.create(user=member, key='memberkey')
client = APIClient('memberkey')
response = client.post('/api/submit/mygroup/myproject/1.0.0/myenvironment')
self.assertEqual(response.status_code, 403)
self.assertEqual(models.TestRun.objects.count(), 0)
def test_good_token_for_member_with_submit_access(self):
member = User.objects.create(username='member')
self.group.add_user(member, 'submitter')
Token.objects.create(user=member, key='memberkey')
client = APIClient('memberkey')
response = client.post('/api/submit/mygroup/myproject/1.0.16/myenvironment')
self.assertEqual(response.status_code, 201)
self.assertEqual(models.TestRun.objects.count(), 1)
def test_auth_with_global_token(self):
self.client.token = self.global_token.key
response = self.client.post('/api/submit/mygroup/myproject/1.0.17/myenvironment')
self.assertEqual(201, response.status_code)
self.assertEqual(1, models.TestRun.objects.count())
def test_404_on_non_existing_group(self):
response = self.client.post('/api/submit/mygrouppp/myproject/1.0.0/myenv')
self.assertEqual(404, response.status_code)
def test_404_on_non_existing_project(self):
response = self.client.post('/api/submit/mygroup/myprojectttt/1.0.0/myenv')
self.assertEqual(404, response.status_code)
def test_invalid_metrics_json(self):
response = self.client.post(
'/api/submit/mygroup/myproject/1.0.0/myenvironment',
{
'metrics': invalid_json(),
}
)
self.assertEqual(400, response.status_code)
def test_invalid_tests_json(self):
response = self.client.post(
'/api/submit/mygroup/myproject/1.0.0/myenvironment',
{
'tests': invalid_json(),
}
)
self.assertEqual(400, response.status_code)
def test_invalid_metadata_json(self):
response = self.client.post(
'/api/submit/mygroup/myproject/1.0.0/myenvironment',
{
'metadata': invalid_json(),
}
)
self.assertEqual(400, response.status_code)
def test_metadata_invalid_date_format(self):
response = self.client.post(
'/api/submit/mygroup/myproject/1.0.0/myenvironment',
{
'metadata': '{"job_id": "123", "datetime": "1661282149"}',
}
)
self.assertEqual(400, response.status_code)
def test_reject_submission_without_job_id(self):
response = self.client.post(
'/api/submit/mygroup/myproject/1.0.18/myenvironment',
{
'metadata': StringIO('{"datetime": "2016-09-01T00:00:00+00:00"}'),
}
)
self.assertEqual(201, response.status_code)
def test_reject_submission_with_existing_job_id(self):
def post():
return self.client.post(
'/api/submit/mygroup/myproject/1.0.19/myenvironment',
{
'metadata': open(metadata_file),
}
)
first = post()
second = post()
self.assertEqual(201, first.status_code)
self.assertEqual(400, second.status_code)
def test_reject_submission_with_int_job_id(self):
response = self.client.post('/api/submit/mygroup/myproject/1.0.20/myenvironment', {'metadata': '{"job_id": 123}'})
self.assertEqual(201, response.status_code)
def test_accepts_uppercase_in_slug(self):
self.group.slug = 'MyGroup'
self.group.save()
self.project.slug = 'MyProject'
self.project.save()
response = self.client.post('/api/submit/MyGroup/MyProject/1.0.21/MyEnvironment')
self.assertEqual(response.status_code, 201)
|
class CreateTestRunApiTest(ApiTest):
def test_create_object_hierarchy(self):
pass
def test_create_object_hierarchy_private(self):
pass
def test_create_test_run(self):
pass
def test_receives_tests_file(self):
pass
def test_receives_tests_file_with_logs(self):
pass
def test_receives_tests_file_as_POST_param(self):
pass
def test_receives_tests_file_as_POST_param_with_logs(self):
pass
def test_receives_metrics_file(self):
pass
def test_receives_metrics_file_as_POST_param_with_no_metric_unit(self):
pass
def test_receives_metrics_file_as_POST_param_with_no_metric_unit(self):
pass
def test_receives_log_file(self):
pass
def test_receives_log_file_as_POST_param(self):
pass
def test_process_data_on_submission(self):
pass
def test_receives_metadata_file(self):
pass
def test_receives_metadata_file_as_POST_param(self):
pass
def test_receives_metadata_fields_as_POST_params(self):
pass
def test_stores_metadata_file(self):
pass
def test_attachment(self):
pass
def test_multiple_attachments(self):
pass
def test_unauthorized(self):
pass
def test_wrong_token(self):
pass
def test_good_token_but_non_member_on_private_project(self):
pass
def test_good_token_but_non_member_on_private_project(self):
pass
def test_good_token_but_member_without_submit_access(self):
pass
def test_good_token_for_member_with_submit_access(self):
pass
def test_auth_with_global_token(self):
pass
def test_404_on_non_existing_group(self):
pass
def test_404_on_non_existing_project(self):
pass
def test_invalid_metrics_json(self):
pass
def test_invalid_tests_json(self):
pass
def test_invalid_metadata_json(self):
pass
def test_metadata_invalid_date_format(self):
pass
def test_reject_submission_without_job_id(self):
pass
def test_reject_submission_with_existing_job_id(self):
pass
def post():
pass
def test_reject_submission_with_int_job_id(self):
pass
def test_accepts_uppercase_in_slug(self):
pass
| 38 | 0 | 9 | 0 | 9 | 0 | 1 | 0 | 1 | 7 | 5 | 0 | 36 | 0 | 36 | 37 | 372 | 42 | 330 | 88 | 292 | 1 | 217 | 84 | 179 | 1 | 2 | 1 | 37 |
146,006 |
LinkCareServices/period
|
LinkCareServices_period/period/main.py
|
period.main.PeriodSyntax
|
class PeriodSyntax(object):
def __init__(self):
self.ops = [".", "|", "!"] # To know operations.
self.uops = ["!"] # Unary operations.
def flatten(self, lst=None):
"""syntax.flatten(token_stream) - compile period tokens
This turns a stream of tokens into p-code for the trivial
stack machine that evaluates period expressions in in_period.
"""
tree = []
uops = [] # accumulated unary operations
s = Stack()
group_len = 0 # in current precendence group
for item in lst:
if type(item) == type([]):
# Subexpression.
tree = tree + self.flatten(item)
group_len = group_len + 1
# Unary ops dump, for things like: '!(Monday|Wednesday)'
for uop in uops:
tree.append(uop)
uops = []
elif item in self.ops and item not in self.uops:
# Operator.
if not s.empty():
prev_op = s.pop()
# If the precendence of the previous operation is
# higher then dump out everything so far, ensuring the
# order of evaluation.
if _precedence[prev_op] > _precedence[item]:
s.push(prev_op) # put it back
for i in range(group_len - 1):
tree.append(s.pop())
group_len = 0
else:
s.push(prev_op)
s.push(item)
else:
s.push(item)
elif item in self.uops:
uops.append(item)
else:
# Token of some sort.
tree.append(item)
group_len = group_len + 1
# Dump any unary operations.
for uop in uops:
tree.append(uop)
uops = []
while not s.empty():
tree.append(s.pop())
# Drop any remaining unary operations.
for uop in uops:
tree.append(uop)
return tree
|
class PeriodSyntax(object):
def __init__(self):
pass
def flatten(self, lst=None):
'''syntax.flatten(token_stream) - compile period tokens
This turns a stream of tokens into p-code for the trivial
stack machine that evaluates period expressions in in_period.
'''
pass
| 3 | 1 | 29 | 2 | 21 | 9 | 7 | 0.43 | 1 | 3 | 1 | 0 | 2 | 2 | 2 | 2 | 60 | 5 | 42 | 13 | 39 | 18 | 37 | 13 | 34 | 12 | 1 | 5 | 13 |
146,007 |
LinkCareServices/period
|
LinkCareServices_period/period/main.py
|
period.main.Stack
|
class Stack(object):
def __init__(self):
self.s = []
def push(self, datum):
self.s.append(datum)
def pop(self):
return self.s.pop()
def empty(self):
return len(self.s) == 0
def __repr__(self):
return repr(self.s)
|
class Stack(object):
def __init__(self):
pass
def push(self, datum):
pass
def pop(self):
pass
def empty(self):
pass
def __repr__(self):
pass
| 6 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 5 | 1 | 5 | 5 | 15 | 4 | 11 | 7 | 5 | 0 | 11 | 7 | 5 | 1 | 1 | 0 | 5 |
146,008 |
LinkCareServices/period
|
LinkCareServices_period/setup.py
|
setup.my_build_py
|
class my_build_py(build_py):
def run(self):
# honor the --dry-run flag
if not self.dry_run:
target_dirs = []
target_dirs.append(os.path.join(self.build_lib,
'period'))
target_dirs.append('period')
# mkpath is a distutils helper to create directories
for dir in target_dirs:
self.mkpath(dir)
try:
for dir in target_dirs:
fobj = open(os.path.join(dir, 'RELEASE-VERSION'), 'w')
fobj.write(version)
fobj.close()
except:
pass
# distutils uses old-style classes, so no super()
build_py.run(self)
|
class my_build_py(build_py):
def run(self):
pass
| 2 | 0 | 21 | 2 | 16 | 3 | 5 | 0.18 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 71 | 22 | 2 | 17 | 5 | 15 | 3 | 16 | 5 | 14 | 5 | 3 | 3 | 5 |
146,009 |
LinkCareServices/period
|
LinkCareServices_period/period/main.py
|
period.main.PeriodParser
|
class PeriodParser(object):
"""Parse time period specifications."""
def __init__(self):
self.SPECIAL = "().|!"
pass
def parse(self, str=None):
if str:
self.str = str
self.i = 0
self.len = len(str)
self.level = 0
expr = []
tok = self.get_token()
while tok != '':
if tok == ')':
self.level = self.level - 1
if self.level < 0:
break # too many closing parens... catch error below
else:
return expr
elif tok == '(':
self.level = self.level + 1
sexpr = _remove_otiose(self.parse())
expr.append(sexpr)
else:
expr.append(tok)
tok = self.get_token()
# If the level isn't correct, then some extra parens are
# involved. Complain about that.
if self.level == 0:
return expr
elif self.level > 0:
raise Exception("mismatched opening parenthesis in expression")
else:
raise Exception("mismatched closing parenthesis in expression")
def get_token(self):
if self.i >= self.len:
return ''
if self.str[self.i] in self.SPECIAL:
self.i = self.i + 1
return self.str[self.i - 1]
else:
tok = ""
while self.i < self.len - 1:
if self.str[self.i] in self.SPECIAL:
break
else:
tok = tok + self.str[self.i]
self.i = self.i + 1
if not self.str[self.i] in self.SPECIAL:
tok = tok + self.str[self.i]
self.i = self.i + 1
return tok
|
class PeriodParser(object):
'''Parse time period specifications.'''
def __init__(self):
pass
def parse(self, str=None):
pass
def get_token(self):
pass
| 4 | 1 | 19 | 2 | 16 | 1 | 5 | 0.08 | 1 | 1 | 0 | 0 | 3 | 5 | 3 | 3 | 61 | 8 | 50 | 13 | 46 | 4 | 43 | 13 | 39 | 8 | 1 | 3 | 15 |
146,010 |
LinkCareServices/period
|
LinkCareServices_period/period/main.py
|
period.main._Time
|
class _Time(object):
"""Utility class for symbolic date manipulation."""
def __init__(self, tyme=None):
if not tyme:
self.time = time.localtime(time.time())
else:
self.time = time.localtime(tyme)
self._set_props()
def _set_props(self):
(self.weekday,
self.month,
self.day,
self.hr,
self.minute,
self.week,
self.year) = str.split(time.strftime("%A %B %d %H %M %U %Y", self.time))
if self.weekday in ['Saturday', 'Sunday']:
self.daytype = 'Weekend'
else:
self.daytype = 'Weekday'
|
class _Time(object):
'''Utility class for symbolic date manipulation.'''
def __init__(self, tyme=None):
pass
def _set_props(self):
pass
| 3 | 1 | 10 | 1 | 9 | 0 | 2 | 0.05 | 1 | 1 | 0 | 0 | 2 | 9 | 2 | 2 | 23 | 3 | 19 | 12 | 16 | 1 | 11 | 6 | 8 | 2 | 1 | 1 | 4 |
146,011 |
LinuxChristian/pyW215
|
LinuxChristian_pyW215/pyW215/pyW215.py
|
pyW215.pyW215.SmartPlug
|
class SmartPlug(object):
"""
Class to access:
* D-Link Smart Plug Switch W215
* D-Link Smart Plug DSP-W110
Usage example when used as library:
p = SmartPlug("192.168.0.10", ('admin', '1234'))
# change state of plug
p.state = OFF
p.state = ON
# query and print current state of plug
print(p.state)
Note:
The library is greatly inspired by the javascript library by @bikerp (https://github.com/bikerp).
Class layout is inspired by @rkabadi (https://github.com/rkabadi) for the Edimax Smart plug.
"""
def __init__(self, ip, password, user="admin",
use_legacy_protocol=False):
"""
Create a new SmartPlug instance identified by the given URL and password.
:rtype : object
:param host: The IP/hostname of the SmartPlug. E.g. '192.168.0.10'
:param password: Password to authenticate with the plug. Located on the plug.
:param user: Username for the plug. Default is admin.
:param use_legacy_protocol: Support legacy firmware versions. Default is False.
"""
self.ip = ip
self.url = "http://{}/HNAP1/".format(ip)
self.user = user
self.password = password
self.use_legacy_protocol = use_legacy_protocol
self.authenticated = None
if self.use_legacy_protocol:
_LOGGER.info("Enabled support for legacy firmware.")
self._error_report = False
self.model_name = self.SOAPAction(Action="GetDeviceSettings", responseElement="ModelName", params="")
def moduleParameters(self, module):
"""Returns moduleID XML.
:type module: str
:param module: module number/ID
:return XML string with moduleID
"""
return '''<ModuleID>{}</ModuleID>'''.format(module)
def controlParameters(self, module, status):
"""Returns control parameters as XML.
:type module: str
:type status: str
:param module: The module number/ID
:param status: The state to set (i.e. true (on) or false (off))
:return XML string to join with payload
"""
if self.use_legacy_protocol:
return '''{}<NickName>Socket 1</NickName><Description>Socket 1</Description>
<OPStatus>{}</OPStatus><Controller>1</Controller>'''.format(self.moduleParameters(module), status)
else:
return '''{}<NickName>Socket 1</NickName><Description>Socket 1</Description>
<OPStatus>{}</OPStatus>'''.format(self.moduleParameters(module), status)
def radioParameters(self, radio):
"""Returns RadioID as XML.
:type radio: str
:param radio: Radio number/ID
"""
return '''<RadioID>{}</RadioID>'''.format(radio)
def requestBody(self, Action, params):
"""Returns the request payload for an action as XML>.
:type Action: str
:type params: str
:param Action: Which action to perform
:param params: Any parameters required for request
:return XML payload for request
"""
return '''<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<{} xmlns="http://purenetworks.com/HNAP1/">
{}
</{}>
</soap:Body>
</soap:Envelope>
'''.format(Action, params, Action)
def SOAPAction(self, Action, responseElement, params="", recursive=False):
"""Generate the SOAP action call.
:type Action: str
:type responseElement: str
:type params: str
:type recursive: bool
:param Action: The action to perform on the device
:param responseElement: The XML element that is returned upon success
:param params: Any additional parameters required for performing request (i.e. RadioID, moduleID, ect)
:param recursive: True if first attempt failed and now attempting to re-authenticate prior
:return: Text enclosed in responseElement brackets
"""
# Authenticate client
if self.authenticated is None:
self.authenticated = self.auth()
auth = self.authenticated
# If not legacy protocol, ensure auth() is called for every call
if not self.use_legacy_protocol:
self.authenticated = None
if auth is None:
return None
payload = self.requestBody(Action, params)
# Timestamp in microseconds
time_stamp = str(round(time.time() / 1e6))
action_url = '"http://purenetworks.com/HNAP1/{}"'.format(Action)
AUTHKey = hmac.new(auth[0].encode(), (time_stamp + action_url).encode(), digestmod=hashlib.md5).hexdigest().upper() + " " + time_stamp
headers = {'Content-Type': '"text/xml; charset=utf-8"',
'SOAPAction': '"http://purenetworks.com/HNAP1/{}"'.format(Action),
'HNAP_AUTH': '{}'.format(AUTHKey),
'Cookie': 'uid={}'.format(auth[1])}
try:
response = urlopen(Request(self.url, payload.encode(), headers))
except (HTTPError, URLError):
# Try to re-authenticate once
self.authenticated = None
# Recursive call to retry action
if not recursive:
return_value = self.SOAPAction(Action, responseElement, params, True)
if recursive or return_value is None:
_LOGGER.warning("Failed to open url to {}".format(self.ip))
self._error_report = True
return None
else:
return return_value
xmlData = response.read().decode()
root = ET.fromstring(xmlData)
# Get value from device
try:
value = root.find('.//{http://purenetworks.com/HNAP1/}%s' % (responseElement)).text
except AttributeError:
_LOGGER.warning("Unable to find %s in response." % responseElement)
return None
if value is None and self._error_report is False:
_LOGGER.warning("Could not find %s in response." % responseElement)
self._error_report = True
return None
self._error_report = False
return value
def fetchMyCgi(self):
"""Fetches statistics from my_cgi.cgi"""
try:
response = urlopen(Request('http://{}/my_cgi.cgi'.format(self.ip), b'request=create_chklst'));
except (HTTPError, URLError):
_LOGGER.warning("Failed to open url to {}".format(self.ip))
self._error_report = True
return None
lines = response.readlines()
return {line.decode().split(':')[0].strip(): line.decode().split(':')[1].strip() for line in lines}
@property
def current_consumption(self):
"""Get the current power consumption in Watt."""
res = 'N/A'
if self.use_legacy_protocol:
# Use /my_cgi.cgi to retrieve current consumption
try:
res = self.fetchMyCgi()['Meter Watt']
except:
return 'N/A'
else:
try:
res = self.SOAPAction('GetCurrentPowerConsumption', 'CurrentConsumption', self.moduleParameters("2"))
except:
return 'N/A'
if res is None:
return 'N/A'
try:
res = float(res)
except ValueError:
_LOGGER.error("Failed to retrieve current power consumption from SmartPlug")
return res
def get_current_consumption(self):
"""Get the current power consumption in Watt."""
return self.current_consumption
@property
def total_consumption(self):
"""Get the total power consumpuntion in the device lifetime."""
if self.use_legacy_protocol:
# TotalConsumption currently fails on the legacy protocol and
# creates a mess in the logs. Just return 'N/A' for now.
return 'N/A'
res = 'N/A'
try:
res = self.SOAPAction("GetPMWarningThreshold", "TotalConsumption", self.moduleParameters("2"))
except:
return 'N/A'
if res is None:
return 'N/A'
try:
float(res)
except ValueError:
_LOGGER.error("Failed to retrieve total power consumption from SmartPlug")
return res
def get_total_consumption(self):
"""Get the total power consumpuntion in the device lifetime."""
return self.total_consumption
@property
def temperature(self):
"""Get the device temperature in celsius."""
try:
res = self.SOAPAction('GetCurrentTemperature', 'CurrentTemperature', self.moduleParameters("3"))
except:
res = 'N/A'
return res
def get_temperature(self):
"""Get the device temperature in celsius."""
return self.temperature
@property
def state(self):
"""Get the device state (i.e. ON or OFF)."""
response = self.SOAPAction('GetSocketSettings', 'OPStatus', self.moduleParameters("1"))
if response is None:
return 'unknown'
elif response.lower() == 'true':
return ON
elif response.lower() == 'false':
return OFF
else:
_LOGGER.warning("Unknown state %s returned" % str(response.lower()))
return 'unknown'
@state.setter
def state(self, value):
"""Set device state.
:type value: str
:param value: Future state (either ON or OFF)
"""
if value.upper() == ON:
return self.SOAPAction('SetSocketSettings', 'SetSocketSettingsResult', self.controlParameters("1", "true"))
elif value.upper() == OFF:
return self.SOAPAction('SetSocketSettings', 'SetSocketSettingsResult', self.controlParameters("1", "false"))
else:
raise TypeError("State %s is not valid." % str(value))
def get_state(self):
"""Get the device state (i.e. ON or OFF)."""
return self.state
def auth(self):
"""Authenticate using the SOAP interface.
Authentication is a two-step process. First a initial payload
is sent to the device requesting additional login information in the form
of a publickey, a challenge string and a cookie.
These values are then hashed by a MD5 algorithm producing a privatekey
used for the header and a hashed password for the XML payload.
If everything is accepted the XML returned will contain a LoginResult tag with the
string 'success'.
See https://github.com/bikerp/dsp-w215-hnap/wiki/Authentication-process for more information.
"""
payload = self.initial_auth_payload()
# Build initial header
headers = {'Content-Type': '"text/xml; charset=utf-8"',
'SOAPAction': '"http://purenetworks.com/HNAP1/Login"'}
# Request privatekey, cookie and challenge
try:
response = urlopen(Request(self.url, payload, headers))
except URLError:
if self._error_report is False:
_LOGGER.warning('Unable to open a connection to dlink switch {}'.format(self.ip))
self._error_report = True
return None
xmlData = response.read().decode()
root = ET.fromstring(xmlData)
# Find responses
ChallengeResponse = root.find('.//{http://purenetworks.com/HNAP1/}Challenge')
CookieResponse = root.find('.//{http://purenetworks.com/HNAP1/}Cookie')
PublickeyResponse = root.find('.//{http://purenetworks.com/HNAP1/}PublicKey')
if (
ChallengeResponse == None or CookieResponse == None or PublickeyResponse == None) and self._error_report is False:
_LOGGER.warning("Failed to receive initial authentication from smartplug.")
self._error_report = True
return None
if self._error_report is True:
return None
Challenge = ChallengeResponse.text
Cookie = CookieResponse.text
Publickey = PublickeyResponse.text
# Generate hash responses
PrivateKey = hmac.new((Publickey + self.password).encode(), (Challenge).encode(), digestmod=hashlib.md5).hexdigest().upper()
login_pwd = hmac.new(PrivateKey.encode(), Challenge.encode(), digestmod=hashlib.md5).hexdigest().upper()
response_payload = self.auth_payload(login_pwd)
# Build response to initial request
headers = {'Content-Type': '"text/xml; charset=utf-8"',
'SOAPAction': '"http://purenetworks.com/HNAP1/Login"',
'HNAP_AUTH': '"{}"'.format(PrivateKey),
'Cookie': 'uid={}'.format(Cookie)}
response = urlopen(Request(self.url, response_payload, headers))
xmlData = response.read().decode()
root = ET.fromstring(xmlData)
# Find responses
login_status = root.find('.//{http://purenetworks.com/HNAP1/}LoginResult').text.lower()
if login_status != "success" and self._error_report is False:
_LOGGER.error("Failed to authenticate with SmartPlug {}".format(self.ip))
self._error_report = True
return None
self._error_report = False # Reset error logging
return (PrivateKey, Cookie)
def initial_auth_payload(self):
"""Return the initial authentication payload."""
return b'''<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Login xmlns="http://purenetworks.com/HNAP1/">
<Action>request</Action>
<Username>admin</Username>
<LoginPassword/>
<Captcha/>
</Login>
</soap:Body>
</soap:Envelope>
'''
def auth_payload(self, login_pwd):
"""Generate a new payload containing generated hash information.
:type login_pwd: str
:param login_pwd: hashed password generated by the auth function.
"""
payload = '''<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Login xmlns="http://purenetworks.com/HNAP1/">
<Action>login</Action>
<Username>{}</Username>
<LoginPassword>{}</LoginPassword>
<Captcha/>
</Login>
</soap:Body>
</soap:Envelope>
'''.format(self.user, login_pwd)
return payload.encode()
|
class SmartPlug(object):
'''
Class to access:
* D-Link Smart Plug Switch W215
* D-Link Smart Plug DSP-W110
Usage example when used as library:
p = SmartPlug("192.168.0.10", ('admin', '1234'))
# change state of plug
p.state = OFF
p.state = ON
# query and print current state of plug
print(p.state)
Note:
The library is greatly inspired by the javascript library by @bikerp (https://github.com/bikerp).
Class layout is inspired by @rkabadi (https://github.com/rkabadi) for the Edimax Smart plug.
'''
def __init__(self, ip, password, user="admin",
use_legacy_protocol=False):
'''
Create a new SmartPlug instance identified by the given URL and password.
:rtype : object
:param host: The IP/hostname of the SmartPlug. E.g. '192.168.0.10'
:param password: Password to authenticate with the plug. Located on the plug.
:param user: Username for the plug. Default is admin.
:param use_legacy_protocol: Support legacy firmware versions. Default is False.
'''
pass
def moduleParameters(self, module):
'''Returns moduleID XML.
:type module: str
:param module: module number/ID
:return XML string with moduleID
'''
pass
def controlParameters(self, module, status):
'''Returns control parameters as XML.
:type module: str
:type status: str
:param module: The module number/ID
:param status: The state to set (i.e. true (on) or false (off))
:return XML string to join with payload
'''
pass
def radioParameters(self, radio):
'''Returns RadioID as XML.
:type radio: str
:param radio: Radio number/ID
'''
pass
def requestBody(self, Action, params):
'''Returns the request payload for an action as XML>.
:type Action: str
:type params: str
:param Action: Which action to perform
:param params: Any parameters required for request
:return XML payload for request
'''
pass
def SOAPAction(self, Action, responseElement, params="", recursive=False):
'''Generate the SOAP action call.
:type Action: str
:type responseElement: str
:type params: str
:type recursive: bool
:param Action: The action to perform on the device
:param responseElement: The XML element that is returned upon success
:param params: Any additional parameters required for performing request (i.e. RadioID, moduleID, ect)
:param recursive: True if first attempt failed and now attempting to re-authenticate prior
:return: Text enclosed in responseElement brackets
'''
pass
def fetchMyCgi(self):
'''Fetches statistics from my_cgi.cgi'''
pass
@property
def current_consumption(self):
'''Get the current power consumption in Watt.'''
pass
def get_current_consumption(self):
'''Get the current power consumption in Watt.'''
pass
@property
def total_consumption(self):
'''Get the total power consumpuntion in the device lifetime.'''
pass
def get_total_consumption(self):
'''Get the total power consumpuntion in the device lifetime.'''
pass
@property
def temperature(self):
'''Get the device temperature in celsius.'''
pass
def get_temperature(self):
'''Get the device temperature in celsius.'''
pass
@property
def state(self):
'''Get the device state (i.e. ON or OFF).'''
pass
@state.setter
def state(self):
'''Set device state.
:type value: str
:param value: Future state (either ON or OFF)
'''
pass
def get_state(self):
'''Get the device state (i.e. ON or OFF).'''
pass
def auth(self):
'''Authenticate using the SOAP interface.
Authentication is a two-step process. First a initial payload
is sent to the device requesting additional login information in the form
of a publickey, a challenge string and a cookie.
These values are then hashed by a MD5 algorithm producing a privatekey
used for the header and a hashed password for the XML payload.
If everything is accepted the XML returned will contain a LoginResult tag with the
string 'success'.
See https://github.com/bikerp/dsp-w215-hnap/wiki/Authentication-process for more information.
'''
pass
def initial_auth_payload(self):
'''Return the initial authentication payload.'''
pass
def auth_payload(self, login_pwd):
'''Generate a new payload containing generated hash information.
:type login_pwd: str
:param login_pwd: hashed password generated by the auth function.
'''
pass
| 25 | 20 | 18 | 2 | 12 | 5 | 3 | 0.45 | 1 | 8 | 0 | 0 | 19 | 8 | 19 | 19 | 392 | 67 | 225 | 67 | 188 | 101 | 171 | 61 | 151 | 9 | 1 | 2 | 50 |
146,012 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Switch
|
class Switch(Conditional):
"""Switch statement"""
def __init__(self, condition: Expr, body: Stmt):
Conditional.__init__(self, condition)
self.body = body
|
class Switch(Conditional):
'''Switch statement'''
def __init__(self, condition: Expr, body: Stmt):
pass
| 2 | 1 | 3 | 0 | 3 | 0 | 1 | 0.25 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 2 | 6 | 1 | 4 | 3 | 2 | 1 | 4 | 3 | 2 | 1 | 3 | 0 | 1 |
146,013 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Terminal
|
class Terminal(Expr):
"""For Terminal expression"""
def __init__(self, value: str):
Expr.__init__(self)
self.value = value
|
class Terminal(Expr):
'''For Terminal expression'''
def __init__(self, value: str):
pass
| 2 | 1 | 3 | 0 | 3 | 0 | 1 | 0.25 | 1 | 1 | 0 | 3 | 1 | 1 | 1 | 1 | 6 | 1 | 4 | 3 | 2 | 1 | 4 | 3 | 2 | 1 | 2 | 0 | 1 |
146,014 |
LionelAuroux/cnorm
|
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LionelAuroux_cnorm/cnorm/type_handling/THandling.py
|
cnorm.type_handling.THandling.Log
|
class Log:
indent = 0
def incdent():
Log.indent += 1
def decdent():
Log.indent -= 1
def log(s):
print("%s%s" % ("\t" * Log.indent, s))
|
class Log:
def incdent():
pass
def decdent():
pass
def log(s):
pass
| 4 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 3 | 3 | 8 | 0 | 8 | 5 | 4 | 0 | 8 | 5 | 4 | 1 | 0 | 0 | 3 |
146,015 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Ternary
|
class Ternary(Func):
"""For ternary operator"""
|
class Ternary(Func):
'''For ternary operator'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 3 | 0 | 0 |
146,016 |
LionelAuroux/cnorm
|
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LionelAuroux_cnorm/cnorm/type_handling/THandling.py
|
cnorm.type_handling.THandling.THandling
|
class THandling:
def __init__(self, scope):
self.scope = scope
# retro propagation des types
def typeFeedback(self, expr, expr_type):
Log.log("type this expr with symbol %s" % expr_type)
expr['symbol'] = expr_type['symbol']
expr['type'] = expr_type['type']
# before remove candidates retro propagate parameter
if 'param' in expr_type:
fun_arity = len(expr_type['param'])
for pidx in range(0, fun_arity):
Log.log("at INDEX %d = %s" % (pidx, repr(expr['param'])))
param_candidat = {
tp['type']: tp for tp in expr['param'][pidx]['candidates']}
if expr_type['param'][pidx] in param_candidat:
Log.incdent()
self.typeFeedback(
expr['param'][pidx], param_candidat[expr_type['param'][pidx]])
Log.decdent()
del expr['candidates']
# type une expression
def typeExpr(self, expr):
# result
candidates = []
Log.log("expr: %s" % repr(expr))
# search all overloads for the function
overloads = self.scope[expr['name']]
Log.log("found overloads for function %s" % expr['name'])
# get all thing overloads
for thing in overloads:
Log.log("overload %s" % thing['symbol'])
# is just a var
if 'param' not in expr or len(expr['param']) == 0:
Log.log("Is JUST A THING:")
candidates.append(thing)
else:
# count function arity in expression
fun_arity = len(expr['param'])
# select only function overloads with same arity TODO: ellipsis
if (len(thing['param']) == fun_arity):
Log.log("select %s for arity" % thing['symbol'])
# result list param
list_param = []
# for all param fetch possible type
for pidx in range(0, fun_arity):
Log.log("idx: %s" % pidx)
# get name of param
pname = expr['param'][pidx]['name']
# get types of this param
Log.incdent()
self.typeExpr(expr['param'][pidx])
Log.decdent()
types = set([tp['type']
for tp in expr['param'][pidx]['candidates']])
Log.log("param %s is %s" % (pname, repr(types)))
# intersect type of overload and types
ptype = thing['param'][pidx]
Log.log("intersect with %s" % ptype)
if ptype in types:
Log.log("FOUND: %s" % ptype)
list_param.append(ptype)
# test the candidates
if (len(list_param) == fun_arity):
candidates.append(thing)
# add candidates in expression
if len(candidates) > 0:
expr['candidates'] = candidates
# TODO: retro propagation
if len(candidates) == 1:
Log.log("retro propagation")
Log.incdent()
self.typeFeedback(expr, expr['candidates'][0])
Log.decdent()
return True
return False
|
class THandling:
def __init__(self, scope):
pass
def typeFeedback(self, expr, expr_type):
pass
def typeExpr(self, expr):
pass
| 4 | 0 | 23 | 0 | 18 | 5 | 5 | 0.3 | 0 | 3 | 1 | 0 | 3 | 1 | 3 | 3 | 75 | 2 | 56 | 17 | 52 | 17 | 55 | 17 | 51 | 9 | 0 | 5 | 14 |
146,017 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.FuncType
|
class FuncType(PrimaryType):
"""For function in declaration"""
def __init__(self, identifier: str, params=[], decltype=None):
PrimaryType.__init__(self, identifier)
self.opened = True
if decltype is not None:
self._decltype = decltype
self._params = params
@property
def params(self):
return self._params
|
class FuncType(PrimaryType):
'''For function in declaration'''
def __init__(self, identifier: str, params=[], decltype=None):
pass
@property
def params(self):
pass
| 4 | 1 | 4 | 0 | 4 | 0 | 2 | 0.1 | 1 | 1 | 0 | 0 | 2 | 3 | 2 | 8 | 13 | 2 | 10 | 7 | 6 | 1 | 9 | 6 | 6 | 2 | 3 | 1 | 3 |
146,018 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Stmt
|
class Stmt(parsing.Node):
"""For statement"""
|
class Stmt(parsing.Node):
'''For statement'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 5 | 0 | 0 | 0 | 0 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 |
146,019 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Continue
|
class Continue(LoopControl):
"""continue statement"""
def __init__(self):
Label.__init__(self, "continue")
|
class Continue(LoopControl):
'''continue statement'''
def __init__(self):
pass
| 2 | 1 | 2 | 0 | 2 | 0 | 1 | 0.33 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 2 | 5 | 1 | 3 | 2 | 1 | 1 | 3 | 2 | 1 | 1 | 4 | 0 | 1 |
146,020 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.ComposedType
|
class ComposedType(CType):
"""For composed type in declaration"""
def __init__(self, identifier: str):
CType.__init__(self)
# identifier (name of the struct/union/enum)
self._identifier = identifier
# if struct/union then self.fields = []
# if enum then self.enums = []
@property
def identifier(self):
return self._identifier
|
class ComposedType(CType):
'''For composed type in declaration'''
def __init__(self, identifier: str):
pass
@property
def identifier(self):
pass
| 4 | 1 | 3 | 0 | 3 | 1 | 1 | 0.57 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 6 | 13 | 2 | 7 | 5 | 3 | 4 | 6 | 4 | 3 | 1 | 2 | 0 | 2 |
146,021 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Conditional
|
class Conditional(Stmt):
"""Conditional statement"""
def __init__(self, condition: Expr):
Stmt.__init__(self)
self.condition = condition
|
class Conditional(Stmt):
'''Conditional statement'''
def __init__(self, condition: Expr):
pass
| 2 | 1 | 3 | 0 | 3 | 0 | 1 | 0.25 | 1 | 1 | 1 | 4 | 1 | 1 | 1 | 1 | 6 | 1 | 4 | 3 | 2 | 1 | 4 | 3 | 2 | 1 | 2 | 0 | 1 |
146,022 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Decl
|
class Decl(Expr):
"""For basic declaration
A declaration contains the following attributes:
* _name: name of the declaration
* _ctype: the CType describing the type of the declaration
* _assign_expr: when the declaration have a value
* _colon_expr: When it's a bitfield
* body: when it's function definition
"""
def __init__(self, name: str, ct=None):
if ct is None:
ct = PrimaryType('int')
Expr.__init__(self)
self._name = name
self._ctype = ct
@property
def ctype(self) -> CType:
return self._ctype
def assign_expr(self, expr=None):
if not hasattr(self, '_assign_expr'):
self._assign_expr = None
if expr is not None:
self._assign_expr = expr
return self._assign_expr
def colon_expr(self, expr=None):
if not hasattr(self, '_colon_expr'):
self._colon_expr = None
if expr is not None:
self._colon_expr = expr
return self._colon_expr
|
class Decl(Expr):
'''For basic declaration
A declaration contains the following attributes:
* _name: name of the declaration
* _ctype: the CType describing the type of the declaration
* _assign_expr: when the declaration have a value
* _colon_expr: When it's a bitfield
* body: when it's function definition
'''
def __init__(self, name: str, ct=None):
pass
@property
def ctype(self) -> CType:
pass
def assign_expr(self, expr=None):
pass
def colon_expr(self, expr=None):
pass
| 6 | 1 | 5 | 0 | 5 | 0 | 2 | 0.36 | 1 | 3 | 2 | 0 | 4 | 4 | 4 | 4 | 37 | 7 | 22 | 10 | 16 | 8 | 21 | 9 | 16 | 3 | 2 | 1 | 9 |
146,023 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.DeclType
|
class DeclType(parsing.Node):
"""For type in declaration"""
def __init__(self):
self._decltype = None
def link(self, t: 'DeclType'=None):
if t is not None:
if not isinstance(t, DeclType):
raise Exception("add only C type declarator")
self._decltype = t
return self._decltype
def push(self, t: 'DeclType'=None):
if t is not None:
if not isinstance(t, DeclType):
raise Exception("add only C type declarator")
old = self._decltype
self._decltype = t
self._decltype.link(old)
return self._decltype
|
class DeclType(parsing.Node):
'''For type in declaration'''
def __init__(self):
pass
def link(self, t: 'DeclType'=None):
pass
def push(self, t: 'DeclType'=None):
pass
| 4 | 1 | 5 | 0 | 5 | 0 | 2 | 0.06 | 1 | 1 | 0 | 5 | 3 | 1 | 3 | 3 | 21 | 3 | 17 | 6 | 13 | 1 | 17 | 6 | 13 | 3 | 1 | 2 | 7 |
146,024 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Do
|
class Do(Conditional):
"""Do statement"""
def __init__(self, condition: Expr, body: Stmt):
Conditional.__init__(self, condition)
self.body = body
|
class Do(Conditional):
'''Do statement'''
def __init__(self, condition: Expr, body: Stmt):
pass
| 2 | 1 | 3 | 0 | 3 | 0 | 1 | 0.25 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 2 | 6 | 1 | 4 | 3 | 2 | 1 | 4 | 3 | 2 | 1 | 3 | 0 | 1 |
146,025 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Func
|
class Func(Expr):
"""For almost everything"""
def __init__(self, call_expr: Expr, params: list):
Expr.__init__(self)
self.call_expr = call_expr
self.params = params
|
class Func(Expr):
'''For almost everything'''
def __init__(self, call_expr: Expr, params: list):
pass
| 2 | 1 | 4 | 0 | 4 | 0 | 1 | 0.2 | 1 | 1 | 0 | 3 | 1 | 2 | 1 | 1 | 7 | 1 | 5 | 4 | 3 | 1 | 5 | 4 | 3 | 1 | 2 | 0 | 1 |
146,026 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.For
|
class For(Stmt):
"""For statement"""
def __init__(self, init: Expr, condition: Expr,
increment: Expr, body: Stmt):
Stmt.__init__(self)
self.init = init
self.condition = condition
self.increment = increment
self.body = body
|
class For(Stmt):
'''For statement'''
def __init__(self, init: Expr, condition: Expr,
increment: Expr, body: Stmt):
pass
| 2 | 1 | 7 | 0 | 7 | 0 | 1 | 0.13 | 1 | 1 | 1 | 0 | 1 | 4 | 1 | 1 | 10 | 1 | 8 | 7 | 5 | 1 | 7 | 6 | 5 | 1 | 2 | 0 | 1 |
146,027 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Dot
|
class Dot(Unary):
"""For . expression"""
|
class Dot(Unary):
'''For . expression'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 4 | 0 | 0 |
146,028 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Cast
|
class Cast(Binary):
"""For cast operator"""
|
class Cast(Binary):
'''For cast operator'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 4 | 0 | 0 |
146,029 |
LionelAuroux/cnorm
|
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LionelAuroux_cnorm/cnorm/type_handling/TypeLang.py
|
cnorm.type_handling.TypeLang.TypeLang
|
class TypeLang(grammar.Grammar):
grammar = """
main ::= [id:id ]+
;
"""
entry = "main"
|
class TypeLang(grammar.Grammar):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 6 | 0 | 6 | 3 | 5 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
146,030 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Case
|
class Case(Branch):
"""Case statement"""
def __init__(self, expr: Expr):
Branch.__init__(self, "case", expr)
|
class Case(Branch):
'''Case statement'''
def __init__(self, expr: Expr):
pass
| 2 | 1 | 2 | 0 | 2 | 0 | 1 | 0.33 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 3 | 5 | 1 | 3 | 2 | 1 | 1 | 3 | 2 | 1 | 1 | 4 | 0 | 1 |
146,031 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Enumerator
|
class Enumerator(parsing.Node):
"""Enumerator A=x in enums"""
def __init__(self, ident: str, expr: Expr):
self.ident = ident
self.expr = expr
|
class Enumerator(parsing.Node):
'''Enumerator A=x in enums'''
def __init__(self, ident: str, expr: Expr):
pass
| 2 | 1 | 3 | 0 | 3 | 0 | 1 | 0.25 | 1 | 2 | 1 | 0 | 1 | 2 | 1 | 1 | 6 | 1 | 4 | 4 | 2 | 1 | 4 | 4 | 2 | 1 | 1 | 0 | 1 |
146,032 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.BlockStmt
|
class BlockStmt(Stmt):
"""Block statement"""
def __init__(self, body: [ExprStmt]):
parsing.Node.__init__(self)
self.body = body
def func(self, name: str):
"""return the first func defined named name"""
for f in self.body:
if (hasattr(f, '_ctype')
and isinstance(f._ctype, FuncType)
and f._name == name):
return f
def var(self, name: str):
"""return the first var instancied named name"""
for f in self.body:
if (hasattr(f, '_ctype')
and not isinstance(f._ctype, FuncType)
and f._name == name):
return f
def type(self, name: str):
"""return the first complete definition of type 'name'"""
for f in self.body:
if (hasattr(f, '_ctype')
and f._ctype._storage == Storages.TYPEDEF
and f._name == name):
return f
def declfuncs(self, name: str):
"""generator on all declaration of function 'name'"""
for f in self.body:
if (hasattr(f, '_ctype')
and isinstance(f._ctype, FuncType)
and f._name == name):
yield f
def declvars(self, name: str):
"""generator on all declaration of variable 'name'"""
for f in self.body:
if (hasattr(f, '_ctype')
and not isinstance(f._ctype, FuncType)
and f._name == name):
yield f
def decltypes(self, name: str):
"""generator on all declaration of type 'name'"""
for f in self.body:
if (hasattr(f, '_ctype')
and f._ctype._storage == Storages.TYPEDEF
and f._name == name):
yield f
def declallfuncs(self):
"""generator on all declaration of function"""
for f in self.body:
if (hasattr(f, '_ctype')
and isinstance(f._ctype, FuncType)):
yield f
def declallvars(self):
"""generator on all declaration of variable"""
for f in self.body:
if (hasattr(f, '_ctype')
and not isinstance(f._ctype, FuncType)):
yield f
def declalltypes(self):
"""generator on all declaration of type"""
for f in self.body:
if (hasattr(f, '_ctype')
and f._ctype._storage == Storages.TYPEDEF):
yield f
|
class BlockStmt(Stmt):
'''Block statement'''
def __init__(self, body: [ExprStmt]):
pass
def func(self, name: str):
'''return the first func defined named name'''
pass
def var(self, name: str):
'''return the first var instancied named name'''
pass
def type(self, name: str):
'''return the first complete definition of type 'name''''
pass
def declfuncs(self, name: str):
'''generator on all declaration of function 'name''''
pass
def declvars(self, name: str):
'''generator on all declaration of variable 'name''''
pass
def decltypes(self, name: str):
'''generator on all declaration of type 'name''''
pass
def declallfuncs(self):
'''generator on all declaration of function'''
pass
def declallvars(self):
'''generator on all declaration of variable'''
pass
def declalltypes(self):
'''generator on all declaration of type'''
pass
| 11 | 10 | 6 | 0 | 5 | 1 | 3 | 0.18 | 1 | 3 | 2 | 1 | 10 | 1 | 10 | 10 | 75 | 10 | 55 | 21 | 44 | 10 | 40 | 21 | 29 | 3 | 2 | 2 | 28 |
146,033 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.BlockInit
|
class BlockInit(Expr):
"""Initializer Block Expression"""
def __init__(self, body: [Expr]):
self.body = body
|
class BlockInit(Expr):
'''Initializer Block Expression'''
def __init__(self, body: [Expr]):
pass
| 2 | 1 | 2 | 0 | 2 | 0 | 1 | 0.33 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 5 | 1 | 3 | 3 | 1 | 1 | 3 | 3 | 1 | 1 | 2 | 0 | 1 |
146,034 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.BlockExpr
|
class BlockExpr(Expr):
"""Compound Block Expression"""
def __init__(self, body: [Expr]):
self.body = body
|
class BlockExpr(Expr):
'''Compound Block Expression'''
def __init__(self, body: [Expr]):
pass
| 2 | 1 | 2 | 0 | 2 | 0 | 1 | 0.33 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 5 | 1 | 3 | 3 | 1 | 1 | 3 | 3 | 1 | 1 | 2 | 0 | 1 |
146,035 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Binary
|
class Binary(Func):
"""For binary operator"""
|
class Binary(Func):
'''For binary operator'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 | 0 | 0 | 0 | 1 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 3 | 0 | 0 |
146,036 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.PrimaryType
|
class PrimaryType(CType):
"""For primary type in declaration"""
def __init__(self, identifier: str):
CType.__init__(self)
# identifier (void, char, int, float, double, typedefname)
self._identifier = identifier
@property
def identifier(self):
return self._identifier
|
class PrimaryType(CType):
'''For primary type in declaration'''
def __init__(self, identifier: str):
pass
@property
def identifier(self):
pass
| 4 | 1 | 3 | 0 | 3 | 1 | 1 | 0.29 | 1 | 1 | 0 | 1 | 2 | 1 | 2 | 6 | 11 | 2 | 7 | 5 | 3 | 2 | 6 | 4 | 3 | 1 | 2 | 0 | 2 |
146,037 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.QualType
|
class QualType(DeclType):
"""For qualifier in declaration"""
def __init__(self, qualifier: Qualifiers=Qualifiers.AUTO):
DeclType.__init__(self)
# qualifier in (auto, const, volatile, restrict)
self._qualifier = qualifier
|
class QualType(DeclType):
'''For qualifier in declaration'''
def __init__(self, qualifier: Qualifiers=Qualifiers.AUTO):
pass
| 2 | 1 | 4 | 0 | 3 | 1 | 1 | 0.5 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 4 | 7 | 1 | 4 | 3 | 2 | 2 | 4 | 3 | 2 | 1 | 2 | 0 | 1 |
146,038 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Range
|
class Range(Binary):
"""For range expression"""
|
class Range(Binary):
'''For range expression'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 4 | 0 | 0 |
146,039 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Raw
|
class Raw(Terminal):
"""Terminal Raw"""
|
class Raw(Terminal):
'''Terminal Raw'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 3 | 0 | 0 |
146,040 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.AttrType
|
class AttrType(DeclType):
"""For attribute specifier in declaration"""
def __init__(self, raw: str):
DeclType.__init__(self)
# fix
self._attr = raw.rstrip(' ')
|
class AttrType(DeclType):
'''For attribute specifier in declaration'''
def __init__(self, raw: str):
pass
| 2 | 1 | 4 | 0 | 3 | 1 | 1 | 0.5 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 4 | 7 | 1 | 4 | 3 | 2 | 2 | 4 | 3 | 2 | 1 | 2 | 0 | 1 |
146,041 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Arrow
|
class Arrow(Unary):
"""For -> expression"""
|
class Arrow(Unary):
'''For -> expression'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 4 | 0 | 0 |
146,042 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.ArrayType
|
class ArrayType(DeclType):
"""For array in declaration"""
def __init__(self, expr=None):
DeclType.__init__(self)
self._expr = expr
@property
def expr(self):
return self._expr
|
class ArrayType(DeclType):
'''For array in declaration'''
def __init__(self, expr=None):
pass
@property
def expr(self):
pass
| 4 | 1 | 3 | 0 | 3 | 0 | 1 | 0.14 | 1 | 0 | 0 | 0 | 2 | 1 | 2 | 5 | 10 | 2 | 7 | 5 | 3 | 1 | 6 | 4 | 3 | 1 | 2 | 0 | 2 |
146,043 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Array
|
class Array(Unary):
"""For [] expression"""
|
class Array(Unary):
'''For [] expression'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 4 | 0 | 0 |
146,044 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Branch
|
class Branch(Label):
"""branch statement"""
def __init__(self, value: str, expr: Expr):
Label.__init__(self, value)
self.expr = expr
|
class Branch(Label):
'''branch statement'''
def __init__(self, value: str, expr: Expr):
pass
| 2 | 1 | 3 | 0 | 3 | 0 | 1 | 0.25 | 1 | 2 | 1 | 3 | 1 | 1 | 1 | 2 | 6 | 1 | 4 | 3 | 2 | 1 | 4 | 3 | 2 | 1 | 3 | 0 | 1 |
146,045 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Goto
|
class Goto(Branch):
"""Goto statement"""
def __init__(self, expr: Expr):
Branch.__init__(self, "goto", expr)
|
class Goto(Branch):
'''Goto statement'''
def __init__(self, expr: Expr):
pass
| 2 | 1 | 2 | 0 | 2 | 0 | 1 | 0.33 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 3 | 5 | 1 | 3 | 2 | 1 | 1 | 3 | 2 | 1 | 1 | 4 | 0 | 1 |
146,046 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Break
|
class Break(LoopControl):
"""break statement"""
def __init__(self):
Label.__init__(self, "break")
|
class Break(LoopControl):
'''break statement'''
def __init__(self):
pass
| 2 | 1 | 2 | 0 | 2 | 0 | 1 | 0.33 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 2 | 5 | 1 | 3 | 2 | 1 | 1 | 3 | 2 | 1 | 1 | 4 | 0 | 1 |
146,047 |
LionelAuroux/cnorm
|
LionelAuroux_cnorm/cnorm/nodes.py
|
cnorm.nodes.Unary
|
class Unary(Func):
"""For unary operator"""
|
class Unary(Func):
'''For unary operator'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 6 | 0 | 0 | 0 | 1 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 3 | 0 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.