hexsha
string | size
int64 | ext
string | lang
string | max_stars_repo_path
string | max_stars_repo_name
string | max_stars_repo_head_hexsha
string | max_stars_repo_licenses
list | max_stars_count
int64 | max_stars_repo_stars_event_min_datetime
string | max_stars_repo_stars_event_max_datetime
string | max_issues_repo_path
string | max_issues_repo_name
string | max_issues_repo_head_hexsha
string | max_issues_repo_licenses
list | max_issues_count
int64 | max_issues_repo_issues_event_min_datetime
string | max_issues_repo_issues_event_max_datetime
string | max_forks_repo_path
string | max_forks_repo_name
string | max_forks_repo_head_hexsha
string | max_forks_repo_licenses
list | max_forks_count
int64 | max_forks_repo_forks_event_min_datetime
string | max_forks_repo_forks_event_max_datetime
string | content
string | avg_line_length
float64 | max_line_length
int64 | alphanum_fraction
float64 | qsc_code_num_words_quality_signal
int64 | qsc_code_num_chars_quality_signal
float64 | qsc_code_mean_word_length_quality_signal
float64 | qsc_code_frac_words_unique_quality_signal
float64 | qsc_code_frac_chars_top_2grams_quality_signal
float64 | qsc_code_frac_chars_top_3grams_quality_signal
float64 | qsc_code_frac_chars_top_4grams_quality_signal
float64 | qsc_code_frac_chars_dupe_5grams_quality_signal
float64 | qsc_code_frac_chars_dupe_6grams_quality_signal
float64 | qsc_code_frac_chars_dupe_7grams_quality_signal
float64 | qsc_code_frac_chars_dupe_8grams_quality_signal
float64 | qsc_code_frac_chars_dupe_9grams_quality_signal
float64 | qsc_code_frac_chars_dupe_10grams_quality_signal
float64 | qsc_code_frac_chars_replacement_symbols_quality_signal
float64 | qsc_code_frac_chars_digital_quality_signal
float64 | qsc_code_frac_chars_whitespace_quality_signal
float64 | qsc_code_size_file_byte_quality_signal
float64 | qsc_code_num_lines_quality_signal
float64 | qsc_code_num_chars_line_max_quality_signal
float64 | qsc_code_num_chars_line_mean_quality_signal
float64 | qsc_code_frac_chars_alphabet_quality_signal
float64 | qsc_code_frac_chars_comments_quality_signal
float64 | qsc_code_cate_xml_start_quality_signal
float64 | qsc_code_frac_lines_dupe_lines_quality_signal
float64 | qsc_code_cate_autogen_quality_signal
float64 | qsc_code_frac_lines_long_string_quality_signal
float64 | qsc_code_frac_chars_string_length_quality_signal
float64 | qsc_code_frac_chars_long_word_length_quality_signal
float64 | qsc_code_frac_lines_string_concat_quality_signal
float64 | qsc_code_cate_encoded_data_quality_signal
float64 | qsc_code_frac_chars_hex_words_quality_signal
float64 | qsc_code_frac_lines_prompt_comments_quality_signal
float64 | qsc_code_frac_lines_assert_quality_signal
float64 | qsc_codepython_cate_ast_quality_signal
float64 | qsc_codepython_frac_lines_func_ratio_quality_signal
float64 | qsc_codepython_cate_var_zero_quality_signal
bool | qsc_codepython_frac_lines_pass_quality_signal
float64 | qsc_codepython_frac_lines_import_quality_signal
float64 | qsc_codepython_frac_lines_simplefunc_quality_signal
float64 | qsc_codepython_score_lines_no_logic_quality_signal
float64 | qsc_codepython_frac_lines_print_quality_signal
float64 | qsc_code_num_words
int64 | qsc_code_num_chars
int64 | qsc_code_mean_word_length
int64 | qsc_code_frac_words_unique
null | qsc_code_frac_chars_top_2grams
int64 | qsc_code_frac_chars_top_3grams
int64 | qsc_code_frac_chars_top_4grams
int64 | qsc_code_frac_chars_dupe_5grams
int64 | qsc_code_frac_chars_dupe_6grams
int64 | qsc_code_frac_chars_dupe_7grams
int64 | qsc_code_frac_chars_dupe_8grams
int64 | qsc_code_frac_chars_dupe_9grams
int64 | qsc_code_frac_chars_dupe_10grams
int64 | qsc_code_frac_chars_replacement_symbols
int64 | qsc_code_frac_chars_digital
int64 | qsc_code_frac_chars_whitespace
int64 | qsc_code_size_file_byte
int64 | qsc_code_num_lines
int64 | qsc_code_num_chars_line_max
int64 | qsc_code_num_chars_line_mean
int64 | qsc_code_frac_chars_alphabet
int64 | qsc_code_frac_chars_comments
int64 | qsc_code_cate_xml_start
int64 | qsc_code_frac_lines_dupe_lines
int64 | qsc_code_cate_autogen
int64 | qsc_code_frac_lines_long_string
int64 | qsc_code_frac_chars_string_length
int64 | qsc_code_frac_chars_long_word_length
int64 | qsc_code_frac_lines_string_concat
null | qsc_code_cate_encoded_data
int64 | qsc_code_frac_chars_hex_words
int64 | qsc_code_frac_lines_prompt_comments
int64 | qsc_code_frac_lines_assert
int64 | qsc_codepython_cate_ast
int64 | qsc_codepython_frac_lines_func_ratio
int64 | qsc_codepython_cate_var_zero
int64 | qsc_codepython_frac_lines_pass
int64 | qsc_codepython_frac_lines_import
int64 | qsc_codepython_frac_lines_simplefunc
int64 | qsc_codepython_score_lines_no_logic
int64 | qsc_codepython_frac_lines_print
int64 | effective
string | hits
int64 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
91d97cda08bef294f6e5eb09e042176be366d2d9
| 21
|
py
|
Python
|
virtual/lib/python3.6/site-packages/pip/_vendor/msgpack/_version.py
|
Lornakimani62/IP4-_One-Minute-Pitch
|
cabd4c9a2fc726f37fc98c5de561f3d86c6c66f9
|
[
"MIT"
] | 548
|
2020-09-20T10:31:50.000Z
|
2022-03-31T06:18:04.000Z
|
virtual/lib/python3.6/site-packages/pip/_vendor/msgpack/_version.py
|
Lornakimani62/IP4-_One-Minute-Pitch
|
cabd4c9a2fc726f37fc98c5de561f3d86c6c66f9
|
[
"MIT"
] | 24
|
2020-06-23T13:59:30.000Z
|
2022-03-08T23:26:34.000Z
|
virtual/lib/python3.6/site-packages/pip/_vendor/msgpack/_version.py
|
Lornakimani62/IP4-_One-Minute-Pitch
|
cabd4c9a2fc726f37fc98c5de561f3d86c6c66f9
|
[
"MIT"
] | 216
|
2020-09-20T12:57:26.000Z
|
2022-03-20T14:07:04.000Z
|
version = (0, 5, 6)
| 10.5
| 20
| 0.47619
| 4
| 21
| 2.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.2
| 0.285714
| 21
| 1
| 21
| 21
| 0.466667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
530d30b4e4fa12ecf98a630e6c3daa90b12e18f3
| 169
|
py
|
Python
|
Hip/Kernels/Costs.py
|
EmilPi/PuzzleLib
|
31aa0fab3b5e9472b9b9871ca52e4d94ea683fa9
|
[
"Apache-2.0"
] | 52
|
2020-02-28T20:40:15.000Z
|
2021-08-25T05:35:17.000Z
|
Hip/Kernels/Costs.py
|
EmilPi/PuzzleLib
|
31aa0fab3b5e9472b9b9871ca52e4d94ea683fa9
|
[
"Apache-2.0"
] | 2
|
2021-02-14T15:57:03.000Z
|
2021-10-05T12:21:34.000Z
|
Hip/Kernels/Costs.py
|
EmilPi/PuzzleLib
|
31aa0fab3b5e9472b9b9871ca52e4d94ea683fa9
|
[
"Apache-2.0"
] | 8
|
2020-02-28T20:40:11.000Z
|
2020-07-09T13:27:23.000Z
|
from PuzzleLib.Cuda.Kernels.Costs import backendTest
def unittest():
from PuzzleLib.Hip import Backend
backendTest(Backend)
if __name__ == "__main__":
unittest()
| 15.363636
| 52
| 0.769231
| 20
| 169
| 6.1
| 0.7
| 0.213115
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.136095
| 169
| 10
| 53
| 16.9
| 0.835616
| 0
| 0
| 0
| 0
| 0
| 0.047337
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.166667
| true
| 0
| 0.333333
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
533d9155dbee219bb141780807782a1f3325b888
| 12,422
|
py
|
Python
|
suitcase/nxsas/tests/test_nexus_md_to_nexus_h5.py
|
jklynch/suitcase-sas
|
914572806f47f7a3a373755e772eafc45a9c3dd4
|
[
"BSD-3-Clause"
] | 1
|
2021-07-30T11:03:26.000Z
|
2021-07-30T11:03:26.000Z
|
suitcase/nxsas/tests/test_nexus_md_to_nexus_h5.py
|
jklynch/suitcase-sas
|
914572806f47f7a3a373755e772eafc45a9c3dd4
|
[
"BSD-3-Clause"
] | 2
|
2020-07-02T18:22:06.000Z
|
2020-12-02T16:38:52.000Z
|
suitcase/nxsas/tests/test_nexus_md_to_nexus_h5.py
|
jklynch/suitcase-sas
|
914572806f47f7a3a373755e772eafc45a9c3dd4
|
[
"BSD-3-Clause"
] | 3
|
2020-06-07T13:54:13.000Z
|
2020-08-10T13:36:28.000Z
|
from pathlib import Path
import h5py
from suitcase.nxsas import _copy_nexus_md_to_nexus_h5
def test_group_with_attributes(tmp_path):
md = {"entry": {"_attributes": {"NX_Class": "NXEntry", "default": "data"}}}
filepath = tmp_path / Path("test.h5")
with h5py.File(filepath, "w") as f:
_copy_nexus_md_to_nexus_h5(nexus_md=md, h5_group_or_dataset=f)
with h5py.File(filepath, "r") as f:
# expect this structure:
# /<group "entry">
# <attr "NX_Class": "NXEntry">
# <attr "default": "data">
assert len(f) == 1
assert "entry" in f
assert len(f["entry"].attrs) == 2
assert f["entry"].attrs["NX_Class"] == "NXEntry"
assert f["entry"].attrs["default"] == "data"
def test_group_with_dataset(tmp_path):
md = {
"entry": {
"_attributes": {"NX_Class": "NXEntry", "default": "data"},
"program_name": "EPICS areaDetector",
}
}
filepath = tmp_path / Path("test.h5")
with h5py.File(filepath, "w") as f:
_copy_nexus_md_to_nexus_h5(nexus_md=md, h5_group_or_dataset=f)
with h5py.File(filepath, "r") as f:
# expect this structure:
# /<group "entry">
# <attr "NX_Class": "NXEntry">
# <attr "default": "data">
# <dataset "program_name": "EPICS areaDetector">
assert len(f) == 1
assert "entry" in f
assert len(f["entry"].attrs) == 2
assert f["entry"].attrs["NX_Class"] == "NXEntry"
assert f["entry"].attrs["default"] == "data"
assert "program_name" in f["entry"]
assert isinstance(f["entry"]["program_name"], h5py.Dataset)
assert f["entry"]["program_name"][()] == "EPICS areaDetector"
def test_group_with_dataset_link(tmp_path):
md = {
"entry": {
"_attributes": {"NX_Class": "NXEntry", "default": "data"},
"GUPNumber": "#bluesky/start/gup_number",
}
}
filepath = tmp_path / Path("test.h5")
with h5py.File(filepath, "w") as f:
# create a target dataset for #bluesky/start/gup_number
f.create_group("bluesky").create_group("start").create_dataset(
name="gup_number", data=1
)
_copy_nexus_md_to_nexus_h5(nexus_md=md, h5_group_or_dataset=f)
with h5py.File(filepath, "r") as f:
# expect this structure:
# /<group "bluesky">
# <group "start">
# <dataset "gup_number": 1>
# /<group "entry">
# <attr "NX_Class": "NXEntry">
# <attr "default": "data">
# <link "GUPNumber" <dataset bluesky/start/gup_number>>
assert len(f) == 2
assert "bluesky" in f
assert "start" in f["bluesky"]
assert "gup_number" in f["bluesky"]["start"]
assert f["bluesky"]["start"]["gup_number"][()] == 1
assert "entry" in f
assert len(f["entry"].attrs) == 2
assert f["entry"].attrs["NX_Class"] == "NXEntry"
assert f["entry"].attrs["default"] == "data"
assert "GUPNumber" in f["entry"]
assert isinstance(f["entry"]["GUPNumber"], h5py.Dataset)
assert f["entry"]["GUPNumber"][()] == 1
assert f["entry"]["GUPNumber"] == f["bluesky"]["start"]["gup_number"]
def test_dataset_with_attributes(tmp_path):
md = {
"entry": {
"_attributes": {"NX_Class": "NXEntry", "default": "data"},
"GUPNumber": {
"_attributes": {
"NDAttrDescription": "GUP proposal number",
"NDAttrName": "GUPNumber",
},
"_data": 123,
},
"ProgramName": {
"_attributes": {
"NDAttrDescription": "Program Name",
"NDAttrName": "ProgramName",
},
"_data": "the name of the program",
},
}
}
filepath = tmp_path / Path("test.h5")
with h5py.File(filepath, "w") as f:
_copy_nexus_md_to_nexus_h5(nexus_md=md, h5_group_or_dataset=f)
with h5py.File(filepath, "r") as f:
# expect this structure:
# /<group "entry">
# <attr "NX_Class": "NXEntry">
# <attr "default": "data">
# <dataset "GUPNumber" <123>>
# <attr "NDAttrDescription": "GUP proposal number">
# <attr "NDAttrName": "GUPNumber">
# <dataset "ProgramName" <"the name of the program">>
# <attr "NDAttrDescription": "Program Name">
# <attr "NDAttrName": "ProgramName">
assert len(f) == 1
# assert "bluesky" in f
# assert "start" in f["bluesky"]
# assert "gup_number" in f["bluesky"]["start"]
# assert f["bluesky"]["start"]["gup_number"][()] == 123
assert "entry" in f
assert len(f["entry"].attrs) == 2
assert f["entry"].attrs["NX_Class"] == "NXEntry"
assert f["entry"].attrs["default"] == "data"
assert "GUPNumber" in f["entry"]
assert isinstance(f["entry"]["GUPNumber"], h5py.Dataset)
assert f["entry"]["GUPNumber"][()] == 123
assert len(f["entry"]["GUPNumber"].attrs) == 2
assert (
f["entry"]["GUPNumber"].attrs["NDAttrDescription"] == "GUP proposal number"
)
assert f["entry"]["GUPNumber"].attrs["NDAttrName"] == "GUPNumber"
assert "ProgramName" in f["entry"]
assert isinstance(f["entry"]["ProgramName"], h5py.Dataset)
assert f["entry"]["ProgramName"][()] == "the name of the program"
assert len(f["entry"]["ProgramName"].attrs) == 2
assert f["entry"]["ProgramName"].attrs["NDAttrDescription"] == "Program Name"
assert f["entry"]["ProgramName"].attrs["NDAttrName"] == "ProgramName"
def test_dataset_link_with_attributes(tmp_path):
md = {
"entry": {
"_attributes": {"NX_Class": "NXEntry", "default": "data"},
"GUPNumber": {
"_attributes": {
"NDAttrDescription": "GUP proposal number",
"NDAttrName": "GUPNumber",
"NDAttrSource": "91dcLAX:GUPNumber",
"NDAttrSourceType": "NDAttrSourceEPICSPV",
},
"_link": "#bluesky/start/gup_number",
},
}
}
filepath = tmp_path / Path("test.h5")
with h5py.File(filepath, "w") as f:
# create a target dataset for #bluesky/start/gup_number
f.create_group("bluesky").create_group("start").create_dataset(
name="gup_number", data=1
)
_copy_nexus_md_to_nexus_h5(nexus_md=md, h5_group_or_dataset=f)
with h5py.File(filepath, "r") as f:
# expect this structure:
# /<group "bluesky">
# <group "start">
# <dataset "gup_number": 1>
# /<group "entry">
# <attr "NX_Class": "NXEntry">
# <attr "default": "data">
# <link "GUPNumber" <dataset bluesky/start/gup_number>>
# <attr "NDAttrDescription": "GUP proposal number">
# <attr "NDAttrName": "GUPNumber">
# <attr "NDAttrSource": "91dcLAX:GUPNumber">
# <attr "NDAttrSourceType": "NDAttrSourceEPICSPV">
assert len(f) == 2
assert "bluesky" in f
assert "start" in f["bluesky"]
assert "gup_number" in f["bluesky"]["start"]
assert f["bluesky"]["start"]["gup_number"][()] == 1
assert "entry" in f
assert len(f["entry"].attrs) == 2
assert f["entry"].attrs["NX_Class"] == "NXEntry"
assert f["entry"].attrs["default"] == "data"
assert "GUPNumber" in f["entry"]
assert isinstance(f["entry"]["GUPNumber"], h5py.Dataset)
assert f["entry"]["GUPNumber"][()] == 1
assert f["entry"]["GUPNumber"] == f["bluesky"]["start"]["gup_number"]
assert len(f["entry"]["GUPNumber"].attrs) == 4
assert (
f["entry"]["GUPNumber"].attrs["NDAttrDescription"] == "GUP proposal number"
)
assert f["entry"]["GUPNumber"].attrs["NDAttrName"] == "GUPNumber"
assert f["entry"]["GUPNumber"].attrs["NDAttrSource"] == "91dcLAX:GUPNumber"
assert (
f["entry"]["GUPNumber"].attrs["NDAttrSourceType"] == "NDAttrSourceEPICSPV"
)
def test_group_with_subgroup(tmp_path):
md = {
"entry": {
"_attributes": {"NX_Class": "NXEntry", "default": "data"},
"instrument": {
"_attributes": {"NX_Class": "NXInstrument"},
"name_1": "#bluesky/start/beamline_id",
"name_2": {
"_attributes": {"NX_This": "NXThat"},
"_link": "#bluesky/start/beamline_id",
},
},
},
}
filepath = tmp_path / Path("test.h5")
with h5py.File(filepath, "w") as f:
# create a target dataset for #bluesky/start/gup_number
f.create_group("bluesky").create_group("start").create_dataset(
name="beamline_id", data="RSOXS"
)
_copy_nexus_md_to_nexus_h5(nexus_md=md, h5_group_or_dataset=f)
with h5py.File(filepath, "r") as f:
# expect this structure:
# /<group "bluesky">
# <group "start">
# <dataset "gup_number": 1>
# /<group "entry">
# <attr "NX_Class": "NXEntry">
# <attr "default": "data">
# <dataset "name_1": "">
# <link "GUPNumber" <dataset bluesky/start/gup_number>>
# <attr "NDAttrDescription": "GUP proposal number">
# <attr "NDAttrName": "GUPNumber">
# <attr "NDAttrSource": "91dcLAX:GUPNumber">
# <attr "NDAttrSourceType": "NDAttrSourceEPICSPV">
assert len(f) == 2
def test(tmp_path):
md = {
"techniques": [
# SAXS technique
{
"version": 1,
"technique": "SAXS",
"nxsas": {
"entry": {
"_attributes": {"NX_Class": "NXEntry", "default": "data"},
"instrument": {
"_attributes": {"NX_Class": "NXInstrument"},
"name": "#bluesky/start/beamline_id",
"aperture": {
"_attributes": {"NX_Class": "NXAperture"},
"vcenter": 1.0,
"vsize": 2.0,
"description": "USAXSslit",
},
},
},
},
},
# more techniques ...
]
}
filepath = tmp_path / Path("test.h5")
with h5py.File(filepath, "w") as f:
f.create_group("bluesky").create_group("start").create_dataset(
name="beamline_id", data="SST-1 RSoXS"
)
_copy_nexus_md_to_nexus_h5(
nexus_md=md["techniques"][0]["nxsas"], h5_group_or_dataset=f
)
with h5py.File(filepath, "r") as f:
print(list(f))
assert "entry" in f
print(list(f["entry"]))
entry_h5_group = f["entry"]
assert len(entry_h5_group.attrs) == 2
assert entry_h5_group.attrs["NX_Class"] == "NXEntry"
assert entry_h5_group.attrs["default"] == "data"
assert "instrument" in entry_h5_group
assert len(entry_h5_group["instrument"].attrs) == 1
assert entry_h5_group["instrument"].attrs["NX_Class"] == "NXInstrument"
# what does [()] mean?
print(entry_h5_group["instrument"]["name"])
assert entry_h5_group["instrument"]["name"][()] == "SST-1 RSoXS"
assert "aperture" in entry_h5_group["instrument"]
assert len(entry_h5_group["instrument"]["aperture"].attrs) == 1
assert (
entry_h5_group["instrument"]["aperture"].attrs["NX_Class"] == "NXAperture"
)
assert entry_h5_group["instrument"]["aperture"]["vcenter"][()] == 1.0
assert entry_h5_group["instrument"]["aperture"]["vsize"][()] == 2.0
assert (
entry_h5_group["instrument"]["aperture"]["description"][()] == "USAXSslit"
)
| 37.303303
| 87
| 0.518194
| 1,264
| 12,422
| 4.911392
| 0.074367
| 0.043492
| 0.048325
| 0.045103
| 0.818782
| 0.765786
| 0.717139
| 0.68299
| 0.673164
| 0.673164
| 0
| 0.013989
| 0.320963
| 12,422
| 332
| 88
| 37.415663
| 0.721992
| 0.181211
| 0
| 0.526786
| 0
| 0
| 0.253934
| 0.012667
| 0
| 0
| 0
| 0
| 0.339286
| 1
| 0.03125
| false
| 0
| 0.013393
| 0
| 0.044643
| 0.013393
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
53599f8db4090affbf3e4921c814fe363174c5e1
| 786
|
py
|
Python
|
matching/admin.py
|
popara/jonny-api
|
29d90c2c7bb6ac70e91bbaa7aad026d5d9229c55
|
[
"MIT"
] | null | null | null |
matching/admin.py
|
popara/jonny-api
|
29d90c2c7bb6ac70e91bbaa7aad026d5d9229c55
|
[
"MIT"
] | null | null | null |
matching/admin.py
|
popara/jonny-api
|
29d90c2c7bb6ac70e91bbaa7aad026d5d9229c55
|
[
"MIT"
] | null | null | null |
from django.contrib import admin
# from models import Agent, ReCa, Accomodation, Beach, Activity, Contact
#
# @admin.register(ReCa, Activity)
# class VenueAdmin(admin.ModelAdmin):
# list_display = ('name', 'internal_rating', 'ready', 'description',)
# list_filter = ('ready', 'internal_rating',)
# search_fields = ['name', 'description', 'address']
# ordering = ['id']
# save_on_top = True
#
#
# @admin.register(Accomodation)
# class AccomodAdmin(VenueAdmin):
# list_display = ('name', 'stars', 'ready', 'description',)
# list_filter = ('ready', 'stars',)
#
#
# @admin.register(Beach)
# class BeachAdmin(admin.ModelAdmin):
# list_display = ('name', 'type', 'description',)
# list_filter = ('name',)
#
#
# admin.site.register(Agent)
# admin.site.register(Contact)
#
#
| 27.103448
| 73
| 0.671756
| 84
| 786
| 6.154762
| 0.452381
| 0.075435
| 0.087041
| 0.10058
| 0.235977
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.139949
| 786
| 28
| 74
| 28.071429
| 0.764793
| 0.888041
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
535e6fba829bb11435055310a814e14d310c9d0c
| 9,636
|
py
|
Python
|
threeML/test/test_spectrum_class.py
|
cescalara/threeML
|
4ac90d91159f5469d3ea90456901f46ba4a2d533
|
[
"BSD-3-Clause"
] | 2
|
2019-05-15T21:13:54.000Z
|
2022-03-15T14:43:11.000Z
|
threeML/test/test_spectrum_class.py
|
henrikef/3ML
|
dd118a106a01f52029da05585fe29affb85b570c
|
[
"BSD-3-Clause"
] | null | null | null |
threeML/test/test_spectrum_class.py
|
henrikef/3ML
|
dd118a106a01f52029da05585fe29affb85b570c
|
[
"BSD-3-Clause"
] | null | null | null |
from __future__ import division
from past.utils import old_div
import numpy as np
import os
import pytest
from astromodels import Powerlaw, PointSource, Model
from threeML.plugins.DispersionSpectrumLike import DispersionSpectrumLike
from threeML.plugins.SpectrumLike import SpectrumLike
from threeML.utils.OGIP.response import OGIPResponse
from threeML.utils.spectrum.binned_spectrum import (
BinnedSpectrum,
BinnedSpectrumWithDispersion,
ChannelSet,
)
from .conftest import get_test_datasets_directory
@pytest.fixture(scope="module")
def loaded_response():
rsp = OGIPResponse(
os.path.join(
get_test_datasets_directory(),
"bn090217206",
"bn090217206_n6_weightedrsp.rsp",
)
)
return rsp
def test_spectrum_constructor():
ebounds = ChannelSet.from_list_of_edges(np.array([1, 2, 3, 4, 5, 6]))
pl = Powerlaw()
ps = PointSource("fake", 0, 0, spectral_shape=pl)
model = Model(ps)
obs_spectrum = BinnedSpectrum(
counts=np.ones(len(ebounds)), exposure=1, ebounds=ebounds, is_poisson=True
)
bkg_spectrum = BinnedSpectrum(
counts=np.ones(len(ebounds)), exposure=1, ebounds=ebounds, is_poisson=True
)
assert np.all(obs_spectrum.counts == obs_spectrum.rates)
assert np.all(bkg_spectrum.counts == bkg_spectrum.rates)
specLike = SpectrumLike("fake", observation=obs_spectrum, background=bkg_spectrum)
specLike.set_model(model)
specLike.get_model()
specLike.get_simulated_dataset()
specLike.rebin_on_background(min_number_of_counts=1e-1)
specLike.remove_rebinning()
specLike.significance
specLike.significance_per_channel
obs_spectrum = BinnedSpectrum(
counts=np.ones(len(ebounds)),
count_errors=np.ones(len(ebounds)),
exposure=1,
ebounds=ebounds,
is_poisson=False,
)
bkg_spectrum = BinnedSpectrum(
counts=np.ones(len(ebounds)), exposure=1, ebounds=ebounds, is_poisson=True
)
with pytest.raises(NotImplementedError):
specLike = SpectrumLike(
"fake", observation=obs_spectrum, background=bkg_spectrum
)
# gaussian source only
obs_spectrum = BinnedSpectrum(
counts=np.ones(len(ebounds)),
count_errors=np.ones(len(ebounds)),
exposure=1,
ebounds=ebounds,
)
specLike = SpectrumLike("fake", observation=obs_spectrum, background=None)
specLike.set_model(model)
specLike.get_model()
specLike.get_simulated_dataset()
with pytest.raises(AssertionError):
specLike.rebin_on_background(min_number_of_counts=1e-1)
def test_spectrum_constructor_no_background():
ebounds = ChannelSet.from_list_of_edges(np.array([0, 1, 2, 3, 4, 5]))
obs_spectrum = BinnedSpectrum(
counts=np.ones(len(ebounds)), exposure=1, ebounds=ebounds, is_poisson=True
)
assert np.all(obs_spectrum.counts == obs_spectrum.rates)
specLike = SpectrumLike("fake", observation=obs_spectrum, background=None)
specLike.__repr__()
def addition_proof_simple(x, y, z):
assert x.counts[3] + y.counts[3] == z.counts[3]
def addition_proof_weighted(x, y, z):
assert old_div(
(
old_div(x.rates[3], x.rate_errors[3] ** 2)
+ old_div(y.rates[3], y.rate_errors[3] ** 2)
),
(old_div(1, x.rate_errors[3] ** 2) + old_div(1, y.rate_errors[3] ** 2)),
) == old_div(z.rates[3], z.exposure)
def spectrum_addition(
obs_spectrum_1, obs_spectrum_2, obs_spectrum_incompatible, addition, addition_proof
):
obs_spectrum = addition(obs_spectrum_1, obs_spectrum_2)
addition_proof(obs_spectrum_1, obs_spectrum_2, obs_spectrum)
assert obs_spectrum_1.exposure + obs_spectrum_2.exposure == obs_spectrum.exposure
assert np.all(obs_spectrum.counts == obs_spectrum.rates * obs_spectrum.exposure)
specLike = SpectrumLike("fake", observation=obs_spectrum, background=None)
assert (
obs_spectrum.count_errors is None
or obs_spectrum.count_errors.__class__ == np.ndarray
)
specLike.__repr__()
def test_spectrum_addition():
ebounds = ChannelSet.from_list_of_edges(np.array([0, 1, 2, 3, 4, 5]))
ebounds_different = ChannelSet.from_list_of_edges(np.array([0, 1, 2, 3, 4, 5]))
obs_spectrum_1 = BinnedSpectrum(
counts=np.ones(len(ebounds)),
count_errors=np.ones(len(ebounds)),
exposure=1,
ebounds=ebounds,
is_poisson=False,
)
obs_spectrum_2 = BinnedSpectrum(
counts=np.ones(len(ebounds)),
count_errors=np.ones(len(ebounds)),
exposure=2,
ebounds=ebounds,
is_poisson=False,
)
obs_spectrum_incompatible = BinnedSpectrum(
counts=np.ones(len(ebounds)),
count_errors=np.ones(len(ebounds)),
exposure=2,
ebounds=ebounds_different,
is_poisson=False,
)
spectrum_addition(
obs_spectrum_1,
obs_spectrum_2,
obs_spectrum_incompatible,
lambda x, y: x + y,
addition_proof_simple,
)
spectrum_addition(
obs_spectrum_1,
obs_spectrum_2,
obs_spectrum_incompatible,
lambda x, y: x.add_inverse_variance_weighted(y),
addition_proof_weighted,
)
def test_spectrum_addition_poisson():
ebounds = ChannelSet.from_list_of_edges(np.array([0, 1, 2, 3, 4, 5]))
ebounds_different = ChannelSet.from_list_of_edges(np.array([0, 1, 2, 3, 4, 5]))
obs_spectrum_1 = BinnedSpectrum(
counts=np.ones(len(ebounds)), exposure=1, ebounds=ebounds, is_poisson=True
)
obs_spectrum_2 = BinnedSpectrum(
counts=np.ones(len(ebounds)), exposure=2, ebounds=ebounds, is_poisson=True
)
obs_spectrum_incompatible = BinnedSpectrum(
counts=np.ones(len(ebounds_different)),
exposure=2,
ebounds=ebounds,
is_poisson=True,
)
spectrum_addition(
obs_spectrum_1,
obs_spectrum_2,
obs_spectrum_incompatible,
lambda x, y: x + y,
addition_proof_simple,
)
# spectrum_addition(obs_spectrum_1,obs_spectrum_2,obs_spectrum_incompatible,lambda x,y:x.add_inverse_variance_weighted(y))
def test_spectrum_clone():
ebounds = ChannelSet.from_list_of_edges(np.array([0, 1, 2, 3, 4, 5]))
obs_spectrum = BinnedSpectrum(
counts=np.ones(len(ebounds)),
count_errors=np.ones(len(ebounds)),
exposure=1,
ebounds=ebounds,
is_poisson=False,
)
obs_spectrum.clone(
new_counts=np.zeros_like(obs_spectrum.counts),
new_count_errors=np.zeros_like(obs_spectrum.counts),
)
obs_spectrum.clone()
def test_dispersion_spectrum_constructor(loaded_response):
rsp = loaded_response
pl = Powerlaw()
ps = PointSource("fake", 0, 0, spectral_shape=pl)
model = Model(ps)
obs_spectrum = BinnedSpectrumWithDispersion(
counts=np.ones(128), exposure=1, response=rsp, is_poisson=True
)
bkg_spectrum = BinnedSpectrumWithDispersion(
counts=np.ones(128), exposure=1, response=rsp, is_poisson=True
)
specLike = DispersionSpectrumLike(
"fake", observation=obs_spectrum, background=bkg_spectrum
)
specLike.set_model(model)
specLike.get_model()
specLike.write_pha("test_from_dispersion", overwrite=True)
assert os.path.exists("test_from_dispersion.pha")
assert os.path.exists("test_from_dispersion_bak.pha")
os.remove("test_from_dispersion.pha")
os.remove("test_from_dispersion_bak.pha")
def test_dispersion_spectrum_addition_poisson(loaded_response):
rsp = loaded_response
ebounds = ChannelSet.from_instrument_response(rsp)
obs_spectrum_1 = BinnedSpectrumWithDispersion(
counts=np.ones(len(ebounds)), exposure=1, response=rsp, is_poisson=True
)
obs_spectrum_2 = BinnedSpectrumWithDispersion(
counts=np.ones(len(ebounds)), exposure=2, response=rsp, is_poisson=True
)
obs_spectrum_incompatible = None
spectrum_addition(
obs_spectrum_1,
obs_spectrum_2,
obs_spectrum_incompatible,
lambda x, y: x + y,
addition_proof_simple,
)
# spectrum_addition(obs_spectrum_1,obs_spectrum_2,obs_spectrum_incompatible,lambda x,y:x.add_inverse_variance_weighted(y),addition_proof_weighted)
def test_dispersion_spectrum_addition(loaded_response):
rsp = loaded_response
ebounds = ChannelSet.from_instrument_response(rsp)
obs_spectrum_1 = BinnedSpectrumWithDispersion(
counts=np.ones(len(ebounds)),
count_errors=np.ones(len(ebounds)),
exposure=1,
response=rsp,
is_poisson=False,
)
obs_spectrum_2 = BinnedSpectrumWithDispersion(
counts=np.ones(len(ebounds)),
count_errors=np.ones(len(ebounds)),
exposure=2,
response=rsp,
is_poisson=False,
)
obs_spectrum_incompatible = None
spectrum_addition(
obs_spectrum_1,
obs_spectrum_2,
obs_spectrum_incompatible,
lambda x, y: x + y,
addition_proof_simple,
)
spectrum_addition(
obs_spectrum_1,
obs_spectrum_2,
obs_spectrum_incompatible,
lambda x, y: x.add_inverse_variance_weighted(y),
addition_proof_weighted,
)
def test_dispersion_spectrum_clone(loaded_response):
rsp = loaded_response
obs_spectrum = BinnedSpectrumWithDispersion(
counts=np.ones(128), exposure=1, response=rsp, is_poisson=True
)
obs_spectrum.clone(
new_counts=np.zeros_like(obs_spectrum.counts), new_count_errors=None
)
obs_spectrum.clone()
| 28.175439
| 150
| 0.688045
| 1,185
| 9,636
| 5.30211
| 0.11308
| 0.134808
| 0.035811
| 0.063664
| 0.776699
| 0.755849
| 0.742161
| 0.708897
| 0.681203
| 0.609741
| 0
| 0.019213
| 0.211395
| 9,636
| 341
| 151
| 28.258065
| 0.807606
| 0.02968
| 0
| 0.570313
| 0
| 0
| 0.021721
| 0.014338
| 0
| 0
| 0
| 0
| 0.042969
| 1
| 0.050781
| false
| 0
| 0.042969
| 0
| 0.097656
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
7267831b1922a6c15b38b981b6a1a43bef66f2d6
| 264
|
py
|
Python
|
src/quill/scan/lever/mmd.py
|
spin-systems/quill
|
b210f840e228295e41feaf4ff79f2cc8bd96889d
|
[
"MIT"
] | null | null | null |
src/quill/scan/lever/mmd.py
|
spin-systems/quill
|
b210f840e228295e41feaf4ff79f2cc8bd96889d
|
[
"MIT"
] | 14
|
2020-11-22T09:59:08.000Z
|
2021-11-02T16:05:35.000Z
|
src/quill/scan/lever/mmd.py
|
spin-systems/quill
|
b210f840e228295e41feaf4ff79f2cc8bd96889d
|
[
"MIT"
] | null | null | null |
from .parser import Doc
__all__ = ["MMD"]
class MMD(Doc):
def __init__(self, mmd_lines, listparseconfig=None):
super().__init__(mmd_lines, listparseconfig=listparseconfig)
def __repr__(self):
return f"Parsed MMD file ({self._doc_repr})"
| 24
| 68
| 0.693182
| 33
| 264
| 4.939394
| 0.575758
| 0.09816
| 0.282209
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.185606
| 264
| 10
| 69
| 26.4
| 0.75814
| 0
| 0
| 0
| 0
| 0
| 0.140152
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.285714
| false
| 0
| 0.142857
| 0.142857
| 0.714286
| 0
| 0
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
728382ace78f1434cbcd5025da3a2f9dbac9fc77
| 274
|
py
|
Python
|
tutorial/interactive.py
|
Felalex57/har2tree
|
5ae851c6f4a6f764447865198e6ed9f6008ea738
|
[
"BSD-3-Clause"
] | 2
|
2020-09-14T05:19:18.000Z
|
2021-01-30T05:15:22.000Z
|
tutorial/interactive.py
|
Felalex57/har2tree
|
5ae851c6f4a6f764447865198e6ed9f6008ea738
|
[
"BSD-3-Clause"
] | 106
|
2020-06-08T12:31:41.000Z
|
2022-03-29T19:19:52.000Z
|
tutorial/interactive.py
|
Felalex57/har2tree
|
5ae851c6f4a6f764447865198e6ed9f6008ea738
|
[
"BSD-3-Clause"
] | 2
|
2020-09-27T17:22:06.000Z
|
2021-04-21T14:06:51.000Z
|
from pathlib import Path
import uuid
from har2tree import CrawledTree
har_path = Path() / 'tests' / 'capture_samples' / 'http_redirect' / '0.har'
my_first_crawled_tree = CrawledTree([har_path], str(uuid.uuid4()))
my_first_crawled_tree.root_hartree.rendered_node.show()
| 45.666667
| 77
| 0.770073
| 39
| 274
| 5.102564
| 0.641026
| 0.140704
| 0.180905
| 0.180905
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.012346
| 0.113139
| 274
| 6
| 78
| 45.666667
| 0.806584
| 0
| 0
| 0
| 0
| 0
| 0.140741
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 0.5
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
72c4516c4e5a90c975bc15e081922f802c55480c
| 166
|
py
|
Python
|
data_api/cli_tasks/install.py
|
andre487/sms487
|
c93fe49d0bb8a0ba74f6f999710e040be36c1cbb
|
[
"MIT"
] | 3
|
2018-04-03T21:18:29.000Z
|
2020-12-28T09:13:30.000Z
|
data_api/cli_tasks/install.py
|
andre487/sms487
|
c93fe49d0bb8a0ba74f6f999710e040be36c1cbb
|
[
"MIT"
] | 1
|
2021-04-06T18:24:01.000Z
|
2021-04-06T18:24:01.000Z
|
data_api/cli_tasks/install.py
|
andre487/sms487
|
c93fe49d0bb8a0ba74f6f999710e040be36c1cbb
|
[
"MIT"
] | 1
|
2018-03-19T10:24:35.000Z
|
2018-03-19T10:24:35.000Z
|
from . import common
def run(c, rebuild_venv, packages):
common.prepare_virtual_env(c, rebuild_venv)
c.run(f'{common.PYTHON} -m pip install -U {packages}')
| 23.714286
| 58
| 0.710843
| 26
| 166
| 4.384615
| 0.692308
| 0.140351
| 0.210526
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.156627
| 166
| 6
| 59
| 27.666667
| 0.814286
| 0
| 0
| 0
| 0
| 0
| 0.26506
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.25
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
72e1ea9a32c2992191237f3c91eae0941fc370b9
| 54
|
py
|
Python
|
Problem172.py
|
Cleancode404/ProjectEuler
|
2f93b256b107bfb6a395b8aa197cfeacc599b00b
|
[
"MIT"
] | null | null | null |
Problem172.py
|
Cleancode404/ProjectEuler
|
2f93b256b107bfb6a395b8aa197cfeacc599b00b
|
[
"MIT"
] | null | null | null |
Problem172.py
|
Cleancode404/ProjectEuler
|
2f93b256b107bfb6a395b8aa197cfeacc599b00b
|
[
"MIT"
] | null | null | null |
"""
Investigating numbers with few repeated digits
"""
| 18
| 46
| 0.759259
| 6
| 54
| 6.833333
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.12963
| 54
| 3
| 47
| 18
| 0.87234
| 0.851852
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
72f41f72ee6ac377447861a6214a7763030119ee
| 165
|
py
|
Python
|
tests/__init__.py
|
praveenv253/polyproject
|
d5cccbf498e509f1ca9dabe19b51e5ab08c38e66
|
[
"MIT"
] | null | null | null |
tests/__init__.py
|
praveenv253/polyproject
|
d5cccbf498e509f1ca9dabe19b51e5ab08c38e66
|
[
"MIT"
] | null | null | null |
tests/__init__.py
|
praveenv253/polyproject
|
d5cccbf498e509f1ca9dabe19b51e5ab08c38e66
|
[
"MIT"
] | null | null | null |
# This file needs to exist in order for pytest-cov to work.
# See this: https://bitbucket.org/memedough/pytest-cov/issues/4/no-coverage-unless-test-directory-has-an
| 55
| 104
| 0.775758
| 29
| 165
| 4.413793
| 0.862069
| 0.140625
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.006711
| 0.09697
| 165
| 2
| 105
| 82.5
| 0.852349
| 0.969697
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
f4166f84acc31ffeec008bdca780151ab7c0c094
| 1,062
|
py
|
Python
|
sonolib/sounds/admin.py
|
bluedahltech/sonolib
|
8ab8eb69682dd7851b955bd950badcda7d05f142
|
[
"MIT"
] | null | null | null |
sonolib/sounds/admin.py
|
bluedahltech/sonolib
|
8ab8eb69682dd7851b955bd950badcda7d05f142
|
[
"MIT"
] | null | null | null |
sonolib/sounds/admin.py
|
bluedahltech/sonolib
|
8ab8eb69682dd7851b955bd950badcda7d05f142
|
[
"MIT"
] | null | null | null |
from django.contrib import admin
from .models import (Wavetable, ImpulseResponse, LoopType,
Instrument, Genre, Sound, Loop, FrequencyKit)
# Register your models here.
@admin.register(Wavetable)
class WavetableAdmin(admin.ModelAdmin):
list_display = ["title", "uuid"]
pass
@admin.register(ImpulseResponse)
class ImpulseResponseAdmin(admin.ModelAdmin):
list_display = ["title", "uuid"]
pass
@admin.register(LoopType)
class LoopTypeAdmin(admin.ModelAdmin):
list_display = ["title"]
pass
@admin.register(Instrument)
class InstrumentAdmin(admin.ModelAdmin):
list_display = ["title"]
pass
@admin.register(Genre)
class GenreAdmin(admin.ModelAdmin):
list_display = ["title"]
pass
@admin.register(Sound)
class SoundAdmin(admin.ModelAdmin):
list_display = ["title", "uuid"]
pass
@admin.register(Loop)
class LoopAdmin(admin.ModelAdmin):
list_display = ["title", "uuid"]
pass
@admin.register(FrequencyKit)
class FrequencyKitAdmin(admin.ModelAdmin):
list_display = ["title", "id"]
pass
| 23.086957
| 61
| 0.715631
| 113
| 1,062
| 6.654867
| 0.292035
| 0.138298
| 0.202128
| 0.276596
| 0.509309
| 0.468085
| 0.468085
| 0.468085
| 0.276596
| 0
| 0
| 0
| 0.160075
| 1,062
| 45
| 62
| 23.6
| 0.843049
| 0.024482
| 0
| 0.428571
| 0
| 0
| 0.056093
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0.228571
| 0.057143
| 0
| 0.514286
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
|
0
| 4
|
f43d5d202030e645ccbf3defc563b6cd3882c454
| 873
|
py
|
Python
|
cctbx_website/run_tests.py
|
TiankunZhou/cctbx_project
|
373f302f00c12d7239f8e37e3165e62bc1d852cc
|
[
"BSD-3-Clause-LBNL"
] | null | null | null |
cctbx_website/run_tests.py
|
TiankunZhou/cctbx_project
|
373f302f00c12d7239f8e37e3165e62bc1d852cc
|
[
"BSD-3-Clause-LBNL"
] | 1
|
2020-05-26T17:46:17.000Z
|
2020-05-26T17:55:19.000Z
|
cctbx_website/run_tests.py
|
TiankunZhou/cctbx_project
|
373f302f00c12d7239f8e37e3165e62bc1d852cc
|
[
"BSD-3-Clause-LBNL"
] | 1
|
2022-02-08T10:11:07.000Z
|
2022-02-08T10:11:07.000Z
|
from __future__ import absolute_import, division, print_function
from libtbx import test_utils
import libtbx.load_env
#tst_list = [
# "$D/regression/tst_py_from_html.py"
# ]
tst_list = [
"$D/regression/tst_1_template.py",
"$D/regression/tst_2_doc_hlo_intro.py",
"$D/regression/tst_3_doc_hlo_model_manager.py",
"$D/regression/tst_4_doc_hlo_data_manager.py",
"$D/regression/tst_5_doc_hlo_map_manager.py",
"$D/regression/tst_6_doc_hlo_model_map_manager.py",
"$D/regression/tst_7_doc_low_flex_advanced.py",
"$D/regression/tst_8_doc_maps_intro.py",
"$D/regression/tst_9_doc_maps_boxing.py",
"$D/regression/tst_10_doc_programming_tips.py",
]
def run():
build_dir = libtbx.env.under_build("cctbx_website")
dist_dir = libtbx.env.dist_path("cctbx_website")
test_utils.run_tests(build_dir, dist_dir, tst_list)
if (__name__ == "__main__"):
run()
| 28.16129
| 64
| 0.764032
| 144
| 873
| 4.104167
| 0.388889
| 0.204738
| 0.260575
| 0.243655
| 0.307953
| 0.087986
| 0
| 0
| 0
| 0
| 0
| 0.013995
| 0.099656
| 873
| 30
| 65
| 29.1
| 0.737913
| 0.059565
| 0
| 0
| 0
| 0
| 0.53912
| 0.497555
| 0
| 0
| 0
| 0
| 0
| 1
| 0.047619
| false
| 0
| 0.142857
| 0
| 0.190476
| 0.047619
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
f485429cbb7f55c985953fd819611e526fcc9efc
| 236
|
py
|
Python
|
tests/sv/uvm_python/python/uvm_python_smoke.py
|
tblink-rpc/tblink-rpc-hdl
|
3cc48075283a7938c92c9aafa9adc033e0f709e9
|
[
"Apache-2.0"
] | 1
|
2022-03-30T11:57:59.000Z
|
2022-03-30T11:57:59.000Z
|
tests/sv/uvm_python/python/uvm_python_smoke.py
|
tblink-rpc/tblink-rpc-hdl
|
3cc48075283a7938c92c9aafa9adc033e0f709e9
|
[
"Apache-2.0"
] | null | null | null |
tests/sv/uvm_python/python/uvm_python_smoke.py
|
tblink-rpc/tblink-rpc-hdl
|
3cc48075283a7938c92c9aafa9adc033e0f709e9
|
[
"Apache-2.0"
] | null | null | null |
import cocotb
import tblink_rpc
from tblink_rpc import cocotb_compat
@cocotb.test()
async def entry(dut):
print("Hello")
print("--> init", flush=True)
await cocotb_compat.init()
print("<-- init", flush=True)
pass
| 16.857143
| 36
| 0.673729
| 32
| 236
| 4.84375
| 0.5625
| 0.154839
| 0.180645
| 0.232258
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.190678
| 236
| 14
| 37
| 16.857143
| 0.811518
| 0
| 0
| 0
| 0
| 0
| 0.088983
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.1
| 0.3
| 0
| 0.3
| 0.3
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
f48a364eda29d165e41581f9da8efb6f58c47bf6
| 599
|
py
|
Python
|
lib/exabgp/bgp/message/keepalive.py
|
bopopescu/exabgp_priv
|
25aac31f2b1166350aa40d9f48447173998246b6
|
[
"BSD-3-Clause"
] | 2
|
2017-03-20T22:54:40.000Z
|
2021-02-24T02:05:38.000Z
|
lib/exabgp/bgp/message/keepalive.py
|
bopopescu/exabgp_priv
|
25aac31f2b1166350aa40d9f48447173998246b6
|
[
"BSD-3-Clause"
] | null | null | null |
lib/exabgp/bgp/message/keepalive.py
|
bopopescu/exabgp_priv
|
25aac31f2b1166350aa40d9f48447173998246b6
|
[
"BSD-3-Clause"
] | 1
|
2020-07-23T16:54:49.000Z
|
2020-07-23T16:54:49.000Z
|
# encoding: utf-8
"""
keepalive.py
Created by Thomas Mangin on 2009-11-05.
Copyright (c) 2009-2015 Exa Networks. All rights reserved.
"""
from exabgp.bgp.message import Message
# =================================================================== KeepAlive
#
class KeepAlive (Message):
ID = Message.CODE.KEEPALIVE
TYPE = chr(Message.CODE.KEEPALIVE)
def message (self):
return self._message('')
def __str__ (self):
return "KEEPALIVE"
@classmethod
def unpack_message (cls, data, negotiated): # pylint: disable=W0613
# XXX: FIXME: raise Notify if data has something
return cls()
| 20.655172
| 79
| 0.63773
| 72
| 599
| 5.222222
| 0.694444
| 0.058511
| 0.106383
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.041257
| 0.15025
| 599
| 28
| 80
| 21.392857
| 0.697446
| 0.460768
| 0
| 0
| 0
| 0
| 0.028939
| 0
| 0
| 0
| 0
| 0.035714
| 0
| 1
| 0.272727
| false
| 0
| 0.090909
| 0.272727
| 0.909091
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
f4901ad46074148fc607b23b5a0844deed60c1c4
| 67
|
py
|
Python
|
src/djai/model/models/ml/torch/pre_trained/vision/keypoint_detection.py
|
Django-AI/DjAI
|
85e624de78726ac52f42580121e1a04efe2da2d7
|
[
"MIT"
] | 3
|
2021-12-03T13:53:17.000Z
|
2021-12-15T11:51:52.000Z
|
src/djai/model/models/ml/torch/pre_trained/vision/keypoint_detection.py
|
Django-AI/DjAI
|
85e624de78726ac52f42580121e1a04efe2da2d7
|
[
"MIT"
] | null | null | null |
src/djai/model/models/ml/torch/pre_trained/vision/keypoint_detection.py
|
Django-AI/DjAI
|
85e624de78726ac52f42580121e1a04efe2da2d7
|
[
"MIT"
] | 1
|
2022-01-31T08:57:16.000Z
|
2022-01-31T08:57:16.000Z
|
"""DjAI Pre-Trained Torch Vision Keypoint Detector Model class."""
| 33.5
| 66
| 0.761194
| 9
| 67
| 5.666667
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.119403
| 67
| 1
| 67
| 67
| 0.864407
| 0.895522
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
be2fa2c8ab896622164f5aaf2cf62bdd530fe96f
| 11,358
|
py
|
Python
|
apps/courses/migrations/0001_initial.py
|
aurmeneta/ramos-uc
|
364ab3c5a55032ab7ffc08665a2da4c5ff04ae58
|
[
"MIT"
] | 7
|
2021-07-14T18:13:35.000Z
|
2021-11-21T20:10:54.000Z
|
apps/courses/migrations/0001_initial.py
|
aurmeneta/ramos-uc
|
364ab3c5a55032ab7ffc08665a2da4c5ff04ae58
|
[
"MIT"
] | 57
|
2021-07-10T01:31:56.000Z
|
2022-01-14T02:02:58.000Z
|
apps/courses/migrations/0001_initial.py
|
aurmeneta/ramos-uc
|
364ab3c5a55032ab7ffc08665a2da4c5ff04ae58
|
[
"MIT"
] | 4
|
2021-07-23T16:51:55.000Z
|
2021-08-31T02:41:41.000Z
|
# Generated by Django 3.1.4 on 2020-12-19 22:26
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="Category",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=255)),
],
),
migrations.CreateModel(
name="Course",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("initials", models.CharField(max_length=8, unique=True)),
("name", models.CharField(max_length=255)),
("credits", models.PositiveSmallIntegerField()),
("req", models.TextField(blank=True, max_length=1000, null=True)),
("con", models.CharField(blank=True, max_length=16, null=True)),
("restr", models.TextField(blank=True, max_length=1000, null=True)),
("program", models.TextField(blank=True, null=True)),
("school", models.CharField(blank=True, max_length=32, null=True)),
("area", models.CharField(blank=True, max_length=32, null=True)),
("category", models.CharField(blank=True, max_length=64, null=True)),
("categories", models.ManyToManyField(to="courses.Category")),
],
),
migrations.CreateModel(
name="Section",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("period", models.CharField(max_length=6)),
("section", models.PositiveSmallIntegerField()),
("nrc", models.CharField(blank=True, max_length=10, null=True)),
("teachers", models.CharField(blank=True, max_length=1000, null=True)),
("schedule", models.CharField(blank=True, max_length=255, null=True)),
("format", models.CharField(blank=True, max_length=16, null=True)),
("campus", models.CharField(blank=True, max_length=32, null=True)),
("is_english", models.BooleanField()),
("is_removable", models.BooleanField()),
("is_special", models.BooleanField()),
("available_quota", models.SmallIntegerField(blank=True, null=True)),
("total_quota", models.SmallIntegerField(blank=True, null=True)),
(
"course",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="courses.course"
),
),
],
),
migrations.CreateModel(
name="FullSchedule",
fields=[
(
"section",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
primary_key=True,
serialize=False,
to="courses.section",
),
),
("l1", models.CharField(default="FREE", max_length=4)),
("l2", models.CharField(default="FREE", max_length=4)),
("l3", models.CharField(default="FREE", max_length=4)),
("l4", models.CharField(default="FREE", max_length=4)),
("l5", models.CharField(default="FREE", max_length=4)),
("l6", models.CharField(default="FREE", max_length=4)),
("l7", models.CharField(default="FREE", max_length=4)),
("l8", models.CharField(default="FREE", max_length=4)),
("m1", models.CharField(default="FREE", max_length=4)),
("m2", models.CharField(default="FREE", max_length=4)),
("m3", models.CharField(default="FREE", max_length=4)),
("m4", models.CharField(default="FREE", max_length=4)),
("m5", models.CharField(default="FREE", max_length=4)),
("m6", models.CharField(default="FREE", max_length=4)),
("m7", models.CharField(default="FREE", max_length=4)),
("m8", models.CharField(default="FREE", max_length=4)),
("w1", models.CharField(default="FREE", max_length=4)),
("w2", models.CharField(default="FREE", max_length=4)),
("w3", models.CharField(default="FREE", max_length=4)),
("w4", models.CharField(default="FREE", max_length=4)),
("w5", models.CharField(default="FREE", max_length=4)),
("w6", models.CharField(default="FREE", max_length=4)),
("w7", models.CharField(default="FREE", max_length=4)),
("w8", models.CharField(default="FREE", max_length=4)),
("j1", models.CharField(default="FREE", max_length=4)),
("j2", models.CharField(default="FREE", max_length=4)),
("j3", models.CharField(default="FREE", max_length=4)),
("j4", models.CharField(default="FREE", max_length=4)),
("j5", models.CharField(default="FREE", max_length=4)),
("j6", models.CharField(default="FREE", max_length=4)),
("j7", models.CharField(default="FREE", max_length=4)),
("j8", models.CharField(default="FREE", max_length=4)),
("v1", models.CharField(default="FREE", max_length=4)),
("v2", models.CharField(default="FREE", max_length=4)),
("v3", models.CharField(default="FREE", max_length=4)),
("v4", models.CharField(default="FREE", max_length=4)),
("v5", models.CharField(default="FREE", max_length=4)),
("v6", models.CharField(default="FREE", max_length=4)),
("v7", models.CharField(default="FREE", max_length=4)),
("v8", models.CharField(default="FREE", max_length=4)),
("s1", models.CharField(default="FREE", max_length=4)),
("s2", models.CharField(default="FREE", max_length=4)),
("s3", models.CharField(default="FREE", max_length=4)),
("s4", models.CharField(default="FREE", max_length=4)),
("s5", models.CharField(default="FREE", max_length=4)),
("s6", models.CharField(default="FREE", max_length=4)),
("s7", models.CharField(default="FREE", max_length=4)),
("s8", models.CharField(default="FREE", max_length=4)),
],
),
migrations.CreateModel(
name="ScheduleInfo",
fields=[
(
"section",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
primary_key=True,
serialize=False,
to="courses.section",
),
),
("total", models.IntegerField(blank=True, null=True)),
("ayu", models.IntegerField(blank=True, null=True)),
("clas", models.IntegerField(blank=True, null=True)),
("lab", models.IntegerField(blank=True, null=True)),
("pra", models.IntegerField(blank=True, null=True)),
("sup", models.IntegerField(blank=True, null=True)),
("tal", models.IntegerField(blank=True, null=True)),
("ter", models.IntegerField(blank=True, null=True)),
("tes", models.IntegerField(blank=True, null=True)),
],
),
migrations.CreateModel(
name="Quota",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("date", models.DateTimeField()),
("category", models.CharField(max_length=255)),
("quota", models.IntegerField(blank=True, null=True)),
("banner", models.CharField(blank=True, max_length=32, null=True)),
(
"section",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="courses.section",
),
),
],
),
migrations.AddIndex(
model_name="section",
index=models.Index(
fields=["period", "course"], name="courses_sec_period_b201a6_idx"
),
),
migrations.AddIndex(
model_name="section",
index=models.Index(
fields=["course", "section"], name="courses_sec_course__784d3c_idx"
),
),
migrations.AddIndex(
model_name="section",
index=models.Index(fields=["campus"], name="courses_sec_campus_7f80b8_idx"),
),
migrations.AddIndex(
model_name="section",
index=models.Index(
fields=["available_quota"], name="courses_sec_availab_72ac76_idx"
),
),
migrations.AddConstraint(
model_name="section",
constraint=models.UniqueConstraint(
fields=("period", "course", "section"), name="period_section"
),
),
migrations.AddIndex(
model_name="scheduleinfo",
index=models.Index(fields=["total"], name="courses_sch_total_4ec1be_idx"),
),
migrations.AddIndex(
model_name="quota",
index=models.Index(
fields=["section_id", "date"], name="courses_quo_section_e01ed6_idx"
),
),
migrations.AddIndex(
model_name="course",
index=models.Index(fields=["req"], name="courses_cou_req_aa456d_idx"),
),
migrations.AddIndex(
model_name="course",
index=models.Index(fields=["school"], name="courses_cou_school_742ea4_idx"),
),
migrations.AddIndex(
model_name="course",
index=models.Index(fields=["area"], name="courses_cou_area_e7795f_idx"),
),
migrations.AddIndex(
model_name="course",
index=models.Index(
fields=["category"], name="courses_cou_categor_fec4a4_idx"
),
),
]
| 44.893281
| 88
| 0.49146
| 1,015
| 11,358
| 5.358621
| 0.170443
| 0.107557
| 0.194153
| 0.229454
| 0.72642
| 0.708402
| 0.611693
| 0.271925
| 0.271925
| 0.197647
| 0
| 0.025904
| 0.364413
| 11,358
| 252
| 89
| 45.071429
| 0.727525
| 0.003962
| 0
| 0.506122
| 1
| 0
| 0.10282
| 0.025462
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.008163
| 0
| 0.02449
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
be45e95f91dcb59ebb08e0c0b9d0decca439f7fb
| 8,263
|
py
|
Python
|
ascetic/interfaces.py
|
emacsway/ascetic
|
a9f2c10af90bfedaa3ec58589b40ef7a677cd712
|
[
"MIT"
] | 17
|
2015-09-05T21:43:51.000Z
|
2022-03-05T13:28:15.000Z
|
ascetic/interfaces.py
|
emacsway/ascetic
|
a9f2c10af90bfedaa3ec58589b40ef7a677cd712
|
[
"MIT"
] | null | null | null |
ascetic/interfaces.py
|
emacsway/ascetic
|
a9f2c10af90bfedaa3ec58589b40ef7a677cd712
|
[
"MIT"
] | null | null | null |
from ascetic.utils import Undef
class IObservable(object):
def attach(self, aspects, observer):
"""
:type aspects: collections.Hashable or list[collections.Hashable]
:type observer: callable
:rtype: ascetic.interfaces.IDisposable
"""
raise NotImplementedError
def detach(self, aspects, observer):
"""
:type aspects: collections.Hashable or list[collections.Hashable]
:type observer: callable
"""
raise NotImplementedError
def notify(self, aspect, *args, **kwargs):
"""
:type aspect: collections.Hashable
"""
raise NotImplementedError
def is_null(self):
"""
:rtype: bool
"""
raise NotImplementedError
class IDisposable(object):
def dispose(self):
raise NotImplementedError
def __add__(self, other):
raise NotImplementedError
class IDatabase(object):
"""
:type transaction: ascetic.interfaces.ITransaction
:type identity_map: ascetic.interfaces.IIdentityMap
:type identity_map: () -> ascetic.interfaces.IObservable
"""
transaction = None
identity_map = None
observed = None
def connection_factory(self, **kwargs):
raise NotImplementedError
def _ensure_connected(self):
"""
:rtype: ascetic.interfaces.IDatabase
"""
raise NotImplementedError
def execute(self, sql, params=()):
"""
:type sql: str
:type params: collections.Iterable
:rtype: sqlite3.Cursor
"""
raise NotImplementedError
def cursor(self):
"""
:rtype: sqlite3.Cursor
"""
raise NotImplementedError
def last_insert_id(self, cursor):
raise NotImplementedError
def begin(self):
raise NotImplementedError
def commit(self):
raise NotImplementedError
def rollback(self):
raise NotImplementedError
def begin_savepoint(self, name):
"""
:type name: str
"""
raise NotImplementedError
def commit_savepoint(self, name):
"""
:type name: str
"""
raise NotImplementedError
def rollback_savepoint(self, name):
"""
:type name: str
"""
raise NotImplementedError
def set_autocommit(self, autocommit):
"""
:type autocommit: bool
"""
raise NotImplementedError
def read_pk(self, db_table):
"""
:type db_table: str
:rtype: tuple
"""
raise NotImplementedError
def read_fields(self, db_table):
"""
:type db_table: str
:rtype: dict
"""
raise NotImplementedError
def describe_table(self, db_table):
"""
:type db_table: str
:rtype: dict
"""
raise NotImplementedError
def qn(self, name):
"""
:type name: str
:rtype: str
"""
def close(self):
raise NotImplementedError
@classmethod
def register(cls, engine):
"""
:type engine: str
:rtype: collections.Callable
"""
raise NotImplementedError
@classmethod
def factory(cls, **kwargs):
"""
:rtype: ascetic.interfaces.IDatabase
"""
raise NotImplementedError
class IBaseRelation(object):
# @property
# def field(self):
# raise NotImplementedError
def setup_reverse_relation(self):
"""
:return bool: True if operation is successful else False
"""
raise NotImplementedError
def bind(self, owner):
"""Using Prototype pattern.
:param owner: type
:return: IRelation
"""
raise NotImplementedError
def get(self, instance):
raise NotImplementedError
def set(self, instance, value):
raise NotImplementedError
def delete(self, instance):
raise NotImplementedError
class IRelation(IBaseRelation):
@property
def name(self):
raise NotImplementedError
@property
def model(self):
raise NotImplementedError
@property
def field(self):
raise NotImplementedError
@property
def query(self):
raise NotImplementedError
@property
def related_relation(self):
raise NotImplementedError
@property
def related_name(self):
raise NotImplementedError
@property
def related_model(self):
raise NotImplementedError
@property
def related_field(self):
raise NotImplementedError
@property
def related_query(self):
raise NotImplementedError
def get_where(self, related_obj):
raise NotImplementedError
def get_related_where(self, obj):
raise NotImplementedError
def get_join_where(self, prefix=None, related_prefix=None):
"""
:type prefix: ascetic.query.Table
:type related_prefix: ascetic.query.Table
:rtype: sqlbuilder.smartsql.expressions.Operable
"""
raise NotImplementedError
def get_value(self, obj):
raise NotImplementedError
def get_related_value(self, related_obj):
raise NotImplementedError
def set_value(self, obj, value):
raise NotImplementedError
def set_related_value(self, related_obj, value):
raise NotImplementedError
class IRelationDescriptor(object):
def get_bound_relation(self, owner):
"""
:type owner: type
:rtype: IRelation
"""
raise NotImplementedError
def __get__(self, instance, owner):
raise NotImplementedError
def __set__(self, instance, value):
raise NotImplementedError
def __delete__(self, instance):
raise NotImplementedError
class ITransaction(object):
def parent(self):
raise NotImplementedError
def begin(self):
raise NotImplementedError
def commit(self):
raise NotImplementedError
def rollback(self):
raise NotImplementedError
def can_reconnect(self):
raise NotImplementedError
def set_autocommit(self, autocommit):
raise NotImplementedError
def is_null(self):
"""
:rtype: bool
"""
raise NotImplementedError
class ITransactionManager(object):
def __call__(self, func=None):
raise NotImplementedError
def __enter__(self):
raise NotImplementedError
def __exit__(self, *args):
raise NotImplementedError
def current(self, node=Undef):
raise NotImplementedError
def begin(self):
raise NotImplementedError
def commit(self):
raise NotImplementedError
def rollback(self):
raise NotImplementedError
def can_reconnect(self):
raise NotImplementedError
def autocommit(self, autocommit=None):
raise NotImplementedError
class IIdentityMap(object):
def add(self, key, value=None):
"""
:type key: collections.Hashable
:type value: object or None
:rtype: object or None
"""
raise NotImplementedError
def get(self, key):
"""
:type key: collections.Hashable
:rtype: object or None
"""
raise NotImplementedError
def exists(self, key):
"""
:type key: collections.Hashable
:rtype: bool
"""
raise NotImplementedError
def do_add(self, key, value=None):
"""
:type key: collections.Hashable
:type value: object or None
"""
raise NotImplementedError
def do_get(self, key):
"""
:type key: collections.Hashable
:rtype: object or None
"""
raise NotImplementedError
def remove(self, key):
"""
:type key: collections.Hashable
"""
raise NotImplementedError
def clear(self):
raise NotImplementedError
def sync(self):
raise NotImplementedError
def set_isolation_level(self, level):
raise NotImplementedError
def enable(self):
raise NotImplementedError
def disable(self):
raise NotImplementedError
| 21.574413
| 73
| 0.608375
| 749
| 8,263
| 6.600801
| 0.18024
| 0.373786
| 0.316748
| 0.119134
| 0.603762
| 0.562702
| 0.390372
| 0.342233
| 0.336165
| 0.302791
| 0
| 0.000351
| 0.310057
| 8,263
| 382
| 74
| 21.63089
| 0.866865
| 0.184679
| 0
| 0.576271
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.435028
| false
| 0
| 0.00565
| 0
| 0.508475
| 0
| 0
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
be5f973694d6a391f8ce1d32273a0335c502c84e
| 25
|
py
|
Python
|
python.py
|
babbawoos/guild-python
|
873edb025503d3377bb2b45008ba24f0587f1a48
|
[
"MIT"
] | null | null | null |
python.py
|
babbawoos/guild-python
|
873edb025503d3377bb2b45008ba24f0587f1a48
|
[
"MIT"
] | null | null | null |
python.py
|
babbawoos/guild-python
|
873edb025503d3377bb2b45008ba24f0587f1a48
|
[
"MIT"
] | null | null | null |
// TODO create python.py
| 12.5
| 24
| 0.72
| 4
| 25
| 4.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.16
| 25
| 1
| 25
| 25
| 0.857143
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
bec1b72a132ba046f0ef1f065f57a57018a0648b
| 248
|
py
|
Python
|
deeppages/signals.py
|
ricardofalasca/deep-pages
|
d1b2a48f62c31e20d767df5c6345e07e4d05290d
|
[
"MIT"
] | null | null | null |
deeppages/signals.py
|
ricardofalasca/deep-pages
|
d1b2a48f62c31e20d767df5c6345e07e4d05290d
|
[
"MIT"
] | null | null | null |
deeppages/signals.py
|
ricardofalasca/deep-pages
|
d1b2a48f62c31e20d767df5c6345e07e4d05290d
|
[
"MIT"
] | null | null | null |
from django.dispatch import Signal
page_requested = Signal(providing_args=['path', 'request'])
page_not_found = Signal(providing_args=['path', 'request'])
page_found = Signal(providing_args=[
'path', 'request', 'page', 'content', 'context'])
| 31
| 59
| 0.721774
| 30
| 248
| 5.733333
| 0.5
| 0.261628
| 0.331395
| 0.401163
| 0.651163
| 0.651163
| 0.453488
| 0
| 0
| 0
| 0
| 0
| 0.104839
| 248
| 7
| 60
| 35.428571
| 0.774775
| 0
| 0
| 0
| 0
| 0
| 0.205645
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.2
| 0
| 0.2
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
fe42016c3ce20dd852156b1e0cae0a1a4bdce336
| 598
|
py
|
Python
|
src/server/plugins/authorization.py
|
jhchen3121/wechat_shop
|
c9d9ad009df1e5bb0eb23ca8d830dd5c15df5328
|
[
"Apache-2.0"
] | null | null | null |
src/server/plugins/authorization.py
|
jhchen3121/wechat_shop
|
c9d9ad009df1e5bb0eb23ca8d830dd5c15df5328
|
[
"Apache-2.0"
] | 5
|
2021-01-28T21:18:27.000Z
|
2022-03-25T19:10:01.000Z
|
src/server/plugins/authorization.py
|
jhchen3121/wechat_shop
|
c9d9ad009df1e5bb0eb23ca8d830dd5c15df5328
|
[
"Apache-2.0"
] | null | null | null |
#-*- coding:utf-8 -*-
import sqlalchemy
import logging
import sys, traceback
import json
import settings
from core_backend.libs.exception import Error
from core_backend.service import plugin
logger = logging.getLogger(__name__)
class Plugin(plugin.plugin):
"""
@param self.session database connection
@param self.request reqeuest of current service
@param self.handler service handler
@param self.context context of service
@param self._service service
"""
def process(self):
header = self.request.header
# TODO 可在此处添加context的柜员信息等
pass
| 23
| 51
| 0.72408
| 72
| 598
| 5.916667
| 0.541667
| 0.105634
| 0.070423
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.002096
| 0.202341
| 598
| 25
| 52
| 23.92
| 0.890985
| 0.396321
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.04
| 0
| 1
| 0.083333
| false
| 0.083333
| 0.583333
| 0
| 0.75
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 1
| 0
|
0
| 4
|
fe532d3fb4660e752bf564de301174e4c98a3027
| 26
|
py
|
Python
|
Lib/site-packages/grpc/_grpcio_metadata.py
|
AbdelrahmanG/google_nl_api
|
3252c1b6a24a5d763543efd15a799e97653a6cf3
|
[
"0BSD"
] | 1
|
2022-01-08T12:30:44.000Z
|
2022-01-08T12:30:44.000Z
|
Lib/site-packages/grpc/_grpcio_metadata.py
|
AbdelrahmanG/google_nl_api
|
3252c1b6a24a5d763543efd15a799e97653a6cf3
|
[
"0BSD"
] | null | null | null |
Lib/site-packages/grpc/_grpcio_metadata.py
|
AbdelrahmanG/google_nl_api
|
3252c1b6a24a5d763543efd15a799e97653a6cf3
|
[
"0BSD"
] | null | null | null |
__version__ = """1.43.0"""
| 26
| 26
| 0.576923
| 4
| 26
| 2.75
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.166667
| 0.076923
| 26
| 1
| 26
| 26
| 0.291667
| 0
| 0
| 0
| 0
| 0
| 0.222222
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
fe5b53b26ab3231bb6fd01a0b3c9784bc67f3eb7
| 1,152
|
py
|
Python
|
pyhipku/test/test_hipku.py
|
lord63/hipku.py
|
4037014ee4d56ed3dd62b3fe1b9681095e6f5de8
|
[
"MIT"
] | 104
|
2015-02-27T14:16:58.000Z
|
2019-07-10T07:03:59.000Z
|
pyhipku/test/test_hipku.py
|
lord63/hipku.py
|
4037014ee4d56ed3dd62b3fe1b9681095e6f5de8
|
[
"MIT"
] | 6
|
2015-03-03T14:39:00.000Z
|
2015-03-19T00:24:04.000Z
|
pyhipku/test/test_hipku.py
|
lord63/hipku.py
|
4037014ee4d56ed3dd62b3fe1b9681095e6f5de8
|
[
"MIT"
] | 6
|
2015-03-11T01:27:27.000Z
|
2021-10-02T21:50:05.000Z
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Test that when you take an IP address, encode it, and then decode it
again, it matches the original address. These tests are applicable to
all versions of Hipku, regardless of changes to the dictionaries or schema.
"""
from __future__ import absolute_import
from pyhipku import encode
from pyhipku import decode
def test_ipv4():
assert decode(encode('0.0.0.0')) == '0.0.0.0'
assert decode(encode('82.158.98.2')) == '82.158.98.2'
assert decode(encode('255.255.255.255')) == '255.255.255.255'
def test_ipv6():
assert decode(encode('0:0:0:0:0:0:0:0')) == '0:0:0:0:0:0:0:0'
assert (decode(encode('2c8f:27aa:61fd:56ec:7ebe:d03a:1f50:475f')) ==
'2c8f:27aa:61fd:56ec:7ebe:d03a:1f50:475f')
assert (decode(encode('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff')) ==
'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff')
def test_abbreviated_ipv6():
assert decode(encode('::0')) == '0:0:0:0:0:0:0:0'
assert decode(encode('0::')) == '0:0:0:0:0:0:0:0'
assert decode(encode('0::0')) == '0:0:0:0:0:0:0:0'
assert decode(encode('0:0::0:0')) == '0:0:0:0:0:0:0:0'
| 32.914286
| 75
| 0.640625
| 209
| 1,152
| 3.488038
| 0.301435
| 0.159122
| 0.213992
| 0.252401
| 0.504801
| 0.504801
| 0.504801
| 0.471879
| 0.384088
| 0.384088
| 0
| 0.145641
| 0.153646
| 1,152
| 34
| 76
| 33.882353
| 0.602051
| 0.22309
| 0
| 0
| 0
| 0
| 0.372461
| 0.176072
| 0
| 0
| 0
| 0
| 0.555556
| 1
| 0.166667
| true
| 0
| 0.166667
| 0
| 0.333333
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
fe5ca169d876f0e5e9da42bbe484d92b6358a7a2
| 77
|
py
|
Python
|
ATSAMD51P19A/libsrc/ATSAMD51P19A/TC7_.py
|
t-ikegami/WioTerminal-CircuitPython
|
efbdc2e13ad969fe009d88f7ec4b836ca61ae973
|
[
"MIT"
] | null | null | null |
ATSAMD51P19A/libsrc/ATSAMD51P19A/TC7_.py
|
t-ikegami/WioTerminal-CircuitPython
|
efbdc2e13ad969fe009d88f7ec4b836ca61ae973
|
[
"MIT"
] | 1
|
2022-01-19T00:16:02.000Z
|
2022-01-26T03:43:34.000Z
|
ATSAMD51P19A/libsrc/ATSAMD51P19A/TC7_.py
|
t-ikegami/WioTerminal-CircuitPython
|
efbdc2e13ad969fe009d88f7ec4b836ca61ae973
|
[
"MIT"
] | null | null | null |
import uctypes as ct
from .TC0_ import TC_
TC7 = ct.struct(0x43001800, TC_)
| 15.4
| 32
| 0.753247
| 13
| 77
| 4.230769
| 0.769231
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.171875
| 0.168831
| 77
| 4
| 33
| 19.25
| 0.6875
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.12987
| 0
| 0
| 1
| 0
| false
| 0
| 0.666667
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
fe65eab30f7d29a65bda6d6c58ca69b53f0e19a6
| 226
|
py
|
Python
|
stager/utils/level.py
|
rorymurdock/stager
|
331b4eaa174ac6c31c724c02c93c7b8e635ea788
|
[
"Apache-2.0"
] | 2
|
2022-02-23T05:57:18.000Z
|
2022-03-07T02:46:40.000Z
|
stager/utils/level.py
|
rorymurdock/stager
|
331b4eaa174ac6c31c724c02c93c7b8e635ea788
|
[
"Apache-2.0"
] | 10
|
2022-02-25T04:33:38.000Z
|
2022-02-25T06:46:59.000Z
|
stager/utils/level.py
|
rorymurdock/stager
|
331b4eaa174ac6c31c724c02c93c7b8e635ea788
|
[
"Apache-2.0"
] | null | null | null |
"""Control the progress bar"""
import stager.utils
def update(level_object_name, strength):
"""Update the progress bar level"""
# Set level
stager.utils.BUILDER.get_object(level_object_name).set_value(strength)
| 22.6
| 74
| 0.738938
| 31
| 226
| 5.193548
| 0.548387
| 0.136646
| 0.173913
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.146018
| 226
| 9
| 75
| 25.111111
| 0.834197
| 0.287611
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0.333333
| 0
| 0.666667
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
fe8ef60145b5dddd0a2f07253460524aa4f5fab5
| 48,081
|
py
|
Python
|
chris_backend/plugininstances/tests/test_views.py
|
jbernal0019/ChRIS_ultron_backEnd
|
bea8065222d231f626763df2e38b0e046c6a5adf
|
[
"MIT"
] | 26
|
2016-05-26T14:09:35.000Z
|
2022-01-28T19:12:43.000Z
|
chris_backend/plugininstances/tests/test_views.py
|
jbernal0019/ChRIS_ultron_backEnd
|
bea8065222d231f626763df2e38b0e046c6a5adf
|
[
"MIT"
] | 168
|
2016-06-24T11:07:15.000Z
|
2022-03-21T12:33:43.000Z
|
chris_backend/plugininstances/tests/test_views.py
|
jbernal0019/ChRIS_ultron_backEnd
|
bea8065222d231f626763df2e38b0e046c6a5adf
|
[
"MIT"
] | 45
|
2017-08-16T16:41:40.000Z
|
2022-03-31T18:12:14.000Z
|
import logging
import json
import time
import io
import os
from unittest import mock, skip
from django.test import TestCase, TransactionTestCase, tag
from django.urls import reverse
from django.contrib.auth.models import User
from django.conf import settings
from rest_framework import status
from celery.contrib.testing.worker import start_worker
from core.celery import app as celery_app
from core.celery import task_routes
from core.swiftmanager import SwiftManager
from plugins.models import PluginMeta, Plugin, PluginParameter, ComputeResource
from plugininstances.models import PluginInstance, PluginInstanceFile
from plugininstances.models import PathParameter, FloatParameter
from plugininstances.services.manager import PluginInstanceManager
from plugininstances import views
COMPUTE_RESOURCE_URL = settings.COMPUTE_RESOURCE_URL
class ViewTests(TestCase):
def setUp(self):
# avoid cluttered console output (for instance logging all the http requests)
logging.disable(logging.WARNING)
self.chris_username = 'chris'
self.chris_password = 'chris12'
self.username = 'foo'
self.password = 'bar'
self.other_username = 'boo'
self.other_password = 'far'
self.content_type='application/vnd.collection+json'
(self.compute_resource, tf) = ComputeResource.objects.get_or_create(
name="host", compute_url=COMPUTE_RESOURCE_URL)
# create the chris superuser and two additional users
User.objects.create_user(username=self.chris_username,
password=self.chris_password)
User.objects.create_user(username=self.other_username,
password=self.other_password)
User.objects.create_user(username=self.username,
password=self.password)
# create two plugins
(pl_meta, tf) = PluginMeta.objects.get_or_create(name='pacspull', type='fs')
(plugin_fs, tf) = Plugin.objects.get_or_create(meta=pl_meta, version='0.1')
plugin_fs.compute_resources.set([self.compute_resource])
plugin_fs.save()
(pl_meta, tf) = PluginMeta.objects.get_or_create(name='mri_convert', type='ds')
(plugin_ds, tf) = Plugin.objects.get_or_create(meta=pl_meta, version='0.1')
plugin_ds.compute_resources.set([self.compute_resource])
plugin_ds.save()
def tearDown(self):
# re-enable logging
logging.disable(logging.NOTSET)
class TasksViewTests(TransactionTestCase):
@classmethod
def setUpClass(cls):
logging.disable(logging.WARNING)
super().setUpClass()
# route tasks to this worker by using the default 'celery' queue
# that is exclusively used for the automated tests
celery_app.conf.update(task_routes=None)
cls.celery_worker = start_worker(celery_app,
concurrency=1,
perform_ping_check=False)
cls.celery_worker.__enter__()
@classmethod
def tearDownClass(cls):
super().tearDownClass()
cls.celery_worker.__exit__(None, None, None)
# reset routes to the original queues
celery_app.conf.update(task_routes=task_routes)
logging.disable(logging.NOTSET)
def setUp(self):
self.swift_manager = SwiftManager(settings.SWIFT_CONTAINER_NAME,
settings.SWIFT_CONNECTION_PARAMS)
self.chris_username = 'chris'
self.chris_password = 'chris12'
self.username = 'foo'
self.password = 'bar'
self.other_username = 'boo'
self.other_password = 'far'
self.content_type = 'application/vnd.collection+json'
(self.compute_resource, tf) = ComputeResource.objects.get_or_create(
name="host", compute_url=COMPUTE_RESOURCE_URL)
# create the chris superuser and two additional users
User.objects.create_user(username=self.chris_username,
password=self.chris_password)
User.objects.create_user(username=self.other_username,
password=self.other_password)
user = User.objects.create_user(username=self.username,
password=self.password)
# create two plugins
(pl_meta, tf) = PluginMeta.objects.get_or_create(name='pacspull', type='fs')
(plugin_fs, tf) = Plugin.objects.get_or_create(meta=pl_meta, version='0.1')
plugin_fs.compute_resources.set([self.compute_resource])
plugin_fs.save()
(pl_meta, tf) = PluginMeta.objects.get_or_create(name='mri_convert', type='ds')
(plugin_ds, tf) = Plugin.objects.get_or_create(meta=pl_meta, version='0.1')
plugin_ds.compute_resources.set([self.compute_resource])
plugin_ds.save()
# create pacspull fs plugin instance
(self.pl_inst, tf) = PluginInstance.objects.get_or_create(
plugin=plugin_fs, owner=user,
compute_resource=plugin_fs.compute_resources.all()[0])
# create mri_convert ds plugin instance
PluginInstance.objects.get_or_create(
plugin=plugin_ds, owner=user, previous=self.pl_inst,
compute_resource=plugin_ds.compute_resources.all()[0])
class PluginInstanceListViewTests(TasksViewTests):
"""
Test the plugininstance-list view.
"""
def setUp(self):
super(PluginInstanceListViewTests, self).setUp()
plugin = Plugin.objects.get(meta__name="pacspull")
self.create_read_url = reverse("plugininstance-list", kwargs={"pk": plugin.id})
self.user_space_path = '%s/uploads/' % self.username
self.post = json.dumps(
{"template": {"data": [{"name": "dir", "value": self.user_space_path},
{"name": "title", "value": 'test1'}]}})
def test_plugin_instance_create_success(self):
# add parameters to the plugin before the POST request
plugin = Plugin.objects.get(meta__name="pacspull")
PluginParameter.objects.get_or_create(plugin=plugin, name='dir', type='string',
optional=False)
# first test 'fs' plugin instance (has no previous plugin instance)
with mock.patch.object(views.run_plugin_instance, 'delay',
return_value=None) as delay_mock:
# make API request
self.client.login(username=self.username, password=self.password)
response = self.client.post(self.create_read_url, data=self.post,
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
# check that the run_plugin_instance task was called with appropriate args
delay_mock.assert_called_with(response.data['id'])
self.assertEqual(response.data['status'], 'scheduled')
# now test 'ds' plugin instance (has previous plugin instance)
previous_plg_inst = PluginInstance.objects.get(title='test1')
plugin = Plugin.objects.get(meta__name="mri_convert")
create_read_url = reverse("plugininstance-list", kwargs={"pk": plugin.id})
post = json.dumps(
{"template": {"data": [{"name": "previous_id", "value": previous_plg_inst.id}]}})
previous_plg_inst.status = 'finishedSuccessfully'
previous_plg_inst.save()
with mock.patch.object(views.run_plugin_instance, 'delay',
return_value=None) as delay_mock:
self.client.login(username=self.username, password=self.password)
response = self.client.post(create_read_url, data=post,
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
# check that the run_plugin_instance task was called with appropriate args
delay_mock.assert_called_with(response.data['id'])
self.assertEqual(response.data['status'], 'scheduled')
previous_plg_inst.status = 'started'
previous_plg_inst.save()
with mock.patch.object(views.run_plugin_instance, 'delay',
return_value=None) as delay_mock:
self.client.login(username=self.username, password=self.password)
response = self.client.post(create_read_url, data=post,
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
# check that the run_plugin_instance task was not called
delay_mock.assert_not_called()
self.assertEqual(response.data['status'], 'waiting')
previous_plg_inst.status = 'finishedWithError'
previous_plg_inst.save()
with mock.patch.object(views.run_plugin_instance, 'delay',
return_value=None) as delay_mock:
self.client.login(username=self.username, password=self.password)
response = self.client.post(create_read_url, data=post,
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
# check that the run_plugin_instance task was not called
delay_mock.assert_not_called()
self.assertEqual(response.data['status'], 'cancelled')
@tag('integration')
def test_integration_plugin_instance_create_success(self):
# add an FS plugin to the system
plugin_parameters = [{'name': 'dir', 'type': 'path', 'action': 'store',
'optional': False, 'flag': '--dir', 'short_flag': '-d',
'help': 'test plugin', 'ui_exposed': True}]
self.plg_data = {'description': 'A simple chris fs app demo',
'version': '0.1',
'dock_image': 'fnndsc/pl-simplefsapp',
'execshell': 'python3',
'selfpath': '/usr/local/bin',
'selfexec': 'simplefsapp'}
self.plg_meta_data = {'name': 'simplefsapp',
'title': 'Dir plugin',
'license': 'MIT',
'type': 'fs',
'icon': 'http://github.com/plugin',
'category': 'Dir',
'stars': 0,
'authors': 'FNNDSC (dev@babyMRI.org)'}
self.plugin_repr = self.plg_data.copy()
self.plugin_repr.update(self.plg_meta_data)
self.plugin_repr['parameters'] = plugin_parameters
(compute_resource, tf) = ComputeResource.objects.get_or_create(
name="host", compute_url=COMPUTE_RESOURCE_URL)
data = self.plg_meta_data.copy()
(pl_meta, tf) = PluginMeta.objects.get_or_create(**data)
data = self.plg_data.copy()
(plugin, tf) = Plugin.objects.get_or_create(meta=pl_meta, **data)
plugin.compute_resources.set([compute_resource])
plugin.save()
# add plugin's parameters
parameters = plugin_parameters
PluginParameter.objects.get_or_create(
plugin=plugin,
name=parameters[0]['name'],
type=parameters[0]['type'],
flag=parameters[0]['flag'])
# upload a file to the Swift storage user's space
with io.StringIO('Test file') as f:
self.swift_manager.upload_obj(self.user_space_path + 'test.txt', f.read(),
content_type='text/plain')
# make POST API request to create a plugin instance
create_read_url = reverse("plugininstance-list", kwargs={"pk": plugin.id})
self.client.login(username=self.username, password=self.password)
response = self.client.post(create_read_url, data=self.post,
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
# instance must be 'started' before checking its status
pl_inst = PluginInstance.objects.get(pk=response.data['id'])
for _ in range(10):
time.sleep(3)
pl_inst.refresh_from_db()
if pl_inst.status == 'started': break
self.assertEqual(pl_inst.status, 'started') # instance must be started
# In the following we keep checking the status until the job ends with
# 'finishedSuccessfully'. The code runs in a lazy loop poll with a
# max number of attempts at 10 second intervals.
plg_inst_manager = PluginInstanceManager(pl_inst)
maxLoopTries = 10
currentLoop = 1
b_checkAgain = True
time.sleep(10)
while b_checkAgain:
str_responseStatus = plg_inst_manager.check_plugin_instance_app_exec_status()
if str_responseStatus == 'finishedSuccessfully':
b_checkAgain = False
elif currentLoop < maxLoopTries:
time.sleep(10)
if currentLoop == maxLoopTries:
b_checkAgain = False
currentLoop += 1
self.assertEqual(pl_inst.status, 'finishedSuccessfully')
# delete files from swift storage
self.swift_manager.delete_obj(self.user_space_path + 'test.txt')
@tag('integration')
def test_integration_ts_plugin_instance_create_success(self):
# create an FS plugin instance
user = User.objects.get(username=self.username)
plugin = Plugin.objects.get(meta__name="pacspull")
(fs_plg_inst, tf) = PluginInstance.objects.get_or_create(
plugin=plugin, owner=user, compute_resource=plugin.compute_resources.all()[0])
# upload FS plugin instace output file to Swift storage
path = os.path.join(fs_plg_inst.get_output_path(), 'test.txt')
with io.StringIO("test file") as test_file:
self.swift_manager.upload_obj(path, test_file.read(),
content_type='text/plain')
(fs_plg_inst_file, tf) = PluginInstanceFile.objects.get_or_create(plugin_inst=fs_plg_inst)
fs_plg_inst_file.fname.name = path
fs_plg_inst_file.save()
fs_plg_inst.status = 'finishedSuccessfully'
fs_plg_inst.save()
# add a TS plugin to the system
plugin_parameters = [{'name': 'plugininstances', 'type': 'string',
'action': 'store', 'optional': True,
'flag': '--plugininstances', 'short_flag': '--plugininstances',
'help': 'test plugin parameter', 'ui_exposed': True},
{'name': 'filter', 'type': 'string',
'action': 'store', 'optional': True,
'flag': '--filter',
'short_flag': '-f',
'help': 'test plugin parameter', 'ui_exposed': True}
]
self.plg_data = {'description': 'A toplological copy ts plugin',
'version': '0.1',
'dock_image': 'fnndsc/pl-topologicalcopy',
'execshell': 'python3',
'selfpath': '/usr/local/bin',
'selfexec': 'topologicalcopy'}
self.plg_meta_data = {'name': 'topologicalcopy',
'title': 'TS copy plugin',
'license': 'MIT',
'type': 'ts',
'icon': 'http://github.com/plugin',
'category': 'Utility',
'stars': 0,
'authors': 'FNNDSC (dev@babyMRI.org)'}
self.plugin_repr = self.plg_data.copy()
self.plugin_repr.update(self.plg_meta_data)
self.plugin_repr['parameters'] = plugin_parameters
(compute_resource, tf) = ComputeResource.objects.get_or_create(
name="host", compute_url=COMPUTE_RESOURCE_URL)
data = self.plg_meta_data.copy()
(pl_meta, tf) = PluginMeta.objects.get_or_create(**data)
data = self.plg_data.copy()
(plugin, tf) = Plugin.objects.get_or_create(meta=pl_meta, **data)
plugin.compute_resources.set([compute_resource])
plugin.save()
# add plugin's parameters
parameters = plugin_parameters
PluginParameter.objects.get_or_create(
plugin=plugin,
name=parameters[0]['name'],
type=parameters[0]['type'],
flag=parameters[0]['flag'])
# make POST API request to create a ts plugin instance
create_read_url = reverse("plugininstance-list", kwargs={"pk": plugin.id})
post = json.dumps(
{"template": {"data": [{"name": "previous_id", "value": fs_plg_inst.id},
{"name": "plugininstances", "value": str(fs_plg_inst.id)},
{"name": "filter", "value": ".txt$"}]}})
self.client.login(username=self.username, password=self.password)
response = self.client.post(create_read_url, data=post,
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
# instance must be 'started' before checking its status
pl_inst = PluginInstance.objects.get(pk=response.data['id'])
for _ in range(10):
time.sleep(3)
pl_inst.refresh_from_db()
if pl_inst.status == 'started': break
self.assertEqual(pl_inst.status, 'started') # instance must be started
# In the following we keep checking the status until the job ends with
# 'finishedSuccessfully'. The code runs in a lazy loop poll with a
# max number of attempts at 10 second intervals.
plg_inst_manager = PluginInstanceManager(pl_inst)
maxLoopTries = 10
currentLoop = 1
b_checkAgain = True
time.sleep(10)
while b_checkAgain:
str_responseStatus = plg_inst_manager.check_plugin_instance_app_exec_status()
if str_responseStatus == 'finishedSuccessfully':
b_checkAgain = False
elif currentLoop < maxLoopTries:
time.sleep(10)
if currentLoop == maxLoopTries:
b_checkAgain = False
currentLoop += 1
self.assertEqual(pl_inst.status, 'finishedSuccessfully')
self.assertEqual(pl_inst.files.count(), 3)
# delete files from swift storage
self.swift_manager.delete_obj(path)
def test_plugin_instance_create_failure_unauthenticated(self):
response = self.client.post(self.create_read_url, data=self.post,
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
def test_plugin_instance_list_success(self):
self.client.login(username=self.username, password=self.password)
response = self.client.get(self.create_read_url)
self.assertContains(response, "pacspull")
def test_plugin_instance_list_failure_unauthenticated(self):
response = self.client.get(self.create_read_url)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
class PluginInstanceDetailViewTests(TasksViewTests):
"""
Test the plugininstance-detail view.
"""
def setUp(self):
super(PluginInstanceDetailViewTests, self).setUp()
self.read_update_delete_url = reverse("plugininstance-detail",
kwargs={"pk": self.pl_inst.id})
def test_plugin_instance_detail_success(self):
self.pl_inst.status = 'started'
self.pl_inst.save()
# make API request
self.client.login(username=self.username, password=self.password)
response = self.client.get(self.read_update_delete_url)
self.assertContains(response, "pacspull")
self.assertEqual(response.data['status'], 'started')
# with mock.patch.object(views.check_plugin_instance_exec_status, 'delay',
# return_value=None) as delay_mock:
# # make API request
# self.client.login(username=self.username, password=self.password)
# response = self.client.get(self.read_update_delete_url)
# self.assertContains(response, "pacspull")
# self.assertEqual(response.data['status'], 'started')
# # check that the check_plugin_instance_exec_status task was called with appropriate args
# delay_mock.assert_called_with(self.pl_inst.id)
@tag('integration', 'error-pman')
def test_integration_plugin_instance_detail_success(self):
# add an FS plugin to the system
plugin_parameters = [{'name': 'dir', 'type': 'path', 'action': 'store',
'optional': False, 'flag': '--dir', 'short_flag': '-d',
'help': 'test plugin', 'ui_exposed': True}]
self.plg_data = {'description': 'A simple chris fs app demo',
'version': '0.1',
'dock_image': 'fnndsc/pl-simplefsapp',
'execshell': 'python3',
'selfpath': '/usr/local/bin',
'selfexec': 'simplefsapp'}
self.plg_meta_data = {'name': 'simplefsapp',
'title': 'Dir plugin',
'license': 'MIT',
'type': 'fs',
'icon': 'http://github.com/plugin',
'category': 'Dir',
'stars': 0,
'authors': 'FNNDSC (dev@babyMRI.org)'}
self.plugin_repr = self.plg_data.copy()
self.plugin_repr.update(self.plg_meta_data)
self.plugin_repr['parameters'] = plugin_parameters
(compute_resource, tf) = ComputeResource.objects.get_or_create(
name="host", compute_url=COMPUTE_RESOURCE_URL)
data = self.plg_meta_data.copy()
(pl_meta, tf) = PluginMeta.objects.get_or_create(**data)
data = self.plg_data.copy()
(plugin, tf) = Plugin.objects.get_or_create(meta=pl_meta, **data)
plugin.compute_resources.set([compute_resource])
plugin.save()
# add plugin's parameters
parameters = plugin_parameters
(pl_param, tf) = PluginParameter.objects.get_or_create(
plugin=plugin,
name=parameters[0]['name'],
type=parameters[0]['type'],
flag=parameters[0]['flag'])
# upload a file to the Swift storage user's space
user_space_path = '%s/uploads/' % self.username
with io.StringIO('Test file') as f:
self.swift_manager.upload_obj(user_space_path + 'test.txt', f.read(),
content_type='text/plain')
# create a plugin's instance
user = User.objects.get(username=self.username)
(pl_inst, tf) = PluginInstance.objects.get_or_create(
title='test2', plugin=plugin, owner=user, status='scheduled',
compute_resource=plugin.compute_resources.all()[0])
PathParameter.objects.get_or_create(plugin_inst=pl_inst, plugin_param=pl_param,
value=user_space_path)
read_update_delete_url = reverse("plugininstance-detail",
kwargs={"pk": pl_inst.id})
# run the plugin instance
plg_inst_manager = PluginInstanceManager(pl_inst)
plg_inst_manager.run_plugin_instance_app()
# In the following we keep checking the status until the job ends with
# 'finishedSuccessfully'. The code runs in a lazy loop poll with a
# max number of attempts at 10 second intervals.
self.client.login(username=self.username, password=self.password)
maxLoopTries = 10
currentLoop = 1
b_checkAgain = True
time.sleep(10)
while b_checkAgain:
plg_inst_manager.check_plugin_instance_app_exec_status()
response = self.client.get(read_update_delete_url)
str_responseStatus = response.data['status']
if str_responseStatus == 'finishedSuccessfully':
b_checkAgain = False
elif currentLoop < maxLoopTries:
time.sleep(10)
if currentLoop == maxLoopTries:
b_checkAgain = False
currentLoop += 1
self.assertContains(response, "finishedSuccessfully")
self.assertContains(response, "simplefsapp")
# delete files from swift storage
self.swift_manager.delete_obj(user_space_path + 'test.txt')
# obj_paths = self.swift_manager.ls(pl_inst.get_output_path())
# for path in obj_paths:
# self.swift_manager.delete_obj(path)
def test_plugin_instance_detail_failure_unauthenticated(self):
response = self.client.get(self.read_update_delete_url)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
def test_plugin_instance_update_success(self):
put = json.dumps({
"template": {"data": [{"name": "title", "value": "Test instance"},
{"name": "status", "value": "cancelled"}]}})
self.client.login(username=self.username, password=self.password)
response = self.client.put(self.read_update_delete_url, data=put,
content_type=self.content_type)
self.assertContains(response, "Test instance")
self.assertContains(response, "cancelled")
def test_plugin_instance_update_failure_current_status_is_finishedSuccessfully_or_finishedWithError(self):
put = json.dumps({
"template": {"data": [{"name": "status", "value": "cancelled"}]}})
self.pl_inst.status = 'finishedSuccessfully'
self.pl_inst.save()
self.client.login(username=self.username, password=self.password)
response = self.client.put(self.read_update_delete_url, data=put,
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.pl_inst.status = 'finishedWithError'
self.pl_inst.save()
self.client.login(username=self.username, password=self.password)
response = self.client.put(self.read_update_delete_url, data=put,
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_plugin_instance_update_failure_status_can_only_be_changed_to_cancelled(self):
put = json.dumps({
"template": {"data": [{"name": "status", "value": "finishedSuccessfully"}]}})
self.client.login(username=self.username, password=self.password)
response = self.client.put(self.read_update_delete_url, data=put,
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_plugin_instance_update_failure_unauthenticated(self):
response = self.client.put(self.read_update_delete_url, data={},
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
def test_plugin_instance_update_failure_access_denied(self):
put = json.dumps({
"template": {"data": [{"name": "status", "value": "cancelled"}]}})
self.client.login(username=self.other_username, password=self.other_password)
response = self.client.put(self.read_update_delete_url, data=put,
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
def test_plugin_instance_delete_success(self):
self.client.login(username=self.username, password=self.password)
response = self.client.delete(self.read_update_delete_url)
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
self.assertEqual(PluginInstance.objects.count(), 0)
def test_plugin_instance_delete_failure_unauthenticated(self):
response = self.client.delete(self.read_update_delete_url)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
def test_plugin_instance_delete_failure_access_denied(self):
self.client.login(username=self.other_username, password=self.other_password)
response = self.client.delete(self.read_update_delete_url)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
class PluginInstanceListQuerySearchViewTests(ViewTests):
"""
Test the plugininstance-list-query-search view.
"""
def setUp(self):
super(PluginInstanceListQuerySearchViewTests, self).setUp()
user = User.objects.get(username=self.username)
# create two plugin instances
plugin = Plugin.objects.get(meta__name="pacspull")
(inst, tf) = PluginInstance.objects.get_or_create(
plugin=plugin, owner=user, compute_resource=plugin.compute_resources.all()[0])
plugin = Plugin.objects.get(meta__name="mri_convert")
(inst, tf) = PluginInstance.objects.get_or_create(
plugin=plugin, owner=user, previous=inst,
compute_resource=plugin.compute_resources.all()[0])
# set second instance's status
inst.status = 'finishedSuccessfully'
inst.save()
self.list_url = reverse("allplugininstance-list-query-search") + '?status=created'
def test_plugin_instance_query_search_list_success(self):
self.client.login(username=self.username, password=self.password)
response = self.client.get(self.list_url)
# response should only contain the instances that match the query
self.assertContains(response, 'created')
self.assertNotContains(response,'finishedSuccessfully')
def test_plugin_instance_query_search_list_failure_unauthenticated(self):
response = self.client.get(self.list_url)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
class PluginInstanceDescendantListViewTests(ViewTests):
"""
Test the plugininstance-descendant-list view.
"""
def setUp(self):
super(PluginInstanceDescendantListViewTests, self).setUp()
user = User.objects.get(username=self.username)
# create an 'fs' plugin instance
plugin = Plugin.objects.get(meta__name="pacspull")
(fs_inst, tf) = PluginInstance.objects.get_or_create(
plugin=plugin, owner=user, compute_resource=plugin.compute_resources.all()[0])
# create a tree of 'ds' plugin instances
plugin = Plugin.objects.get(meta__name="mri_convert")
PluginInstance.objects.get_or_create(
plugin=plugin, owner=user, previous=fs_inst,
compute_resource=plugin.compute_resources.all()[0])
(pl_meta, tf) = PluginMeta.objects.get_or_create(name='mri_info', type='ds')
(plugin, tf) = Plugin.objects.get_or_create(meta=pl_meta, version='0.1')
plugin.compute_resources.set([self.compute_resource])
plugin.save()
(ds_inst, tf) = PluginInstance.objects.get_or_create(
plugin=plugin, owner=user, previous=fs_inst,
compute_resource=plugin.compute_resources.all()[0])
(pl_meta, tf) = PluginMeta.objects.get_or_create(name='mri_surf', type='ds')
(plugin, tf) = Plugin.objects.get_or_create(meta=pl_meta, version='0.1')
plugin.compute_resources.set([self.compute_resource])
plugin.save()
PluginInstance.objects.get_or_create(
plugin=plugin, owner=user, previous=ds_inst,
compute_resource=plugin.compute_resources.all()[0])
self.list_url = reverse("plugininstance-descendant-list", kwargs={"pk": fs_inst.id})
def test_plugin_instance_descendant_list_success(self):
self.client.login(username=self.username, password=self.password)
response = self.client.get(self.list_url)
# response should contain all the instances in the tree
self.assertContains(response, "pacspull")
self.assertContains(response, "mri_convert")
self.assertContains(response, "mri_info")
self.assertContains(response, "mri_surf")
def test_plugin_instance_descendant_list_failure_unauthenticated(self):
response = self.client.get(self.list_url)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
class PluginInstanceSplitListViewTests(ViewTests):
"""
Test the plugininstancesplit-list view.
"""
def setUp(self):
super(PluginInstanceSplitListViewTests, self).setUp()
user = User.objects.get(username=self.username)
# create an 'fs' plugin instance
plugin = Plugin.objects.get(meta__name="pacspull")
(self.fs_inst, tf) = PluginInstance.objects.get_or_create(
plugin=plugin, owner=user, compute_resource=plugin.compute_resources.all()[0])
# create a 'ts' plugin
(pl_meta, tf) = PluginMeta.objects.get_or_create(name='pl-topologicalcopy', type='ts')
(plugin_ts, tf) = Plugin.objects.get_or_create(meta=pl_meta, version='0.1')
plugin_ts.compute_resources.set([self.compute_resource])
plugin_ts.save()
self.create_read_url = reverse("plugininstancesplit-list", kwargs={"pk": self.fs_inst.id})
def test_plugin_instance_split_create_failure_access_denied(self):
post = json.dumps({"template": {"data": [{"name": "filter", "value": ""}]}})
self.client.login(username=self.other_username, password=self.other_password)
response = self.client.post(self.create_read_url, data=post,
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
def test_plugin_instance_split_create_success(self):
post = json.dumps({"template": {"data": [{"name": "filter", "value": ""}]}})
# add parameters to the plugin before the POST request
plugin = Plugin.objects.get(meta__name="pl-topologicalcopy")
PluginParameter.objects.get_or_create(plugin=plugin, name='filter', type='string')
PluginParameter.objects.get_or_create(plugin=plugin, name='plugininstances',
type='string')
self.client.login(username=self.username, password=self.password)
# make API requests
response = self.client.post(self.create_read_url, data=post,
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.fs_inst.status = 'finishedSuccessfully'
self.fs_inst.save()
with mock.patch.object(views.run_plugin_instance, 'delay',
return_value=None) as delay_mock:
response = self.client.post(self.create_read_url, data=post,
content_type=self.content_type)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
# check that the run_plugin_instance task was called with appropriate args
delay_mock.assert_called_once()
def test_plugin_instance_split_list_success(self):
self.client.login(username=self.username, password=self.password)
response = self.client.get(self.create_read_url)
# response should contain all the instances in the tree
self.assertContains(response, "filter")
def test_plugin_instance_split_list_failure_unauthenticated(self):
response = self.client.get(self.create_read_url)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
class PluginInstanceParameterListViewTests(ViewTests):
"""
Test the plugininstance-parameter-list view.
"""
def setUp(self):
super(PluginInstanceParameterListViewTests, self).setUp()
user = User.objects.get(username=self.username)
# create a plugin
plugin = Plugin.objects.get(meta__name="pacspull")
parameters = [{"type": "path", "name": "param1", "flag": "--param1"},
{"type": "float", "name": "param2", "flag": "--param2"}]
# add plugin's parameters
(param1, tf) = PluginParameter.objects.get_or_create(
plugin=plugin,
name=parameters[0]['name'],
type=parameters[0]['type'],
flag=parameters[0]['flag'])
(param2, tf) = PluginParameter.objects.get_or_create(
plugin=plugin,
name=parameters[1]['name'],
type=parameters[1]['type'],
flag=parameters[1]['flag'])
# create a plugin instance
(inst, tf) = PluginInstance.objects.get_or_create(
plugin=plugin, owner=user, compute_resource=plugin.compute_resources.all()[0])
# create two plugin parameter instances associated to the plugin instance
PathParameter.objects.get_or_create(plugin_inst=inst, plugin_param=param1,
value=self.username)
FloatParameter.objects.get_or_create(plugin_inst=inst, plugin_param=param2,
value=3.14)
self.list_url = reverse("plugininstance-parameter-list", kwargs={"pk": inst.id})
def test_plugin_instance_parameter_list_success(self):
self.client.login(username=self.username, password=self.password)
response = self.client.get(self.list_url)
self.assertContains(response, "param1")
self.assertContains(response, self.username)
self.assertContains(response, "param2")
self.assertContains(response, 3.14)
def test_plugin_instance_parameter_list_failure_unauthenticated(self):
response = self.client.get(self.list_url)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
class PluginInstanceFileViewTests(ViewTests):
"""
Generic plugin instance file view tests' setup and tearDown.
"""
def setUp(self):
super().setUp()
# create a plugin instance
user = User.objects.get(username=self.username)
plugin = Plugin.objects.get(meta__name="pacspull")
(self.plg_inst, tf) = PluginInstance.objects.get_or_create(
plugin=plugin, owner=user, compute_resource=plugin.compute_resources.all()[0])
# create a plugin instance file associated to the plugin instance
self.swift_manager = SwiftManager(settings.SWIFT_CONTAINER_NAME,
settings.SWIFT_CONNECTION_PARAMS)
# upload file to Swift storage
self.path = 'tests/file1.txt'
with io.StringIO("test file") as file1:
self.swift_manager.upload_obj(self.path, file1.read(),
content_type='text/plain')
(self.plg_inst_file, tf) = PluginInstanceFile.objects.get_or_create(
plugin_inst=self.plg_inst
)
self.plg_inst_file.fname.name = self.path
self.plg_inst_file.save()
# create test directory where files are created
# self.test_dir = settings.MEDIA_ROOT + '/test'
# settings.MEDIA_ROOT = self.test_dir
# if not os.path.exists(self.test_dir):
# os.makedirs(self.test_dir)
def tearDown(self):
# delete file from Swift storage
self.swift_manager.delete_obj(self.path)
super().tearDown()
# remove test directory
# shutil.rmtree(self.test_dir)
# settings.MEDIA_ROOT = os.path.dirname(self.test_dir)
class PluginInstanceFileListViewTests(PluginInstanceFileViewTests):
"""
Test the plugininstancefile-list view.
"""
def setUp(self):
super(PluginInstanceFileListViewTests, self).setUp()
self.list_url = reverse("plugininstancefile-list", kwargs={"pk": self.plg_inst.id})
def test_plugin_instance_file_create_failure_post_not_allowed(self):
self.client.login(username=self.username, password=self.password)
# try to create a new plugin file with a POST request to the list
# POST request using multipart/form-data to be able to upload file
with io.StringIO("test file") as f:
post = {"fname": f}
response = self.client.post(self.list_url, data=post)
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
def test_plugin_instance_file_list_success(self):
self.client.login(username=self.username, password=self.password)
response = self.client.get(self.list_url)
self.assertContains(response, "file1.txt")
def test_plugin_instance_file_list_failure_unauthenticated(self):
response = self.client.get(self.list_url)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
def test_plugin_instance_file_list_failure_access_denied(self):
self.client.login(username=self.other_username, password=self.other_password)
response = self.client.get(self.list_url)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
class AllPluginInstanceFileListViewTests(PluginInstanceFileViewTests):
"""
Test the allplugininstancefile-list view.
"""
def setUp(self):
super(AllPluginInstanceFileListViewTests, self).setUp()
self.list_url = reverse("allplugininstancefile-list")
def test_all_plugin_instance_file_create_failure_post_not_allowed(self):
self.client.login(username=self.username, password=self.password)
# try to create a new plugin file with a POST request to the list
# POST request using multipart/form-data to be able to upload file
with io.StringIO("test file") as f:
post = {"fname": f}
response = self.client.post(self.list_url, data=post)
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
def test_all_plugin_instance_file_list_success(self):
self.client.login(username=self.username, password=self.password)
response = self.client.get(self.list_url)
self.assertContains(response, "file1.txt")
def test_all_plugin_instance_file_list_from_shared_feed_success(self):
self.client.login(username=self.other_username, password=self.other_password)
plg_inst = self.plg_inst
user1 = User.objects.get(username=self.username)
user2 = User.objects.get(username=self.other_username)
plg_inst.feed.owner.set([user1, user2])
response = self.client.get(self.list_url)
self.assertContains(response, "file1.txt")
def test_all_plugin_instance_file_list_failure_unauthenticated(self):
response = self.client.get(self.list_url)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
def test_all_plugin_instance_file_list_files_in_not_owned_feeds_inaccessible(self):
self.client.login(username=self.other_username, password=self.other_password)
response = self.client.get(self.list_url)
self.assertNotContains(response, "file1.txt")
class AllPluginInstanceFileListQuerySearchViewTests(PluginInstanceFileViewTests):
"""
Test the allplugininstancefile-list-query-search view.
"""
def setUp(self):
super(AllPluginInstanceFileListQuerySearchViewTests, self).setUp()
self.list_url = reverse("allplugininstancefile-list-query-search") + '?id=' + \
str(self.plg_inst_file.id)
def test_plugin_instance_query_search_list_success(self):
self.client.login(username=self.username, password=self.password)
response = self.client.get(self.list_url)
self.assertContains(response, 'file1.txt')
def test_plugin_instance_query_search_list_failure_unauthenticated(self):
response = self.client.get(self.list_url)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
class PluginInstanceFileDetailViewTests(PluginInstanceFileViewTests):
"""
Test the plugininstancefile-detail view.
"""
def setUp(self):
super(PluginInstanceFileDetailViewTests, self).setUp()
#self.corresponding_feed_url = reverse("feed-detail", kwargs={"pk": feed.id})
self.corresponding_plugin_instance_url = reverse("plugininstance-detail",
kwargs={"pk": self.plg_inst.id})
self.read_url = reverse("plugininstancefile-detail",
kwargs={"pk": self.plg_inst_file.id})
def test_plugin_instance_file_detail_success(self):
self.client.login(username=self.username, password=self.password)
response = self.client.get(self.read_url)
self.assertContains(response, "file1.txt")
self.assertTrue(response.data["plugin_inst"].endswith(
self.corresponding_plugin_instance_url))
def test_plugin_instance_file_detail_success_user_chris(self):
self.client.login(username=self.chris_username, password=self.chris_password)
response = self.client.get(self.read_url)
self.assertContains(response, "file1.txt")
self.assertTrue(response.data["plugin_inst"].endswith(
self.corresponding_plugin_instance_url))
def test_plugin_instance_file_detail_failure_not_related_feed_owner(self):
self.client.login(username=self.other_username, password=self.other_password)
response = self.client.get(self.read_url)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
def test_plugin_instance_file_detail_failure_unauthenticated(self):
response = self.client.get(self.read_url)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
class FileResourceViewTests(PluginInstanceFileViewTests):
"""
Test the plugininstancefile-resource view.
"""
def setUp(self):
super(FileResourceViewTests, self).setUp()
self.download_url = reverse("plugininstancefile-resource",
kwargs={"pk": self.plg_inst_file.id}) + 'file1.txt'
def test_fileresource_get(self):
plg_inst_file = PluginInstanceFile.objects.get(fname="tests/file1.txt")
fileresource_view_inst = mock.Mock()
fileresource_view_inst.get_object = mock.Mock(return_value=plg_inst_file)
request_mock = mock.Mock()
with mock.patch('plugininstances.views.Response') as response_mock:
views.FileResource.get(fileresource_view_inst, request_mock)
response_mock.assert_called_with(plg_inst_file.fname)
@tag('integration')
def test_integration_fileresource_download_success(self):
self.client.login(username=self.username, password=self.password)
response = self.client.get(self.download_url)
self.assertEqual(response.status_code, 200)
self.assertEqual(str(response.content, 'utf-8'), "test file")
def test_fileresource_download_failure_not_related_feed_owner(self):
self.client.login(username=self.other_username, password=self.other_password)
response = self.client.get(self.download_url)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
def test_fileresource_download_failure_unauthenticated(self):
response = self.client.get(self.download_url)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
| 45.747859
| 110
| 0.645369
| 5,416
| 48,081
| 5.503139
| 0.074409
| 0.02919
| 0.020533
| 0.0308
| 0.786579
| 0.751149
| 0.718403
| 0.686865
| 0.658782
| 0.635195
| 0
| 0.006616
| 0.251763
| 48,081
| 1,050
| 111
| 45.791429
| 0.821853
| 0.100268
| 0
| 0.633609
| 0
| 0
| 0.081336
| 0.011167
| 0
| 0
| 0
| 0
| 0.108815
| 1
| 0.088154
| false
| 0.064738
| 0.027548
| 0
| 0.134986
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
228748a47a5004dc7264445d2e0291e88e169882
| 104
|
py
|
Python
|
src/officehours_api/apps.py
|
vikaschanduri/remote-office-hours-queue
|
485b7df27a013e804c42f04612cff0d1a911c64a
|
[
"Apache-2.0"
] | 9
|
2020-04-13T13:18:43.000Z
|
2022-03-04T21:10:58.000Z
|
src/officehours_api/apps.py
|
vikaschanduri/remote-office-hours-queue
|
485b7df27a013e804c42f04612cff0d1a911c64a
|
[
"Apache-2.0"
] | 249
|
2020-04-11T15:34:50.000Z
|
2022-02-19T00:25:28.000Z
|
src/officehours_api/apps.py
|
vikaschanduri/remote-office-hours-queue
|
485b7df27a013e804c42f04612cff0d1a911c64a
|
[
"Apache-2.0"
] | 7
|
2020-04-10T12:19:54.000Z
|
2021-04-25T19:42:41.000Z
|
from django.apps import AppConfig
class OfficehoursApiConfig(AppConfig):
name = 'officehours_api'
| 17.333333
| 38
| 0.788462
| 11
| 104
| 7.363636
| 0.909091
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.144231
| 104
| 5
| 39
| 20.8
| 0.910112
| 0
| 0
| 0
| 0
| 0
| 0.144231
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
2297c3160a507ec8cf3e0dd8574a4bad5f49d556
| 101
|
py
|
Python
|
sky_status_app/apps.py
|
embersabsalon/sky_status
|
829930904cd088b0933f4a2e54224582a0ad3d95
|
[
"MIT"
] | null | null | null |
sky_status_app/apps.py
|
embersabsalon/sky_status
|
829930904cd088b0933f4a2e54224582a0ad3d95
|
[
"MIT"
] | null | null | null |
sky_status_app/apps.py
|
embersabsalon/sky_status
|
829930904cd088b0933f4a2e54224582a0ad3d95
|
[
"MIT"
] | null | null | null |
from django.apps import AppConfig
class SkyStatusAppConfig(AppConfig):
name = 'sky_status_app'
| 16.833333
| 36
| 0.782178
| 12
| 101
| 6.416667
| 0.916667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.148515
| 101
| 5
| 37
| 20.2
| 0.895349
| 0
| 0
| 0
| 0
| 0
| 0.138614
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
229f254db42ab034a97ecc74524ff43700aecc52
| 256
|
py
|
Python
|
ds2/sorting/selectionsort.py
|
keelya/datastructures
|
467794cc67a124509d9edad0648a87a76ed2b0fc
|
[
"MIT"
] | null | null | null |
ds2/sorting/selectionsort.py
|
keelya/datastructures
|
467794cc67a124509d9edad0648a87a76ed2b0fc
|
[
"MIT"
] | null | null | null |
ds2/sorting/selectionsort.py
|
keelya/datastructures
|
467794cc67a124509d9edad0648a87a76ed2b0fc
|
[
"MIT"
] | null | null | null |
def selectionsort(L):
n = len(L)
for i in range(n-1):
max_index=0
for index in range(n - i):
if L[index] > L[max_index]:
max_index = index
L[n-i-1], L[max_index] = L[max_index], L[n-i-1]
| 25.6
| 55
| 0.476563
| 44
| 256
| 2.659091
| 0.318182
| 0.34188
| 0.230769
| 0.239316
| 0.153846
| 0
| 0
| 0
| 0
| 0
| 0
| 0.025157
| 0.378906
| 256
| 9
| 56
| 28.444444
| 0.710692
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.125
| false
| 0
| 0
| 0
| 0.125
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
22a211a74ced25992afe450d00a703bd0ceb0355
| 482
|
py
|
Python
|
seal_coating/api.py
|
bhavikpatel7023/seal_coatings
|
b9830074d48b908311a06857da62b5227c20941d
|
[
"MIT"
] | null | null | null |
seal_coating/api.py
|
bhavikpatel7023/seal_coatings
|
b9830074d48b908311a06857da62b5227c20941d
|
[
"MIT"
] | null | null | null |
seal_coating/api.py
|
bhavikpatel7023/seal_coatings
|
b9830074d48b908311a06857da62b5227c20941d
|
[
"MIT"
] | null | null | null |
from __future__ import unicode_literals
import frappe
from frappe import msgprint,throw, _
from erpnext.stock.doctype.quality_inspection_template.quality_inspection_template import get_template_details
@frappe.whitelist()
def get_item_specification_details(quality_inspection_template):
parameters = frappe.get_doc("Quality Inspection Template",quality_inspection_template)
return parameters.item_quality_inspection_parameter
@frappe.whitelist()
def test():
return "test"
| 28.352941
| 110
| 0.854772
| 58
| 482
| 6.706897
| 0.431034
| 0.262211
| 0.321337
| 0.164524
| 0.257069
| 0.257069
| 0
| 0
| 0
| 0
| 0
| 0
| 0.082988
| 482
| 16
| 111
| 30.125
| 0.880091
| 0
| 0
| 0.181818
| 0
| 0
| 0.064449
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.181818
| false
| 0
| 0.363636
| 0.090909
| 0.727273
| 0.090909
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
22b31abd10bf671cdaa303ba3f9be15a4a8bc6f3
| 37
|
py
|
Python
|
tests/__init__.py
|
SoftwareCraftsmanship2016Bristol/connect4server
|
621c3c3d01f0466acea5e0ee34d7a511bf0bd7de
|
[
"MIT"
] | null | null | null |
tests/__init__.py
|
SoftwareCraftsmanship2016Bristol/connect4server
|
621c3c3d01f0466acea5e0ee34d7a511bf0bd7de
|
[
"MIT"
] | 1
|
2016-05-22T12:46:56.000Z
|
2017-11-14T11:09:12.000Z
|
tests/__init__.py
|
SoftwareCraftsmanship2016Bristol/connect4server
|
621c3c3d01f0466acea5e0ee34d7a511bf0bd7de
|
[
"MIT"
] | null | null | null |
"""
Connect 4 Server test suite.
"""
| 9.25
| 28
| 0.621622
| 5
| 37
| 4.6
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.033333
| 0.189189
| 37
| 3
| 29
| 12.333333
| 0.733333
| 0.756757
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
22ca0f3f9b7485c28581a3d535699f14f24855c1
| 632
|
py
|
Python
|
controllers/gear/migrations/0004_auto_20210426_1845.py
|
rhaamo/camgear
|
38200cc616120ac381892bfc1996a1e97dbbfc83
|
[
"MIT"
] | null | null | null |
controllers/gear/migrations/0004_auto_20210426_1845.py
|
rhaamo/camgear
|
38200cc616120ac381892bfc1996a1e97dbbfc83
|
[
"MIT"
] | 37
|
2019-01-04T04:30:33.000Z
|
2022-03-11T23:36:05.000Z
|
controllers/gear/migrations/0004_auto_20210426_1845.py
|
rhaamo/camgear
|
38200cc616120ac381892bfc1996a1e97dbbfc83
|
[
"MIT"
] | null | null | null |
# Generated by Django 3.1.8 on 2021-04-26 18:45
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("gear", "0003_auto_20210426_1813"),
]
operations = [
migrations.RemoveField(
model_name="camera",
name="files",
),
migrations.RemoveField(
model_name="camera",
name="pictures",
),
migrations.RemoveField(
model_name="lens",
name="files",
),
migrations.RemoveField(
model_name="lens",
name="pictures",
),
]
| 21.066667
| 47
| 0.522152
| 56
| 632
| 5.767857
| 0.571429
| 0.260062
| 0.321981
| 0.371517
| 0.513932
| 0.513932
| 0
| 0
| 0
| 0
| 0
| 0.076923
| 0.362342
| 632
| 29
| 48
| 21.793103
| 0.724566
| 0.071203
| 0
| 0.695652
| 1
| 0
| 0.124786
| 0.039316
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.043478
| 0
| 0.173913
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
22ed4f75b4d609279e7a99255eab2a246a046bb4
| 281
|
py
|
Python
|
call_vector_representation.py
|
ADCenterNetwork/discern-fmk
|
4781f1a986f7b24f298b2729b87ddee4227cb1d0
|
[
"MIT"
] | null | null | null |
call_vector_representation.py
|
ADCenterNetwork/discern-fmk
|
4781f1a986f7b24f298b2729b87ddee4227cb1d0
|
[
"MIT"
] | null | null | null |
call_vector_representation.py
|
ADCenterNetwork/discern-fmk
|
4781f1a986f7b24f298b2729b87ddee4227cb1d0
|
[
"MIT"
] | null | null | null |
from parameters import *
from vector_representation import Vector_representation
x = Vector_representation(folder, pattern, vector_size = vector_size, learning_rate = learning_rate, momentum = momentum, l2_penalty = l2_penalty, epoch_first = epoch_first)
x.vector_representation()
| 56.2
| 173
| 0.836299
| 35
| 281
| 6.371429
| 0.457143
| 0.358744
| 0.188341
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.007905
| 0.099644
| 281
| 5
| 174
| 56.2
| 0.873518
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 0.5
| 0
| 0
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
22fab069ffd08dd4cb571b9fb98d68faa87815db
| 724
|
py
|
Python
|
audio/audio_io/__init__.py
|
dzungcamlang/noise_adversarial_tacotron
|
7a7fda49eb8bf82f5139743d55639d48ff204e9e
|
[
"MIT"
] | 11
|
2019-11-25T12:16:39.000Z
|
2020-11-05T15:47:13.000Z
|
audio/audio_io/__init__.py
|
yqlihust/noise_adversarial_tacotron
|
7a7fda49eb8bf82f5139743d55639d48ff204e9e
|
[
"MIT"
] | null | null | null |
audio/audio_io/__init__.py
|
yqlihust/noise_adversarial_tacotron
|
7a7fda49eb8bf82f5139743d55639d48ff204e9e
|
[
"MIT"
] | 3
|
2021-04-28T04:59:04.000Z
|
2022-01-05T12:22:03.000Z
|
import librosa
import torch
import librosa.filters
import numpy as np
import scipy
def load_wav(path, sample_rate):
return librosa.core.load(path, sr=sample_rate)[0]
def load_to_torch(path, sample_rate):
wave = load_wav(path, sample_rate)
return torch.from_numpy(wave).float()
def save_wav(wav, path, sample_rate):
wav *= 32767 / max(0.01, np.max(np.abs(wav)))
scipy.io.wavfile.write(path, sample_rate, wav.astype(np.int16))
def save_from_torch(wav, path, sample_rate):
wav = wav.detach().cpu().numpy()
save_wav(wav, path, sample_rate)
def show_notebook(wave:np.ndarray, sr=16000):
from IPython.display import Audio
wave = np.int16(wave * 65536)
return Audio(wave, rate=sr)
| 23.354839
| 67
| 0.714088
| 117
| 724
| 4.264957
| 0.358974
| 0.160321
| 0.196393
| 0.170341
| 0.250501
| 0.204409
| 0
| 0
| 0
| 0
| 0
| 0.037767
| 0.15884
| 724
| 30
| 68
| 24.133333
| 0.781609
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.3
| 0.05
| 0.7
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
a3bc61c8428fb4f0784468105d33aa3580a28023
| 2,470
|
py
|
Python
|
IPython/kernel/managerabc.py
|
pyarnold/ipython
|
c4797f7f069d0a974ddfa1e4251c7550c809dba0
|
[
"BSD-3-Clause-Clear"
] | 1
|
2020-12-18T01:07:55.000Z
|
2020-12-18T01:07:55.000Z
|
IPython/kernel/managerabc.py
|
pyarnold/ipython
|
c4797f7f069d0a974ddfa1e4251c7550c809dba0
|
[
"BSD-3-Clause-Clear"
] | null | null | null |
IPython/kernel/managerabc.py
|
pyarnold/ipython
|
c4797f7f069d0a974ddfa1e4251c7550c809dba0
|
[
"BSD-3-Clause-Clear"
] | null | null | null |
"""Abstract base class for kernel managers."""
#-----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
import abc
from IPython.utils.py3compat import with_metaclass
class KernelManagerABC(with_metaclass(abc.ABCMeta, object)):
"""KernelManager ABC.
The docstrings for this class can be found in the base implementation:
`IPython.kernel.kernelmanager.KernelManager`
"""
@abc.abstractproperty
def kernel(self):
pass
@abc.abstractproperty
def shell_channel_class(self):
pass
@abc.abstractproperty
def iopub_channel_class(self):
pass
@abc.abstractproperty
def hb_channel_class(self):
pass
@abc.abstractproperty
def stdin_channel_class(self):
pass
#--------------------------------------------------------------------------
# Channel management methods
#--------------------------------------------------------------------------
@abc.abstractmethod
def start_channels(self, shell=True, iopub=True, stdin=True, hb=True):
pass
@abc.abstractmethod
def stop_channels(self):
pass
@abc.abstractproperty
def channels_running(self):
pass
@abc.abstractproperty
def shell_channel(self):
pass
@abc.abstractproperty
def iopub_channel(self):
pass
@abc.abstractproperty
def stdin_channel(self):
pass
@abc.abstractproperty
def hb_channel(self):
pass
#--------------------------------------------------------------------------
# Kernel management
#--------------------------------------------------------------------------
@abc.abstractmethod
def start_kernel(self, **kw):
pass
@abc.abstractmethod
def shutdown_kernel(self, now=False, restart=False):
pass
@abc.abstractmethod
def restart_kernel(self, now=False, **kw):
pass
@abc.abstractproperty
def has_kernel(self):
pass
@abc.abstractmethod
def interrupt_kernel(self):
pass
@abc.abstractmethod
def signal_kernel(self, signum):
pass
@abc.abstractmethod
def is_alive(self):
pass
| 23.084112
| 79
| 0.533198
| 227
| 2,470
| 5.696035
| 0.312775
| 0.08662
| 0.187162
| 0.201083
| 0.342614
| 0.319412
| 0.266821
| 0
| 0
| 0
| 0
| 0.002592
| 0.219028
| 2,470
| 106
| 80
| 23.301887
| 0.667703
| 0.345344
| 0
| 0.633333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.316667
| false
| 0.316667
| 0.033333
| 0
| 0.366667
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
a3d2af159ce0476044502bc9fee626a6023c77e2
| 185
|
py
|
Python
|
boards/cache.py
|
vladtsap/collection
|
d5687607080ff7d7bc6fd8ac29bb6a6233b486d1
|
[
"Apache-2.0"
] | null | null | null |
boards/cache.py
|
vladtsap/collection
|
d5687607080ff7d7bc6fd8ac29bb6a6233b486d1
|
[
"Apache-2.0"
] | null | null | null |
boards/cache.py
|
vladtsap/collection
|
d5687607080ff7d7bc6fd8ac29bb6a6233b486d1
|
[
"Apache-2.0"
] | null | null | null |
from boards.models import Board
def collection_last_modified_at(request):
board = Board.objects.filter(slug='collection').first()
return board.refreshed_at if board else None
| 26.428571
| 59
| 0.778378
| 26
| 185
| 5.384615
| 0.769231
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.135135
| 185
| 6
| 60
| 30.833333
| 0.875
| 0
| 0
| 0
| 0
| 0
| 0.054054
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.25
| 0
| 0.75
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
a3f29dc2be4eef2453b48e2212ac6437897df3cb
| 134
|
py
|
Python
|
src/http/post-index/user.py
|
StrataOncology/karmabot
|
66a282d382d87d0573e70a1fb3dbdf806fea2834
|
[
"MIT"
] | null | null | null |
src/http/post-index/user.py
|
StrataOncology/karmabot
|
66a282d382d87d0573e70a1fb3dbdf806fea2834
|
[
"MIT"
] | null | null | null |
src/http/post-index/user.py
|
StrataOncology/karmabot
|
66a282d382d87d0573e70a1fb3dbdf806fea2834
|
[
"MIT"
] | null | null | null |
from dataclasses import dataclass, field
@dataclass
class User:
name: str = field(default="")
karma: int = field(default=0)
| 16.75
| 40
| 0.69403
| 17
| 134
| 5.470588
| 0.764706
| 0.258065
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.009259
| 0.19403
| 134
| 7
| 41
| 19.142857
| 0.851852
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.2
| 0
| 0.8
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
4a2a1f3a5457d83765b7b492d5d1eb8b1d5adf2b
| 102
|
py
|
Python
|
payment_system/apps.py
|
OlexandrTopuzov/Data_converter
|
0ac2319ccaae790af35ab2202724c65d83d32ecc
|
[
"MIT"
] | null | null | null |
payment_system/apps.py
|
OlexandrTopuzov/Data_converter
|
0ac2319ccaae790af35ab2202724c65d83d32ecc
|
[
"MIT"
] | null | null | null |
payment_system/apps.py
|
OlexandrTopuzov/Data_converter
|
0ac2319ccaae790af35ab2202724c65d83d32ecc
|
[
"MIT"
] | null | null | null |
from django.apps import AppConfig
class PaymentSystemConfig(AppConfig):
name = 'payment_system'
| 17
| 37
| 0.784314
| 11
| 102
| 7.181818
| 0.909091
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.147059
| 102
| 5
| 38
| 20.4
| 0.908046
| 0
| 0
| 0
| 0
| 0
| 0.137255
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
4a353be78fc1cf071fa1e58e175e432b9cf96fa8
| 12
|
py
|
Python
|
hipsternet/constant.py
|
lmxhappy/hipsternet
|
c505330d3677689c0aa836a3480f513a56ca18ef
|
[
"Unlicense"
] | null | null | null |
hipsternet/constant.py
|
lmxhappy/hipsternet
|
c505330d3677689c0aa836a3480f513a56ca18ef
|
[
"Unlicense"
] | null | null | null |
hipsternet/constant.py
|
lmxhappy/hipsternet
|
c505330d3677689c0aa836a3480f513a56ca18ef
|
[
"Unlicense"
] | null | null | null |
eps = 1e-8
| 6
| 11
| 0.5
| 3
| 12
| 2
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.25
| 0.333333
| 12
| 1
| 12
| 12
| 0.5
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
4a4c5371f76f5580e038f0bf88e8d99dfb7139ef
| 632
|
py
|
Python
|
chapter_4/test_4_3.py
|
ztaylor2/cracking-the-coding-interview
|
0587d233d76f99481667a96806acd6dd007aa5e6
|
[
"MIT"
] | null | null | null |
chapter_4/test_4_3.py
|
ztaylor2/cracking-the-coding-interview
|
0587d233d76f99481667a96806acd6dd007aa5e6
|
[
"MIT"
] | null | null | null |
chapter_4/test_4_3.py
|
ztaylor2/cracking-the-coding-interview
|
0587d233d76f99481667a96806acd6dd007aa5e6
|
[
"MIT"
] | null | null | null |
"""Test 4.3."""
import sys
sys.path.insert(0, '/Users/zt/programming/interviews/interview-prep/cracking-the-coding-interview/data_structures')
from bst import BinarySearchTree, Node
# def test_list_of_depths():
# """Test list of depths returns correctly."""
# from CTCI_4_3 import list_of_depths
# bst = BinarySearchTree()
# bst.root = Node(5)
# bst.root.left = Node(3)
# bst.root.right = Node(7)
# bst.root.left.left = Node(2)
# bst.root.left.right = Node(4)
# bst.root.right.left = Node(6)
# bst.root.right.right = Node(8)
# assert list_of_depths(bst) == [[5], [3, 7], [2, 4, 6, 8]]
| 31.6
| 115
| 0.64557
| 97
| 632
| 4.103093
| 0.402062
| 0.123116
| 0.120603
| 0.080402
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.036822
| 0.183544
| 632
| 19
| 116
| 33.263158
| 0.734496
| 0.685127
| 0
| 0
| 0
| 0.333333
| 0.510989
| 0.510989
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.666667
| 0
| 0.666667
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
4a765c295075a8263b11b37345ea5a7ee28e2dab
| 166
|
py
|
Python
|
Analyzer.py
|
yuxiang-zhang/conuhacks-vi
|
f4eb7c5f068ad820bde5ee2051f76a5851e52ec1
|
[
"MIT"
] | null | null | null |
Analyzer.py
|
yuxiang-zhang/conuhacks-vi
|
f4eb7c5f068ad820bde5ee2051f76a5851e52ec1
|
[
"MIT"
] | null | null | null |
Analyzer.py
|
yuxiang-zhang/conuhacks-vi
|
f4eb7c5f068ad820bde5ee2051f76a5851e52ec1
|
[
"MIT"
] | null | null | null |
import pandas as pd
class TracksAnalyzer:
def __init__(self, json_data):
self.data = pd.json_normalize(json_data)
def analyze(self):
pass
| 15.090909
| 48
| 0.662651
| 22
| 166
| 4.681818
| 0.636364
| 0.15534
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.259036
| 166
| 10
| 49
| 16.6
| 0.837398
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0.166667
| 0.166667
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 1
| 0
|
0
| 4
|
4ac1a29b0b9999bdff825528ff44ac909194df92
| 175
|
py
|
Python
|
Scripts/django-admin.py
|
mohamed-byte/django-blog
|
bd554dd2c00578b827343aef739cc4c602fc1a92
|
[
"bzip2-1.0.6"
] | null | null | null |
Scripts/django-admin.py
|
mohamed-byte/django-blog
|
bd554dd2c00578b827343aef739cc4c602fc1a92
|
[
"bzip2-1.0.6"
] | null | null | null |
Scripts/django-admin.py
|
mohamed-byte/django-blog
|
bd554dd2c00578b827343aef739cc4c602fc1a92
|
[
"bzip2-1.0.6"
] | null | null | null |
#!c:\users\administrator\desktop\projects\blogger\scripts\python.exe
from django.core import management
if __name__ == "__main__":
management.execute_from_command_line()
| 29.166667
| 68
| 0.8
| 22
| 175
| 5.863636
| 0.909091
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.085714
| 175
| 5
| 69
| 35
| 0.80625
| 0.382857
| 0
| 0
| 0
| 0
| 0.074766
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.333333
| 0
| 0.333333
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
4352d3aeb5bcaa91d0be19c5c1d1964f91a02a25
| 967
|
py
|
Python
|
month03.2/django/day01/mysitel/mysitel/views.py
|
Amiao-miao/all-codes
|
ec50036d42d40086cac5fddf6baf4de18ac91e55
|
[
"Apache-2.0"
] | 1
|
2021-02-02T02:17:37.000Z
|
2021-02-02T02:17:37.000Z
|
month03.2/django/day01/mysitel/mysitel/views.py
|
Amiao-miao/all-codes
|
ec50036d42d40086cac5fddf6baf4de18ac91e55
|
[
"Apache-2.0"
] | null | null | null |
month03.2/django/day01/mysitel/mysitel/views.py
|
Amiao-miao/all-codes
|
ec50036d42d40086cac5fddf6baf4de18ac91e55
|
[
"Apache-2.0"
] | null | null | null |
from django.http import HttpResponse
# 视图函数
# 参数为请求对象
# 返回值为响应对象
def page_2003(request):
return HttpResponse('这是编号为2003的页面')
def page_2004(request):
return HttpResponse('这是编号为2004的页面')
def page_index(request):
return HttpResponse('<h1>不要找小火箭页面啦,我是默认首页</h1>')
def page_num(request,num):
return HttpResponse(f'path转换器:这是编号为{num}的页面')
def page_data(request,data):
return HttpResponse(f'data:{data}')
def page_path(request,data2):
return HttpResponse(f'path:{data2}')
def mymath(request,n1,giao,n2):
if giao not in ['add','sub','mul']:
return HttpResponse('运算有误')
result=0
if giao=='add':
result=n1+n2
elif giao=='sub':
result=n1-n2
elif giao=='mul':
result=n1*n2
# 测试request对象的使用,从request对象中获取客户端请求的信息
print(request.method)
print(request.path_info)
return HttpResponse(f'计算结果为{result}')
def birthday_view(request,y,m,d):
return HttpResponse(f'您的生日为:{y}年{m}月{d}日')
| 22.488372
| 52
| 0.682523
| 131
| 967
| 4.977099
| 0.435115
| 0.248466
| 0.145706
| 0.042945
| 0.055215
| 0
| 0
| 0
| 0
| 0
| 0
| 0.036341
| 0.174767
| 967
| 43
| 53
| 22.488372
| 0.780702
| 0.059979
| 0
| 0
| 0
| 0
| 0.161326
| 0.050829
| 0
| 0
| 0
| 0
| 0
| 1
| 0.285714
| false
| 0
| 0.035714
| 0.25
| 0.642857
| 0.071429
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
43563cb9498830ff26a81f59479ab920b2ef4ea0
| 64
|
py
|
Python
|
src/pcrunner/scripts/pcr.py
|
maartenq/pcrunner
|
52503ada09a0351e55562db7492a16f41809a734
|
[
"0BSD"
] | null | null | null |
src/pcrunner/scripts/pcr.py
|
maartenq/pcrunner
|
52503ada09a0351e55562db7492a16f41809a734
|
[
"0BSD"
] | 82
|
2016-08-13T14:07:00.000Z
|
2022-01-31T19:10:55.000Z
|
src/pcrunner/scripts/pcr.py
|
maartenq/pcrunner
|
52503ada09a0351e55562db7492a16f41809a734
|
[
"0BSD"
] | null | null | null |
#!/usr/bin/env python3
from pcrunner.main import main
main()
| 9.142857
| 30
| 0.71875
| 10
| 64
| 4.6
| 0.8
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.018519
| 0.15625
| 64
| 6
| 31
| 10.666667
| 0.833333
| 0.328125
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.5
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
437970cfde712cb45584abb29d32ed2dd57d9364
| 1,178
|
py
|
Python
|
beetsplug/pathfield.py
|
fortysix2ahead/beets-kergoth
|
23e3175bb66abdde8237aa4677c5e4890019249c
|
[
"BlueOak-1.0.0"
] | 2
|
2020-01-06T22:30:21.000Z
|
2020-05-07T08:01:19.000Z
|
beetsplug/pathfield.py
|
fortysix2ahead/beets-kergoth
|
23e3175bb66abdde8237aa4677c5e4890019249c
|
[
"BlueOak-1.0.0"
] | 3
|
2021-11-02T11:09:09.000Z
|
2021-11-06T23:20:25.000Z
|
beetsplug/pathfield.py
|
fortysix2ahead/beets-kergoth
|
23e3175bb66abdde8237aa4677c5e4890019249c
|
[
"BlueOak-1.0.0"
] | 1
|
2020-04-20T18:42:19.000Z
|
2020-04-20T18:42:19.000Z
|
"""Add template functions for working with paths via fields.
- path: join the arguments with a null (\0)
- pathfield: replace a null (\0) with the path separator
With the former, we can store a path with \0 separators in a saved format, i.e.
with the savedformats plugin. With the latter, we can make use of such a path in
a path format, whether provided by that plugin or the inline plugin.
Example:
item_fields:
some_path: '\0'.join('Music', 'Subdir1', genre)
item_formats:
some_other_path: '%path{Music,Subdir2,$composer}'
paths:
comp:1: %pathfield{$some_other_path}/%$artist - $title
default: %pathfield{$some_path}/%$artist - $title
"""
from __future__ import division, absolute_import, print_function
from beets import config
from beets.plugins import BeetsPlugin
from beets.library import Album, Item
class PathfieldPlugin(BeetsPlugin):
def __init__(self):
super().__init__()
self.template_funcs['path'] = self.tmpl_path
self.template_funcs['pathfield'] = self.tmpl_pathfield
def tmpl_path(self, *p):
return '\0'.join(p)
def tmpl_pathfield(self, path):
return path.replace('\0', '/')
| 28.047619
| 80
| 0.705433
| 168
| 1,178
| 4.779762
| 0.47619
| 0.034869
| 0.014944
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.009385
| 0.185908
| 1,178
| 41
| 81
| 28.731707
| 0.827946
| 0.558574
| 0
| 0
| 0
| 0
| 0.035363
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.230769
| false
| 0
| 0.307692
| 0.153846
| 0.769231
| 0.076923
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 1
| 1
| 0
|
0
| 4
|
43a695a1851a4d34d1e5e9ef3259004fc6c11306
| 8,294
|
py
|
Python
|
boto3_type_annotations_with_docs/boto3_type_annotations/mediatailor/paginator.py
|
cowboygneox/boto3_type_annotations
|
450dce1de4e066b939de7eac2ec560ed1a7ddaa2
|
[
"MIT"
] | 119
|
2018-12-01T18:20:57.000Z
|
2022-02-02T10:31:29.000Z
|
boto3_type_annotations_with_docs/boto3_type_annotations/mediatailor/paginator.py
|
cowboygneox/boto3_type_annotations
|
450dce1de4e066b939de7eac2ec560ed1a7ddaa2
|
[
"MIT"
] | 15
|
2018-11-16T00:16:44.000Z
|
2021-11-13T03:44:18.000Z
|
boto3_type_annotations_with_docs/boto3_type_annotations/mediatailor/paginator.py
|
cowboygneox/boto3_type_annotations
|
450dce1de4e066b939de7eac2ec560ed1a7ddaa2
|
[
"MIT"
] | 11
|
2019-05-06T05:26:51.000Z
|
2021-09-28T15:27:59.000Z
|
from typing import Dict
from botocore.paginate import Paginator
class ListPlaybackConfigurations(Paginator):
def paginate(self, PaginationConfig: Dict = None) -> Dict:
"""
Creates an iterator that will paginate through responses from :py:meth:`MediaTailor.Client.list_playback_configurations`.
See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/mediatailor-2018-04-23/ListPlaybackConfigurations>`_
**Request Syntax**
::
response_iterator = paginator.paginate(
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
**Response Syntax**
::
{
'Items': [
{
'AdDecisionServerUrl': 'string',
'CdnConfiguration': {
'AdSegmentUrlPrefix': 'string',
'ContentSegmentUrlPrefix': 'string'
},
'DashConfiguration': {
'ManifestEndpointPrefix': 'string',
'MpdLocation': 'string',
'OriginManifestType': 'SINGLE_PERIOD'|'MULTI_PERIOD'
},
'HlsConfiguration': {
'ManifestEndpointPrefix': 'string'
},
'Name': 'string',
'PlaybackConfigurationArn': 'string',
'PlaybackEndpointPrefix': 'string',
'SessionInitializationEndpointPrefix': 'string',
'SlateAdUrl': 'string',
'Tags': {
'string': 'string'
},
'TranscodeProfileName': 'string',
'VideoContentSourceUrl': 'string'
},
],
}
**Response Structure**
- *(dict) --*
Success.
- **Items** *(list) --*
Array of playback configurations. This might be all the available configurations or a subset, depending on the settings that you provide and the total number of configurations stored.
- *(dict) --*
The AWSMediaTailor configuration.
- **AdDecisionServerUrl** *(string) --*
The URL for the ad decision server (ADS). This includes the specification of static parameters and placeholders for dynamic parameters. AWS Elemental MediaTailor substitutes player-specific and session-specific parameters as needed when calling the ADS. Alternately, for testing, you can provide a static VAST URL. The maximum length is 25,000 characters.
- **CdnConfiguration** *(dict) --*
The configuration for using a content delivery network (CDN), like Amazon CloudFront, for content and ad segment management.
- **AdSegmentUrlPrefix** *(string) --*
A non-default content delivery network (CDN) to serve ad segments. By default, AWS Elemental MediaTailor uses Amazon CloudFront with default cache settings as its CDN for ad segments. To set up an alternate CDN, create a rule in your CDN for the following origin: ads.mediatailor.<region>.amazonaws.com. Then specify the rule's name in this AdSegmentUrlPrefix. When AWS Elemental MediaTailor serves a manifest, it reports your CDN as the source for ad segments.
- **ContentSegmentUrlPrefix** *(string) --*
A content delivery network (CDN) to cache content segments, so that content requests don’t always have to go to the origin server. First, create a rule in your CDN for the content segment origin server. Then specify the rule's name in this ContentSegmentUrlPrefix. When AWS Elemental MediaTailor serves a manifest, it reports your CDN as the source for content segments.
- **DashConfiguration** *(dict) --*
The configuration for DASH content.
- **ManifestEndpointPrefix** *(string) --*
The URL generated by MediaTailor to initiate a playback session. The session uses server-side reporting. This setting is ignored in PUT operations.
- **MpdLocation** *(string) --*
The setting that controls whether MediaTailor includes the Location tag in DASH manifests. MediaTailor populates the Location tag with the URL for manifest update requests, to be used by players that don't support sticky redirects. Disable this if you have CDN routing rules set up for accessing MediaTailor manifests, and you are either using client-side reporting or your players support sticky HTTP redirects. Valid values are DISABLED and EMT_DEFAULT. The EMT_DEFAULT setting enables the inclusion of the tag and is the default value.
- **OriginManifestType** *(string) --*
The setting that controls whether MediaTailor handles manifests from the origin server as multi-period manifests or single-period manifests. If your origin server produces single-period manifests, set this to SINGLE_PERIOD. The default setting is MULTI_PERIOD. For multi-period manifests, omit this setting or set it to MULTI_PERIOD.
- **HlsConfiguration** *(dict) --*
The configuration for HLS content.
- **ManifestEndpointPrefix** *(string) --*
The URL that is used to initiate a playback session for devices that support Apple HLS. The session uses server-side reporting.
- **Name** *(string) --*
The identifier for the playback configuration.
- **PlaybackConfigurationArn** *(string) --*
The Amazon Resource Name (ARN) for the playback configuration.
- **PlaybackEndpointPrefix** *(string) --*
The URL that the player accesses to get a manifest from AWS Elemental MediaTailor. This session will use server-side reporting.
- **SessionInitializationEndpointPrefix** *(string) --*
The URL that the player uses to initialize a session that uses client-side reporting.
- **SlateAdUrl** *(string) --*
The URL for a high-quality video asset to transcode and use to fill in time that's not used by ads. AWS Elemental MediaTailor shows the slate to fill in gaps in media content. Configuring the slate is optional for non-VPAID playback configurations. For VPAID, the slate is required because MediaTailor provides it in the slots designated for dynamic ad content. The slate must be a high-quality asset that contains both audio and video.
- **Tags** *(dict) --*
The tags assigned to the playback configuration.
- *(string) --*
- *(string) --*
- **TranscodeProfileName** *(string) --*
The name that is used to associate this playback configuration with a custom transcode profile. This overrides the dynamic transcoding defaults of MediaTailor. Use this only if you have already set up custom profiles with the help of AWS Support.
- **VideoContentSourceUrl** *(string) --*
The URL prefix for the master playlist for the stream, minus the asset ID. The maximum length is 512 characters.
:type PaginationConfig: dict
:param PaginationConfig:
A dictionary that provides parameters to control pagination.
- **MaxItems** *(integer) --*
The total number of items to return. If the total number of items available is more than the value specified in max-items then a ``NextToken`` will be provided in the output that you can use to resume pagination.
- **PageSize** *(integer) --*
The size of each page.
- **StartingToken** *(string) --*
A token to specify where to start paginating. This is the ``NextToken`` from a previous response.
:rtype: dict
:returns:
"""
pass
| 74.720721
| 559
| 0.60586
| 862
| 8,294
| 5.816705
| 0.334107
| 0.02154
| 0.016753
| 0.009573
| 0.143398
| 0.092142
| 0.069007
| 0.050658
| 0.02872
| 0.02872
| 0
| 0.00391
| 0.321558
| 8,294
| 110
| 560
| 75.4
| 0.887151
| 0.87702
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| false
| 0.2
| 0.4
| 0
| 0.8
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 1
| 0
|
0
| 4
|
43bf864b64b53962e7825d5398fc3b8e13290928
| 10,047
|
py
|
Python
|
webapps/py/cswaTest.py
|
pfarestveit/Tools
|
f05b012ae4a83f2692e760b0644c2a77d836ee32
|
[
"ECL-2.0"
] | null | null | null |
webapps/py/cswaTest.py
|
pfarestveit/Tools
|
f05b012ae4a83f2692e760b0644c2a77d836ee32
|
[
"ECL-2.0"
] | null | null | null |
webapps/py/cswaTest.py
|
pfarestveit/Tools
|
f05b012ae4a83f2692e760b0644c2a77d836ee32
|
[
"ECL-2.0"
] | null | null | null |
from cswaUtils import *
# to test this module on the command line you have to pass in two cgi values:
# $ python cswaUtils.py "lo.location1=Hearst Gym, 30, L 12, 2&lo.location2=Hearst Gym, 30, L 12, 7"
# $ python cswaUtils.py "lo.location1=X&lo.location2=Y"
# this will load the config file and attempt to update some records in server identified
# in that config file!
updateItems = {}
if True:
print "starting keyinfo update"
form = {'webapp': 'pahma_Keyinfo_Dev', 'action': 'Update Object Information',
'fieldset': 'placeanddate',
'csusername': 'import@pahma.cspace.berkeley.edu',
'cspassword': 'lash428!puck',
#'fieldset': 'registration',
'onm.70d40782-6d11-4346-bb9b-2f85f1e00e91': 'Cradle',
'oox.70d40782-6d11-4346-bb9b-2f85f1e00e91': '1-1',
'csid.70d40782-6d11-4346-bb9b-2f85f1e00e91': '70d40782-6d11-4346-bb9b-2f85f1e00e91',
'vfcp.70d40782-6d11-4346-bb9b-2f85f1e00e91': 'yyy',
'cd.70d40782-6d11-4346-bb9b-2f85f1e00e91': '11/3/15',
}
config = getConfig(form)
doUpdateKeyinfo(form, config)
if False:
print "starting keyinfo update"
form = {'webapp': 'pahma_Keyinfo_Dev', 'action': 'Update Object Information',
'fieldset': 'namedesc',
'csusername': 'import@pahma.cspace.berkeley.edu',
'cspassword': 'lash428!puck',
#'fieldset': 'registration',
'onm.70d40782-6d11-4346-bb9b-2f85f1e00e91': 'Cradle',
'oox.70d40782-6d11-4346-bb9b-2f85f1e00e91': '1-1',
'csid.70d40782-6d11-4346-bb9b-2f85f1e00e91': '70d40782-6d11-4346-bb9b-2f85f1e00e91',
'bdx.70d40782-6d11-4346-bb9b-2f85f1e00e91': 'brief description 999 888 777',
'anm.70d40782-6d11-4346-bb9b-2f85f1e00e91': 'xxx',
'ant.70d40782-6d11-4346-bb9b-2f85f1e00e91': 'xxx',
'pc.70d40782-6d11-4346-bb9b-2f85f1e00e91': 'Dr. Philip Mills Jones',
}
config = getConfig(form)
doUpdateKeyinfo(form, config)
if False:
form = {'webapp': 'keyinfoDev', 'action': 'Update Object Information',
'fieldset': 'namedesc',
#'fieldset': 'registration',
'onm.70d40782-6d11-4346-bb9b-2f85f1e00e91': 'Cradle',
'oox.70d40782-6d11-4346-bb9b-2f85f1e00e91': '1-1',
'csid.70d40782-6d11-4346-bb9b-2f85f1e00e91': '70d40782-6d11-4346-bb9b-2f85f1e00e91',
'bdx.70d40782-6d11-4346-bb9b-2f85f1e00e91': 'brief description 999 888 777',
'anm.70d40782-6d11-4346-bb9b-2f85f1e00e91': 'xxx',
'ant.70d40782-6d11-4346-bb9b-2f85f1e00e91': 'xxx',
'pc.70d40782-6d11-4346-bb9b-2f85f1e00e91': 'Dr. Philip Mills Jones',
}
form = {'webapp': 'ucbgLocationReportDev', 'dora': 'alive'}
config = getConfig(form)
starthtml(form, config)
print setFilters(form)
doUpdateKeyinfo(form, config)
#sys.exit()
if False:
form = {'webapp': 'bamInventoryDev'}
config = getConfig(form)
realm = config.get('connect', 'realm')
hostname = config.get('connect', 'hostname')
username = 'import@bampfa.cspace.berkeley.edu'
password = 'bjeScwj2'
institution = config.get('info', 'institution')
#print relationsPayload(f)
updateItems = {'objectStatus': 'found',
'subjectCsid': '41568668-00a7-439b-8a09-8525578e5df4',
'objectCsid': '41568668-00a7-439b-8a09-8525578e5df4',
'inventoryNote': 'inventory note',
'crate': '',
'handlerRefName': "JW",
'reason': "urn:cspace:bampfa.cspace.berkeley.edu:vocabularies:name(movereason):item:name(movereason002)'Exhibition'",
'computedSummary': 'systematic inventory test',
'locationRefname': "urn:cspace:bampfa.cspace.berkeley.edu:locationauthorities:name(location):item:name(x793)'Print Storage, Bin 02 Lower'",
'locationDate': '2014-10-23T05:45:30Z',
'objectNumber': '9-12689'}
#updateLocations(f2,config)
#print "updateLocations succeeded..."
#sys.exit(0)
uri = 'movements'
print "<br>posting to movements REST API..."
payload = lmiPayload(updateItems,institution)
print payload
#sys.exit(0)
(url, data, csid, elapsedtime) = postxml('POST', uri, realm, hostname, username, password, payload)
updateItems['subjectCsid'] = csid
print 'got csid', csid, '. elapsedtime', elapsedtime
print "movements REST API post succeeded..."
uri = 'relations'
print "<br>posting inv2obj to relations REST API..."
updateItems['subjectDocumentType'] = 'Movement'
updateItems['objectDocumentType'] = 'CollectionObject'
payload = relationsPayload(updateItems)
(url, data, csid, elapsedtime) = postxml('POST', uri, realm, hostname, username, password, payload)
print 'got csid', csid, '. elapsedtime', elapsedtime
print "relations REST API post succeeded..."
# reverse the roles
print "<br>posting obj2inv to relations REST API..."
temp = updateItems['objectCsid']
updateItems['objectCsid'] = updateItems['subjectCsid']
updateItems['subjectCsid'] = temp
updateItems['subjectDocumentType'] = 'CollectionObject'
updateItems['objectDocumentType'] = 'Movement'
payload = relationsPayload(updateItems)
(url, data, csid, elapsedtime) = postxml('POST', uri, realm, hostname, username, password, payload)
print 'got csid', csid, '. elapsedtime', elapsedtime
print "relations REST API post succeeded..."
print "<h3>Done w update!</h3>"
#sys.exit()
if False:
form = {'webapp': 'bamInventoryDev'}
config = getConfig(form)
realm = config.get('connect', 'realm')
hostname = config.get('connect', 'hostname')
username = config.get('connect', 'username')
password = config.get('connect', 'password')
institution = config.get('info', 'institution')
#print lmiPayload(f)
#print relationsPayload(f)
f2 = {'objectStatus': 'found',
'subjectCsid': '',
'inventoryNote': '',
'crate': "urn:cspace:pahma.cspace.berkeley.edu:locationauthorities:name(crate):item:name(cr2113)'Faunal Box 421'",
'handlerRefName': "urn:cspace:pahma.cspace.berkeley.edu:personauthorities:name(person):item:name(999)'Michael T. Black'",
'objectCsid': '35d1e048-e803-4e19-81de-ac1079f9bf47',
'reason': 'Inventory',
'computedSummary': 'systematic inventory test',
'locationRefname': "urn:cspace:pahma.cspace.berkeley.edu:locationauthorities:name(location):item:name(sl12158)'Kroeber, 20A, AA 1, 2'",
'locationDate': '2012-07-24T05:45:30Z',
'objectNumber': '9-12689'}
#updateLocations(f2,config)
#print "updateLocations succeeded..."
#sys.exit(0)
uri = 'movements'
print "<br>posting to movements REST API..."
payload = lmiPayload(updateItems)
(url, data, csid, elapsedtime) = postxml('POST', uri, realm, hostname, username, password, payload)
updateItems['subjectCsid'] = csid
print 'got csid', csid, '. elapsedtime', elapsedtime
print "movements REST API post succeeded..."
uri = 'relations'
print "<br>posting inv2obj to relations REST API..."
updateItems['subjectDocumentType'] = 'Movement'
updateItems['objectDocumentType'] = 'CollectionObject'
payload = relationsPayload(updateItems)
(url, data, csid, elapsedtime) = postxml('POST', uri, realm, hostname, username, password, payload)
print 'got csid', csid, '. elapsedtime', elapsedtime
print "relations REST API post succeeded..."
# reverse the roles
print "<br>posting obj2inv to relations REST API..."
temp = updateItems['objectCsid']
updateItems['objectCsid'] = updateItems['subjectCsid']
updateItems['subjectCsid'] = temp
updateItems['subjectDocumentType'] = 'CollectionObject'
updateItems['objectDocumentType'] = 'Movement'
payload = relationsPayload(updateItems)
(url, data, csid, elapsedtime) = postxml('POST', uri, realm, hostname, username, password, payload)
print 'got csid', csid, '. elapsedtime', elapsedtime
print "relations REST API post succeeded..."
print "<h3>Done w update!</h3>"
#sys.exit()
if False:
print cswaDB.getplants('Velleia rosea', '', 1, config, 'locreport', 'dead')
#sys.exit()
endhtml(form, config, 0.0)
if False:
#print "starting packing list"
#doPackingList(form,config)
#sys.exit()
print '\nlocations\n'
for loc in cswaDB.getloclist('range', '1001, Green House 1', '1003, Tropical House', 1000, config):
print loc
print '\nlocations\n'
for loc in cswaDB.getloclist('set', 'Kroeber, 20A, W B', '', 10, config):
print loc
print '\nlocations\n'
for loc in cswaDB.getloclist('set', 'Kroeber, 20A, CC 4', '', 3, config):
print loc
print '\nobjects\n'
rows = cswaDB.getlocations('Kroeber, 20A, CC 4', '', 3, config, 'keyinfo','pahma')
for r in rows:
print r
#urn:cspace:pahma.cspace.berkeley.edu:locationauthorities:name(location):item:name(sl31520)'Regatta, A150, RiveTier 1, B'
f = {'objectCsid': '242e9ee7-983a-49e9-b3b5-7b49dd403aa2',
'subjectCsid': '250d75dc-c704-4b3b-abaa',
'locationRefname': "urn:cspace:pahma.cspace.berkeley.edu:locationauthorities:name(location):item:name(sl284)'Kroeber, 20Mez, 53 D'",
'locationDate': '2000-01-01T00:00:00Z',
'computedSummary': 'systematic inventory test',
'inventoryNote': 'this is a test inventory note',
'objectDocumentType': 'CollectionObject',
'subjectDocumentType': 'Movement',
'reason': 'Inventory',
'handlerRefName': "urn:cspace:pahma.cspace.berkeley.edu:personauthorities:name(person):item:name(7412)'Madeleine W. Fang'"
}
#print lmiPayload(f)
#print relationsPayload(f)
form = {'webapp': 'barcodeprintDev', 'ob.objectnumber': '1-504', 'action': 'Create Labels for Objects'}
config = getConfig(form)
print doBarCodes(form, config)
#sys.exit()
| 37.770677
| 149
| 0.65323
| 1,073
| 10,047
| 6.112768
| 0.260951
| 0.04025
| 0.053667
| 0.067083
| 0.751944
| 0.719622
| 0.678152
| 0.662906
| 0.624485
| 0.624485
| 0
| 0.100261
| 0.199861
| 10,047
| 265
| 150
| 37.913208
| 0.715636
| 0.095451
| 0
| 0.664706
| 0
| 0.041176
| 0.495693
| 0.201413
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0.058824
| 0.023529
| null | null | 0.205882
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
43ce13db017bf8ec1b7104d2c1fd816205573892
| 22
|
py
|
Python
|
cruft/_version.py
|
camabeh/cruft
|
da1617807cb81bfcbcb687882d9adf211e57d458
|
[
"MIT"
] | 313
|
2016-12-04T13:25:21.000Z
|
2022-03-31T09:46:15.000Z
|
cruft/_version.py
|
camabeh/cruft
|
da1617807cb81bfcbcb687882d9adf211e57d458
|
[
"MIT"
] | 232
|
2016-12-02T22:55:20.000Z
|
2022-03-27T06:48:02.000Z
|
cruft/_version.py
|
camabeh/cruft
|
da1617807cb81bfcbcb687882d9adf211e57d458
|
[
"MIT"
] | 90
|
2017-09-23T15:09:48.000Z
|
2022-03-17T03:13:40.000Z
|
__version__ = "2.9.0"
| 11
| 21
| 0.636364
| 4
| 22
| 2.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.157895
| 0.136364
| 22
| 1
| 22
| 22
| 0.368421
| 0
| 0
| 0
| 0
| 0
| 0.227273
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
43e2c4c46a877eb11ecf534c766d56e029663ef1
| 141
|
py
|
Python
|
reddit2telegram/channels/r_wikileaks/app.py
|
mainyordle/reddit2telegram
|
1163e15aed3b6ff0fba65b222d3d9798f644c386
|
[
"MIT"
] | 187
|
2016-09-20T09:15:54.000Z
|
2022-03-29T12:22:33.000Z
|
reddit2telegram/channels/r_wikileaks/app.py
|
mainyordle/reddit2telegram
|
1163e15aed3b6ff0fba65b222d3d9798f644c386
|
[
"MIT"
] | 84
|
2016-09-22T14:25:07.000Z
|
2022-03-19T01:26:17.000Z
|
reddit2telegram/channels/r_wikileaks/app.py
|
mainyordle/reddit2telegram
|
1163e15aed3b6ff0fba65b222d3d9798f644c386
|
[
"MIT"
] | 172
|
2016-09-21T15:39:39.000Z
|
2022-03-16T15:15:58.000Z
|
#encoding:utf-8
subreddit = 'WikiLeaks'
t_channel = '@r_WikiLeaks'
def send_post(submission, r2t):
return r2t.send_simple(submission)
| 15.666667
| 38
| 0.744681
| 19
| 141
| 5.315789
| 0.789474
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.02459
| 0.134752
| 141
| 8
| 39
| 17.625
| 0.803279
| 0.099291
| 0
| 0
| 0
| 0
| 0.166667
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0
| 0.25
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
|
0
| 4
|
78e4b759281076befb5c63490cbffb3fc39d105c
| 2,717
|
py
|
Python
|
src/design/forms.py
|
maumg1196/GearDesign
|
35aaeaab9b0eaa187c585fe68242cfa8bd3de9a7
|
[
"MIT"
] | null | null | null |
src/design/forms.py
|
maumg1196/GearDesign
|
35aaeaab9b0eaa187c585fe68242cfa8bd3de9a7
|
[
"MIT"
] | null | null | null |
src/design/forms.py
|
maumg1196/GearDesign
|
35aaeaab9b0eaa187c585fe68242cfa8bd3de9a7
|
[
"MIT"
] | null | null | null |
from django import forms
from .models import Gear
class GearForm(forms.ModelForm):
class Meta:
model = Gear
fields = [
'fs',
'HP',
'Np',
'Pd',
'Wg',
'Wp',
'q',
'hrs',
'Ep',
'Eg',
'Vp',
'Vg',
]
widgets = {
'fs': forms.NumberInput(attrs={'step': "0.01"}),
'HP': forms.NumberInput(attrs={'step': "0.01"}),
'Pd': forms.NumberInput(attrs={'step': "0.01"}),
'Wg': forms.NumberInput(attrs={'step': "0.01"}),
'Wp': forms.NumberInput(attrs={'step': "0.01"}),
'hrs': forms.NumberInput(attrs={'step': "0.01"}),
'q': forms.NumberInput(attrs={'step': "0.01"}),
'Ep': forms.NumberInput(attrs={'step': "0.01"}),
'Eg': forms.NumberInput(attrs={'step': "0.01"}),
'Vp': forms.NumberInput(attrs={'step': "0.01"}),
'Vg': forms.NumberInput(attrs={'step': "0.01"}),
}
class GearForm2(forms.ModelForm):
Ynp_choices = (
(1, 1),
(2, 2),
(3, 3),
(4, 4),
(5, 5),
(6, 6),
)
Znp_choices = (
(1, 1),
(2, 2),
(3, 3),
)
aligment_choices = (
('Open gearing', 'Open gearing'),
('Commercial enclosed gear units', 'Commercial enclosed gear units'),
('Precision enclosed gear units', 'Precision enclosed gear units'),
('Extra-precision enclosed gear units', 'Extra-precision enclosed gear units'),
)
Ynp = forms.ChoiceField(
required=True,
choices=Ynp_choices,
)
Znp = forms.ChoiceField(
required=True,
choices=Znp_choices,
)
Yng = forms.ChoiceField(
required=True,
choices=Ynp_choices,
)
Zng = forms.ChoiceField(
required=True,
choices=Znp_choices,
)
aligment_type = forms.ChoiceField(
required=True,
choices=aligment_choices,
)
class Meta:
model = Gear
fields = [
'Jp',
'Jg',
'I',
'kr',
'SF',
]
widgets = {
'Jp': forms.NumberInput(attrs={'step': "0.01"}),
'Jg': forms.NumberInput(attrs={'step': "0.01"}),
'I': forms.NumberInput(attrs={'step': "0.01"}),
'kr': forms.NumberInput(attrs={'step': "0.01"}),
'SF': forms.NumberInput(attrs={'step': "0.01"}),
}
class GearForm3(forms.ModelForm):
class Meta:
model = Gear
fields = [
'materialp',
'materialg'
]
| 24.926606
| 87
| 0.458594
| 263
| 2,717
| 4.703422
| 0.235741
| 0.206952
| 0.271625
| 0.323363
| 0.751819
| 0.704123
| 0.387227
| 0.07114
| 0.07114
| 0
| 0
| 0.039743
| 0.370261
| 2,717
| 108
| 88
| 25.157407
| 0.683226
| 0
| 0
| 0.273684
| 0
| 0
| 0.155318
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.021053
| 0
| 0.168421
| 0
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
78f03b2a5cdb11200fb905e490bfbf5328dee279
| 104
|
py
|
Python
|
brotground/__init__.py
|
adiamaan92/brotground
|
25263438b69fa46c2c3fc0667a42bd6524b76d9e
|
[
"MIT"
] | 3
|
2021-11-24T03:12:35.000Z
|
2022-02-07T02:15:45.000Z
|
brotground/__init__.py
|
adiamaan92/brotground
|
25263438b69fa46c2c3fc0667a42bd6524b76d9e
|
[
"MIT"
] | null | null | null |
brotground/__init__.py
|
adiamaan92/brotground
|
25263438b69fa46c2c3fc0667a42bd6524b76d9e
|
[
"MIT"
] | null | null | null |
from .BrotBase import BrotBase, RangeType
from .Brots import JuliaBrot, MandelBrot, MultiBrot, UserBrot
| 34.666667
| 61
| 0.826923
| 12
| 104
| 7.166667
| 0.75
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.115385
| 104
| 2
| 62
| 52
| 0.934783
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
78f6f0e0c0061c66f844123decc8fa4f6d4a5716
| 211
|
py
|
Python
|
django_ethereum_events/apps.py
|
eur00t/django-ethereum-events
|
15277c9e1e0b85625df049b9f4de566e7188895c
|
[
"MIT"
] | 36
|
2017-09-27T12:52:10.000Z
|
2022-03-16T16:35:47.000Z
|
django_ethereum_events/apps.py
|
eur00t/django-ethereum-events
|
15277c9e1e0b85625df049b9f4de566e7188895c
|
[
"MIT"
] | 8
|
2017-12-20T15:34:27.000Z
|
2021-11-02T12:41:11.000Z
|
django_ethereum_events/apps.py
|
eur00t/django-ethereum-events
|
15277c9e1e0b85625df049b9f4de566e7188895c
|
[
"MIT"
] | 11
|
2017-12-13T17:58:02.000Z
|
2021-11-04T18:42:55.000Z
|
from django.apps import AppConfig
class EthereumEventsConfig(AppConfig):
name = 'django_ethereum_events'
def ready(self):
super().ready()
import django_ethereum_events.signals # noqa
| 21.1
| 53
| 0.7109
| 23
| 211
| 6.347826
| 0.695652
| 0.191781
| 0.273973
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.208531
| 211
| 10
| 53
| 21.1
| 0.874252
| 0.018957
| 0
| 0
| 0
| 0
| 0.106796
| 0.106796
| 0
| 0
| 0
| 0
| 0
| 1
| 0.166667
| false
| 0
| 0.333333
| 0
| 0.833333
| 0
| 1
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
600a20ba0cd51b37fee5e5aaa05949663187c1c3
| 460
|
py
|
Python
|
score_try.py
|
serook/coursera_python4everybody
|
4886543abd77b3001dca6a16f7edb5a29474380f
|
[
"Apache-2.0"
] | null | null | null |
score_try.py
|
serook/coursera_python4everybody
|
4886543abd77b3001dca6a16f7edb5a29474380f
|
[
"Apache-2.0"
] | null | null | null |
score_try.py
|
serook/coursera_python4everybody
|
4886543abd77b3001dca6a16f7edb5a29474380f
|
[
"Apache-2.0"
] | null | null | null |
try :
inp=input('enter numberscore\n')
score=float(inp)
if score >= 0.9 and score <= 1.0:
print 'grade is A'
elif score >= 0.8 and score<=1.0 :
print 'grade is B'
elif score >= 0.7 and score<=1.0 :
print 'grade is C'
elif score >= 0.6 and score<=1.0 :
print 'grade is D'
elif score >= 0.0 and score <= 0.6 :
print 'grade is F'
else :
print 'ERROR'
except:
print 'bad score'
| 23
| 40
| 0.526087
| 76
| 460
| 3.184211
| 0.381579
| 0.14876
| 0.247934
| 0.165289
| 0.363636
| 0.363636
| 0.363636
| 0
| 0
| 0
| 0
| 0.066007
| 0.341304
| 460
| 19
| 41
| 24.210526
| 0.732673
| 0
| 0
| 0
| 0
| 0
| 0.181223
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 0.411765
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
603dec748003514eed4c97b3efba12305ba3a170
| 24
|
py
|
Python
|
data/studio21_generated/introductory/3481/starter_code.py
|
vijaykumawat256/Prompt-Summarization
|
614f5911e2acd2933440d909de2b4f86653dc214
|
[
"Apache-2.0"
] | null | null | null |
data/studio21_generated/introductory/3481/starter_code.py
|
vijaykumawat256/Prompt-Summarization
|
614f5911e2acd2933440d909de2b4f86653dc214
|
[
"Apache-2.0"
] | null | null | null |
data/studio21_generated/introductory/3481/starter_code.py
|
vijaykumawat256/Prompt-Summarization
|
614f5911e2acd2933440d909de2b4f86653dc214
|
[
"Apache-2.0"
] | null | null | null |
def get_char_count(s):
| 12
| 22
| 0.75
| 5
| 24
| 3.2
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.125
| 24
| 2
| 23
| 12
| 0.761905
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
6073877db9a42d24a5dfd5f66406cae93f34b74f
| 80,715
|
py
|
Python
|
test/test_routing.py
|
tongni1975/unit
|
fdf570f1d9561bfc349f24c87e1ac35afd2254e2
|
[
"Apache-2.0"
] | null | null | null |
test/test_routing.py
|
tongni1975/unit
|
fdf570f1d9561bfc349f24c87e1ac35afd2254e2
|
[
"Apache-2.0"
] | null | null | null |
test/test_routing.py
|
tongni1975/unit
|
fdf570f1d9561bfc349f24c87e1ac35afd2254e2
|
[
"Apache-2.0"
] | null | null | null |
import unittest
from unit.applications.proto import TestApplicationProto
class TestRouting(TestApplicationProto):
prerequisites = ['python']
def setUp(self):
super().setUp()
self.conf(
{
"listeners": {"*:7080": {"pass": "routes"}},
"routes": [
{
"match": {"method": "GET"},
"action": {"pass": "applications/empty"},
}
],
"applications": {
"empty": {
"type": "python",
"processes": {"spare": 0},
"path": self.current_dir + '/python/empty',
"working_directory": self.current_dir
+ '/python/empty',
"module": "wsgi",
},
"mirror": {
"type": "python",
"processes": {"spare": 0},
"path": self.current_dir + '/python/mirror',
"working_directory": self.current_dir
+ '/python/mirror',
"module": "wsgi",
},
},
}
)
def route(self, route):
return self.conf([route], 'routes')
def test_routes_match_method_positive(self):
self.assertEqual(self.get()['status'], 200, 'method positive GET')
self.assertEqual(self.post()['status'], 404, 'method positive POST')
def test_routes_match_method_positive_many(self):
self.assertIn(
'success',
self.route(
{
"match": {"method": ["GET", "POST"]},
"action": {"pass": "applications/empty"},
}
),
'method positive many configure',
)
self.assertEqual(self.get()['status'], 200, 'method positive many GET')
self.assertEqual(
self.post()['status'], 200, 'method positive many POST'
)
self.assertEqual(
self.delete()['status'], 404, 'method positive many DELETE'
)
def test_routes_match_method_negative(self):
self.assertIn(
'success',
self.route(
{
"match": {"method": "!GET"},
"action": {"pass": "applications/empty"},
}
),
'method negative configure',
)
self.assertEqual(self.get()['status'], 404, 'method negative GET')
self.assertEqual(self.post()['status'], 200, 'method negative POST')
def test_routes_match_method_negative_many(self):
self.assertIn(
'success',
self.route(
{
"match": {"method": ["!GET", "!POST"]},
"action": {"pass": "applications/empty"},
}
),
'method negative many configure',
)
self.assertEqual(self.get()['status'], 404, 'method negative many GET')
self.assertEqual(
self.post()['status'], 404, 'method negative many POST'
)
self.assertEqual(
self.delete()['status'], 200, 'method negative many DELETE'
)
def test_routes_match_method_wildcard_left(self):
self.assertIn(
'success',
self.route(
{
"match": {"method": "*ET"},
"action": {"pass": "applications/empty"},
}
),
'method wildcard left configure',
)
self.assertEqual(self.get()['status'], 200, 'method wildcard left GET')
self.assertEqual(
self.post()['status'], 404, 'method wildcard left POST'
)
def test_routes_match_method_wildcard_right(self):
self.assertIn(
'success',
self.route(
{
"match": {"method": "GE*"},
"action": {"pass": "applications/empty"},
}
),
'method wildcard right configure',
)
self.assertEqual(
self.get()['status'], 200, 'method wildcard right GET'
)
self.assertEqual(
self.post()['status'], 404, 'method wildcard right POST'
)
def test_routes_match_method_wildcard_left_right(self):
self.assertIn(
'success',
self.route(
{
"match": {"method": "*GET*"},
"action": {"pass": "applications/empty"},
}
),
'method wildcard left right configure',
)
self.assertEqual(
self.get()['status'], 200, 'method wildcard right GET'
)
self.assertEqual(
self.post()['status'], 404, 'method wildcard right POST'
)
def test_routes_match_method_wildcard(self):
self.assertIn(
'success',
self.route(
{
"match": {"method": "*"},
"action": {"pass": "applications/empty"},
}
),
'method wildcard configure',
)
self.assertEqual(self.get()['status'], 200, 'method wildcard')
def test_routes_match_invalid(self):
self.assertIn(
'error',
self.route(
{
"match": {"method": "**"},
"action": {"pass": "applications/empty"},
}
),
'wildcard invalid',
)
self.assertIn(
'error',
self.route(
{
"match": {"method": "blah**"},
"action": {"pass": "applications/empty"},
}
),
'wildcard invalid 2',
)
self.assertIn(
'error',
self.route(
{
"match": {"host": "*blah*blah"},
"action": {"pass": "applications/empty"},
}
),
'wildcard invalid 3',
)
self.assertIn(
'error',
self.route(
{
"match": {"host": "blah*blah*blah"},
"action": {"pass": "applications/empty"},
}
),
'wildcard invalid 4',
)
self.assertIn(
'error',
self.route(
{
"match": {"host": "blah*blah*"},
"action": {"pass": "applications/empty"},
}
),
'wildcard invalid 5',
)
def test_routes_match_wildcard_middle(self):
self.assertIn(
'success',
self.route(
{
"match": {"host": "ex*le"},
"action": {"pass": "applications/empty"},
}
),
'host wildcard middle configure',
)
self.assertEqual(
self.get(headers={'Host': 'example', 'Connection': 'close'})[
'status'
],
200,
'host wildcard middle',
)
self.assertEqual(
self.get(headers={'Host': 'www.example', 'Connection': 'close'})[
'status'
],
404,
'host wildcard middle 2',
)
self.assertEqual(
self.get(headers={'Host': 'example.com', 'Connection': 'close'})[
'status'
],
404,
'host wildcard middle 3',
)
self.assertEqual(
self.get(headers={'Host': 'exampl', 'Connection': 'close'})[
'status'
],
404,
'host wildcard middle 4',
)
def test_routes_match_method_case_insensitive(self):
self.assertIn(
'success',
self.route(
{
"match": {"method": "get"},
"action": {"pass": "applications/empty"},
}
),
'method case insensitive configure',
)
self.assertEqual(self.get()['status'], 200, 'method case insensitive')
def test_routes_match_wildcard_left_case_insensitive(self):
self.assertIn(
'success',
self.route(
{
"match": {"method": "*et"},
"action": {"pass": "applications/empty"},
}
),
'match wildcard case insensitive configure',
)
self.assertEqual(
self.get()['status'], 200, 'match wildcard case insensitive'
)
def test_routes_match_wildcard_middle_case_insensitive(self):
self.assertIn(
'success',
self.route(
{
"match": {"method": "g*t"},
"action": {"pass": "applications/empty"},
}
),
'match wildcard case insensitive configure',
)
self.assertEqual(
self.get()['status'], 200, 'match wildcard case insensitive'
)
def test_routes_match_wildcard_right_case_insensitive(self):
self.assertIn(
'success',
self.route(
{
"match": {"method": "get*"},
"action": {"pass": "applications/empty"},
}
),
'match wildcard case insensitive configure',
)
self.assertEqual(
self.get()['status'], 200, 'match wildcard case insensitive'
)
def test_routes_match_wildcard_substring_case_insensitive(self):
self.assertIn(
'success',
self.route(
{
"match": {"method": "*et*"},
"action": {"pass": "applications/empty"},
}
),
'match wildcard substring case insensitive configure',
)
self.assertEqual(
self.get()['status'],
200,
'match wildcard substring case insensitive',
)
def test_routes_match_wildcard_left_case_sensitive(self):
self.assertIn(
'success',
self.route(
{
"match": {"uri": "*blah"},
"action": {"pass": "applications/empty"},
}
),
'match wildcard left case sensitive configure',
)
self.assertEqual(
self.get(url='/blah')['status'],
200,
'match wildcard left case sensitive /blah',
)
self.assertEqual(
self.get(url='/BLAH')['status'],
404,
'match wildcard left case sensitive /BLAH',
)
def test_routes_match_wildcard_middle_case_sensitive(self):
self.assertIn(
'success',
self.route(
{
"match": {"uri": "/b*h"},
"action": {"pass": "applications/empty"},
}
),
'match wildcard middle case sensitive configure',
)
self.assertEqual(
self.get(url='/blah')['status'],
200,
'match wildcard middle case sensitive /blah',
)
self.assertEqual(
self.get(url='/BLAH')['status'],
404,
'match wildcard middle case sensitive /BLAH',
)
def test_routes_match_wildcard_right_case_sensitive(self):
self.assertIn(
'success',
self.route(
{
"match": {"uri": "/bla*"},
"action": {"pass": "applications/empty"},
}
),
'match wildcard right case sensitive configure',
)
self.assertEqual(
self.get(url='/blah')['status'],
200,
'match wildcard right case sensitive /blah',
)
self.assertEqual(
self.get(url='/BLAH')['status'],
404,
'match wildcard right case sensitive /BLAH',
)
def test_routes_match_wildcard_substring_case_sensitive(self):
self.assertIn(
'success',
self.route(
{
"match": {"uri": "*bla*"},
"action": {"pass": "applications/empty"},
}
),
'match wildcard substring case sensitive configure',
)
self.assertEqual(
self.get(url='/blah')['status'],
200,
'match wildcard substring case sensitive /blah',
)
self.assertEqual(
self.get(url='/BLAH')['status'],
404,
'match wildcard substring case sensitive /BLAH',
)
def test_routes_absent(self):
self.conf(
{
"listeners": {"*:7081": {"pass": "applications/empty"}},
"applications": {
"empty": {
"type": "python",
"processes": {"spare": 0},
"path": self.current_dir + '/python/empty',
"working_directory": self.current_dir
+ '/python/empty',
"module": "wsgi",
}
},
}
)
self.assertEqual(self.get(port=7081)['status'], 200, 'routes absent')
def test_routes_pass_invalid(self):
self.assertIn(
'error',
self.conf({"pass": "routes/blah"}, 'listeners/*:7080'),
'routes invalid',
)
def test_route_empty(self):
self.assertIn(
'success',
self.conf(
{
"listeners": {"*:7080": {"pass": "routes/main"}},
"routes": {"main": []},
"applications": {
"empty": {
"type": "python",
"processes": {"spare": 0},
"path": self.current_dir + '/python/empty',
"working_directory": self.current_dir
+ '/python/empty',
"module": "wsgi",
},
"mirror": {
"type": "python",
"processes": {"spare": 0},
"path": self.current_dir + '/python/mirror',
"working_directory": self.current_dir
+ '/python/mirror',
"module": "wsgi",
},
},
}
),
'route empty configure',
)
self.assertEqual(self.get()['status'], 404, 'route empty')
def test_routes_route_empty(self):
self.assertIn(
'success',
self.conf({}, 'listeners'),
'routes empty listeners configure',
)
self.assertIn(
'success', self.conf({}, 'routes'), 'routes empty configure'
)
def test_routes_route_match_absent(self):
self.assertIn(
'success',
self.conf([{"action": {"pass": "applications/empty"}}], 'routes'),
'route match absent configure',
)
self.assertEqual(self.get()['status'], 200, 'route match absent')
def test_routes_route_action_absent(self):
self.skip_alerts.append(r'failed to apply new conf')
self.assertIn(
'error',
self.conf([{"match": {"method": "GET"}}], 'routes'),
'route pass absent configure',
)
def test_routes_route_pass_absent(self):
self.skip_alerts.append(r'failed to apply new conf')
self.assertIn(
'error',
self.conf([{"match": {"method": "GET"}, "action": {}}], 'routes'),
'route pass absent configure',
)
def test_routes_rules_two(self):
self.assertIn(
'success',
self.conf(
[
{
"match": {"method": "GET"},
"action": {"pass": "applications/empty"},
},
{
"match": {"method": "POST"},
"action": {"pass": "applications/mirror"},
},
],
'routes',
),
'rules two configure',
)
self.assertEqual(self.get()['status'], 200, 'rules two match first')
self.assertEqual(
self.post(
headers={
'Host': 'localhost',
'Content-Type': 'text/html',
'Connection': 'close',
},
body='X',
)['status'],
200,
'rules two match second',
)
def test_routes_two(self):
self.assertIn(
'success',
self.conf(
{
"listeners": {"*:7080": {"pass": "routes/first"}},
"routes": {
"first": [
{
"match": {"method": "GET"},
"action": {"pass": "routes/second"},
}
],
"second": [
{
"match": {"host": "localhost"},
"action": {"pass": "applications/empty"},
}
],
},
"applications": {
"empty": {
"type": "python",
"processes": {"spare": 0},
"path": self.current_dir + '/python/empty',
"working_directory": self.current_dir
+ '/python/empty',
"module": "wsgi",
}
},
}
),
'routes two configure',
)
self.assertEqual(self.get()['status'], 200, 'routes two')
def test_routes_match_host_positive(self):
self.assertIn(
'success',
self.route(
{
"match": {"host": "localhost"},
"action": {"pass": "applications/empty"},
}
),
'match host positive configure',
)
self.assertEqual(
self.get()['status'], 200, 'match host positive localhost'
)
self.assertEqual(
self.get(headers={'Host': 'localhost.', 'Connection': 'close'})[
'status'
],
200,
'match host positive trailing dot',
)
self.assertEqual(
self.get(headers={'Host': 'www.localhost', 'Connection': 'close'})[
'status'
],
404,
'match host positive www.localhost',
)
self.assertEqual(
self.get(headers={'Host': 'localhost1', 'Connection': 'close'})[
'status'
],
404,
'match host positive localhost1',
)
self.assertEqual(
self.get(headers={'Host': 'example.com', 'Connection': 'close'})[
'status'
],
404,
'match host positive example.com',
)
@unittest.skip('not yet')
def test_routes_match_host_absent(self):
self.assertIn(
'success',
self.route(
{
"match": {"host": "localhost"},
"action": {"pass": "applications/empty"},
}
),
'match host absent configure',
)
self.assertEqual(
self.get(headers={'Connection': 'close'})['status'],
400,
'match host absent',
)
def test_routes_match_host_ipv4(self):
self.assertIn(
'success',
self.route(
{
"match": {"host": "127.0.0.1"},
"action": {"pass": "applications/empty"},
}
),
'match host ipv4 configure',
)
self.assertEqual(
self.get(headers={'Host': '127.0.0.1', 'Connection': 'close'})[
'status'
],
200,
'match host ipv4',
)
def test_routes_match_host_ipv6(self):
self.assertIn(
'success',
self.route(
{
"match": {"host": "[::1]"},
"action": {"pass": "applications/empty"},
}
),
'match host ipv6 configure',
)
self.assertEqual(
self.get(headers={'Host': '[::1]', 'Connection': 'close'})[
'status'
],
200,
'match host ipv6',
)
self.assertEqual(
self.get(headers={'Host': '[::1]:7080', 'Connection': 'close'})[
'status'
],
200,
'match host ipv6 port',
)
def test_routes_match_host_positive_many(self):
self.assertIn(
'success',
self.route(
{
"match": {"host": ["localhost", "example.com"]},
"action": {"pass": "applications/empty"},
}
),
'match host positive many configure',
)
self.assertEqual(
self.get()['status'], 200, 'match host positive many localhost'
)
self.assertEqual(
self.get(headers={'Host': 'example.com', 'Connection': 'close'})[
'status'
],
200,
'match host positive many example.com',
)
def test_routes_match_host_positive_and_negative(self):
self.assertIn(
'success',
self.route(
{
"match": {"host": ["*example.com", "!www.example.com"]},
"action": {"pass": "applications/empty"},
}
),
'match host positive and negative configure',
)
self.assertEqual(
self.get()['status'],
404,
'match host positive and negative localhost',
)
self.assertEqual(
self.get(headers={'Host': 'example.com', 'Connection': 'close'})[
'status'
],
200,
'match host positive and negative example.com',
)
self.assertEqual(
self.get(
headers={'Host': 'www.example.com', 'Connection': 'close'}
)['status'],
404,
'match host positive and negative www.example.com',
)
self.assertEqual(
self.get(
headers={'Host': '!www.example.com', 'Connection': 'close'}
)['status'],
200,
'match host positive and negative !www.example.com',
)
def test_routes_match_host_positive_and_negative_wildcard(self):
self.assertIn(
'success',
self.route(
{
"match": {"host": ["*example*", "!www.example*"]},
"action": {"pass": "applications/empty"},
}
),
'match host positive and negative wildcard configure',
)
self.assertEqual(
self.get(headers={'Host': 'example.com', 'Connection': 'close'})[
'status'
],
200,
'match host positive and negative wildcard example.com',
)
self.assertEqual(
self.get(
headers={'Host': 'www.example.com', 'Connection': 'close'}
)['status'],
404,
'match host positive and negative wildcard www.example.com',
)
def test_routes_match_host_case_insensitive(self):
self.assertIn(
'success',
self.route(
{
"match": {"host": "Example.com"},
"action": {"pass": "applications/empty"},
}
),
'host case insensitive configure',
)
self.assertEqual(
self.get(headers={'Host': 'example.com', 'Connection': 'close'})[
'status'
],
200,
'host case insensitive example.com',
)
self.assertEqual(
self.get(headers={'Host': 'EXAMPLE.COM', 'Connection': 'close'})[
'status'
],
200,
'host case insensitive EXAMPLE.COM',
)
def test_routes_match_host_port(self):
self.assertIn(
'success',
self.route(
{
"match": {"host": "example.com"},
"action": {"pass": "applications/empty"},
}
),
'match host port configure',
)
self.assertEqual(
self.get(
headers={'Host': 'example.com:7080', 'Connection': 'close'}
)['status'],
200,
'match host port',
)
def test_routes_match_host_empty(self):
self.assertIn(
'success',
self.route(
{
"match": {"host": ""},
"action": {"pass": "applications/empty"},
}
),
'match host empty configure',
)
self.assertEqual(
self.get(headers={'Host': '', 'Connection': 'close'})['status'],
200,
'match host empty',
)
self.assertEqual(
self.get(http_10=True, headers={})['status'],
200,
'match host empty 2',
)
self.assertEqual(self.get()['status'], 404, 'match host empty 3')
def test_routes_match_uri_positive(self):
self.assertIn(
'success',
self.route(
{
"match": {"uri": "/"},
"action": {"pass": "applications/empty"},
}
),
'match uri positive configure',
)
self.assertEqual(self.get()['status'], 200, 'match uri positive')
self.assertEqual(
self.get(url='/blah')['status'], 404, 'match uri positive blah'
)
self.assertEqual(
self.get(url='/#blah')['status'], 200, 'match uri positive #blah'
)
self.assertEqual(
self.get(url='/?var')['status'], 200, 'match uri params'
)
self.assertEqual(
self.get(url='//')['status'], 200, 'match uri adjacent slashes'
)
self.assertEqual(
self.get(url='/blah/../')['status'], 200, 'match uri relative path'
)
self.assertEqual(
self.get(url='/./')['status'], 200, 'match uri relative path'
)
def test_routes_match_uri_case_sensitive(self):
self.assertIn(
'success',
self.route(
{
"match": {"uri": "/BLAH"},
"action": {"pass": "applications/empty"},
}
),
'match uri case sensitive configure',
)
self.assertEqual(
self.get(url='/blah')['status'],
404,
'match uri case sensitive blah',
)
self.assertEqual(
self.get(url='/BlaH')['status'],
404,
'match uri case sensitive BlaH',
)
self.assertEqual(
self.get(url='/BLAH')['status'],
200,
'match uri case sensitive BLAH',
)
def test_routes_match_uri_normalize(self):
self.assertIn(
'success',
self.route(
{
"match": {"uri": "/blah"},
"action": {"pass": "applications/empty"},
}
),
'match uri normalize configure',
)
self.assertEqual(
self.get(url='/%62%6c%61%68')['status'], 200, 'match uri normalize'
)
def test_routes_match_empty_array(self):
self.assertIn(
'success',
self.route(
{
"match": {"uri": []},
"action": {"pass": "applications/empty"},
}
),
'match empty array configure',
)
self.assertEqual(
self.get(url='/blah')['status'],
200,
'match empty array',
)
def test_routes_reconfigure(self):
self.assertIn('success', self.conf([], 'routes'), 'routes redefine')
self.assertEqual(self.get()['status'], 404, 'routes redefine request')
self.assertIn(
'success',
self.conf([{"action": {"pass": "applications/empty"}}], 'routes'),
'routes redefine 2',
)
self.assertEqual(
self.get()['status'], 200, 'routes redefine request 2'
)
self.assertIn('success', self.conf([], 'routes'), 'routes redefine 3')
self.assertEqual(
self.get()['status'], 404, 'routes redefine request 3'
)
self.assertIn(
'success',
self.conf(
{
"listeners": {"*:7080": {"pass": "routes/main"}},
"routes": {
"main": [{"action": {"pass": "applications/empty"}}]
},
"applications": {
"empty": {
"type": "python",
"processes": {"spare": 0},
"path": self.current_dir + '/python/empty',
"working_directory": self.current_dir
+ '/python/empty',
"module": "wsgi",
}
},
}
),
'routes redefine 4',
)
self.assertEqual(
self.get()['status'], 200, 'routes redefine request 4'
)
self.assertIn(
'success', self.conf_delete('routes/main/0'), 'routes redefine 5'
)
self.assertEqual(
self.get()['status'], 404, 'routes redefine request 5'
)
self.assertIn(
'success',
self.conf_post(
{"action": {"pass": "applications/empty"}}, 'routes/main'
),
'routes redefine 6',
)
self.assertEqual(
self.get()['status'], 200, 'routes redefine request 6'
)
self.assertIn(
'error',
self.conf(
{"action": {"pass": "applications/empty"}}, 'routes/main/2'
),
'routes redefine 7',
)
self.assertIn(
'success',
self.conf(
{"action": {"pass": "applications/empty"}}, 'routes/main/1'
),
'routes redefine 8',
)
self.assertEqual(
len(self.conf_get('routes/main')), 2, 'routes redefine conf 8'
)
self.assertEqual(
self.get()['status'], 200, 'routes redefine request 8'
)
def test_routes_edit(self):
self.assertIn(
'success',
self.route(
{
"match": {"method": "GET"},
"action": {"pass": "applications/empty"},
}
),
'routes edit configure',
)
self.assertEqual(self.get()['status'], 200, 'routes edit GET')
self.assertEqual(self.post()['status'], 404, 'routes edit POST')
self.assertIn(
'success',
self.conf_post(
{
"match": {"method": "POST"},
"action": {"pass": "applications/empty"},
},
'routes',
),
'routes edit configure 2',
)
self.assertEqual(
'GET',
self.conf_get('routes/0/match/method'),
'routes edit configure 2 check',
)
self.assertEqual(
'POST',
self.conf_get('routes/1/match/method'),
'routes edit configure 2 check 2',
)
self.assertEqual(self.get()['status'], 200, 'routes edit GET 2')
self.assertEqual(self.post()['status'], 200, 'routes edit POST 2')
self.assertIn(
'success',
self.conf_delete('routes/0'),
'routes edit configure 3',
)
self.assertEqual(self.get()['status'], 404, 'routes edit GET 3')
self.assertEqual(self.post()['status'], 200, 'routes edit POST 3')
self.assertIn(
'error',
self.conf_delete('routes/1'),
'routes edit configure invalid',
)
self.assertIn(
'error',
self.conf_delete('routes/-1'),
'routes edit configure invalid 2',
)
self.assertIn(
'error',
self.conf_delete('routes/blah'),
'routes edit configure invalid 3',
)
self.assertEqual(self.get()['status'], 404, 'routes edit GET 4')
self.assertEqual(self.post()['status'], 200, 'routes edit POST 4')
self.assertIn(
'success',
self.conf_delete('routes/0'),
'routes edit configure 5',
)
self.assertEqual(self.get()['status'], 404, 'routes edit GET 5')
self.assertEqual(self.post()['status'], 404, 'routes edit POST 5')
self.assertIn(
'success',
self.conf_post(
{
"match": {"method": "POST"},
"action": {"pass": "applications/empty"},
},
'routes',
),
'routes edit configure 6',
)
self.assertEqual(self.get()['status'], 404, 'routes edit GET 6')
self.assertEqual(self.post()['status'], 200, 'routes edit POST 6')
self.assertIn(
'success',
self.conf(
{
"listeners": {"*:7080": {"pass": "routes/main"}},
"routes": {
"main": [{"action": {"pass": "applications/empty"}}]
},
"applications": {
"empty": {
"type": "python",
"processes": {"spare": 0},
"path": self.current_dir + '/python/empty',
"working_directory": self.current_dir
+ '/python/empty',
"module": "wsgi",
}
},
}
),
'route edit configure 7',
)
self.assertIn(
'error',
self.conf_delete('routes/0'),
'routes edit configure invalid 4',
)
self.assertIn(
'error',
self.conf_delete('routes/main'),
'routes edit configure invalid 5',
)
self.assertEqual(self.get()['status'], 200, 'routes edit GET 7')
self.assertIn(
'success',
self.conf_delete('listeners/*:7080'),
'route edit configure 8',
)
self.assertIn(
'success',
self.conf_delete('routes/main'),
'route edit configure 9',
)
def test_match_edit(self):
self.skip_alerts.append(r'failed to apply new conf')
self.assertIn(
'success',
self.route(
{
"match": {"method": ["GET", "POST"]},
"action": {"pass": "applications/empty"},
}
),
'match edit configure',
)
self.assertEqual(self.get()['status'], 200, 'match edit GET')
self.assertEqual(self.post()['status'], 200, 'match edit POST')
self.assertEqual(self.put()['status'], 404, 'match edit PUT')
self.assertIn(
'success',
self.conf_post('\"PUT\"', 'routes/0/match/method'),
'match edit configure 2',
)
self.assertListEqual(
['GET', 'POST', 'PUT'],
self.conf_get('routes/0/match/method'),
'match edit configure 2 check',
)
self.assertEqual(self.get()['status'], 200, 'match edit GET 2')
self.assertEqual(self.post()['status'], 200, 'match edit POST 2')
self.assertEqual(self.put()['status'], 200, 'match edit PUT 2')
self.assertIn(
'success',
self.conf_delete('routes/0/match/method/1'),
'match edit configure 3',
)
self.assertListEqual(
['GET', 'PUT'],
self.conf_get('routes/0/match/method'),
'match edit configure 3 check',
)
self.assertEqual(self.get()['status'], 200, 'match edit GET 3')
self.assertEqual(self.post()['status'], 404, 'match edit POST 3')
self.assertEqual(self.put()['status'], 200, 'match edit PUT 3')
self.assertIn(
'success',
self.conf_delete('routes/0/match/method/1'),
'match edit configure 4',
)
self.assertListEqual(
['GET'],
self.conf_get('routes/0/match/method'),
'match edit configure 4 check',
)
self.assertEqual(self.get()['status'], 200, 'match edit GET 4')
self.assertEqual(self.post()['status'], 404, 'match edit POST 4')
self.assertEqual(self.put()['status'], 404, 'match edit PUT 4')
self.assertIn(
'error',
self.conf_delete('routes/0/match/method/1'),
'match edit configure invalid',
)
self.assertIn(
'error',
self.conf_delete('routes/0/match/method/-1'),
'match edit configure invalid 2',
)
self.assertIn(
'error',
self.conf_delete('routes/0/match/method/blah'),
'match edit configure invalid 3',
)
self.assertListEqual(
['GET'],
self.conf_get('routes/0/match/method'),
'match edit configure 5 check',
)
self.assertEqual(self.get()['status'], 200, 'match edit GET 5')
self.assertEqual(self.post()['status'], 404, 'match edit POST 5')
self.assertEqual(self.put()['status'], 404, 'match edit PUT 5')
self.assertIn(
'success',
self.conf_delete('routes/0/match/method/0'),
'match edit configure 6',
)
self.assertListEqual(
[],
self.conf_get('routes/0/match/method'),
'match edit configure 6 check',
)
self.assertEqual(self.get()['status'], 200, 'match edit GET 6')
self.assertEqual(self.post()['status'], 200, 'match edit POST 6')
self.assertEqual(self.put()['status'], 200, 'match edit PUT 6')
self.assertIn(
'success',
self.conf('"GET"', 'routes/0/match/method'),
'match edit configure 7',
)
self.assertEqual(self.get()['status'], 200, 'match edit GET 7')
self.assertEqual(self.post()['status'], 404, 'match edit POST 7')
self.assertEqual(self.put()['status'], 404, 'match edit PUT 7')
self.assertIn(
'error',
self.conf_delete('routes/0/match/method/0'),
'match edit configure invalid 5',
)
self.assertIn(
'error',
self.conf({}, 'routes/0/action'),
'match edit configure invalid 6',
)
self.assertIn(
'success',
self.conf({}, 'routes/0/match'),
'match edit configure 8',
)
self.assertEqual(self.get()['status'], 200, 'match edit GET 8')
def test_routes_match_rules(self):
self.assertIn(
'success',
self.route(
{
"match": {
"method": "GET",
"host": "localhost",
"uri": "/",
},
"action": {"pass": "applications/empty"},
}
),
'routes match rules configure',
)
self.assertEqual(self.get()['status'], 200, 'routes match rules')
def test_routes_loop(self):
self.assertIn(
'success',
self.route({"match": {"uri": "/"}, "action": {"pass": "routes"}}),
'routes loop configure',
)
self.assertEqual(self.get()['status'], 500, 'routes loop')
def test_routes_match_headers(self):
self.assertIn(
'success',
self.route(
{
"match": {"headers": {"host": "localhost"}},
"action": {"pass": "applications/empty"},
}
),
'match headers configure',
)
self.assertEqual(self.get()['status'], 200, 'match headers')
self.assertEqual(
self.get(
headers={
"Host": "Localhost",
"Connection": "close",
}
)['status'],
200,
'match headers case insensitive',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost.com",
"Connection": "close",
}
)['status'],
404,
'match headers exact',
)
self.assertEqual(
self.get(
headers={
"Host": "llocalhost",
"Connection": "close",
}
)['status'],
404,
'match headers exact 2',
)
self.assertEqual(
self.get(
headers={
"Host": "host",
"Connection": "close",
}
)['status'],
404,
'match headers exact 3',
)
def test_routes_match_headers_multiple(self):
self.assertIn(
'success',
self.route(
{
"match": {
"headers": {"host": "localhost", "x-blah": "test"}
},
"action": {"pass": "applications/empty"},
}
),
'match headers multiple configure',
)
self.assertEqual(self.get()['status'], 404, 'match headers multiple')
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"X-blah": "test",
"Connection": "close",
}
)['status'],
200,
'match headers multiple 2',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"X-blah": "",
"Connection": "close",
}
)['status'],
404,
'match headers multiple 3',
)
def test_routes_match_headers_multiple_values(self):
self.assertIn(
'success',
self.route(
{
"match": {"headers": {"x-blah": "test"}},
"action": {"pass": "applications/empty"},
}
),
'match headers multiple values configure',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"X-blah": ["test", "test", "test"],
"Connection": "close",
}
)['status'],
200,
'match headers multiple values',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"X-blah": ["test", "blah", "test"],
"Connection": "close",
}
)['status'],
404,
'match headers multiple values 2',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"X-blah": ["test", "", "test"],
"Connection": "close",
}
)['status'],
404,
'match headers multiple values 3',
)
def test_routes_match_headers_multiple_rules(self):
self.assertIn(
'success',
self.route(
{
"match": {"headers": {"x-blah": ["test", "blah"]}},
"action": {"pass": "applications/empty"},
}
),
'match headers multiple rules configure',
)
self.assertEqual(
self.get()['status'], 404, 'match headers multiple rules'
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"X-blah": "test",
"Connection": "close",
}
)['status'],
200,
'match headers multiple rules 2',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"X-blah": "blah",
"Connection": "close",
}
)['status'],
200,
'match headers multiple rules 3',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"X-blah": ["test", "blah", "test"],
"Connection": "close",
}
)['status'],
200,
'match headers multiple rules 4',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"X-blah": ["blah", ""],
"Connection": "close",
}
)['status'],
404,
'match headers multiple rules 5',
)
def test_routes_match_headers_case_insensitive(self):
self.assertIn(
'success',
self.route(
{
"match": {"headers": {"X-BLAH": "TEST"}},
"action": {"pass": "applications/empty"},
}
),
'match headers case insensitive configure',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"x-blah": "test",
"Connection": "close",
}
)['status'],
200,
'match headers case insensitive',
)
def test_routes_match_headers_invalid(self):
self.assertIn(
'error',
self.route(
{
"match": {"headers": ["blah"]},
"action": {"pass": "applications/empty"},
}
),
'match headers invalid',
)
self.assertIn(
'error',
self.route(
{
"match": {"headers": {"foo": ["bar", {}]}},
"action": {"pass": "applications/empty"},
}
),
'match headers invalid 2',
)
def test_routes_match_headers_empty_rule(self):
self.assertIn(
'success',
self.route(
{
"match": {"headers": {"host": ""}},
"action": {"pass": "applications/empty"},
}
),
'match headers empty rule configure',
)
self.assertEqual(self.get()['status'], 404, 'match headers empty rule')
self.assertEqual(
self.get(headers={"Host": "", "Connection": "close"})['status'],
200,
'match headers empty rule 2',
)
def test_routes_match_headers_rule_field_empty(self):
self.assertIn(
'error',
self.route(
{
"match": {"headers": {"": "blah"}},
"action": {"pass": "applications/empty"},
}
),
'match headers rule field empty configure',
)
def test_routes_match_headers_empty(self):
self.assertIn(
'success',
self.route(
{
"match": {"headers": {}},
"action": {"pass": "applications/empty"},
}
),
'match headers empty configure',
)
self.assertEqual(self.get()['status'], 200, 'match headers empty')
self.assertIn(
'success',
self.route(
{
"match": {"headers": []},
"action": {"pass": "applications/empty"},
}
),
'match headers array empty configure 2',
)
self.assertEqual(
self.get()['status'], 200, 'match headers array empty 2'
)
def test_routes_match_headers_rule_array_empty(self):
self.assertIn(
'success',
self.route(
{
"match": {"headers": {"blah": []}},
"action": {"pass": "applications/empty"},
}
),
'match headers rule array empty configure',
)
self.assertEqual(
self.get()['status'], 404, 'match headers rule array empty'
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"blah": "foo",
"Connection": "close",
}
)['status'], 200, 'match headers rule array empty 2'
)
def test_routes_match_headers_array(self):
self.assertIn(
'success',
self.route(
{
"match": {
"headers": [
{"x-header1": "foo*"},
{"x-header2": "bar"},
{"x-header3": ["foo", "bar"]},
{"x-header1": "bar", "x-header4": "foo"},
]
},
"action": {"pass": "applications/empty"},
}
),
'match headers array configure',
)
self.assertEqual(self.get()['status'], 404, 'match headers array')
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"x-header1": "foo123",
"Connection": "close",
}
)['status'],
200,
'match headers array 2',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"x-header2": "bar",
"Connection": "close",
}
)['status'],
200,
'match headers array 3',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"x-header3": "bar",
"Connection": "close",
}
)['status'],
200,
'match headers array 4',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"x-header1": "bar",
"Connection": "close",
}
)['status'],
404,
'match headers array 5',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"x-header1": "bar",
"x-header4": "foo",
"Connection": "close",
}
)['status'],
200,
'match headers array 6',
)
self.assertIn(
'success',
self.conf_delete('routes/0/match/headers/1'),
'match headers array configure 2',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"x-header2": "bar",
"Connection": "close",
}
)['status'],
404,
'match headers array 7',
)
self.assertEqual(
self.get(
headers={
"Host": "localhost",
"x-header3": "foo",
"Connection": "close",
}
)['status'],
200,
'match headers array 8',
)
def test_routes_match_arguments(self):
self.assertIn(
'success',
self.route(
{
"match": {"arguments": {"foo": "bar"}},
"action": {"pass": "applications/empty"},
}
),
'match arguments configure',
)
self.assertEqual(self.get()['status'], 404, 'match arguments')
self.assertEqual(
self.get(url='/?foo=bar')['status'], 200, 'match arguments 2'
)
self.assertEqual(
self.get(url='/?Foo=bar')['status'],
404,
'match arguments case sensitive',
)
self.assertEqual(
self.get(url='/?foo=Bar')['status'],
404,
'match arguments case sensitive 2',
)
self.assertEqual(
self.get(url='/?foo=bar1')['status'],
404,
'match arguments exact',
)
self.assertEqual(
self.get(url='/?1foo=bar')['status'],
404,
'match arguments exact 2',
)
def test_routes_match_arguments_empty(self):
self.assertIn(
'success',
self.route(
{
"match": {"arguments": {}},
"action": {"pass": "applications/empty"},
}
),
'match arguments empty configure',
)
self.assertEqual(self.get()['status'], 200, 'match arguments empty')
self.assertIn(
'success',
self.route(
{
"match": {"arguments": []},
"action": {"pass": "applications/empty"},
}
),
'match arguments empty configure 2',
)
self.assertEqual(self.get()['status'], 200, 'match arguments empty 2')
def test_routes_match_arguments_invalid(self):
self.assertIn(
'error',
self.route(
{
"match": {"arguments": ["var"]},
"action": {"pass": "applications/empty"},
}
),
'match arguments invalid',
)
self.assertIn(
'error',
self.route(
{
"match": {"arguments": [{"var1": {}}]},
"action": {"pass": "applications/empty"},
}
),
'match arguments invalid 2',
)
self.assertIn(
'error',
self.route(
{
"match": {"arguments": {"": "bar"}},
"action": {"pass": "applications/empty"},
}
),
'match arguments invalid 3',
)
@unittest.skip('not yet')
def test_routes_match_arguments_space(self):
self.assertIn(
'success',
self.route(
{
"match": {"arguments": {"foo": "bar "}},
"action": {"pass": "applications/empty"},
}
),
'match arguments space configure',
)
self.assertEqual(
self.get(url='/?foo=bar &')['status'],
200,
'match arguments space',
)
self.assertEqual(
self.get(url='/?foo=bar+&')['status'],
200,
'match arguments space 2',
) # FAIL
self.assertEqual(
self.get(url='/?foo=bar%20&')['status'],
200,
'match arguments space 3',
) # FAIL
@unittest.skip('not yet')
def test_routes_match_arguments_plus(self):
self.assertIn(
'success',
self.route(
{
"match": {"arguments": [{"foo": "bar+"}]},
"action": {"pass": "applications/empty"},
}
),
'match arguments plus configure',
)
self.assertEqual(
self.get(url='/?foo=bar+&')['status'],
200,
'match arguments plus',
)
self.assertEqual(
self.get(url='/?foo=bar%2B&')['status'],
200,
'match arguments plus 2',
) # FAIL
@unittest.skip('not yet')
def test_routes_match_arguments_hex(self):
self.assertIn(
'success',
self.route(
{
"match": {"arguments": [{"foo": "bar"}]},
"action": {"pass": "applications/empty"},
}
),
'match arguments hex configure',
)
self.assertEqual(
self.get(url='/?%66%6F%6f=%62%61%72&')['status'],
200,
'match arguments hex',
) # FAIL
def test_routes_match_arguments_chars(self):
self.assertIn(
'success',
self.route(
{
"match": {"arguments": {"foo": "-._()[],;"}},
"action": {"pass": "applications/empty"},
}
),
'match arguments chars configure',
)
self.assertEqual(
self.get(url='/?foo=-._()[],;')['status'],
200,
'match arguments chars',
)
def test_routes_match_arguments_complex(self):
self.assertIn(
'success',
self.route(
{
"match": {"arguments": {"foo": ""}},
"action": {"pass": "applications/empty"},
}
),
'match arguments complex configure',
)
self.assertEqual(
self.get(url='/?foo')['status'],
200,
'match arguments complex',
)
self.assertEqual(
self.get(url='/?blah=blah&foo=')['status'],
200,
'match arguments complex 2',
)
self.assertEqual(
self.get(url='/?&&&foo&&&')['status'],
200,
'match arguments complex 3',
)
self.assertEqual(
self.get(url='/?foo&foo=bar&foo')['status'],
404,
'match arguments complex 4',
)
self.assertEqual(
self.get(url='/?foo=&foo')['status'],
200,
'match arguments complex 5',
)
self.assertEqual(
self.get(url='/?&=&foo&==&')['status'],
200,
'match arguments complex 6',
)
self.assertEqual(
self.get(url='/?&=&bar&==&')['status'],
404,
'match arguments complex 7',
)
def test_routes_match_arguments_multiple(self):
self.assertIn(
'success',
self.route(
{
"match": {"arguments": {"foo": "bar", "blah": "test"}},
"action": {"pass": "applications/empty"},
}
),
'match arguments multiple configure',
)
self.assertEqual(self.get()['status'], 404, 'match arguments multiple')
self.assertEqual(
self.get(url='/?foo=bar&blah=test')['status'],
200,
'match arguments multiple 2',
)
self.assertEqual(
self.get(url='/?foo=bar&blah')['status'],
404,
'match arguments multiple 3',
)
def test_routes_match_arguments_multiple_rules(self):
self.assertIn(
'success',
self.route(
{
"match": {"arguments": {"foo": ["bar", "blah"]}},
"action": {"pass": "applications/empty"},
}
),
'match arguments multiple rules configure',
)
self.assertEqual(
self.get()['status'], 404, 'match arguments multiple rules'
)
self.assertEqual(
self.get(url='/?foo=bar')['status'],
200,
'match arguments multiple rules 2',
)
self.assertEqual(
self.get(url='/?foo=blah')['status'],
200,
'match arguments multiple rules 3',
)
self.assertEqual(
self.get(url='/?foo=blah&foo=bar&foo=blah')['status'],
200,
'match arguments multiple rules 4',
)
self.assertEqual(
self.get(url='/?foo=blah&foo=bar&foo=')['status'],
404,
'match arguments multiple rules 5',
)
def test_routes_match_arguments_array(self):
self.assertIn(
'success',
self.route(
{
"match": {
"arguments": [
{"var1": "val1*"},
{"var2": "val2"},
{"var3": ["foo", "bar"]},
{"var1": "bar", "var4": "foo"},
]
},
"action": {"pass": "applications/empty"},
}
),
'match arguments array configure',
)
self.assertEqual(self.get()['status'], 404, 'match arguments array')
self.assertEqual(
self.get(url='/?var1=val123')['status'],
200,
'match arguments array 2',
)
self.assertEqual(
self.get(url='/?var2=val2')['status'],
200,
'match arguments array 3',
)
self.assertEqual(
self.get(url='/?var3=bar')['status'],
200,
'match arguments array 4',
)
self.assertEqual(
self.get(url='/?var1=bar')['status'],
404,
'match arguments array 5',
)
self.assertEqual(
self.get(url='/?var1=bar&var4=foo')['status'],
200,
'match arguments array 6',
)
self.assertIn(
'success',
self.conf_delete('routes/0/match/arguments/1'),
'match arguments array configure 2',
)
self.assertEqual(
self.get(url='/?var2=val2')['status'],
404,
'match arguments array 7',
)
self.assertEqual(
self.get(url='/?var3=foo')['status'],
200,
'match arguments array 8',
)
def test_routes_match_cookies(self):
self.assertIn(
'success',
self.route(
{
"match": {"cookies": {"foO": "bar"}},
"action": {"pass": "applications/empty"},
}
),
'match cookie configure',
)
self.assertEqual(self.get()['status'], 404, 'match cookie')
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'foO=bar',
'Connection': 'close',
},
)['status'],
200,
'match cookies 2',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': ['foO=bar', 'blah=blah'],
'Connection': 'close',
},
)['status'],
200,
'match cookies 3',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'foO=bar; blah=blah',
'Connection': 'close',
},
)['status'],
200,
'match cookies 4',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'Foo=bar',
'Connection': 'close',
},
)['status'],
404,
'match cookies case sensitive',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'foO=Bar',
'Connection': 'close',
},
)['status'],
404,
'match cookies case sensitive 2',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'foO=bar1',
'Connection': 'close',
},
)['status'],
404,
'match cookies exact',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': '1foO=bar;',
'Connection': 'close',
},
)['status'],
404,
'match cookies exact 2',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'foO=bar;1',
'Connection': 'close',
},
)['status'],
200,
'match cookies exact 3',
)
def test_routes_match_cookies_empty(self):
self.assertIn(
'success',
self.route(
{
"match": {"cookies": {}},
"action": {"pass": "applications/empty"},
}
),
'match cookies empty configure',
)
self.assertEqual(self.get()['status'], 200, 'match cookies empty')
self.assertIn(
'success',
self.route(
{
"match": {"cookies": []},
"action": {"pass": "applications/empty"},
}
),
'match cookies empty configure 2',
)
self.assertEqual(self.get()['status'], 200, 'match cookies empty 2')
def test_routes_match_cookies_invalid(self):
self.assertIn(
'error',
self.route(
{
"match": {"cookies": ["var"]},
"action": {"pass": "applications/empty"},
}
),
'match cookies invalid',
)
self.assertIn(
'error',
self.route(
{
"match": {"cookies": [{"foo": {}}]},
"action": {"pass": "applications/empty"},
}
),
'match cookies invalid 2',
)
def test_routes_match_cookies_multiple(self):
self.assertIn(
'success',
self.route(
{
"match": {"cookies": {"foo": "bar", "blah": "blah"}},
"action": {"pass": "applications/empty"},
}
),
'match cookies multiple configure',
)
self.assertEqual(self.get()['status'], 404, 'match cookies multiple')
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'foo=bar; blah=blah',
'Connection': 'close',
}
)['status'],
200,
'match cookies multiple 2',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': ['foo=bar', 'blah=blah'],
'Connection': 'close',
}
)['status'],
200,
'match cookies multiple 3',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': ['foo=bar; blah', 'blah'],
'Connection': 'close',
}
)['status'],
404,
'match cookies multiple 4',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': ['foo=bar; blah=test', 'blah=blah'],
'Connection': 'close',
}
)['status'],
404,
'match cookies multiple 5',
)
def test_routes_match_cookies_multiple_values(self):
self.assertIn(
'success',
self.route(
{
"match": {"cookies": {"blah": "blah"}},
"action": {"pass": "applications/empty"},
}
),
'match cookies multiple values configure',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': ['blah=blah', 'blah=blah', 'blah=blah'],
'Connection': 'close',
}
)['status'],
200,
'match headers multiple values',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': ['blah=blah', 'blah=test', 'blah=blah'],
'Connection': 'close',
}
)['status'],
404,
'match cookies multiple values 2',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': ['blah=blah; blah=', 'blah=blah'],
'Connection': 'close',
}
)['status'],
404,
'match cookies multiple values 3',
)
def test_routes_match_cookies_multiple_rules(self):
self.assertIn(
'success',
self.route(
{
"match": {"cookies": {"blah": ["test", "blah"]}},
"action": {"pass": "applications/empty"},
}
),
'match cookies multiple rules configure',
)
self.assertEqual(
self.get()['status'], 404, 'match cookies multiple rules'
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'blah=test',
'Connection': 'close',
}
)['status'],
200,
'match cookies multiple rules 2',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'blah=blah',
'Connection': 'close',
}
)['status'],
200,
'match cookies multiple rules 3',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': ['blah=blah', 'blah=test', 'blah=blah'],
'Connection': 'close',
}
)['status'],
200,
'match cookies multiple rules 4',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': ['blah=blah; blah=test', 'blah=blah'],
'Connection': 'close',
}
)['status'],
200,
'match cookies multiple rules 5',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': ['blah=blah', 'blah'], # invalid cookie
'Connection': 'close',
}
)['status'],
200,
'match cookies multiple rules 6',
)
def test_routes_match_cookies_array(self):
self.assertIn(
'success',
self.route(
{
"match": {
"cookies": [
{"var1": "val1*"},
{"var2": "val2"},
{"var3": ["foo", "bar"]},
{"var1": "bar", "var4": "foo"},
]
},
"action": {"pass": "applications/empty"},
}
),
'match cookies array configure',
)
self.assertEqual(self.get()['status'], 404, 'match cookies array')
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'var1=val123',
'Connection': 'close',
},
)['status'],
200,
'match cookies array 2',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'var2=val2',
'Connection': 'close',
},
)['status'],
200,
'match cookies array 3',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'var3=bar',
'Connection': 'close',
},
)['status'],
200,
'match cookies array 4',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'var3=bar;',
'Connection': 'close',
},
)['status'],
200,
'match cookies array 5',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'var1=bar',
'Connection': 'close',
},
)['status'],
404,
'match cookies array 6',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'var1=bar; var4=foo;',
'Connection': 'close',
},
)['status'],
200,
'match cookies array 7',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': ['var1=bar', 'var4=foo'],
'Connection': 'close',
},
)['status'],
200,
'match cookies array 8',
)
self.assertIn(
'success',
self.conf_delete('routes/0/match/cookies/1'),
'match cookies array configure 2',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'var2=val2',
'Connection': 'close',
},
)['status'],
404,
'match cookies array 9',
)
self.assertEqual(
self.get(
headers={
'Host': 'localhost',
'Cookie': 'var3=foo',
'Connection': 'close',
},
)['status'],
200,
'match cookies array 10',
)
def test_routes_match_scheme(self):
self.assertIn(
'success',
self.route(
{
"match": {"scheme": "http"},
"action": {"pass": "applications/empty"},
}
),
'match scheme http configure',
)
self.assertIn(
'success',
self.route(
{
"match": {"scheme": "https"},
"action": {"pass": "applications/empty"},
}
),
'match scheme https configure',
)
self.assertIn(
'success',
self.route(
{
"match": {"scheme": "HtTp"},
"action": {"pass": "applications/empty"},
}
),
'match scheme http case insensitive configure',
)
self.assertIn(
'success',
self.route(
{
"match": {"scheme": "HtTpS"},
"action": {"pass": "applications/empty"},
}
),
'match scheme https case insensitive configure',
)
def test_routes_match_scheme_invalid(self):
self.assertIn(
'error',
self.route(
{
"match": {"scheme": ["http"]},
"action": {"pass": "applications/empty"},
}
),
'scheme invalid type no arrays allowed',
)
self.assertIn(
'error',
self.route(
{
"match": {"scheme": "ftp"},
"action": {"pass": "applications/empty"},
}
),
'scheme invalid protocol 1',
)
self.assertIn(
'error',
self.route(
{
"match": {"scheme": "ws"},
"action": {"pass": "applications/empty"},
}
),
'scheme invalid protocol 2',
)
self.assertIn(
'error',
self.route(
{
"match": {"scheme": "*"},
"action": {"pass": "applications/empty"},
}
),
'scheme invalid no wildcard allowed',
)
self.assertIn(
'error',
self.route(
{
"match": {"scheme": ""},
"action": {"pass": "applications/empty"},
}
),
'scheme invalid empty',
)
if __name__ == '__main__':
TestRouting.main()
| 29.458029
| 79
| 0.403717
| 6,037
| 80,715
| 5.33129
| 0.03197
| 0.105329
| 0.131645
| 0.131925
| 0.940376
| 0.901662
| 0.847755
| 0.747367
| 0.653192
| 0.510797
| 0
| 0.023825
| 0.459704
| 80,715
| 2,739
| 80
| 29.468784
| 0.714194
| 0.000421
| 0
| 0.517685
| 0
| 0
| 0.263365
| 0.006198
| 0
| 0
| 0
| 0
| 0.144293
| 1
| 0.032154
| false
| 0.044212
| 0.000804
| 0.000402
| 0.034164
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
608abf8c3af3aacee6c73d573aef18bf17790bea
| 376
|
py
|
Python
|
SUAVE/SUAVE-2.5.0/trunk/SUAVE/Methods/Weights/Correlations/__init__.py
|
Vinicius-Tanigawa/Undergraduate-Research-Project
|
e92372f07882484b127d7affe305eeec2238b8a9
|
[
"MIT"
] | null | null | null |
SUAVE/SUAVE-2.5.0/trunk/SUAVE/Methods/Weights/Correlations/__init__.py
|
Vinicius-Tanigawa/Undergraduate-Research-Project
|
e92372f07882484b127d7affe305eeec2238b8a9
|
[
"MIT"
] | null | null | null |
SUAVE/SUAVE-2.5.0/trunk/SUAVE/Methods/Weights/Correlations/__init__.py
|
Vinicius-Tanigawa/Undergraduate-Research-Project
|
e92372f07882484b127d7affe305eeec2238b8a9
|
[
"MIT"
] | null | null | null |
## @defgroup Methods-Weights-Correlations Correlations
#Correlation methods provide component weight breakdowns for different vehicle configurations based on regressed data
# @ingroup Methods-Weights
from . import Propulsion
from . import Transport
from . import BWB
from . import Human_Powered
from . import UAV
from . import Common
from . import FLOPS
from . import Raymer
| 28.923077
| 117
| 0.81117
| 47
| 376
| 6.468085
| 0.617021
| 0.263158
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.143617
| 376
| 12
| 118
| 31.333333
| 0.944099
| 0.510638
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
608d9f9ee87eb582cc9b209bb80dec9eb77a0be0
| 8,922
|
py
|
Python
|
test/test_pb_upload.py
|
pandorabots/pb-cli
|
06bb675399f196df2d460a7399e0209324b957a5
|
[
"BSD-2-Clause"
] | 34
|
2015-06-07T03:36:52.000Z
|
2021-04-14T12:49:22.000Z
|
test/test_pb_upload.py
|
pandorabots/pb-cli
|
06bb675399f196df2d460a7399e0209324b957a5
|
[
"BSD-2-Clause"
] | 17
|
2015-02-27T00:50:31.000Z
|
2021-08-11T09:10:04.000Z
|
test/test_pb_upload.py
|
pandorabots/pb-cli
|
06bb675399f196df2d460a7399e0209324b957a5
|
[
"BSD-2-Clause"
] | 15
|
2015-05-29T16:31:49.000Z
|
2020-12-08T05:42:08.000Z
|
import unittest
import subprocess
import json
import os
import util
import time
from TestConfig import *
config = {}
test_env = os.getenv('test_env', 'aiaas')
env_setup = TestConfig()
config = env_setup.setEnvironment(test_env)
cli = os.path.abspath('./pb-cli/index.js')
class TestPBUpload(unittest.TestCase):
@classmethod
def setUpClass(self):
self.util = util.TestUtil()
self.util.announce_test_block('pb upload')
self.hostname = config["hostname"]
print self.hostname
def setUp(self):
self.util.create_bot()
def test_upload_aiml(self):
self.util.it('successfully uploads an aiml file.')
bot_files = self.util.get_file_list()
self.assertFalse('test.aiml' in bot_files)
result = subprocess.Popen([
cli,
'upload',
'--app_id', config['appId'],
'--user_key', config['userKey'],
'--botname', config['botName'],
'--hostname', self.hostname,
os.path.abspath(os.path.dirname(__file__) + '/test_data/test.aiml')
],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
time.sleep(1)
bot_files = self.util.get_file_list()
self.assertTrue('test.aiml' in bot_files)
def test_upload_set(self):
self.util.it('successfully uploads a set file.')
bot_files = self.util.get_file_list()
self.assertFalse('test.set' in bot_files)
result = subprocess.Popen([
cli,
'upload',
'--app_id', config['appId'],
'--user_key', config['userKey'],
'--botname', config['botName'],
'--hostname', self.hostname,
os.path.abspath(os.path.dirname(__file__) + '/test_data/test.set')
],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
time.sleep(1)
bot_files = self.util.get_file_list()
self.assertTrue('test.set' in bot_files)
def test_upload_map(self):
self.util.it('successfully uploads a map file.')
bot_files = self.util.get_file_list()
self.assertFalse('test.map' in bot_files)
result = subprocess.Popen([
cli,
'upload',
'--app_id', config['appId'],
'--user_key', config['userKey'],
'--botname', config['botName'],
'--hostname', self.hostname,
os.path.abspath(os.path.dirname(__file__) + '/test_data/test.map')
],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
time.sleep(1)
bot_files = self.util.get_file_list()
self.assertTrue('test.map' in bot_files)
def test_map_failure(self):
self.util.it(['rejects files with invalid json', 'returns status 400.'])
result = subprocess.Popen([
cli,
'upload',
'--app_id', config['appId'],
'--user_key', config['userKey'],
'--botname', config['botName'],
'--hostname', self.hostname,
os.path.abspath(os.path.dirname(__file__) + '/test_data/invalid.map')
],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
time.sleep(1)
self.assertTrue('400' in result.stdout.read())
def test_upload_substitution(self):
self.util.it('successfully uploads a substitution file.')
bot_files = self.util.get_file_list()
self.assertFalse('test.substitution' in bot_files)
result = subprocess.Popen([
cli,
'upload',
'--app_id', config['appId'],
'--user_key', config['userKey'],
'--botname', config['botName'],
'--hostname', self.hostname,
os.path.abspath(os.path.dirname(__file__) + '/test_data/test.substitution')
],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
time.sleep(1)
bot_files = self.util.get_file_list()
self.assertTrue('test.substitution' in bot_files)
def test_upload_properties(self):
self.util.it('successfully uploads a properties file.')
result = subprocess.Popen([
cli,
'upload',
'--app_id', config['appId'],
'--user_key', config['userKey'],
'--botname', config['botName'],
'--hostname', self.hostname,
os.path.abspath(os.path.dirname(__file__) + '/test_data/test.properties')
],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
time.sleep(1)
self.util.download_file('testbot.properties')
with open(os.path.abspath(os.path.dirname(__file__) + '/test_data/test_output/testbot.properties')) as f:
f = json.load(f)
file_content = f
self.assertTrue(['name', 'Testbot'] in file_content)
self.util.delete_local_file('testbot.properties')
def test_upload_pdefaults(self):
self.util.it('successfully uploads a pdefaults file.')
bot_files = self.util.get_file_list()
try:
self.assertFalse('testbot.pdefaults' in bot_files)
except:
self.util.delete_file(filename='testbot.pdefaults')
time.sleep(1)
bot_files = self.util.get_file_list()
self.assertFalse('testbot.pdefaults' in bot_files)
result = subprocess.Popen([
cli,
'upload',
'--app_id', config['appId'],
'--user_key', config['userKey'],
'--botname', config['botName'],
'--hostname', self.hostname,
os.path.abspath(os.path.dirname(__file__) + '/test_data/test.pdefaults')
],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
time.sleep(1)
bot_files = self.util.get_file_list()
self.assertTrue('testbot.pdefaults' in bot_files)
self.util.delete_file(filename='testbot.pdefaults')
def test_invalid_botName(self):
self.util.it('returns 400 if the botname is invalid.')
result = subprocess.Popen([
cli, 'upload',
'--app_id', config['appId'],
'--user_key', config['userKey'],
'--botname', 'ABCDEFG',
'--hostname', self.hostname,
os.path.abspath(os.path.dirname(__file__) + '/test_data/test.aiml')
],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
self.assertTrue('400' in result.stdout.read())
def test_bot_not_found(self):
self.util.it('returns 412 if the bot does not exist.')
result = subprocess.Popen([
cli, 'upload',
'--app_id', config['appId'],
'--user_key', config['userKey'],
'--botname', '123456',
'--hostname', self.hostname,
os.path.abspath(os.path.dirname(__file__) + '/test_data/test.aiml')
],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
self.assertTrue('412' in result.stdout.read())
def test_invalid_userKey(self):
self.util.it('returns 401 if the user_key is invalid.')
result = subprocess.Popen([
cli, 'upload',
'--app_id', config['appId'],
'--user_key', '12345',
'--botname', config['botName'],
'--hostname', self.hostname,
os.path.abspath(os.path.dirname(__file__) + '/test_data/test.aiml')
],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
self.assertTrue('401' in result.stdout.read())
def test_invalid_appId(self):
self.util.it('returns 401 if the app_id is invalid.')
result = subprocess.Popen([
cli, 'upload',
'--app_id', '12345',
'--user_key', config['userKey'],
'--botname', config['botName'],
'--hostname', self.hostname,
os.path.abspath(os.path.dirname(__file__) + '/test_data/test.aiml')
],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
self.assertTrue('401' in result.stdout.read())
def tearDown(self):
self.util.delete_bot()
if __name__ == "__main__":
unittest.main()
| 33.667925
| 113
| 0.543376
| 929
| 8,922
| 5.029064
| 0.116254
| 0.05137
| 0.035959
| 0.041096
| 0.793878
| 0.766267
| 0.744435
| 0.668664
| 0.649615
| 0.623716
| 0
| 0.008929
| 0.322125
| 8,922
| 264
| 114
| 33.795455
| 0.763558
| 0
| 0
| 0.632287
| 0
| 0
| 0.186393
| 0.015916
| 0
| 0
| 0
| 0
| 0.076233
| 0
| null | null | 0
| 0.03139
| null | null | 0.004484
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
608f5cf23f81afc7526f5797d3616f4d3b21b984
| 133
|
py
|
Python
|
fars_cleaner/__init__.py
|
mzabrams/fars-cleaner
|
789a8c735654fc8a88fb4b5e20d1292eb1ead204
|
[
"BSD-3-Clause"
] | 1
|
2021-04-26T17:04:36.000Z
|
2021-04-26T17:04:36.000Z
|
fars_cleaner/__init__.py
|
mzabrams/fars-cleaner
|
789a8c735654fc8a88fb4b5e20d1292eb1ead204
|
[
"BSD-3-Clause"
] | null | null | null |
fars_cleaner/__init__.py
|
mzabrams/fars-cleaner
|
789a8c735654fc8a88fb4b5e20d1292eb1ead204
|
[
"BSD-3-Clause"
] | null | null | null |
name = 'fars_cleaner'
from .datasets import FARSFetcher
from .fars_processor import FARSProcessor
#from .data_loader import pipeline
| 26.6
| 41
| 0.834586
| 17
| 133
| 6.352941
| 0.705882
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.112782
| 133
| 4
| 42
| 33.25
| 0.915254
| 0.24812
| 0
| 0
| 0
| 0
| 0.121212
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.666667
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
608f6d62e645ef4b15e9a7de58075b2781ad07d7
| 359
|
py
|
Python
|
python/testData/inspections/PyMethodParametersInspectionMetacls/test.py
|
jnthn/intellij-community
|
8fa7c8a3ace62400c838e0d5926a7be106aa8557
|
[
"Apache-2.0"
] | 2
|
2019-04-28T07:48:50.000Z
|
2020-12-11T14:18:08.000Z
|
python/testData/inspections/PyMethodParametersInspectionMetacls/test.py
|
Cyril-lamirand/intellij-community
|
60ab6c61b82fc761dd68363eca7d9d69663cfa39
|
[
"Apache-2.0"
] | 173
|
2018-07-05T13:59:39.000Z
|
2018-08-09T01:12:03.000Z
|
python/testData/inspections/PyMethodParametersInspectionMetacls/test.py
|
Cyril-lamirand/intellij-community
|
60ab6c61b82fc761dd68363eca7d9d69663cfa39
|
[
"Apache-2.0"
] | 2
|
2020-03-15T08:57:37.000Z
|
2020-04-07T04:48:14.000Z
|
class Meta(type):
def __new__(<weak_warning descr="Usually first parameter of such methods is named 'metacls'">self</weak_warning>, *rest): # rename to "metacls"
pass
@classmethod
def baz(<weak_warning descr="Usually first parameter of such methods is named 'metacls'">moo</weak_warning>): # <- rename to "metacls"
return "foobar"
| 51.285714
| 147
| 0.699164
| 48
| 359
| 5.0625
| 0.5625
| 0.18107
| 0.131687
| 0.1893
| 0.526749
| 0.526749
| 0.526749
| 0.526749
| 0.526749
| 0.526749
| 0
| 0
| 0.183844
| 359
| 7
| 148
| 51.285714
| 0.829352
| 0.116992
| 0
| 0
| 0
| 0
| 0.387302
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0.166667
| 0
| null | null | 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
609bdd7c07936ec984d28814b0be780ecaf4894f
| 256
|
py
|
Python
|
elpis/engines/common/errors.py
|
guillaume-wisniewski/elpis
|
550c350fd0098751b9a502a253bc4066f15c47db
|
[
"Apache-2.0"
] | 118
|
2018-11-25T22:00:11.000Z
|
2022-03-18T10:18:33.000Z
|
elpis/engines/common/errors.py
|
guillaume-wisniewski/elpis
|
550c350fd0098751b9a502a253bc4066f15c47db
|
[
"Apache-2.0"
] | 189
|
2019-01-25T01:37:59.000Z
|
2022-02-16T02:31:23.000Z
|
elpis/engines/common/errors.py
|
guillaume-wisniewski/elpis
|
550c350fd0098751b9a502a253bc4066f15c47db
|
[
"Apache-2.0"
] | 34
|
2018-11-28T20:31:38.000Z
|
2022-01-27T12:20:59.000Z
|
class InterfaceError(Exception):
def __init__(self, message, human_message=None):
super().__init__(message)
if human_message is None:
self.human_message = message
else:
self.human_message = human_message
| 32
| 52
| 0.648438
| 28
| 256
| 5.464286
| 0.464286
| 0.392157
| 0.248366
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.273438
| 256
| 7
| 53
| 36.571429
| 0.822581
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.142857
| false
| 0
| 0
| 0
| 0.285714
| 0
| 1
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
60a8e632907cf1c388f9215b3d758c94eaf3ec77
| 489
|
py
|
Python
|
webstompy/listener.py
|
point8/webstompy
|
e4cf473c5b18489543660b7bdf30302e8d412fbc
|
[
"MIT"
] | 2
|
2020-02-18T08:38:53.000Z
|
2020-11-26T06:47:29.000Z
|
webstompy/listener.py
|
point8/webstompy
|
e4cf473c5b18489543660b7bdf30302e8d412fbc
|
[
"MIT"
] | null | null | null |
webstompy/listener.py
|
point8/webstompy
|
e4cf473c5b18489543660b7bdf30302e8d412fbc
|
[
"MIT"
] | null | null | null |
"""StompListener: base class for a listener which will be invoked upon message
arrival
"""
class StompListener(object):
"""StompListener: base class for a listener which will be invoked upon message
arrival
"""
def on_message(self, frame):
"""Called by the STOMP receiver thread upon message arrival.
Parameters
----------
frame: webstompy.StompFrame
The frame containing the headers and the message
"""
pass
| 24.45
| 82
| 0.640082
| 56
| 489
| 5.571429
| 0.553571
| 0.105769
| 0.173077
| 0.160256
| 0.448718
| 0.448718
| 0.448718
| 0.448718
| 0.448718
| 0.448718
| 0
| 0
| 0.278119
| 489
| 19
| 83
| 25.736842
| 0.883853
| 0.672802
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0.333333
| 0
| 0
| 0.666667
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 1
| 0
|
0
| 4
|
60af64c59edda8262836fb184765f8de7744fe10
| 14,378
|
py
|
Python
|
res/loader/synthetic_loader.py
|
GregoryEHunter/generalization_to_OOD_category_viewpoint_combinations
|
52aacbb3420639cae64ce65085c17b245e5ef865
|
[
"MIT"
] | 10
|
2022-02-21T17:15:18.000Z
|
2022-03-19T16:06:40.000Z
|
res/loader/synthetic_loader.py
|
GregoryEHunter/generalization_to_OOD_category_viewpoint_combinations
|
52aacbb3420639cae64ce65085c17b245e5ef865
|
[
"MIT"
] | null | null | null |
res/loader/synthetic_loader.py
|
GregoryEHunter/generalization_to_OOD_category_viewpoint_combinations
|
52aacbb3420639cae64ce65085c17b245e5ef865
|
[
"MIT"
] | 1
|
2022-03-30T00:04:37.000Z
|
2022-03-30T00:04:37.000Z
|
import torch.utils.data as data
from PIL import Image
import os
import os.path
import sys
import numpy as np
#LABEL_FOLDER = '/media/ssd500/light_invariant/old_dataset'
def format_label(imarray):
imarray = imarray[0,:,:]
imarray[imarray>150] = 255
imarray[imarray<150] = 0
imarray[imarray==255] = 1
return imarray
# This below code was for old dataset labels. In that cars were labelled 1-136. In new rendering, cars are labelled 250,249,248 ... so on for every car added. Other objects are added as 1, 14, 27... (+13) for every object. 105 is the max label for objects other than cars.
# imarray = imarray[0,:,:]
# imarray[imarray==0] = 255
# imarray[imarray<137] = 1
# imarray[imarray>1] = 0
# return imarray
# Uncommented because the new dataset format has changed and will now be constant. so, don't need this flexible function.
# def image_path_to_label_path(impath,LABEL_FOLDER):
# image_name = impath.split('/')[-1]
# object_name = impath.split('/')[-2]
# phase_name = impath.split('/')[-3]
# label_path = '%s/%s'%(LABEL_FOLDER,"label_"+image_name)
# print(label_path)
# return label_path
def has_file_allowed_extension(filename, extensions):
"""Checks if a file is an allowed extension.
Args:
filename (string): path to a file
extensions (iterable of strings): extensions to consider (lowercase)
Returns:
bool: True if the filename ends with one of given extensions
"""
filename_lower = filename.lower()
return "label" not in filename_lower
def is_image_file(filename):
"""Checks if a file is an allowed image extension.
Args:
filename (string): path to a file
Returns:
bool: True if the filename ends with a known image extension
"""
return has_file_allowed_extension(filename, IMG_EXTENSIONS)
def make_dataset(dir, extensions):
images = []
dir = os.path.expanduser(dir)
image_folder = dir + 'images/'
label_folder = dir + 'labels/'
for image_file in sorted(os.listdir(image_folder)):
label_file = 'label_' + image_file
image_file_path = image_folder + image_file
label_file_path = label_folder + label_file
if '.png' in image_file_path and '.png' in label_file_path:
item = (image_file_path,label_file_path)
images.append(item)
return images
# render_file = os.path.join(dir, "render.txt")
# # print('render file is',render_file)
# # print('second part is',os.path.isfile(render_file))
# # print(render_file, os.path.isfile(render_file))
# with open(render_file, 'r') as imlist:
# for target in imlist:
# fname = target[:-1]
# d = os.path.join(dir, fname)
# if not os.path.exists(d):
# continue
# if has_file_allowed_extension(fname, extensions):
# path = d
# label_path = image_path_to_label_path(path,dir)
# if not os.path.exists(label_path):
# continue
# else:
# item = (path, label_path)
# images.append(item)
# # print(item)
# return images
class DatasetFolder(data.Dataset):
"""A generic data loader where the samples are arranged in this way: ::
root/class_x/xxx.ext
root/class_x/xxy.ext
root/class_x/xxz.ext
root/class_y/123.ext
root/class_y/nsdf3.ext
root/class_y/asd932_.ext
Args:
root (string): Root directory path.
loader (callable): A function to load a sample given its path.
extensions (list[string]): A list of allowed extensions.
transform (callable, optional): A function/transform that takes in
a sample and returns a transformed version.
E.g, ``transforms.RandomCrop`` for images.
target_transform (callable, optional): A function/transform that takes
in the target and transforms it.
Attributes:
classes (list): List of the class names.
class_to_idx (dict): Dict with items (class_name, class_index).
samples (list): List of (sample path, class_index) tuples
targets (list): The class_index value for each image in the dataset
"""
def __init__(self, root, loader, extensions, transform=None, target_transform=None):
# classes, class_to_idx = self._find_classes(root)
samples = make_dataset(root, extensions)
if len(samples) == 0:
raise(RuntimeError("Found 0 files in subfolders of: " + root + "\n"
"Supported extensions are: " + ",".join(extensions)))
self.root = root
self.loader = loader
self.extensions = extensions
#self.classes = classes
# self.class_to_idx = class_to_idx
self.samples = samples
self.targets = [s[1] for s in samples]
self.transform = transform
self.target_transform = target_transform
def _find_classes(self, dir):
"""
Finds the class folders in a dataset.
Args:
dir (string): Root directory path.
Returns:
tuple: (classes, class_to_idx) where classes are relative to (dir), and class_to_idx is a dictionary.
Ensures:
No class is a subdirectory of another.
"""
if sys.version_info >= (3, 5):
# Faster and available in Python 3.5 and above
classes = [d.name for d in os.scandir(dir) if d.is_dir()]
else:
classes = [d for d in os.listdir(dir) if os.path.isdir(os.path.join(dir, d))]
classes.sort()
class_to_idx = {classes[i]: i for i in range(len(classes))}
return classes, class_to_idx
def __getitem__(self, index):
"""
Args:
index (int): Index
Returns:
tuple: (sample, target) where target is class_index of the target class.
"""
path, label_path = self.samples[index]
# print(path)
sample = self.loader(path)
sample_label = self.loader(label_path)
# reformatted_label = assign_pixel_val(label)
if self.transform is not None:
sample = self.transform(sample)
if self.target_transform is not None:
target = self.target_transform(sample_label)
formatted_label = format_label(target*255)
# single_channel = target[0,:,:]
return sample, formatted_label
def __len__(self):
return len(self.samples)
def __repr__(self):
fmt_str = 'Dataset ' + self.__class__.__name__ + '\n'
fmt_str += ' Number of datapoints: {}\n'.format(self.__len__())
fmt_str += ' Root Location: {}\n'.format(self.root)
tmp = ' Transforms (if any): '
fmt_str += '{0}{1}\n'.format(tmp, self.transform.__repr__().replace('\n', '\n' + ' ' * len(tmp)))
tmp = ' Target Transforms (if any): '
fmt_str += '{0}{1}'.format(tmp, self.target_transform.__repr__().replace('\n', '\n' + ' ' * len(tmp)))
return fmt_str
class DatasetFolder_with_paths(data.Dataset):
"""A generic data loader where the samples are arranged in this way: ::
root/class_x/xxx.ext
root/class_x/xxy.ext
root/class_x/xxz.ext
root/class_y/123.ext
root/class_y/nsdf3.ext
root/class_y/asd932_.ext
Args:
root (string): Root directory path.
loader (callable): A function to load a sample given its path.
extensions (list[string]): A list of allowed extensions.
transform (callable, optional): A function/transform that takes in
a sample and returns a transformed version.
E.g, ``transforms.RandomCrop`` for images.
target_transform (callable, optional): A function/transform that takes
in the target and transforms it.
Attributes:
classes (list): List of the class names.
class_to_idx (dict): Dict with items (class_name, class_index).
samples (list): List of (sample path, class_index) tuples
targets (list): The class_index value for each image in the dataset
"""
def __init__(self, root, loader, extensions, transform=None, target_transform=None):
# classes, class_to_idx = self._find_classes(root)
samples = make_dataset(root, extensions)
if len(samples) == 0:
raise(RuntimeError("Found 0 files in subfolders of: " + root + "\n"
"Supported extensions are: " + ",".join(extensions)))
self.root = root
self.loader = loader
self.extensions = extensions
#self.classes = classes
# self.class_to_idx = class_to_idx
self.samples = samples
self.targets = [s[1] for s in samples]
self.transform = transform
self.target_transform = target_transform
def _find_classes(self, dir):
"""
Finds the class folders in a dataset.
Args:
dir (string): Root directory path.
Returns:
tuple: (classes, class_to_idx) where classes are relative to (dir), and class_to_idx is a dictionary.
Ensures:
No class is a subdirectory of another.
"""
if sys.version_info >= (3, 5):
# Faster and available in Python 3.5 and above
classes = [d.name for d in os.scandir(dir) if d.is_dir()]
else:
classes = [d for d in os.listdir(dir) if os.path.isdir(os.path.join(dir, d))]
classes.sort()
class_to_idx = {classes[i]: i for i in range(len(classes))}
return classes, class_to_idx
def __getitem__(self, index):
"""
Args:
index (int): Index
Returns:
tuple: (sample, target) where target is class_index of the target class.
"""
path, label_path = self.samples[index]
# print(path)
sample = self.loader(path)
sample_label = self.loader(label_path)
# reformatted_label = assign_pixel_val(label)
if self.transform is not None:
sample = self.transform(sample)
if self.target_transform is not None:
target = self.target_transform(sample_label)
formatted_label = format_label(target*255)
# single_channel = target[0,:,:]
return sample, formatted_label,path,label_path
def __len__(self):
return len(self.samples)
def __repr__(self):
fmt_str = 'Dataset ' + self.__class__.__name__ + '\n'
fmt_str += ' Number of datapoints: {}\n'.format(self.__len__())
fmt_str += ' Root Location: {}\n'.format(self.root)
tmp = ' Transforms (if any): '
fmt_str += '{0}{1}\n'.format(tmp, self.transform.__repr__().replace('\n', '\n' + ' ' * len(tmp)))
tmp = ' Target Transforms (if any): '
fmt_str += '{0}{1}'.format(tmp, self.target_transform.__repr__().replace('\n', '\n' + ' ' * len(tmp)))
return fmt_str
IMG_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.pgm', '.tif']
def pil_loader(path):
# open path as file to avoid ResourceWarning (https://github.com/python-pillow/Pillow/issues/835)
with open(path, 'rb') as f:
img = Image.open(f)
return img.convert('RGB')
def accimage_loader(path):
import accimage
try:
return accimage.Image(path)
except IOError:
# Potentially a decoding problem, fall back to PIL.Image
return pil_loader(path)
def default_loader(path):
from torchvision import get_image_backend
if get_image_backend() == 'accimage':
return accimage_loader(path)
else:
return pil_loader(path)
class ImageFolder(DatasetFolder):
"""A generic data loader where the images are arranged in this way: ::
root/dog/xxx.png
root/dog/xxy.png
root/dog/xxz.png
root/cat/123.png
root/cat/nsdf3.png
root/cat/asd932_.png
Args:
root (string): Root directory path.
transform (callable, optional): A function/transform that takes in an PIL image
and returns a transformed version. E.g, ``transforms.RandomCrop``
target_transform (callable, optional): A function/transform that takes in the
target and transforms it.
loader (callable, optional): A function to load an image given its path.
Attributes:
classes (list): List of the class names.
class_to_idx (dict): Dict with items (class_name, class_index).
imgs (list): List of (image path, class_index) tuples
"""
def __init__(self, root, transform=None, target_transform=None,
loader=default_loader):
super(ImageFolder, self).__init__(root, loader, IMG_EXTENSIONS,
transform=transform,
target_transform=target_transform)
self.imgs = self.samples
class ImageFolder_with_paths(DatasetFolder_with_paths):
"""A generic data loader where the images are arranged in this way: ::
root/dog/xxx.png
root/dog/xxy.png
root/dog/xxz.png
root/cat/123.png
root/cat/nsdf3.png
root/cat/asd932_.png
Args:
root (string): Root directory path.
transform (callable, optional): A function/transform that takes in an PIL image
and returns a transformed version. E.g, ``transforms.RandomCrop``
target_transform (callable, optional): A function/transform that takes in the
target and transforms it.
loader (callable, optional): A function to load an image given its path.
Attributes:
classes (list): List of the class names.
class_to_idx (dict): Dict with items (class_name, class_index).
imgs (list): List of (image path, class_index) tuples
"""
def __init__(self, root, transform=None, target_transform=None,
loader=default_loader):
super(ImageFolder_with_paths, self).__init__(root, loader, IMG_EXTENSIONS,
transform=transform,
target_transform=target_transform)
self.imgs = self.samples
| 35.154034
| 272
| 0.613089
| 1,837
| 14,378
| 4.624932
| 0.146979
| 0.038842
| 0.021186
| 0.029426
| 0.748352
| 0.720339
| 0.720339
| 0.714689
| 0.697269
| 0.697269
| 0
| 0.01137
| 0.284323
| 14,378
| 408
| 273
| 35.240196
| 0.814286
| 0.485603
| 0
| 0.641379
| 0
| 0
| 0.072248
| 0
| 0.027586
| 0
| 0
| 0
| 0
| 1
| 0.131034
| false
| 0
| 0.055172
| 0.013793
| 0.331034
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
60b744f10b860b37f72b95954c62c69e34ca2fe5
| 147
|
py
|
Python
|
orderprocessing/orders/services/base_orders_processor.py
|
iomegak12/intel-training-usecase-1
|
0d1ab6f6076f46f7fbb290ceb41d6b851da1af3a
|
[
"MIT"
] | null | null | null |
orderprocessing/orders/services/base_orders_processor.py
|
iomegak12/intel-training-usecase-1
|
0d1ab6f6076f46f7fbb290ceb41d6b851da1af3a
|
[
"MIT"
] | null | null | null |
orderprocessing/orders/services/base_orders_processor.py
|
iomegak12/intel-training-usecase-1
|
0d1ab6f6076f46f7fbb290ceb41d6b851da1af3a
|
[
"MIT"
] | null | null | null |
from abc import ABC, abstractmethod
class BaseOrdersProcessor(ABC):
@abstractmethod
def process_orders(self, ordersFolder):
pass
| 18.375
| 43
| 0.734694
| 15
| 147
| 7.133333
| 0.8
| 0.317757
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.204082
| 147
| 7
| 44
| 21
| 0.91453
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| false
| 0.2
| 0.2
| 0
| 0.6
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
60ed3bd649720fb930587e46c94f6c7aaaf2710e
| 70
|
py
|
Python
|
v6.py
|
Vedantdavile/Soc-Py
|
654c5efa2dbc77820b72b767644c63790f3949bc
|
[
"MIT"
] | null | null | null |
v6.py
|
Vedantdavile/Soc-Py
|
654c5efa2dbc77820b72b767644c63790f3949bc
|
[
"MIT"
] | null | null | null |
v6.py
|
Vedantdavile/Soc-Py
|
654c5efa2dbc77820b72b767644c63790f3949bc
|
[
"MIT"
] | null | null | null |
import socket
ip=socket.gethostbyname('www.ipv6.google.com')
print ip
| 17.5
| 46
| 0.8
| 11
| 70
| 5.090909
| 0.818182
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.015385
| 0.071429
| 70
| 3
| 47
| 23.333333
| 0.846154
| 0
| 0
| 0
| 0
| 0
| 0.271429
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0
| 0.333333
| null | null | 0.333333
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
60efb28f53e3ce699b5f188caae758c778e1d167
| 377
|
py
|
Python
|
appium-examples/pytest/rdc/ios/tests/test_invald_login.py
|
sauceaaron/demo-python
|
cd7e0a8a9860771000a231371e64d7728f930d0c
|
[
"MIT"
] | null | null | null |
appium-examples/pytest/rdc/ios/tests/test_invald_login.py
|
sauceaaron/demo-python
|
cd7e0a8a9860771000a231371e64d7728f930d0c
|
[
"MIT"
] | null | null | null |
appium-examples/pytest/rdc/ios/tests/test_invald_login.py
|
sauceaaron/demo-python
|
cd7e0a8a9860771000a231371e64d7728f930d0c
|
[
"MIT"
] | 1
|
2021-12-07T16:18:36.000Z
|
2021-12-07T16:18:36.000Z
|
import pytest
def test_blank_credentials(ios_driver):
ios_driver.find_element_by_accessibility_id("test-Username").send_keys("")
ios_driver.find_element_by_accessibility_id("test-Password").send_keys("")
ios_driver.find_element_by_accessibility_id("test-LOGIN").click()
assert ios_driver.find_element_by_accessibility_id("test-Error message").is_displayed()
| 37.7
| 91
| 0.809019
| 53
| 377
| 5.264151
| 0.45283
| 0.16129
| 0.18638
| 0.286738
| 0.645161
| 0.645161
| 0.645161
| 0.645161
| 0.351254
| 0.351254
| 0
| 0
| 0.076923
| 377
| 9
| 92
| 41.888889
| 0.801724
| 0
| 0
| 0
| 0
| 0
| 0.143236
| 0
| 0
| 0
| 0
| 0
| 0.166667
| 1
| 0.166667
| false
| 0.166667
| 0.166667
| 0
| 0.333333
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
715af1649c8b7e222da00e5c1591aeeda18c192b
| 23
|
py
|
Python
|
mezzanine/__init__.py
|
dimasciput/mezzanine
|
ff821f5bf769b42db74f44674dff04890550fe41
|
[
"BSD-2-Clause"
] | null | null | null |
mezzanine/__init__.py
|
dimasciput/mezzanine
|
ff821f5bf769b42db74f44674dff04890550fe41
|
[
"BSD-2-Clause"
] | null | null | null |
mezzanine/__init__.py
|
dimasciput/mezzanine
|
ff821f5bf769b42db74f44674dff04890550fe41
|
[
"BSD-2-Clause"
] | null | null | null |
__version__ = "4.2.1"
| 7.666667
| 21
| 0.608696
| 4
| 23
| 2.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.157895
| 0.173913
| 23
| 2
| 22
| 11.5
| 0.368421
| 0
| 0
| 0
| 0
| 0
| 0.227273
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
717aa27eceddb43658fa6565caa1ea33ffd0c1b1
| 123
|
py
|
Python
|
emailusernames/context_processors.py
|
ramkishorem/django-emailusernames
|
b614a747ee0f2a0aae59b3d38adb3e8a1a0f3092
|
[
"BSD-3-Clause"
] | null | null | null |
emailusernames/context_processors.py
|
ramkishorem/django-emailusernames
|
b614a747ee0f2a0aae59b3d38adb3e8a1a0f3092
|
[
"BSD-3-Clause"
] | null | null | null |
emailusernames/context_processors.py
|
ramkishorem/django-emailusernames
|
b614a747ee0f2a0aae59b3d38adb3e8a1a0f3092
|
[
"BSD-3-Clause"
] | null | null | null |
from django.conf import settings
def user_resources(request):
return {
'LOGIN_URL': settings.LOGIN_URL,
}
| 17.571429
| 40
| 0.682927
| 15
| 123
| 5.4
| 0.8
| 0.197531
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.227642
| 123
| 6
| 41
| 20.5
| 0.852632
| 0
| 0
| 0
| 0
| 0
| 0.073171
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| false
| 0
| 0.2
| 0.2
| 0.6
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
719e4cb15d5380e572aa63f33dd86864b3b64604
| 21
|
py
|
Python
|
qap/version.py
|
manwithadodla/quality-assessment-protocol
|
9f4d660bd67eb20d4b4a28ae7e837e6d396f0318
|
[
"BSD-3-Clause"
] | 38
|
2015-01-23T20:07:22.000Z
|
2021-11-08T07:08:27.000Z
|
qap/version.py
|
manwithadodla/quality-assessment-protocol
|
9f4d660bd67eb20d4b4a28ae7e837e6d396f0318
|
[
"BSD-3-Clause"
] | 107
|
2015-01-09T00:34:34.000Z
|
2022-02-28T07:44:10.000Z
|
qap/version.py
|
manwithadodla/quality-assessment-protocol
|
9f4d660bd67eb20d4b4a28ae7e837e6d396f0318
|
[
"BSD-3-Clause"
] | 24
|
2015-09-14T16:11:12.000Z
|
2021-10-04T08:09:16.000Z
|
__version__="1.0.8b"
| 10.5
| 20
| 0.714286
| 4
| 21
| 2.75
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.15
| 0.047619
| 21
| 1
| 21
| 21
| 0.4
| 0
| 0
| 0
| 0
| 0
| 0.285714
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
71a6518ea705f09bda84df4251a4b0aa5f0616dd
| 4,601
|
py
|
Python
|
homepanelapi/api.py
|
timmo001/python-homepanelapi
|
584dcb76a010a74a307b4d16d27e82538b53fbf1
|
[
"MIT"
] | 1
|
2019-10-10T19:28:40.000Z
|
2019-10-10T19:28:40.000Z
|
homepanelapi/api.py
|
timmo001/python-homepanelapi
|
584dcb76a010a74a307b4d16d27e82538b53fbf1
|
[
"MIT"
] | null | null | null |
homepanelapi/api.py
|
timmo001/python-homepanelapi
|
584dcb76a010a74a307b4d16d27e82538b53fbf1
|
[
"MIT"
] | null | null | null |
"""Access the Home Panel API."""
import logging
import json
import asyncio
import aiohttp
_LOGGER = logging.getLogger(__name__)
class HomePanelApi:
"""Class for Home Panel API Client."""
def __init__(self, host: str, port: str, ssl: bool) -> json:
"""Initilalize."""
self.url = "{}://{}:{}".format("https" if ssl else "http", host, port)
self.authentication = None
def authenticate(self, username: str, password: str) -> bool:
"""Authenticate with Home Panel."""
loop = asyncio.get_event_loop()
data = loop.run_until_complete(
asyncio.wait_for(
self.post(
"/authentication",
{
"strategy": "local",
"username": username,
"password": password,
},
),
timeout=10.0,
)
)
if data and data["accessToken"]:
self.authentication = data
return True
if data and data["message"]:
_LOGGER.error("Error authenticating: %s", data["message"])
else:
_LOGGER.error("Error authenticating: Unknown")
return False
async def async_authenticate(self, username: str, password: str) -> bool:
"""Authenticate with Home Panel."""
data = await self.post(
"/authentication",
{"strategy": "local", "username": username, "password": password},
)
if data and data["accessToken"]:
self.authentication = data
return True
if data and data["message"]:
_LOGGER.error("Error authenticating: %s", data["message"])
else:
_LOGGER.error("Error authenticating: Unknown")
return False
def send_command(self, page: str, card: str, command: str) -> json:
"""Send a command to Home Panel."""
loop = asyncio.get_event_loop()
return loop.run_until_complete(
asyncio.wait_for(
self.post_with_auth(
"/controller",
{"page": page, "card": card, "command": command},
),
timeout=10.0,
)
)
# pylint: disable=C0330
async def async_send_command(
self, page: str, card: str, command: str
) -> json:
"""Send a command to Home Panel."""
return await self.post_with_auth(
"/controller", {"page": page, "card": card, "command": command}
)
def get_config(self) -> json:
"""Get config from Home Panel."""
loop = asyncio.get_event_loop()
result = loop.run_until_complete(
asyncio.wait_for(self.get_with_auth("/config"), timeout=10.0)
)
if result and result["data"]:
return result["data"][0]["config"]
return None
async def async_get_config(self) -> json:
"""Get config from Home Panel."""
result = await self.get_with_auth("/config")
if result and result["data"]:
return result["data"][0]["config"]
return None
async def post(self, endpoint: str, data: json) -> json:
"""Post to Home Panel."""
url = "{}{}".format(self.url, endpoint)
async with aiohttp.ClientSession() as session:
async with session.post(url=url, data=data) as response:
return await response.json()
async def post_with_auth(self, endpoint: str, data: json) -> json:
"""Post to Home Panel with authentication."""
url = "{}{}".format(self.url, endpoint)
authorization = "Bearer {}".format(self.authentication["accessToken"])
async with aiohttp.ClientSession() as session:
# pylint: disable=C0330
async with session.post(
url=url, data=data, headers={"Authorization": authorization}
) as response:
return await response.json()
async def get_with_auth(self, endpoint: str) -> json:
"""Get from Home Panel with authentication."""
url = "{}{}".format(self.url, endpoint)
authorization = "Bearer {}".format(self.authentication["accessToken"])
async with aiohttp.ClientSession() as session:
# pylint: disable=C0330
async with session.get(
url=url,
data={"userId": self.authentication["user"]["_id"]},
headers={"Authorization": authorization},
) as response:
return await response.json()
| 36.228346
| 78
| 0.547055
| 472
| 4,601
| 5.230932
| 0.188559
| 0.040097
| 0.014581
| 0.021061
| 0.818955
| 0.781288
| 0.765897
| 0.737951
| 0.681652
| 0.514783
| 0
| 0.007429
| 0.327103
| 4,601
| 126
| 79
| 36.515873
| 0.790052
| 0.049337
| 0
| 0.469388
| 0
| 0
| 0.108685
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.040816
| false
| 0.040816
| 0.040816
| 0
| 0.22449
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
71c16bbcfb8241860a5b7416ab2e5a517f099c14
| 118
|
py
|
Python
|
play-django/apps/echo/admin.py
|
piaoger/playground-python
|
1b0a3a79106b46cdf991a1c79c07653ec5a31488
|
[
"MIT"
] | null | null | null |
play-django/apps/echo/admin.py
|
piaoger/playground-python
|
1b0a3a79106b46cdf991a1c79c07653ec5a31488
|
[
"MIT"
] | 6
|
2018-12-07T20:46:29.000Z
|
2021-06-10T20:54:51.000Z
|
webresume/api/admin.py
|
cmput401-fall2018/web-app-ci-cd-with-travis-ci-ybekele
|
276c278612e16b05ea607cfd236d273b77341fe3
|
[
"MIT"
] | 1
|
2018-11-02T19:34:16.000Z
|
2018-11-02T19:34:16.000Z
|
from django.contrib import admin
# Register your models here.
from .models import Person
admin.site.register(Person)
| 19.666667
| 32
| 0.805085
| 17
| 118
| 5.588235
| 0.647059
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.127119
| 118
| 5
| 33
| 23.6
| 0.92233
| 0.220339
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.666667
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
71ccef3fd15cf1cd80f0608a4f2a517e2ef8dbed
| 1,474
|
py
|
Python
|
src/bst/pygasus/scaffolding/fields/model.py
|
codeix/bst.pygasus.scaffolding
|
e07c11ace109e4086f477d0d6c07ca3aafa564e9
|
[
"ZPL-2.1"
] | null | null | null |
src/bst/pygasus/scaffolding/fields/model.py
|
codeix/bst.pygasus.scaffolding
|
e07c11ace109e4086f477d0d6c07ca3aafa564e9
|
[
"ZPL-2.1"
] | null | null | null |
src/bst/pygasus/scaffolding/fields/model.py
|
codeix/bst.pygasus.scaffolding
|
e07c11ace109e4086f477d0d6c07ca3aafa564e9
|
[
"ZPL-2.1"
] | null | null | null |
from zope import schema
from bst.pygasus.core import ext
from bst.pygasus.scaffolding.fields import BuilderBase
from bst.pygasus.scaffolding.interfaces import IScaffoldingRecipeModel
class ModelBuilderBase(BuilderBase):
ext.baseclass()
def base(self, overrides):
b = dict(name=self.field.getName(),
useNull=not self.field.required)
b.update(overrides)
return b
class StringField(ModelBuilderBase):
ext.adapts(IScaffoldingRecipeModel, schema.interfaces.IField)
def __call__(self):
return self.base(dict(type='string'))
class DateField(ModelBuilderBase):
ext.adapts(IScaffoldingRecipeModel, schema.interfaces.IDate)
def __call__(self):
return self.base(dict(type='date',
dateFormat='Y-m-d H:i:s.u'))
class TimeField(ModelBuilderBase):
ext.adapts(IScaffoldingRecipeModel, schema.interfaces.ITime)
def __call__(self):
return self.base(dict(type='date',
dateFormat='H:i:s.u'))
class IntField(ModelBuilderBase):
ext.adapts(IScaffoldingRecipeModel, schema.interfaces.IInt)
def __call__(self):
return self.base(dict(type='int'))
class BoolField(ModelBuilderBase):
ext.adapts(IScaffoldingRecipeModel, schema.interfaces.IBool)
def __call__(self):
return self.base(dict(type='boolean'))
class IdField(IntField):
ext.adapts(IScaffoldingRecipeModel, schema.interfaces.IId)
| 25.859649
| 70
| 0.695387
| 161
| 1,474
| 6.242236
| 0.354037
| 0.053731
| 0.191045
| 0.226866
| 0.576119
| 0.510448
| 0.19204
| 0.19204
| 0.093532
| 0.093532
| 0
| 0
| 0.197422
| 1,474
| 56
| 71
| 26.321429
| 0.849535
| 0
| 0
| 0.2
| 0
| 0
| 0.029851
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.171429
| false
| 0
| 0.114286
| 0.142857
| 0.657143
| 0
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
e0b4c2c638dcac7189c3f6cac424e5243435a18e
| 124
|
py
|
Python
|
atec/qq_sim_helper/kaggle-quora-question-pairs/bin/feature_engineering/__init__.py
|
yscoder-github/nlp_competition
|
b49d1fe2b6aed2c73e5f1bc7e1524032b6cc5635
|
[
"Apache-2.0"
] | 4
|
2019-07-05T06:11:46.000Z
|
2021-08-01T22:46:58.000Z
|
atec/qq_sim_helper/kaggle-quora-question-pairs/bin/feature_engineering/__init__.py
|
yscoder-github/kaggle-nlp
|
b49d1fe2b6aed2c73e5f1bc7e1524032b6cc5635
|
[
"Apache-2.0"
] | null | null | null |
atec/qq_sim_helper/kaggle-quora-question-pairs/bin/feature_engineering/__init__.py
|
yscoder-github/kaggle-nlp
|
b49d1fe2b6aed2c73e5f1bc7e1524032b6cc5635
|
[
"Apache-2.0"
] | 2
|
2019-07-05T06:11:48.000Z
|
2021-08-01T22:46:59.000Z
|
#! /usr/bin/python
# -*- coding: utf-8 -*-
# @Time : 2017/6/18 10:39
# @Author : HouJP
# @Email : houjp1992@gmail.com
| 20.666667
| 32
| 0.564516
| 18
| 124
| 3.888889
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.163265
| 0.209677
| 124
| 5
| 33
| 24.8
| 0.55102
| 0.919355
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
e0bdf77938450084bf46eb7072d9dbb3027d5bb5
| 76
|
py
|
Python
|
departments_scraper/config/directories.py
|
DIS-SIN/Comments-Scraper
|
ee9321aefcb0dfd2fbd45d0be7daaffe118667d1
|
[
"MIT"
] | null | null | null |
departments_scraper/config/directories.py
|
DIS-SIN/Comments-Scraper
|
ee9321aefcb0dfd2fbd45d0be7daaffe118667d1
|
[
"MIT"
] | 8
|
2019-08-06T14:35:35.000Z
|
2021-06-01T23:47:51.000Z
|
departments_scraper/config/directories.py
|
DIS-SIN/Cognos-Scraper-
|
5531f8f64bb6ce049724409ab02899f837127dfa
|
[
"MIT"
] | null | null | null |
PROCESSED_DIR = '/home/ubuntu/Cognos-Scraper/departments_scraper/processed'
| 38
| 75
| 0.842105
| 9
| 76
| 6.888889
| 0.777778
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.039474
| 76
| 1
| 76
| 76
| 0.849315
| 0
| 0
| 0
| 0
| 0
| 0.75
| 0.75
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
e0d1b5c56dda41a45615ac3809a879f425c45386
| 133
|
py
|
Python
|
nose2/tests/functional/support/scenario/module_import_err/test_import_err.py
|
deeplow/nose2
|
eb0394160e24afe760e984d93dbece8351dbae7a
|
[
"BSD-2-Clause"
] | 637
|
2015-01-12T02:02:53.000Z
|
2022-03-30T19:47:48.000Z
|
nose2/tests/functional/support/scenario/module_import_err/test_import_err.py
|
deeplow/nose2
|
eb0394160e24afe760e984d93dbece8351dbae7a
|
[
"BSD-2-Clause"
] | 276
|
2015-01-02T19:14:06.000Z
|
2022-03-18T04:03:08.000Z
|
nose2/tests/functional/support/scenario/module_import_err/test_import_err.py
|
deeplow/nose2
|
eb0394160e24afe760e984d93dbece8351dbae7a
|
[
"BSD-2-Clause"
] | 127
|
2015-01-08T12:02:10.000Z
|
2022-01-10T20:52:29.000Z
|
import unittest
raise ImportError("booms")
def test():
pass
class Test(unittest.TestCase):
def test(self):
pass
| 10.230769
| 30
| 0.646617
| 16
| 133
| 5.375
| 0.6875
| 0.162791
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.24812
| 133
| 12
| 31
| 11.083333
| 0.86
| 0
| 0
| 0.285714
| 0
| 0
| 0.037594
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.285714
| false
| 0.285714
| 0.285714
| 0
| 0.714286
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 1
| 0
|
0
| 4
|
461b491ff6c0beee666f9dc879d6d7367b2ba024
| 181
|
py
|
Python
|
coursework/src/constants.py
|
SpeedoDevo/G51FSE
|
bf5e203d936965e254eff1efa0b74edc368a6cda
|
[
"MIT"
] | null | null | null |
coursework/src/constants.py
|
SpeedoDevo/G51FSE
|
bf5e203d936965e254eff1efa0b74edc368a6cda
|
[
"MIT"
] | null | null | null |
coursework/src/constants.py
|
SpeedoDevo/G51FSE
|
bf5e203d936965e254eff1efa0b74edc368a6cda
|
[
"MIT"
] | null | null | null |
BLACK = ( 0, 0, 0)
WHITE = ( 255, 255, 255)
GREEN = ( 0, 255, 0)
RED = ( 255, 0, 0)
GREY = ( 100, 100, 100)
SCREEN_WIDTH = 900
SCREEN_HEIGHT = 600
| 20.111111
| 27
| 0.464088
| 26
| 181
| 3.153846
| 0.5
| 0.073171
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.333333
| 0.38674
| 181
| 8
| 28
| 22.625
| 0.405405
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
1cc34e497603d5e88471da00ccf82f5b312a4370
| 3,588
|
py
|
Python
|
tests/tasks/test_prosess_queue.py
|
modun/integration
|
5f806a09fe8add19bfa94f7ea6fcd6eb8271d3b1
|
[
"MIT"
] | 1
|
2022-03-13T03:24:44.000Z
|
2022-03-13T03:24:44.000Z
|
tests/tasks/test_prosess_queue.py
|
modun/integration
|
5f806a09fe8add19bfa94f7ea6fcd6eb8271d3b1
|
[
"MIT"
] | null | null | null |
tests/tasks/test_prosess_queue.py
|
modun/integration
|
5f806a09fe8add19bfa94f7ea6fcd6eb8271d3b1
|
[
"MIT"
] | null | null | null |
# pylint: disable=missing-function-docstring,missing-module-docstring, protected-access
from unittest.mock import AsyncMock, patch
import pytest
from custom_components.hacs.base import HacsBase
from custom_components.hacs.enums import HacsDisabledReason, HacsStage
from custom_components.hacs.exceptions import HacsExecutionStillInProgress
dummy_task = AsyncMock()
@pytest.mark.asyncio
async def test_prosess_queue_disabled(hacs: HacsBase, caplog: pytest.LogCaptureFixture):
hacs.stage = HacsStage.RUNNING
assert not hacs.queue.has_pending_tasks
task = hacs.tasks.get("prosess_queue")
assert task
hacs.disable_hacs(HacsDisabledReason.RATE_LIMIT)
assert hacs.system.disabled
assert hacs.system.disabled_reason == HacsDisabledReason.RATE_LIMIT
await task.execute_task()
assert "HacsTask<prosess_queue> Skipping task, HACS is disabled rate_limit" in caplog.text
@pytest.mark.asyncio
async def test_prosess_queue_no_pending_tasks(hacs: HacsBase, caplog: pytest.LogCaptureFixture):
hacs.stage = HacsStage.RUNNING
assert not hacs.queue.has_pending_tasks
task = hacs.tasks.get("prosess_queue")
assert task
await task.execute_task()
assert "HacsTask<prosess_queue> Nothing in the queue" in caplog.text
assert not hacs.queue.has_pending_tasks
@pytest.mark.asyncio
async def test_prosess_queue_running(hacs: HacsBase, caplog: pytest.LogCaptureFixture):
hacs.stage = HacsStage.RUNNING
hacs.queue.running = True
assert not hacs.queue.has_pending_tasks
hacs.queue.add(dummy_task())
task = hacs.tasks.get("prosess_queue")
assert task
await task.execute_task()
assert "HacsTask<prosess_queue> Queue is already running" in caplog.text
assert hacs.queue.has_pending_tasks
@pytest.mark.asyncio
async def test_prosess_queue_ratelimted(hacs: HacsBase, caplog: pytest.LogCaptureFixture):
hacs.stage = HacsStage.RUNNING
hacs.queue.running = False
assert not hacs.queue.has_pending_tasks
hacs.queue.add(dummy_task())
task = hacs.tasks.get("prosess_queue")
assert task
with patch("custom_components.hacs.base.HacsBase.async_can_update", return_value=0):
await task.execute_task()
assert hacs.queue.has_pending_tasks
@pytest.mark.asyncio
async def test_prosess_queue_not_ratelimted(hacs: HacsBase, caplog: pytest.LogCaptureFixture):
hacs.stage = HacsStage.RUNNING
hacs.queue.running = False
assert not hacs.queue.has_pending_tasks
hacs.queue.add(dummy_task())
task = hacs.tasks.get("prosess_queue")
assert task
with patch("custom_components.hacs.base.HacsBase.async_can_update", return_value=100):
await task.execute_task()
assert "Can update 100 repositories, items in queue 1" in caplog.text
assert "Queue execution finished" in caplog.text
assert not hacs.queue.has_pending_tasks
@pytest.mark.asyncio
async def test_prosess_queue_exception(hacs: HacsBase, caplog: pytest.LogCaptureFixture):
hacs.stage = HacsStage.RUNNING
hacs.queue.running = False
assert not hacs.queue.has_pending_tasks
hacs.queue.add(dummy_task())
task = hacs.tasks.get("prosess_queue")
assert task
with patch("custom_components.hacs.base.HacsBase.async_can_update", return_value=100), patch(
"custom_components.hacs.utils.queue_manager.QueueManager.execute",
side_effect=HacsExecutionStillInProgress,
):
await task.execute_task()
assert "Can update 100 repositories, items in queue 1" in caplog.text
assert hacs.queue.has_pending_tasks
| 27.813953
| 97
| 0.761984
| 472
| 3,588
| 5.610169
| 0.173729
| 0.064577
| 0.049849
| 0.078927
| 0.740559
| 0.733006
| 0.733006
| 0.733006
| 0.684668
| 0.671073
| 0
| 0.004941
| 0.153846
| 3,588
| 128
| 98
| 28.03125
| 0.86726
| 0.02369
| 0
| 0.657895
| 0
| 0
| 0.163382
| 0.083119
| 0
| 0
| 0
| 0
| 0.328947
| 1
| 0
| false
| 0
| 0.065789
| 0
| 0.065789
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
e80df3efa381dab8e8337580dd73eb34e63868b9
| 52
|
py
|
Python
|
copo_code/copo/train/__init__.py
|
decisionforce/CoPO
|
3a06a48522b901db2e380a62a0efb5e8a30cd079
|
[
"Apache-2.0"
] | 37
|
2021-11-01T03:30:30.000Z
|
2022-03-29T08:38:12.000Z
|
copo_code/copo/train/__init__.py
|
binderwang/CoPO
|
a3ddef3b2bd264b1256747800919c66061ad4d5e
|
[
"Apache-2.0"
] | null | null | null |
copo_code/copo/train/__init__.py
|
binderwang/CoPO
|
a3ddef3b2bd264b1256747800919c66061ad4d5e
|
[
"Apache-2.0"
] | 4
|
2021-11-05T06:55:34.000Z
|
2022-01-04T07:08:37.000Z
|
from .utils import initialize_ray, get_train_parser
| 26
| 51
| 0.865385
| 8
| 52
| 5.25
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.096154
| 52
| 1
| 52
| 52
| 0.893617
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
e8161ec670159ca4cc95fe86a44888d03cd5a233
| 1,834
|
py
|
Python
|
hwwhile.py
|
Zhamiliaa/FisrtProject
|
cc37050e15890637f44fc548ce19fba2eec19a11
|
[
"MIT"
] | null | null | null |
hwwhile.py
|
Zhamiliaa/FisrtProject
|
cc37050e15890637f44fc548ce19fba2eec19a11
|
[
"MIT"
] | null | null | null |
hwwhile.py
|
Zhamiliaa/FisrtProject
|
cc37050e15890637f44fc548ce19fba2eec19a11
|
[
"MIT"
] | null | null | null |
#
# data = ['Wt', 'Ht', 342432423424324, 5.996, 5.77778,
# 'Insurance_History_2', 34243242342432124545312312534534534, 'Insurance_History_4',
# 'Insurance_History_5', 'Insurance_History_7', 234242049004328402384023849028402348203,
# 55, 66, 11, 'Medical_Keyword_3',
# 'Medical_Keyword_4', 'Medical_Keyword_5', 'Medical_Keyword_6', 34243242342432124545312312534534534534503495345,
# 'lalalalallalalalalalalalalalalala', 23409284028430928420483209482904380428, 'Medical_Keyword_10',
# 'Medical_Keyword_11',
# 92384923849023849023842903482934324290, 93429423018319238192004829423482942, 'Medical_Keyword_14',
# 'Medical_Keyword_15',
# 'Medical_Keyword_16', 5.888, 'Medical_Keyword_18asfdasfdasfdasfdasdfasdfas', 'Medicagsfgsfgsfkgjsfkg',
# 9.131, 0.978, 'Famidasdasdlasdlaspdlaspdlasp2948203948',
# 'Familygsdglksflg2849023840923;fksdkgsd234234234238409238490238', 'Family_Hist_4',
# 'Family_Hist_5', 9.19, 'Medical_History_2', 'Medical_History_3', 'Medical_History_4',
# 13, 'Medical_History_6', 'Medical_History_7', 111, 'Medical_History_9',
# 123.7773, 'Medical_History_41', 55823428882482374824828472348, 'Product_Info_3', 1111111111111111111111,
# 'Product_Info_5', ]
# clear_data = []
# i = 0
# while i < len(data):
# obj = data[i]
# if isinstance(obj, float):
# if obj % 1 >= 0.8 or obj % 1 <= 0.2:
# clear_data.append(round(obj))
# else:
# clear_data.append(int(obj))
#
# elif isinstance(obj, int):
#
# if len(str(obj)) <= 20:
# clear_data.append(str(obj))
# #i -= 1
#
# elif isinstance(obj, str):
# if len(obj) < 50:
# clear_data.append(obj)
# #i -= 1
# i += 1
# print(clear_data)
| 44.731707
| 121
| 0.654308
| 182
| 1,834
| 6.285714
| 0.395604
| 0.122378
| 0.052448
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.302228
| 0.217012
| 1,834
| 40
| 122
| 45.85
| 0.494429
| 0.955289
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
e832b342d7e5ac15fbacd341d0e82bf4e3363f9e
| 791
|
py
|
Python
|
day2/solution.py
|
kmacpherson/advent-2019
|
907aac17dce428fe8db8f88682571f921b65dc62
|
[
"MIT"
] | null | null | null |
day2/solution.py
|
kmacpherson/advent-2019
|
907aac17dce428fe8db8f88682571f921b65dc62
|
[
"MIT"
] | null | null | null |
day2/solution.py
|
kmacpherson/advent-2019
|
907aac17dce428fe8db8f88682571f921b65dc62
|
[
"MIT"
] | null | null | null |
file = open('input.txt', 'r')
inputCodes = file.readline().split(',')
def processCode(codeIndex):
result = 0
if (inputCodes[codeIndex] == '1'):
result = int(inputCodes[int(inputCodes[codeIndex+1])]) + int(inputCodes[int(inputCodes[codeIndex+2])])
inputCodes[int(inputCodes[codeIndex+3])] = str(result)
processCode(codeIndex+4)
elif (inputCodes[codeIndex] == '2'):
result = int(inputCodes[int(inputCodes[codeIndex+1])]) * int(inputCodes[int(inputCodes[codeIndex+2])])
inputCodes[int(inputCodes[codeIndex+3])] = str(result)
processCode(codeIndex+4)
elif (inputCodes[codeIndex] == '99'):
print(inputCodes[0])
else:
print(f"Error invalid code at position {codeIndex}: {inputCodes[codeIndex]}")
processCode(0)
| 39.55
| 110
| 0.656131
| 88
| 791
| 5.897727
| 0.340909
| 0.366089
| 0.265896
| 0.369942
| 0.631985
| 0.631985
| 0.631985
| 0.631985
| 0.631985
| 0.631985
| 0
| 0.022971
| 0.174463
| 791
| 20
| 111
| 39.55
| 0.771822
| 0
| 0
| 0.235294
| 0
| 0
| 0.103535
| 0.02904
| 0
| 0
| 0
| 0
| 0
| 1
| 0.058824
| false
| 0
| 0
| 0
| 0.058824
| 0.117647
| 0
| 0
| 0
| null | 1
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
1c237c8108707a843172e4789e8bafa54ae6a274
| 40,601
|
py
|
Python
|
tutorials/tutorial_views.py
|
Nightfurex/MSS
|
51a1bc0d4ce759288b5f3a0a46e538aa0c1a8788
|
[
"Apache-2.0"
] | null | null | null |
tutorials/tutorial_views.py
|
Nightfurex/MSS
|
51a1bc0d4ce759288b5f3a0a46e538aa0c1a8788
|
[
"Apache-2.0"
] | null | null | null |
tutorials/tutorial_views.py
|
Nightfurex/MSS
|
51a1bc0d4ce759288b5f3a0a46e538aa0c1a8788
|
[
"Apache-2.0"
] | null | null | null |
"""
mss.tutorials.tutorial_views
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This python script generates an automatic demonstration of how to use the top view, side view, table view and
linear view section of Mission Support System in creating a operation and planning the flightrack.
This file is part of mss.
:copyright: Copyright 2021 Hrithik Kumar Verma
:copyright: Copyright 2021-2022 by the mss team, see AUTHORS.
:license: APACHE-2.0, see LICENSE for details.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import pyautogui as pag
import multiprocessing
import sys
from sys import platform
from pyscreeze import ImageNotFoundException
from tutorials import screenrecorder as sr
from mslib.msui import mss_pyui
def initial_ops():
"""
Executes the initial operations such as closing all opened windows and showing the desktop.
"""
pag.sleep(5)
if platform == "linux" or platform == "linux2":
pag.hotkey('winleft', 'd')
print("\n INFO : Automation is running on Linux system..\n")
elif platform == "darwin":
pag.hotkey('option', 'command', 'm')
print("\n INFO : Automation is running on Mac OS..\n")
elif platform == "win32":
pag.hotkey('win', 'd')
print("\n INFO : Automation is running on Windows OS..\n")
else:
pag.alert(text="Sorry, no support on this platform!", title="Platform Exception", button='OK')
print("\n INFO : We will be learning how to create a operation in MSS with all the views.\n")
def call_recorder():
"""
Calls the screen recorder class to start the recording of the automation.
"""
sr.main()
def call_mss():
"""
Calls the main MSS GUI window since operations are to be performed on it only.
"""
mss_pyui.main()
def automate_views():
"""
This is the main automating script of the MSS views tutorial which will cover all the views(topview, sideview,
tableview, linear view) in demonstrating how to create a operation. This will be recorded and savedto a file having
dateframe nomenclature with a .mp4 extension(codec).
"""
# Giving time for loading of the MSS GUI.
pag.sleep(5)
if platform == 'linux' or platform == 'linux2' or platform == 'darwin':
dir_path = 'pictures/tutorial_views/win/'
wms_path = 'pictures/tutorial_wms/linux/'
elif platform == 'win32':
dir_path = 'pictures/tutorial_views/win/'
wms_path = 'pictures/tutorial_wms/win/'
# Screen Resolutions
sc_width, sc_height = pag.size()[0] - 1, pag.size()[1] - 1
# Maximizing the window
try:
if platform == 'linux' or platform == 'linux2':
pag.hotkey('winleft', 'up')
elif platform == 'darwin':
pag.hotkey('ctrl', 'command', 'f')
elif platform == 'win32':
pag.hotkey('win', 'up')
except Exception:
print("\nException : Enable Shortcuts for your system or try again!")
pag.sleep(2)
pag.hotkey('ctrl', 'h')
pag.sleep(2)
# Shfting topview window to upper right corner
try:
x, y = pag.locateCenterOnScreen(f'{dir_path}add_waypoint.png')
pag.click(x, y - 56, interval=2)
if platform == 'win32' or platform == 'darwin':
pag.dragRel(525, -110, duration=2)
elif platform == 'linux' or platform == 'linux2':
pag.dragRel(910, -25, duration=2)
pag.move(None, 56)
add_tv_x, add_tv_y = pag.position()
pag.move(-486, -56, duration=1)
pag.click(interval=1)
if platform == 'win32' or platform == 'linux' or platform == 'linux2':
pag.hotkey('ctrl', 'v')
elif platform == 'darwin':
pag.hotkey('command', 'v')
pag.sleep(4)
# Shifting Sideview window to upper left corner.
try:
x1, y1 = pag.locateCenterOnScreen(f'{dir_path}add_waypoint.png')
if platform == 'win32' or platform == 'darwin':
pag.moveTo(x1, y1 - 56, duration=1)
pag.dragRel(-494, -177, duration=2)
elif platform == 'linux' or platform == 'linux2':
pag.moveTo(x1, y1 - 56, duration=1)
pag.dragRel(-50, -30, duration=2)
pag.sleep(2)
if platform == 'linux' or platform == 'linux2':
pag.keyDown('altleft')
# ToDo selection of views have to be done with ctrl f
# this selects the next window in the window manager on budgie
pag.press('tab')
pag.keyUp('tab')
pag.press('tab')
pag.keyUp('tab')
pag.keyUp('altleft')
elif platform == 'win32':
pag.keyDown('alt')
pag.press('tab')
pag.press('right')
pag.keyUp('alt')
elif platform == 'darwin':
pag.press('command', 'tab', 'right')
pag.sleep(1)
except (ImageNotFoundException, OSError, Exception):
print("Exception: \'Side View Window Header\' was not found on the screen")
except (ImageNotFoundException, OSError, Exception):
print("Exception: \'Topview Window Header\' was not found on the screen")
# Adding waypoints
if add_tv_x is not None and add_tv_y is not None:
pag.sleep(1)
pag.click(add_tv_x, add_tv_y, interval=2)
pag.move(-50, 150, duration=1)
pag.click(interval=2)
pag.sleep(1)
pag.move(65, 65, duration=1)
pag.click(interval=2)
pag.sleep(1)
pag.move(-150, 30, duration=1)
x1, y1 = pag.position()
pag.click(interval=2)
pag.sleep(1)
pag.move(200, 150, duration=1)
pag.click(interval=2)
x2, y2 = pag.position()
pag.sleep(1)
pag.move(100, -80, duration=1)
pag.click(interval=2)
pag.move(56, -63, duration=1)
pag.click(interval=2)
pag.sleep(3)
else:
print("Screen coordinates not available for add waypoints for topview")
# Locating Server Layer
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}layers.png', region=(int(sc_width / 2) - 100, 0, sc_width, sc_height))
pag.click(x, y, interval=2)
# Entering wms URL
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}wms_url.png', region=(int(sc_width / 2), 0,
sc_width, sc_height))
pag.click(x + 220, y, interval=2)
pag.hotkey('ctrl', 'a', interval=1)
pag.write('http://open-mss.org/', interval=0.25)
except (ImageNotFoundException, OSError, Exception):
print("\nException : Topviews' \'WMS URL\' editbox button/option not found on the screen.")
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}get_capabilities.png', region=(int(sc_width / 2), 0, sc_width,
sc_height))
pag.click(x, y, interval=2)
pag.sleep(4)
except (ImageNotFoundException, OSError, Exception):
print("\nException : Topviews' \'Get capabilities\' button/option not found on the screen.")
# Relocating Layerlist of topview
if platform == 'win32':
pag.move(-171, -390, duration=1)
pag.dragRel(10, 627, duration=2)
elif platform == 'linux' or platform == 'linux2' or platform == 'darwin':
pag.move(-171, -390, duration=1)
pag.dragRel(10, 675, duration=2) # To be decided
pag.sleep(1)
# Storing screen coordinates for List layer of top view
ll_tov_x, ll_tov_y = pag.position()
except (ImageNotFoundException, OSError, Exception):
print("\nException : Topviews WMS' \'Server\\Layers\' button/option not found on the screen.")
# Selecting some layers in topview layerlist
if platform == 'win32':
gap = 22
elif platform == 'linux' or platform == 'linux2' or platform == 'darwin':
gap = 16
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}divergence_layer.png', region=(int(sc_width / 2), 0, sc_width,
sc_height))
temp1, temp2 = x, y
pag.click(x, y, interval=2)
pag.sleep(3)
pag.move(None, gap, duration=1)
pag.click(interval=1)
pag.sleep(3)
pag.move(None, gap * 2, duration=1)
pag.click(interval=1)
pag.sleep(3)
pag.move(None, gap, duration=1)
pag.click(interval=1)
pag.sleep(3)
pag.move(None, -gap * 4, duration=1)
pag.click(interval=1)
pag.sleep(3)
except (ImageNotFoundException, OSError, Exception):
print("\nException : Topview's \'Divergence Layer\' option not found on the screen.")
# Setting different levels and valid time
if temp1 is not None and temp2 is not None:
pag.click(temp1, temp2 + (gap * 3), interval=2)
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}level.png', region=(int(sc_width / 2) - 100, 0, sc_width, sc_height))
pag.click(x + 200, y, interval=2)
pag.move(None, 140, duration=1)
pag.click(interval=1)
pag.sleep(4)
except (ImageNotFoundException, OSError, Exception):
print("\nException : Topview's \'Pressure level\' button/option not found on the screen.")
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}valid.png', region=(int(sc_width / 2) - 100, 0, sc_width, sc_height))
pag.click(x + 200, y, interval=1)
pag.move(None, 80, duration=1)
pag.click(interval=1)
pag.sleep(4)
except (ImageNotFoundException, OSError, Exception):
print("\nException : Topview's \'Valid till\' button/option not found on the screen.")
# Moving waypoints in Topview
try:
x, y = pag.locateCenterOnScreen(f'{dir_path}move_waypoint.png', region=(int(sc_width / 2) - 100, 0, sc_width,
sc_height))
if platform == 'win32' or platform == 'darwin':
pag.click(x, y, interval=2)
pag.moveTo(x2 + 4, y2 - 96, duration=1)
pag.click(interval=2)
pag.dragRel(100, 150, duration=1)
pag.moveTo(x1 + 46, y1 - 67, duration=1)
pag.dragRel(35, -50, duration=1)
x3, y3 = pag.position()
elif platform == 'linux' or platform == 'linux2':
pag.click(x, y, interval=2)
pag.moveTo(x2 + 5, y2 - 82, duration=1)
pag.click(interval=2)
pag.dragRel(100, 150, duration=1)
pag.moveTo(x1 + 35, y1 - 60, duration=1)
pag.dragRel(35, -50, duration=1)
x3, y3 = pag.position()
pag.sleep(1)
except ImageNotFoundException:
print("\n Exception : Move Waypoint button could not be located on the screen")
# Deleting waypoints
try:
x, y = pag.locateCenterOnScreen('pictures/remove_waypoint.PNG', region=(int(sc_width / 2) - 100, 0, sc_width,
sc_height))
pag.click(x, y, interval=2)
pag.moveTo(x3, y3, duration=1)
pag.click(duration=1)
if platform == 'win32':
pag.press('left')
pag.sleep(2)
if platform == 'linux' or platform == 'linux2' or platform == 'win32':
pag.press('enter', interval=1)
elif platform == 'darwin':
pag.press('return', interval=1)
pag.sleep(2)
except ImageNotFoundException:
print("\n Exception : Remove Waypoint button could not be located on the screen")
# Changing map to Global
try:
if platform == 'linux' or platform == 'linux2' or platform == 'darwin':
x, y = pag.locateCenterOnScreen('pictures/europe(cyl).PNG', region=(int(sc_width / 2) - 100, 0, sc_width,
sc_height))
pag.click(x, y, interval=2)
elif platform == 'win32':
x, y = pag.locateCenterOnScreen('pictures/europe(cyl)win.PNG', region=(int(sc_width / 2) - 100, 0, sc_width,
sc_height))
pag.click(x, y, interval=2)
pag.press('down', presses=2, interval=0.5)
if platform == 'linux' or platform == 'linux2' or platform == 'win32':
pag.press('enter', interval=1)
elif platform == 'darwin':
pag.press('return', interval=1)
pag.sleep(6)
except (ImageNotFoundException, TypeError, OSError, Exception):
print("\n Exception : Topview's Map change dropdown could not be located on the screen")
# Zooming into the map
try:
x, y = pag.locateCenterOnScreen(f'{dir_path}zoom.png', region=(int(sc_width / 2) - 100, 0, sc_width, sc_height))
pag.click(x, y, interval=2)
pag.move(155, 121, duration=1)
pag.click(duration=1)
pag.dragRel(260, 110, duration=2)
pag.sleep(4)
except ImageNotFoundException:
print("\n Exception : Topview's Zoom button could not be located on the screen")
# SideView Operations
# Opening web map service
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}selecttoopencontrol.png', region=(0, 0, int(sc_width / 2) - 100,
sc_height))
pag.click(x, y, interval=2)
pag.press('down', interval=1)
if platform == 'linux' or platform == 'linux2' or platform == 'win32':
pag.press('enter', interval=1)
elif platform == 'darwin':
pag.press('return', interval=1)
except (ImageNotFoundException, OSError, Exception):
print("\nException :\'SideView's select to open control\' button/option not found on the screen.")
# Locating Server Layer
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}layers.png', region=(0, 0, int(sc_width / 2) - 100, sc_height))
pag.click(x, y, interval=2)
# Entering wms URL
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}wms_url.png', region=(0, 0, int(sc_width / 2) - 100, sc_height))
pag.click(x + 220, y, interval=2)
pag.hotkey('ctrl', 'a', interval=1)
pag.write('http://open-mss.org/', interval=0.25)
except (ImageNotFoundException, OSError, Exception):
print("\nException : Sideviews' \'WMS URL\' editbox button/option not found on the screen.")
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}get_capabilities.png', region=(0, 0, int(sc_width / 2) - 100,
sc_height))
pag.click(x, y, interval=2)
pag.sleep(3)
except (ImageNotFoundException, OSError, Exception):
print("\nException : SideView's \'Get capabilities\' button/option not found on the screen.")
if platform == 'win32':
pag.move(-171, -390, duration=1)
pag.dragRel(10, 570, duration=2)
elif platform == 'linux' or platform == 'linux2' or platform == 'darwin':
pag.move(-171, -390, duration=1)
pag.dragRel(10, 600, duration=2)
# Storing screen coordinates for List layer of side view
ll_sv_x, ll_sv_y = pag.position()
pag.sleep(1)
except (ImageNotFoundException, OSError, Exception):
print("\nException : Sideviews WMS' \'Server\\Layers\' button/option not found on the screen.")
# Selecting some layers in Sideview WMS
if platform == 'win32':
gap = 22
elif platform == 'linux' or platform == 'linux2' or platform == 'darwin':
gap = 16
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}cloudcover.png', region=(0, 0, int(sc_width / 2) - 100, sc_height))
temp1, temp2 = x, y
pag.click(x, y, interval=2)
pag.sleep(3)
pag.move(None, gap, duration=1)
pag.click(interval=1)
pag.sleep(3)
pag.move(None, gap * 2, duration=1)
pag.click(interval=1)
pag.sleep(3)
pag.move(None, gap, duration=1)
pag.click(interval=1)
pag.sleep(3)
pag.move(None, -gap * 4, duration=1)
pag.click(interval=1)
pag.sleep(3)
except (ImageNotFoundException, OSError, Exception):
print("\nException : Sideview's \'Cloud Cover Layer\' option not found on the screen.")
# Setting different levels and valid time
if temp1 is not None and temp2 is not None:
pag.click(temp1, temp2 + (gap * 4), interval=2)
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}valid.png', region=(0, 0, int(sc_width / 2) - 100, sc_height))
pag.click(x + 200, y, interval=1)
pag.move(None, 80, duration=1)
pag.click(interval=1)
pag.sleep(4)
except (ImageNotFoundException, OSError, Exception):
print("\nException : Sideview's \'Valid till\' button/option not found on the screen.")
# Move waypoints in SideView
try:
x, y = pag.locateCenterOnScreen(f'{dir_path}move_waypoint.png', region=(0, 0, int(sc_width / 2) - 100, sc_height))
pag.click(x, y, interval=2)
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}options.png', region=(0, 0, int(sc_width / 2) - 100, sc_height))
if platform == 'win32' or platform == 'darwin':
pag.click(x + 76, y - 80, duration=1)
pag.dragRel(-1, -139, duration=2)
pag.click(x + 508, y - 80, duration=1)
pag.dragRel(None, -80, duration=2)
pag.click(x + 684, y - 80, duration=1)
pag.dragRel(None, -150, duration=2)
elif platform == 'linux' or platform == 'linux2':
pag.click(x + 90, y - 80, duration=1)
pag.dragRel(-1, -139, duration=2)
pag.click(x + 508, y - 80, duration=1)
pag.dragRel(None, -110, duration=2)
pag.click(x + 695, y - 80, duration=1)
pag.dragRel(None, -150, duration=2)
pag.sleep(2)
except (ImageNotFoundException, OSError, TypeError, Exception):
print("\nException : Sideview's waypoints location (Options button) not found on the screen.")
except ImageNotFoundException:
print("\n Exception :Sideview's Move Waypoint button could not be located on the screen")
# Adding waypoints in SideView
try:
x, y = pag.locateCenterOnScreen(f'{dir_path}add_waypoint.png', region=(0, 0, int(sc_width / 2) - 100, sc_height))
pag.click(x, y, duration=1)
pag.click(x + 239, y + 186, duration=1)
pag.sleep(3)
pag.click(x + 383, y + 93, duration=1)
pag.sleep(3)
pag.click(x + 450, y + 140, duration=1)
pag.sleep(4)
pag.click(x, y, duration=1)
pag.sleep(1)
except (ImageNotFoundException, OSError, TypeError, Exception):
print("\nException : Sideview's add waypoint button not found on the screen.")
# Closing list layer of sideview and topview to make screen a little less congested.
pag.click(ll_sv_x, ll_sv_y, duration=2)
if platform == 'linux' or platform == 'linux2':
pag.hotkey('altleft', 'f4')
elif platform == 'win32':
pag.hotkey('alt', 'f4')
elif platform == 'darwin':
pag.hotkey('command', 'w')
pag.sleep(1)
pag.click(ll_tov_x, ll_tov_y, duration=2)
if platform == 'linux' or platform == 'linux2':
pag.hotkey('altleft', 'f4')
elif platform == 'win32':
pag.hotkey('alt', 'f4')
elif platform == 'darwin':
pag.hotkey('command', 'w')
# Table View
# Opening Table View
pag.move(-80, 120, duration=1)
# pag.moveTo(1800, 1000, duration=1)
pag.click(duration=1)
pag.sleep(1)
pag.hotkey('ctrl', 't')
pag.sleep(2)
# Relocating Tableview and performing operations on table view
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}selecttoopencontrol.png')
pag.moveTo(x, y - 462, duration=1)
if platform == 'linux' or platform == 'linux2':
pag.dragRel(250, 887, duration=3)
elif platform == 'win32' or platform == 'darwin':
pag.dragRel(None, 487, duration=2)
pag.sleep(2)
if platform == 'linux' or platform == 'linux2':
pag.keyDown('altleft')
pag.press('tab')
pag.press('right')
pag.keyUp('altleft')
pag.sleep(1)
pag.keyDown('altleft')
pag.press('tab')
pag.press('right', presses=2) # This needs to be checked in Linux
pag.keyUp('altleft')
elif platform == 'win32':
pag.keyDown('alt')
pag.press('tab')
pag.press('right')
pag.keyUp('alt')
pag.sleep(1)
pag.keyDown('alt')
pag.press('tab')
pag.press('right', presses=2)
pag.keyUp('alt')
elif platform == 'darwin':
pag.keyDown('command')
pag.press('tab')
pag.press('right')
pag.keyUp('command')
pag.sleep(1)
pag.keyDown('command')
pag.press('tab')
pag.press('right', presses=2)
pag.keyUp('command')
pag.sleep(1)
if platform == 'win32' or platform == 'darwin':
pag.dragRel(None, -300, duration=2)
tv_x, tv_y = pag.position()
elif platform == 'linux' or platform == 'linux2':
pag.dragRel(None, -450, duration=2)
tv_x, tv_y = pag.position()
# Locating the selecttoopencontrol for tableview to perform operations
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}selecttoopencontrol.png',
region=(0, int(sc_height * 0.75), sc_width, int(sc_height * 0.25)))
# Changing names of certain waypoints to predefined names
pag.click(x, y - 190, duration=1) if platform == 'win32' else pag.click(x, y - 325, duration=1)
pag.sleep(1)
pag.doubleClick(duration=1)
pag.sleep(2)
pag.move(88, None, duration=1) if platform == 'win32' else pag.move(78, None, duration=1)
pag.sleep(1)
pag.click(duration=1)
pag.press('down', presses=5, interval=0.2)
pag.sleep(1)
pag.press('return') if platform == 'darwin' else pag.press('enter')
pag.sleep(1)
# Giving user defined names to waypoints
pag.click(x, y - 160, duration=1) if platform == 'win32' else pag.click(x, y - 294, duration=1)
pag.sleep(1)
pag.doubleClick(duration=1)
pag.sleep(1.5)
if platform == 'linux' or platform == 'linux2' or platform == 'win32':
pag.hotkey('ctrl', 'a')
elif platform == 'darwin':
pag.hotkey('command', 'a')
pag.sleep(1)
pag.write('Location A', interval=0.1)
pag.sleep(1)
pag.press('return') if platform == 'darwin' else pag.press('enter')
pag.sleep(2)
pag.click(x, y - 127, duration=1) if platform == 'win32' else pag.click(x, y - 263, duration=1)
pag.sleep(1)
pag.doubleClick(duration=1)
pag.sleep(2)
if platform == 'linux' or platform == 'linux2' or platform == 'win32':
pag.hotkey('ctrl', 'a')
elif platform == 'darwin':
pag.hotkey('command', 'a')
pag.sleep(1)
pag.write('Stop Point', interval=0.1)
pag.sleep(1)
pag.press('return') if platform == 'darwin' else pag.press('enter')
pag.sleep(2)
# Changing Length of Flight Level
pag.click(x + 266, y - 95, duration=1) if platform == 'win32' else pag.click(x + 236, y - 263, duration=1)
pag.sleep(1)
pag.doubleClick(duration=1)
pag.sleep(1)
pag.write('319', interval=0.2)
pag.sleep(1)
pag.press('return') if platform == 'darwin' else pag.press('enter')
pag.sleep(2)
# Changing hPa level of waypoints
pag.click(x + 344, y - 65, duration=1) if platform == 'win32' else pag.click(x + 367, y - 232, duration=1)
pag.sleep(1)
pag.doubleClick(duration=1)
pag.sleep(1)
pag.write('250', interval=0.2)
pag.sleep(1)
pag.press('return') if platform == 'darwin' else pag.press('enter')
pag.sleep(2)
# Changing longitude of 'Location A' waypoint
pag.click(x + 194, y - 160, duration=1) if platform == 'win32' else pag.click(x + 165, y - 294, duration=1)
pag.sleep(1)
pag.doubleClick(duration=1)
pag.sleep(1)
pag.write('12.36', interval=0.2)
pag.sleep(1)
pag.press('return') if platform == 'darwin' else pag.press('enter')
pag.sleep(2)
# Cloning the row of waypoint
try:
x1, y1 = pag.locateCenterOnScreen(f'{wms_path}clone.png')
pag.click(x + 15, y - 130, duration=1) if platform == 'win32' else pag.click(x + 15, y - 263,
duration=1)
pag.sleep(1)
pag.click(x1, y1, duration=1)
pag.sleep(2)
pag.click(x + 15, y - 100, duration=1) if platform == 'win32' else pag.click(x + 15, y - 232,
duration=1)
pag.sleep(1)
pag.doubleClick(x + 130, y - 100, duration=1) if platform == 'win32' else pag.click(x + 117, y - 232,
duration=1)
pag.sleep(1)
pag.write('65.26', interval=0.2)
pag.sleep(1)
pag.press('return') if platform == 'darwin' else pag.press('enter')
pag.sleep(2)
pag.move(580, None, duration=1) if platform == 'win32' else pag.move(459, None, duration=1)
pag.doubleClick(duration=1)
pag.sleep(2)
pag.write('This is a reference comment', interval=0.2)
pag.sleep(1)
pag.press('return') if platform == 'darwin' else pag.press('enter')
pag.sleep(2)
except (ImageNotFoundException, OSError, TypeError, Exception):
print("\nException : Tableview's CLONE button not found on the screen.")
# Inserting a new row of waypoints
try:
x1, y1 = pag.locateCenterOnScreen(f'{wms_path}insert.png')
pag.click(x + 130, y - 160, duration=1) if platform == 'win32' else pag.click(x + 117, y - 294,
duration=1)
pag.sleep(2)
pag.click(x1, y1, duration=1)
pag.sleep(2)
pag.click(x + 130, y - 125, duration=1) if platform == 'win32' else pag.click(x + 117, y - 263,
duration=1)
pag.sleep(1)
pag.doubleClick(duration=1)
pag.sleep(1)
pag.write('58', interval=0.2)
pag.sleep(0.5)
pag.press('return') if platform == 'darwin' else pag.press('enter')
pag.sleep(2)
pag.move(63, None, duration=1) if platform == 'win32' else pag.move(48, None, duration=1)
pag.doubleClick(duration=1)
pag.sleep(1)
pag.write('-1.64', interval=0.2)
pag.sleep(1)
pag.press('return') if platform == 'darwin' else pag.press('enter')
pag.sleep(2)
pag.move(108, None, duration=1) if platform == 'win32' else pag.move(71, None, duration=1)
pag.doubleClick(duration=1)
pag.sleep(1)
pag.write('360', interval=0.2)
pag.sleep(0.5)
pag.press('return') if platform == 'darwin' else pag.press('enter')
pag.sleep(2)
except (ImageNotFoundException, OSError, TypeError, Exception):
print("\nException : Tableview's INSERT button not found on the screen.")
# Delete Selected waypoints row
try:
x1, y1 = pag.locateCenterOnScreen(f'{wms_path}deleteselected.png')
pag.click(x + 150, y - 70, duration=1) if platform == 'win32' else pag.click(x + 150, y - 201,
duration=1)
pag.sleep(2)
pag.click(x1, y1, duration=1)
pag.press('left')
pag.sleep(1)
pag.press('return') if platform == 'darwin' else pag.press('enter')
pag.sleep(2)
except (ImageNotFoundException, OSError, TypeError, Exception):
print("\nException : Tableview's DELETE SELECTED button not found on the screen.")
# Reverse waypoints' order
try:
x1, y1 = pag.locateCenterOnScreen(f'{wms_path}reverse.png')
for _ in range(3):
pag.click(x1, y1, duration=1)
pag.sleep(1.5)
except (ImageNotFoundException, OSError, TypeError, Exception):
print("\nException : Tableview's REVERSE button not found on the screen.")
except (ImageNotFoundException, OSError, TypeError, Exception):
print("\nException : Tableview's selecttoopencontrol button (bottom part) not found on the screen.")
except (ImageNotFoundException, OSError, TypeError, Exception):
print("\nException : TableView's Select to open Control option (at the top) not found on the screen.")
# Closing Table View to make space on screen
if tv_x is not None and tv_y is not None:
pag.click(tv_x, tv_y, duration=1)
if platform == 'linux' or platform == 'linux2':
pag.hotkey('altleft', 'f4')
pag.press('left')
pag.sleep(1)
pag.press('enter')
elif platform == 'win32':
pag.hotkey('alt', 'f4')
pag.press('left')
pag.sleep(1)
pag.press('enter')
elif platform == 'darwin':
pag.hotkey('command', 'w')
pag.press('left')
pag.sleep(1)
pag.press('return')
# Opening Linear View
pag.sleep(1)
pag.move(None, 400, duration=1)
pag.click(interval=1)
pag.hotkey('ctrl', 'l')
pag.sleep(4)
# Relocating Linear View
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}selecttoopencontrol.png')
pag.moveTo(x, y - 587, duration=1)
if platform == 'linux' or platform == 'linux2':
pag.dragRel(1053, 860, duration=3)
elif platform == 'win32' or platform == 'darwin':
pag.dragRel(553, 660, duration=2)
pag.sleep(2)
if platform == 'linux' or platform == 'linux2':
pag.keyDown('altleft')
pag.press('tab')
pag.press('right')
pag.keyUp('altleft')
pag.sleep(1)
pag.keyDown('altleft')
pag.press('tab')
pag.press('right', presses=2)
pag.keyUp('altleft')
elif platform == 'win32':
pag.keyDown('alt')
pag.press('tab')
pag.press('right')
pag.keyUp('alt')
pag.sleep(1)
pag.keyDown('alt')
pag.press('tab')
pag.press('right', presses=2, interval=1)
pag.keyUp('alt')
elif platform == 'darwin':
pag.keyDown('command')
pag.press('tab')
pag.press('right')
pag.keyUp('command')
pag.sleep(1)
pag.keyDown('command')
pag.press('tab')
pag.press('right', presses=2, interval=1)
pag.keyUp('command')
pag.sleep(1)
pag.dragRel(-102, -470, duration=2) if platform == 'win32' else pag.dragRel(-90, -500, duration=2)
lv_x, lv_y = pag.position()
except (ImageNotFoundException, OSError, TypeError, Exception):
print("\nException : Linearview's window header not found on the screen.")
# Opening Linear WMS
try:
if platform == 'linux' or platform == 'linux2' or platform == 'darwin':
x, y = pag.locateCenterOnScreen(f'{wms_path}selecttoopencontrol.png',
region=(0, int(sc_height * 0.85), sc_width, int(sc_height * 0.15)))
elif platform == 'win32':
x, y = pag.locateCenterOnScreen(f'{wms_path}selecttoopencontrol.png',
region=(0, int(sc_height * 0.75), sc_width, int(sc_height * 0.25)))
pag.click(x, y, duration=1)
pag.press('down')
pag.press('return') if platform == 'darwin' else pag.press('enter')
pag.sleep(1)
# Locating Server Layer
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}layers.png', region=(0, int(sc_height * 0.75), sc_width,
int(sc_height * 0.25)))
pag.click(x, y, interval=2)
# Entering wms URL
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}wms_url.png', region=(0, int(sc_height * 0.65), sc_width,
int(sc_height * 0.35)))
pag.click(x + 220, y, interval=2)
pag.hotkey('ctrl', 'a', interval=1)
pag.write('http://open-mss.org/', interval=0.25)
except (ImageNotFoundException, OSError, Exception):
print("\nException : Linearviews' \'WMS URL\' editbox button/option not found on the screen.")
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}get_capabilities.png',
region=(0, int(sc_height * 0.65), sc_width, int(sc_height * 0.35)))
pag.click(x, y, interval=2)
pag.sleep(3)
except (ImageNotFoundException, OSError, Exception):
print("\nException : LinearView's \'Get capabilities\' button/option not found on the screen.")
if platform == 'win32':
pag.move(-171, -390, duration=1)
pag.dragRel(-867, 135, duration=2)
elif platform == 'linux' or platform == 'linux2' or platform == 'darwin':
pag.move(-171, -390, duration=1)
pag.dragRel(-900, 245, duration=2)
# Storing screen coordinates for List layer of side view
ll_lv_x, ll_lv_y = pag.position()
pag.sleep(1)
except (ImageNotFoundException, OSError, Exception):
print("\nException : Linearview's WMS \'Server\\Layers\' button/option not found on the screen.")
except (ImageNotFoundException, OSError, TypeError, Exception):
print("\nException : Linearview's selecttoopencontrol not found on the screen.")
# Selecting Some Layers in Linear wms section
if platform == 'win32':
gap = 22
elif platform == 'linux' or platform == 'linux2' or platform == 'darwin':
gap = 16
try:
x, y = pag.locateCenterOnScreen(f'{wms_path}horizontalwind.png', region=(0, int(sc_height / 2), sc_width,
int(sc_height / 2)))
temp1, temp2 = x, y
pag.click(x, y, interval=2)
pag.sleep(1)
pag.move(None, gap, duration=1)
pag.click(interval=1)
pag.sleep(1)
pag.move(None, gap * 2, duration=1)
pag.click(interval=1)
pag.sleep(1)
pag.move(None, gap, duration=1)
pag.click(interval=1)
pag.sleep(1)
pag.move(None, -gap * 4, duration=1)
pag.click(interval=1)
pag.sleep(1)
except (ImageNotFoundException, OSError, Exception):
print("\nException : Linearview's \'Horizontal Wind Layer\' option not found on the screen.")
# Add waypoints after anaylzing the linear section wms
try:
x, y = pag.locateCenterOnScreen(f'{dir_path}add_waypoint.png', region=(0, 0, int(sc_width / 2), sc_height))
pag.click(x, y, interval=2)
pag.sleep(1)
pag.click(x + 30, y + 50, duration=1)
pag.sleep(2)
except (ImageNotFoundException, OSError, Exception):
print("\n Exception :Sideview's Add Waypoint button could not be located on the screen")
# CLosing Linear View Layer List
if temp1 is not None and temp2 is not None:
pag.click(temp1, temp2 + (gap * 4), duration=2)
pag.sleep(1)
if platform == 'linux' or platform == 'linux2':
pag.hotkey('altleft', 'f4')
elif platform == 'win32':
pag.hotkey('alt', 'f4')
elif platform == 'darwin':
pag.hotkey('command', 'w')
pag.sleep(1)
# Clicking on Linear View Window Head
if lv_x is not None and lv_y is not None:
pag.click(lv_x, lv_y, duration=1)
print("\nAutomation is over for this tutorial. Watch next tutorial for other functions.")
# Close Everything!
try:
if platform == 'linux' or platform == 'linux2':
for _ in range(4):
pag.hotkey('altleft', 'f4')
pag.sleep(1)
pag.press('left')
pag.sleep(1)
pag.press('enter')
pag.sleep(1)
pag.keyDown('altleft')
pag.press('tab')
pag.press('left')
pag.keyUp('altleft')
pag.sleep(1)
pag.press('q')
if platform == 'win32':
for _ in range(4):
pag.hotkey('alt', 'f4')
pag.sleep(1)
pag.press('left')
pag.sleep(1)
pag.press('enter')
pag.sleep(1)
pag.hotkey('alt', 'tab')
pag.sleep(1)
pag.press('q')
elif platform == 'darwin':
for _ in range(4):
pag.hotkey('command', 'w')
pag.sleep(1)
pag.press('left')
pag.sleep(1)
pag.press('return')
pag.sleep(1)
pag.hotkey('command', 'tab')
pag.sleep(1)
pag.press('q')
except Exception:
print("Cannot automate : Enable Shortcuts for your system or try again")
# pag.press('q') # In some cases, recording windows does not closes. So it needs to ne there.
def main():
"""
This function runs the above functions as different processes at the same time and can be
controlled from here. (This is the main process.)
"""
p1 = multiprocessing.Process(target=call_mss)
p2 = multiprocessing.Process(target=automate_views)
p3 = multiprocessing.Process(target=call_recorder)
print("\nINFO : Starting Automation.....\n")
p3.start()
pag.sleep(5)
initial_ops()
p1.start()
p2.start()
p2.join()
p1.join()
p3.join()
print("\n\nINFO : Automation Completes Successfully!")
sys.exit()
if __name__ == '__main__':
main()
| 43.423529
| 122
| 0.545331
| 4,982
| 40,601
| 4.404055
| 0.103974
| 0.032451
| 0.047035
| 0.035003
| 0.788706
| 0.756028
| 0.720432
| 0.683788
| 0.633927
| 0.5662
| 0
| 0.046922
| 0.328637
| 40,601
| 934
| 123
| 43.470021
| 0.758016
| 0.089505
| 0
| 0.702842
| 1
| 0.003876
| 0.16668
| 0.023131
| 0
| 0
| 0
| 0.001071
| 0
| 1
| 0.00646
| false
| 0
| 0.009044
| 0
| 0.015504
| 0.056848
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
1c311b580482ffa462e622f3c9d59ce48f1417ba
| 21
|
py
|
Python
|
song/__init__.py
|
louisgv/song-cli
|
10186b26f66c2f07e3cf1a3cd7b5212610c33afb
|
[
"MIT"
] | 70
|
2017-05-17T15:11:27.000Z
|
2021-01-10T01:09:06.000Z
|
song/__init__.py
|
louisgv/song-cli
|
10186b26f66c2f07e3cf1a3cd7b5212610c33afb
|
[
"MIT"
] | 9
|
2017-05-12T17:29:46.000Z
|
2018-03-16T19:21:50.000Z
|
song/__init__.py
|
louisgv/song-cli
|
10186b26f66c2f07e3cf1a3cd7b5212610c33afb
|
[
"MIT"
] | 17
|
2017-05-28T20:27:35.000Z
|
2021-07-12T03:41:25.000Z
|
__version__ = '2.9.1'
| 21
| 21
| 0.666667
| 4
| 21
| 2.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.157895
| 0.095238
| 21
| 1
| 21
| 21
| 0.368421
| 0
| 0
| 0
| 0
| 0
| 0.227273
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
1c348b2a617346f4892a06a93923aa29bbc60222
| 121
|
py
|
Python
|
app/multiplication.py
|
magicalcarpet/python_modules_and_packages
|
663a957674c41d0dc33e3f6ca7eefe4c808606b4
|
[
"MIT"
] | null | null | null |
app/multiplication.py
|
magicalcarpet/python_modules_and_packages
|
663a957674c41d0dc33e3f6ca7eefe4c808606b4
|
[
"MIT"
] | null | null | null |
app/multiplication.py
|
magicalcarpet/python_modules_and_packages
|
663a957674c41d0dc33e3f6ca7eefe4c808606b4
|
[
"MIT"
] | null | null | null |
def multiply(x, y):
'''
Multiply two numbers x and y
'''
print('multiplying x: {} * y: {}'.format(x, y))
| 20.166667
| 51
| 0.512397
| 17
| 121
| 3.647059
| 0.588235
| 0.096774
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.280992
| 121
| 5
| 52
| 24.2
| 0.712644
| 0.231405
| 0
| 0
| 0
| 0
| 0.324675
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.5
| false
| 0
| 0
| 0
| 0.5
| 0.5
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
1c3c09ff7db1d4fedc0b924ff9e82237138e432c
| 139
|
py
|
Python
|
termux/termuxapi.py
|
gornostay25/other
|
eb75606f56af6472fb65ed85db06b699b6dbce7e
|
[
"MIT"
] | null | null | null |
termux/termuxapi.py
|
gornostay25/other
|
eb75606f56af6472fb65ed85db06b699b6dbce7e
|
[
"MIT"
] | null | null | null |
termux/termuxapi.py
|
gornostay25/other
|
eb75606f56af6472fb65ed85db06b699b6dbce7e
|
[
"MIT"
] | null | null | null |
proc = subprocess.Popen(["termux-dialog -t test"], stdout=subprocess.PIPE, shell=True) \n a = proc.stdout \n a = a.read().strip().decode()
| 69.5
| 138
| 0.683453
| 22
| 139
| 4.318182
| 0.727273
| 0.042105
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.107914
| 139
| 1
| 139
| 139
| 0.766129
| 0
| 0
| 0
| 0
| 0
| 0.151079
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
1c464563ae1c020a956ead49bce39b9e88737950
| 223
|
py
|
Python
|
cannes_accomodation/tests/test_accomodation.py
|
Xogiga/CPOA_INEC_SAVIGNY_VALADE
|
f33a9e9448f011bcc56abc0c2270bf0c3d9ae43a
|
[
"MIT"
] | null | null | null |
cannes_accomodation/tests/test_accomodation.py
|
Xogiga/CPOA_INEC_SAVIGNY_VALADE
|
f33a9e9448f011bcc56abc0c2270bf0c3d9ae43a
|
[
"MIT"
] | null | null | null |
cannes_accomodation/tests/test_accomodation.py
|
Xogiga/CPOA_INEC_SAVIGNY_VALADE
|
f33a9e9448f011bcc56abc0c2270bf0c3d9ae43a
|
[
"MIT"
] | null | null | null |
class TestAccomodation:
def test_list_accomodation(self, client):
response = client.get('/accomodation')
assert response.status_code == 200
def test_update_accomodation(client):
pass
| 27.875
| 47
| 0.672646
| 23
| 223
| 6.304348
| 0.695652
| 0.096552
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.017857
| 0.246637
| 223
| 7
| 48
| 31.857143
| 0.845238
| 0
| 0
| 0
| 0
| 0
| 0.060185
| 0
| 0
| 0
| 0
| 0
| 0.166667
| 1
| 0.333333
| false
| 0.166667
| 0
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
1c572ec593a93c54319069fbc18773c3c6852346
| 1,249
|
py
|
Python
|
azure-iot-device/azure/iot/device/common/transport_exceptions.py
|
dt-boringtao/azure-iot-sdk-python
|
35a09679bdf4d7a727391b265a8f1fbb99a30c45
|
[
"MIT"
] | null | null | null |
azure-iot-device/azure/iot/device/common/transport_exceptions.py
|
dt-boringtao/azure-iot-sdk-python
|
35a09679bdf4d7a727391b265a8f1fbb99a30c45
|
[
"MIT"
] | null | null | null |
azure-iot-device/azure/iot/device/common/transport_exceptions.py
|
dt-boringtao/azure-iot-sdk-python
|
35a09679bdf4d7a727391b265a8f1fbb99a30c45
|
[
"MIT"
] | null | null | null |
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
"""This module defines errors that may be raised from a transport"""
class ConnectionFailedError(Exception):
"""
Connection failed to be established
"""
pass
class ConnectionDroppedError(Exception):
"""
Previously established connection was dropped
"""
pass
class NoConnectionError(Exception):
"""
There is no connection
"""
class UnauthorizedError(Exception):
"""
Authorization was rejected
"""
pass
class ProtocolClientError(Exception):
"""
Error returned from protocol client library
"""
pass
class TlsExchangeAuthError(Exception):
"""
Error returned when transport layer exchanges
result in a SSLCertVerification error.
"""
pass
class ProtocolProxyError(Exception):
"""
All proxy-related errors.
TODO : Not sure what to name it here. There is a class called Proxy Error already in Pysocks
"""
pass
| 19.825397
| 96
| 0.60048
| 116
| 1,249
| 6.465517
| 0.637931
| 0.06
| 0.058667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.21217
| 1,249
| 62
| 97
| 20.145161
| 0.762195
| 0.595677
| 0
| 0.461538
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.016129
| 0
| 1
| 0
| true
| 0.461538
| 0
| 0
| 0.538462
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 1
| 0
|
0
| 4
|
1c5e3786754fa5e44c0044f6f1959d13e1f1dde4
| 246
|
py
|
Python
|
hubconf.py
|
moabitcoin/video-resnet
|
fc749e2ee354c3e4ddbb144cf511bb868b008f61
|
[
"MIT"
] | 252
|
2019-09-27T17:10:18.000Z
|
2022-03-31T05:43:55.000Z
|
hubconf.py
|
moabitcoin/video-resnet
|
fc749e2ee354c3e4ddbb144cf511bb868b008f61
|
[
"MIT"
] | 36
|
2019-09-27T17:30:45.000Z
|
2021-12-09T08:13:41.000Z
|
hubconf.py
|
moabitcoin/video-resnet
|
fc749e2ee354c3e4ddbb144cf511bb868b008f61
|
[
"MIT"
] | 31
|
2019-10-01T00:47:43.000Z
|
2022-01-19T08:50:52.000Z
|
dependencies = ["torch", "torchvision"]
from ig65m.models import r2plus1d_34_8_ig65m, \
r2plus1d_34_32_ig65m, \
r2plus1d_34_8_kinetics, \
r2plus1d_34_32_kinetics
| 35.142857
| 51
| 0.54065
| 23
| 246
| 5.26087
| 0.521739
| 0.330579
| 0.181818
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.189189
| 0.398374
| 246
| 6
| 52
| 41
| 0.628378
| 0
| 0
| 0
| 0
| 0
| 0.065041
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.2
| 0
| 0.2
| 0
| 1
| 0
| 0
| null | 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
1c668dd4596d77ee70c8382c9d05ec30c15ba221
| 141
|
py
|
Python
|
live_feed/run.py
|
xgt001/infinite_feed
|
44d72b5a8118f8549bda1d5eb3815d15e60731d5
|
[
"Apache-2.0"
] | 1
|
2015-12-17T08:53:10.000Z
|
2015-12-17T08:53:10.000Z
|
live_feed/run.py
|
xgt001/infinite_feed
|
44d72b5a8118f8549bda1d5eb3815d15e60731d5
|
[
"Apache-2.0"
] | 2
|
2016-01-28T18:09:55.000Z
|
2016-01-28T18:10:44.000Z
|
live_feed/run.py
|
xgt001/infinite_feed
|
44d72b5a8118f8549bda1d5eb3815d15e60731d5
|
[
"Apache-2.0"
] | null | null | null |
# Run a test server.
from facebook import app
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8080, debug=True, threaded=True)
| 20.142857
| 65
| 0.680851
| 24
| 141
| 3.666667
| 0.75
| 0.068182
| 0.068182
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.067797
| 0.163121
| 141
| 6
| 66
| 23.5
| 0.677966
| 0.12766
| 0
| 0
| 0
| 0
| 0.125
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.333333
| 0
| 0.333333
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
1c8c33fddc98d6cc75ddcbf9f997af5d0e8bce31
| 184
|
py
|
Python
|
examples/example.py
|
madamak/how-to-opensource
|
71c05d0c24ba7a8ecbef5360f64858475e99d27d
|
[
"BSD-3-Clause"
] | 6
|
2021-05-28T12:13:54.000Z
|
2022-01-15T09:58:25.000Z
|
examples/example.py
|
madamak/how-to-opensource
|
71c05d0c24ba7a8ecbef5360f64858475e99d27d
|
[
"BSD-3-Clause"
] | 1
|
2021-06-18T07:47:02.000Z
|
2021-06-18T07:47:02.000Z
|
examples/example.py
|
madamak/how-to-opensource
|
71c05d0c24ba7a8ecbef5360f64858475e99d27d
|
[
"BSD-3-Clause"
] | 8
|
2021-06-11T09:06:39.000Z
|
2022-01-15T12:52:55.000Z
|
"""
===========
Toy Example
===========
L'exemple le plus simple que l'on puisse imaginer.
"""
from how_to_opensource import add_two_vectors
add_two_vectors([12.5, 26.1], [7.5, 3.9])
| 18.4
| 50
| 0.63587
| 31
| 184
| 3.580645
| 0.83871
| 0.108108
| 0.234234
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.062112
| 0.125
| 184
| 9
| 51
| 20.444444
| 0.627329
| 0.467391
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.5
| 0
| 0.5
| 0
| 0
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
98c7f1bff8df635557d526c9f1136b079fc034bc
| 126
|
py
|
Python
|
application.py
|
ahtesham11/flask-sentimental-deploy
|
a4ebb1214e4cb8aa85f99960739ebf1e49a74adc
|
[
"MIT"
] | 1
|
2021-01-03T11:30:35.000Z
|
2021-01-03T11:30:35.000Z
|
application.py
|
ahtesham11/flask-sentimental-deploy
|
a4ebb1214e4cb8aa85f99960739ebf1e49a74adc
|
[
"MIT"
] | 3
|
2021-03-31T19:44:40.000Z
|
2021-09-08T01:46:44.000Z
|
application.py
|
nbroad1881/sentimentr
|
cb4f57ce48a43a104d2e56f792a04e667b5e7c88
|
[
"MIT"
] | null | null | null |
from flask_app import application
if __name__ == '__main__':
application.run(debug=True, host='0.0.0.0', port='5000')
| 15.75
| 60
| 0.690476
| 19
| 126
| 4.105263
| 0.789474
| 0.076923
| 0.076923
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.074766
| 0.150794
| 126
| 7
| 61
| 18
| 0.654206
| 0
| 0
| 0
| 0
| 0
| 0.153226
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.333333
| 0
| 0.333333
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
98fa4d8830ef7be762997992d5feca12c07387a4
| 349
|
py
|
Python
|
sys/debug/kdump.py
|
mzr/mimiker
|
ff97e370ffebb0c7390407c6dfcfbd3db1d3404a
|
[
"BSD-3-Clause"
] | null | null | null |
sys/debug/kdump.py
|
mzr/mimiker
|
ff97e370ffebb0c7390407c6dfcfbd3db1d3404a
|
[
"BSD-3-Clause"
] | 2
|
2019-01-29T21:36:14.000Z
|
2019-12-01T22:36:31.000Z
|
sys/debug/kdump.py
|
mzr/mimiker
|
ff97e370ffebb0c7390407c6dfcfbd3db1d3404a
|
[
"BSD-3-Clause"
] | null | null | null |
from .physmem import KernelSegments, KernelFreePages
from .virtmem import VMMapSegments
from .cmd import CommandDispatcher
class Kdump(CommandDispatcher):
"""Examine kernel data structures."""
def __init__(self):
super().__init__('kdump', [KernelSegments(), KernelFreePages(),
VMMapSegments()])
| 29.083333
| 71
| 0.673352
| 29
| 349
| 7.827586
| 0.655172
| 0.255507
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.226361
| 349
| 11
| 72
| 31.727273
| 0.840741
| 0.088825
| 0
| 0
| 0
| 0
| 0.016026
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.142857
| false
| 0
| 0.428571
| 0
| 0.714286
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
c704bea93a30fa07d0ea8e3f1c96e1ef0720a2b0
| 31
|
py
|
Python
|
DjangoWeb/DjangoWeb/__init__.py
|
chimmilisrinivas/python-sample-vs-learning-django
|
30ce250b187507a99bf35e2691d483ebf03aa7f8
|
[
"MIT"
] | 13
|
2018-07-19T04:05:17.000Z
|
2019-03-19T22:35:27.000Z
|
DjangoWeb/DjangoWeb/__init__.py
|
chimmilisrinivas/python-sample-vs-learning-django
|
30ce250b187507a99bf35e2691d483ebf03aa7f8
|
[
"MIT"
] | 4
|
2018-10-02T04:39:11.000Z
|
2018-11-29T01:06:30.000Z
|
DjangoWeb/DjangoWeb/__init__.py
|
chimmilisrinivas/python-sample-vs-learning-django
|
30ce250b187507a99bf35e2691d483ebf03aa7f8
|
[
"MIT"
] | 16
|
2019-11-03T23:14:50.000Z
|
2022-03-16T06:12:38.000Z
|
"""
Package for DjangoWeb.
"""
| 7.75
| 22
| 0.612903
| 3
| 31
| 6.333333
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.16129
| 31
| 3
| 23
| 10.333333
| 0.730769
| 0.709677
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
c71bf66494566693cc4f79a2ba6f692b7d295bdb
| 78
|
py
|
Python
|
pony/assert-after-500/src/polls/__init__.py
|
zgoda/issues
|
55e14f566d0bb587cb22ab8ddcf06094cd3ffd79
|
[
"MIT"
] | 2
|
2020-01-31T16:12:59.000Z
|
2022-01-30T04:50:44.000Z
|
pony/assert-after-500/src/polls/__init__.py
|
zgoda/issues
|
55e14f566d0bb587cb22ab8ddcf06094cd3ffd79
|
[
"MIT"
] | 3
|
2021-04-15T19:19:54.000Z
|
2022-03-30T19:05:53.000Z
|
pony/assert-after-500/src/polls/__init__.py
|
zgoda/issues
|
55e14f566d0bb587cb22ab8ddcf06094cd3ffd79
|
[
"MIT"
] | null | null | null |
from ._version import get_version
__version__ = get_version()
del get_version
| 19.5
| 33
| 0.833333
| 11
| 78
| 5.181818
| 0.454545
| 0.526316
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.115385
| 78
| 3
| 34
| 26
| 0.826087
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.333333
| 0
| 0.333333
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
c71eedcd7c1688d21d54ddde993c5092c8026be3
| 86
|
py
|
Python
|
tests/test_staff_info.py
|
Forward83/staff_info
|
7ca2b4dd9abd50129252ae89d4c93fec73170c1f
|
[
"MIT"
] | null | null | null |
tests/test_staff_info.py
|
Forward83/staff_info
|
7ca2b4dd9abd50129252ae89d4c93fec73170c1f
|
[
"MIT"
] | null | null | null |
tests/test_staff_info.py
|
Forward83/staff_info
|
7ca2b4dd9abd50129252ae89d4c93fec73170c1f
|
[
"MIT"
] | null | null | null |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for `staff_info` package."""
| 14.333333
| 37
| 0.581395
| 12
| 86
| 4.083333
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.013699
| 0.151163
| 86
| 5
| 38
| 17.2
| 0.657534
| 0.860465
| 0
| null | 0
| null | 0
| 0
| null | 0
| 0
| 0
| null | 1
| null | true
| 0
| 0
| null | null | null | 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
c7341bbe1c2543ae6e0f09305c80543f42b79847
| 99
|
py
|
Python
|
statsmodels/regression/__init__.py
|
dieterv77/statsmodels
|
ec3b6d02c96cd9c8f4b993434f0bbae4b3e91a21
|
[
"BSD-3-Clause"
] | 34
|
2018-07-13T11:30:46.000Z
|
2022-01-05T13:48:10.000Z
|
venv/lib/python3.6/site-packages/statsmodels/regression/__init__.py
|
HeyWeiPan/vnpy_crypto
|
844381797a475a01c05a4e162592a5a6e3a48032
|
[
"MIT"
] | 6
|
2015-08-28T16:59:03.000Z
|
2019-04-12T22:29:01.000Z
|
venv/lib/python3.6/site-packages/statsmodels/regression/__init__.py
|
HeyWeiPan/vnpy_crypto
|
844381797a475a01c05a4e162592a5a6e3a48032
|
[
"MIT"
] | 28
|
2015-04-01T20:02:25.000Z
|
2021-07-03T00:09:28.000Z
|
from .linear_model import yule_walker
from statsmodels import PytestTester
test = PytestTester()
| 16.5
| 37
| 0.828283
| 12
| 99
| 6.666667
| 0.75
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.131313
| 99
| 5
| 38
| 19.8
| 0.930233
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.666667
| 0
| 0.666667
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
c73912b9dbc30bb4e59c7a27f121260e1656597d
| 1,357
|
py
|
Python
|
backend/notifiers/admin.py
|
hibare/Moni
|
83f63205c0b348d3c1bc05208122779b8fe1d117
|
[
"MIT"
] | 1
|
2020-06-02T09:53:01.000Z
|
2020-06-02T09:53:01.000Z
|
backend/notifiers/admin.py
|
hibare/Moni
|
83f63205c0b348d3c1bc05208122779b8fe1d117
|
[
"MIT"
] | 78
|
2021-05-18T11:29:33.000Z
|
2022-03-28T05:21:45.000Z
|
backend/notifiers/admin.py
|
hibare/Moni
|
83f63205c0b348d3c1bc05208122779b8fe1d117
|
[
"MIT"
] | 2
|
2019-12-13T04:51:12.000Z
|
2021-03-26T18:40:40.000Z
|
"""Notifiers admin"""
from typing import Optional
from django.contrib import admin
from django.http.request import HttpRequest
from notifiers.models import Notifiers, NotifiersHistory
@admin.register(Notifiers)
class NotifiersAdmin(admin.ModelAdmin):
"""Notifiers admin class"""
empty_value_display = '-empty-'
list_display = ['uuid', 'url', 'type',
'description']
list_filter = ['type']
def has_add_permission(self, request: HttpRequest) -> bool:
return False
def has_change_permission(self, request: HttpRequest, obj: Optional[Notifiers] = None) -> bool:
return False
def has_delete_permission(self, request: HttpRequest, obj: Optional[Notifiers] = None) -> bool:
return False
@admin.register(NotifiersHistory)
class NotifiersHistoryAdmin(admin.ModelAdmin):
"""Notifiers admin class"""
empty_value_display = '-empty-'
list_display = ['timestamp', 'uuid', 'status', 'status_code', 'error']
list_filter = ['uuid', 'status_code']
def has_add_permission(self, request: HttpRequest) -> bool:
return False
def has_change_permission(self, request: HttpRequest, obj: Optional[Notifiers] = None) -> bool:
return False
def has_delete_permission(self, request: HttpRequest, obj: Optional[Notifiers] = None) -> bool:
return False
| 30.840909
| 99
| 0.695652
| 149
| 1,357
| 6.187919
| 0.288591
| 0.039046
| 0.136659
| 0.208243
| 0.626898
| 0.626898
| 0.626898
| 0.626898
| 0.626898
| 0.626898
| 0
| 0
| 0.190125
| 1,357
| 43
| 100
| 31.55814
| 0.838944
| 0.043478
| 0
| 0.518519
| 0
| 0
| 0.070203
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.222222
| false
| 0
| 0.148148
| 0.222222
| 0.888889
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 1
| 0
| 0
|
0
| 4
|
c769553e32461ce82e2db5c8821544ac91c97f02
| 88
|
py
|
Python
|
Condor/python/Lib/site-packages/comtypes/gen/_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py
|
OriolOriolOriol/Condor
|
5b855ff7170e43149f9e9f81a97b6b88282915c5
|
[
"MIT"
] | null | null | null |
Condor/python/Lib/site-packages/comtypes/gen/_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py
|
OriolOriolOriol/Condor
|
5b855ff7170e43149f9e9f81a97b6b88282915c5
|
[
"MIT"
] | null | null | null |
Condor/python/Lib/site-packages/comtypes/gen/_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py
|
OriolOriolOriol/Condor
|
5b855ff7170e43149f9e9f81a97b6b88282915c5
|
[
"MIT"
] | 1
|
2020-11-04T08:32:26.000Z
|
2020-11-04T08:32:26.000Z
|
# -*- coding: mbcs -*-
typelib_path = 'C:\\WINDOWS\\System32\\Speech\\Common\\sapi.dll'
| 29.333333
| 64
| 0.647727
| 11
| 88
| 5.090909
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.025
| 0.090909
| 88
| 2
| 65
| 44
| 0.675
| 0.227273
| 0
| 0
| 0
| 0
| 0.712121
| 0.712121
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
c77631d7298eb37df20c6c2a1a404fd06be752d1
| 156
|
py
|
Python
|
worker.py
|
mekanix/cbsdng-backend
|
0c0058521ffb97b0dd9948a257290c5489ae5216
|
[
"BSD-2-Clause"
] | null | null | null |
worker.py
|
mekanix/cbsdng-backend
|
0c0058521ffb97b0dd9948a257290c5489ae5216
|
[
"BSD-2-Clause"
] | 5
|
2020-10-19T21:54:55.000Z
|
2020-11-20T13:02:49.000Z
|
worker.py
|
mekanix/cbsdng-backend
|
0c0058521ffb97b0dd9948a257290c5489ae5216
|
[
"BSD-2-Clause"
] | 1
|
2020-10-10T18:00:39.000Z
|
2020-10-10T18:00:39.000Z
|
import os
from application import init
config_name = os.getenv('FLASK_ENV', 'default')
application = init(config_name, False)
celery = application.celery
| 19.5
| 47
| 0.782051
| 21
| 156
| 5.666667
| 0.619048
| 0.168067
| 0.235294
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.121795
| 156
| 7
| 48
| 22.285714
| 0.868613
| 0
| 0
| 0
| 0
| 0
| 0.102564
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.4
| 0
| 0.4
| 0
| 1
| 0
| 0
| null | 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
c78f95a604d161157c0a68ab2947db2778f80470
| 55
|
py
|
Python
|
tsts/thirdparty/__init__.py
|
TakuyaShintate/tsts
|
483db1edc2f765a5449137446a77acaf17684ce9
|
[
"MIT"
] | 16
|
2021-08-28T16:15:41.000Z
|
2022-02-25T09:47:01.000Z
|
tsts/thirdparty/__init__.py
|
TakuyaShintate/tsts
|
483db1edc2f765a5449137446a77acaf17684ce9
|
[
"MIT"
] | null | null | null |
tsts/thirdparty/__init__.py
|
TakuyaShintate/tsts
|
483db1edc2f765a5449137446a77acaf17684ce9
|
[
"MIT"
] | 1
|
2021-12-05T20:35:38.000Z
|
2021-12-05T20:35:38.000Z
|
from . import dilate, sam
__all__ = ["dilate", "sam"]
| 13.75
| 27
| 0.636364
| 7
| 55
| 4.428571
| 0.714286
| 0.580645
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.181818
| 55
| 3
| 28
| 18.333333
| 0.688889
| 0
| 0
| 0
| 0
| 0
| 0.163636
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 0.5
| 0
| 1
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
c790cce28072dd60daf945e690bd53afa4c6e2aa
| 103
|
py
|
Python
|
highlighter/tests/__main__.py
|
python-packaging/highlighter
|
8f64ce525879cd2d8c41fefee3ea228c0c1ed83f
|
[
"MIT"
] | 1
|
2020-09-28T18:41:40.000Z
|
2020-09-28T18:41:40.000Z
|
highlighter/tests/__main__.py
|
python-packaging/highlighter
|
8f64ce525879cd2d8c41fefee3ea228c0c1ed83f
|
[
"MIT"
] | 2
|
2020-10-02T19:35:12.000Z
|
2020-10-03T19:34:42.000Z
|
highlighter/tests/__main__.py
|
python-packaging/highlighter
|
8f64ce525879cd2d8c41fefee3ea228c0c1ed83f
|
[
"MIT"
] | 1
|
2022-01-27T13:17:03.000Z
|
2022-01-27T13:17:03.000Z
|
import unittest
if __name__ == "__main__":
unittest.main(module="highlighter.tests", verbosity=2)
| 20.6
| 58
| 0.737864
| 12
| 103
| 5.666667
| 0.833333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.011111
| 0.126214
| 103
| 4
| 59
| 25.75
| 0.744444
| 0
| 0
| 0
| 0
| 0
| 0.242718
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.333333
| 0
| 0.333333
| 0
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
c798871fb3f876e59519a6f0d6cd87f114e55c1e
| 530
|
py
|
Python
|
app/utils.py
|
KamalDGRT/libms
|
61dae1913c409aff35c295c65d8fc7667ff05bb9
|
[
"MIT"
] | 1
|
2022-02-26T04:20:07.000Z
|
2022-02-26T04:20:07.000Z
|
app/utils.py
|
KamalDGRT/libms
|
61dae1913c409aff35c295c65d8fc7667ff05bb9
|
[
"MIT"
] | null | null | null |
app/utils.py
|
KamalDGRT/libms
|
61dae1913c409aff35c295c65d8fc7667ff05bb9
|
[
"MIT"
] | null | null | null |
# This file will hold a bunch of utility functions
from passlib.context import CryptContext
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
def hash(password: str):
"""
Returns bcrypt hashed string
"""
return pwd_context.hash(password)
# We could have done the below thing in the auth.py but we would have to
# import the above stuff again. So, it is better to group related stuff.
def verify(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
| 27.894737
| 72
| 0.750943
| 77
| 530
| 5.077922
| 0.662338
| 0.076726
| 0.081841
| 0.127877
| 0.168798
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.171698
| 530
| 18
| 73
| 29.444444
| 0.890661
| 0.415094
| 0
| 0
| 0
| 0
| 0.034247
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0.833333
| 0.166667
| 0.166667
| 0.833333
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 1
| 0
| 1
| 1
| 0
|
0
| 4
|
c7b7e03ca4b48e2152374b163c908e69886084f2
| 107
|
py
|
Python
|
basics/numbers_and_math.py
|
peter88tom/python_rebooted
|
042ca1c3905816c809a724434a9d797a4de0dd61
|
[
"MIT"
] | null | null | null |
basics/numbers_and_math.py
|
peter88tom/python_rebooted
|
042ca1c3905816c809a724434a9d797a4de0dd61
|
[
"MIT"
] | null | null | null |
basics/numbers_and_math.py
|
peter88tom/python_rebooted
|
042ca1c3905816c809a724434a9d797a4de0dd61
|
[
"MIT"
] | null | null | null |
print("I will now count my chickens:")
print("Hens", 25 + 30 / 6)
print(f"Roosters {100 - 25 * 3 % 4}")
| 15.285714
| 38
| 0.588785
| 19
| 107
| 3.315789
| 0.842105
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.142857
| 0.214953
| 107
| 6
| 39
| 17.833333
| 0.607143
| 0
| 0
| 0
| 0
| 0
| 0.560748
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.