function
stringlengths 11
56k
| repo_name
stringlengths 5
60
| features
sequence |
---|---|---|
def signal_shutdown(self) -> None:
logger.debug("Signalling shutdown")
self._stop_event.set() | gjcarneiro/yacron | [
400,
38,
400,
9,
1500314642
] |
def job_should_run(startup: bool, job: JobConfig) -> bool:
if (
startup
and isinstance(job.schedule, str)
and job.schedule == "@reboot"
):
logger.debug(
"Job %s (%s) is scheduled for startup (@reboot)",
job.name,
job.schedule_unparsed,
)
return True
elif isinstance(job.schedule, CronTab):
crontab = job.schedule # type: CronTab
if crontab.test(get_now(job.timezone).replace(second=0)):
logger.debug(
"Job %s (%s) is scheduled for now",
job.name,
job.schedule_unparsed,
)
return True
else:
logger.debug(
"Job %s (%s) not scheduled for now",
job.name,
job.schedule_unparsed,
)
return False
else:
return False | gjcarneiro/yacron | [
400,
38,
400,
9,
1500314642
] |
def genetic_modification(testapp, lab, award):
item = {
'award': award['@id'],
'lab': lab['@id'],
'modified_site_by_coordinates': {
'assembly': 'GRCh38',
'chromosome': '11',
'start': 20000,
'end': 21000
},
'purpose': 'repression',
'category': 'deletion',
'method': 'CRISPR',
'zygosity': 'homozygous'
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_RNAi(testapp, lab, award):
item = {
'award': award['@id'],
'lab': lab['@id'],
'modified_site_by_coordinates': {
'assembly': 'GRCh38',
'chromosome': '11',
'start': 20000,
'end': 21000
},
'purpose': 'repression',
'category': 'deletion',
'method': 'RNAi'
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_source(testapp, lab, award, source, gene):
item = {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'introduced_gene': gene['@id'],
'purpose': 'expression',
'method': 'CRISPR',
'reagents': [
{
'source': source['@id'],
'identifier': 'sigma:ABC123'
}
]
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def crispr_deletion(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'deletion',
'purpose': 'repression',
'method': 'CRISPR'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def crispr_deletion_1(testapp, lab, award, target):
item = {
'lab': lab['@id'],
'award': award['@id'],
'category': 'deletion',
'purpose': 'repression',
'method': 'CRISPR',
'modified_site_by_target_id': target['@id'],
'guide_rna_sequences': ['ACCGGAGA']
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def tale_deletion(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'deletion',
'purpose': 'repression',
'method': 'TALEN',
'zygosity': 'heterozygous'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def crispr_tag(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'purpose': 'tagging',
'method': 'CRISPR'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def bombardment_tag(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'purpose': 'tagging',
'nucleic_acid_delivery_method': ['bombardment']
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def recomb_tag(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'purpose': 'tagging',
'method': 'site-specific recombination'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def transfection_tag(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'purpose': 'tagging',
'nucleic_acid_delivery_method': ['stable transfection']
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def crispri(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'interference',
'purpose': 'repression',
'method': 'CRISPR'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def rnai(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'interference',
'purpose': 'repression',
'method': 'RNAi'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def mutagen(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'mutagenesis',
'purpose': 'repression',
'method': 'mutagen treatment'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def tale_replacement(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'replacement',
'purpose': 'characterization',
'method': 'TALEN',
'zygosity': 'heterozygous'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def mpra(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'purpose': 'characterization',
'nucleic_acid_delivery_method': ['transduction']
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def starr_seq(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'episome',
'purpose': 'characterization',
'nucleic_acid_delivery_method': ['transient transfection']
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def introduced_elements(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'episome',
'purpose': 'characterization',
'nucleic_acid_delivery_method': ['transient transfection'],
'introduced_elements': 'genomic DNA regions'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def crispr_tag_1(testapp, lab, award, ctcf):
item = {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'purpose': 'tagging',
'method': 'CRISPR',
'modified_site_by_gene_id': ctcf['@id'],
'introduced_tags': [{'name': 'mAID-mClover', 'location': 'C-terminal'}]
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def mpra_1(testapp, lab, award):
item = {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'purpose': 'characterization',
'nucleic_acid_delivery_method': ['transduction'],
'introduced_elements': 'synthesized DNA',
'modified_site_nonspecific': 'random'
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def recomb_tag_1(testapp, lab, award, target, treatment_5, document):
item = {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'purpose': 'tagging',
'method': 'site-specific recombination',
'modified_site_by_target_id': target['@id'],
'modified_site_nonspecific': 'random',
'category': 'insertion',
'treatments': [treatment_5['@id']],
'documents': [document['@id']],
'introduced_tags': [{'name': 'eGFP', 'location': 'C-terminal'}]
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def rnai_1(testapp, lab, award, source, target):
item = {
'lab': lab['@id'],
'award': award['@id'],
'category': 'interference',
'purpose': 'repression',
'method': 'RNAi',
'reagents': [{'source': source['@id'], 'identifier': 'addgene:12345'}],
'rnai_sequences': ['ATTACG'],
'modified_site_by_target_id': target['@id']
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_1(lab, award):
return {
'modification_type': 'deletion',
'award': award['uuid'],
'lab': lab['uuid'],
'modifiction_description': 'some description'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_2(lab, award):
return {
'modification_type': 'deletion',
'award': award['uuid'],
'lab': lab['uuid'],
'modification_description': 'some description',
'modification_zygocity': 'homozygous',
'modification_purpose': 'tagging',
'modification_treatments': [],
'modification_genome_coordinates': [{
'chromosome': '11',
'start': 5309435,
'end': 5309451
}]
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def crispr_gm(lab, award, source):
return {
'lab': lab['uuid'],
'award': award['uuid'],
'source': source['uuid'],
'guide_rna_sequences': [
"ACA",
"GCG"
],
'insert_sequence': 'TCGA',
'aliases': ['encode:crispr_technique1'],
'@type': ['Crispr', 'ModificationTechnique', 'Item'],
'@id': '/crisprs/79c1ec08-c878-4419-8dba-66aa4eca156b/',
'uuid': '79c1ec08-c878-4419-8dba-66aa4eca156b'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_5(lab, award, crispr_gm):
return {
'modification_type': 'deletion',
'award': award['uuid'],
'lab': lab['uuid'],
'description': 'blah blah description blah',
'zygosity': 'homozygous',
'treatments': [],
'source': 'sigma',
'product_id': '12345',
'modification_techniques': [crispr_gm],
'modified_site': [{
'assembly': 'GRCh38',
'chromosome': '11',
'start': 5309435,
'end': 5309451
}]
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_6(lab, award, crispr_gm, source):
return {
'purpose': 'validation',
'category': 'deeltion',
'award': award['uuid'],
'lab': lab['uuid'],
'description': 'blah blah description blah',
"method": "CRISPR",
"modified_site_by_target_id": "/targets/FLAG-ZBTB43-human/",
"reagents": [
{
"identifier": "placeholder_id",
"source": source['uuid']
}
]
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_7_invalid_reagent(lab, award, crispr_gm):
return {
'purpose': 'characterization',
'category': 'deletion',
'award': award['uuid'],
'lab': lab['uuid'],
'description': 'blah blah description blah',
"method": "CRISPR",
"modified_site_by_target_id": "/targets/FLAG-ZBTB43-human/",
"reagents": [
{
"identifier": "placeholder_id",
"source": "/sources/sigma/"
}
]
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_7_valid_reagent(lab, award, crispr_gm):
return {
'purpose': 'characterization',
'category': 'deletion',
'award': award['uuid'],
'lab': lab['uuid'],
'description': 'blah blah description blah',
"method": "CRISPR",
"modified_site_by_target_id": "/targets/FLAG-ZBTB43-human/",
"reagents": [
{
"identifier": "ABC123",
"source": "/sources/sigma/"
}
]
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_7_addgene_source(testapp):
item = {
'name': 'addgene',
'title': 'Addgene',
'status': 'released'
}
return testapp.post_json('/source', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_7_multiple_matched_identifiers(lab, award, crispr_gm):
return {
'purpose': 'characterization',
'category': 'deletion',
'award': award['uuid'],
'lab': lab['uuid'],
'description': 'blah blah description blah',
"method": "CRISPR",
"modified_site_by_target_id": "/targets/FLAG-ZBTB43-human/",
"reagents": [
{
"identifier": "12345",
"source": "/sources/addgene/"
}
]
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_7_multiple_reagents(lab, award, crispr_gm):
return {
'purpose': 'characterization',
'category': 'deletion',
'award': award['uuid'],
'lab': lab['uuid'],
'description': 'blah blah description blah',
"method": "CRISPR",
"modified_site_by_target_id": "/targets/FLAG-ZBTB43-human/",
"reagents": [
{
"identifier": "12345",
"source": "/sources/addgene/",
"url": "http://www.addgene.org"
},
{
"identifier": "67890",
"source": "/sources/addgene/",
"url": "http://www.addgene.org"
}
]
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_8(lab, award):
return {
'purpose': 'analysis',
'category': 'interference',
'award': award['uuid'],
'lab': lab['uuid'],
"method": "CRISPR",
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def construct_genetic_modification(
testapp,
lab,
award,
document,
target_ATF5_genes,
target_promoter):
item = {
'award': award['@id'],
'documents': [document['@id']],
'lab': lab['@id'],
'category': 'insertion',
'purpose': 'tagging',
'nucleic_acid_delivery_method': ['stable transfection'],
'introduced_tags': [{'name':'eGFP', 'location': 'C-terminal', 'promoter_used': target_promoter['@id']}],
'modified_site_by_target_id': target_ATF5_genes['@id']
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def construct_genetic_modification_N(
testapp,
lab,
award,
document,
target):
item = {
'award': award['@id'],
'documents': [document['@id']],
'lab': lab['@id'],
'category': 'insertion',
'purpose': 'tagging',
'nucleic_acid_delivery_method': ['stable transfection'],
'introduced_tags': [{'name':'eGFP', 'location': 'N-terminal'}],
'modified_site_by_target_id': target['@id']
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def interference_genetic_modification(
testapp,
lab,
award,
document,
target):
item = {
'award': award['@id'],
'documents': [document['@id']],
'lab': lab['@id'],
'category': 'interference',
'purpose': 'repression',
'method': 'RNAi',
'modified_site_by_target_id': target['@id']
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def crispr_knockout(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'knockout',
'purpose': 'characterization',
'method': 'CRISPR'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def recombination_knockout(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'knockout',
'purpose': 'repression',
'method': 'site-specific recombination',
'modified_site_by_coordinates': {
"assembly": "GRCh38",
"chromosome": "11",
"start": 60000,
"end": 62000
}
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def characterization_insertion_transfection(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'purpose': 'characterization',
'nucleic_acid_delivery_method': ['stable transfection'],
'modified_site_nonspecific': 'random',
'introduced_elements': 'synthesized DNA'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def characterization_insertion_CRISPR(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'purpose': 'characterization',
'method': 'CRISPR',
'modified_site_nonspecific': 'random',
'introduced_elements': 'synthesized DNA'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def disruption_genetic_modification(testapp, lab, award):
item = {
'lab': lab['@id'],
'award': award['@id'],
'category': 'CRISPR cutting',
'purpose': 'characterization',
'method': 'CRISPR'
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def activation_genetic_modification(testapp, lab, award):
item = {
'lab': lab['@id'],
'award': award['@id'],
'category': 'CRISPRa',
'purpose': 'characterization',
'method': 'CRISPR'
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def binding_genetic_modification(testapp, lab, award):
item = {
'lab': lab['@id'],
'award': award['@id'],
'category': 'CRISPR dCas',
'purpose': 'characterization',
'method': 'CRISPR'
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def HR_knockout(lab, award, target):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'knockout',
'purpose': 'repression',
'method': 'homologous recombination',
'modified_site_by_target_id': target['@id']
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def CRISPR_introduction(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'purpose': 'expression',
'nucleic_acid_delivery_method': ['transient transfection']
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_9(lab, award, human_donor_1):
return {
'lab': lab['@id'],
'award': award['@id'],
'donor': human_donor_1['@id'],
'category': 'insertion',
'purpose': 'expression',
'method': 'transient transfection'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def transgene_insertion(testapp, lab, award, ctcf):
item = {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'purpose': 'in vivo enhancer characterization',
'nucleic_acid_delivery_method': ['mouse pronuclear microinjection'],
'modified_site_by_gene_id': ctcf['@id'],
'introduced_sequence': 'ATCGTA'
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def guides_transduction_GM(testapp, lab, award):
item = {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'purpose': 'expression',
'nucleic_acid_delivery_method': ['transduction'],
'introduced_elements': 'gRNAs and CRISPR machinery',
'MOI': 'high',
'guide_type': 'sgRNA'
}
return testapp.post_json('/genetic_modification', item).json['@graph'][0] | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_10(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'insertion',
'purpose': 'expression',
'nucleic_acid_delivery_method': ['transduction'],
'introduced_elements': 'gRNAs and CRISPR machinery',
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def genetic_modification_11(lab, award):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'disruption',
'purpose': 'characterization',
'method': 'CRISPR'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def transgene_insertion_2(testapp, lab, award, ctcf):
return {
'lab': lab['@id'],
'award': award['@id'],
'category': 'transgene insertion',
'purpose': 'in vivo enhancer characterization',
'nucleic_acid_delivery_method': ['mouse pronuclear microinjection'],
'modified_site_by_gene_id': ctcf['@id'],
'introduced_sequence': 'ATCGTA'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def activation_genetic_modification_2(testapp, lab, award):
return{
'lab': lab['@id'],
'award': award['@id'],
'category': 'activation',
'purpose': 'characterization',
'method': 'CRISPR'
} | ENCODE-DCC/encoded | [
104,
54,
104,
70,
1354841541
] |
def test_make_gym_venv_nostack(name, num_envs, state_shape, reward_scale):
seed = 0
frame_op = None
frame_op_len = None
venv = make_gym_venv(name, num_envs, seed, frame_op=frame_op, frame_op_len=frame_op_len, reward_scale=reward_scale)
venv.reset()
for i in range(5):
state, reward, done, info = venv.step([venv.action_space.sample()] * num_envs)
assert isinstance(state, np.ndarray)
assert state.shape == (num_envs,) + state_shape
assert isinstance(reward, np.ndarray)
assert reward.shape == (num_envs,)
assert isinstance(done, np.ndarray)
assert done.shape == (num_envs,)
assert len(info) == num_envs
venv.close() | kengz/Unity-Lab | [
1131,
242,
1131,
13,
1506982822
] |
def test_make_gym_concat(name, num_envs, state_shape, reward_scale):
seed = 0
frame_op = 'concat' # used for image, or for concat vector
frame_op_len = 4
venv = make_gym_venv(name, num_envs, seed, frame_op=frame_op, frame_op_len=frame_op_len, reward_scale=reward_scale)
venv.reset()
for i in range(5):
state, reward, done, info = venv.step([venv.action_space.sample()] * num_envs)
assert isinstance(state, np.ndarray)
stack_shape = (num_envs, frame_op_len * state_shape[0],) + state_shape[1:]
assert state.shape == stack_shape
assert isinstance(reward, np.ndarray)
assert reward.shape == (num_envs,)
assert isinstance(done, np.ndarray)
assert done.shape == (num_envs,)
assert len(info) == num_envs
venv.close() | kengz/Unity-Lab | [
1131,
242,
1131,
13,
1506982822
] |
def test_make_gym_stack(name, num_envs, state_shape, reward_scale):
seed = 0
frame_op = 'stack' # used for rnn
frame_op_len = 4
venv = make_gym_venv(name, num_envs, seed, frame_op=frame_op, frame_op_len=frame_op_len, reward_scale=reward_scale)
venv.reset()
for i in range(5):
state, reward, done, info = venv.step([venv.action_space.sample()] * num_envs)
assert isinstance(state, np.ndarray)
stack_shape = (num_envs, frame_op_len,) + state_shape
assert state.shape == stack_shape
assert isinstance(reward, np.ndarray)
assert reward.shape == (num_envs,)
assert isinstance(done, np.ndarray)
assert done.shape == (num_envs,)
assert len(info) == num_envs
venv.close() | kengz/Unity-Lab | [
1131,
242,
1131,
13,
1506982822
] |
def __init__(
self, plotly_name="minexponent", parent_name="choropleth.colorbar", **kwargs | plotly/plotly.py | [
13052,
2308,
13052,
1319,
1385013188
] |
def isplayfile(pathname) :
if os.path.isfile(pathname) == False:
return False
ext = os.path.splitext(pathname)[1]
ext = ext.lower()
if (ext == '.mp2') : return True;
if (ext == '.mp3') : return True;
if (ext == '.ogg') : return True;
return False | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def validate_password(self, login, password):
if login in users :
if encrypt(password) == users[login] :
cherrypy.session['username'] = login
cherrypy.session['database'] = userdatabase(login)
return True
return False | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def index(self):
html = header
(_1, _2, id) = getradio('0')
(radio, genre, url) = getradio(id)
if id != 0:
html += '''<h3><a href="#" onClick="fplayradio('%s')"> ''' % id
html += '''Play Last Radio %s <span class="glyphicon glyphicon-play"></span></a></h3>''' % radio
html += getfooter()
return html | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def music(self, directory='/mnt/Media/Music/'):
html = header
count = 0
html += '''<table class="table table-condensed">'''
filelist = os.listdir(directory)
filelist.sort()
for f in filelist:
file = os.path.join(directory, f)
html += '''<tr>'''
if isplayfile(file):
html += '''<td ><a href="#" onClick="fplayradio('%s')">''' % file
html += '''Play %s<span class="glyphicon glyphicon-play"></span></a></td>''' % (file)
if os.path.isdir(file):
html += '''<td ><a href="/music?directory=%s">%s</a> </td>''' % (file, f)
html += '''</tr>'''
count += 1
html += '''</table>'''
html += '''</div> </div>'''
html += getfooter()
return html | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def g(self, name="", genre="", randomlist='false'):
list = searchradio(name.decode('utf8'), genre)
count = 0
# Randomlist
if randomlist == 'true' : shuffle(list)
listhtml = '''<table class="table table-condensed">'''
for id,radio,gen,url in list:
listhtml += '''<tr>'''
listhtml += '''<td width="200px"><a href="#" onClick="fmodradio('%s')" alt="%s">%s</a></td>''' % (id, url, radio)
listhtml += '''<td width="100px">%s</td>''' % gen
listhtml += '''<td ><a href="#" onClick="fplayradio('%s')">Play <span class="glyphicon glyphicon-play"></span></a></td>''' % (id)
listhtml += '''</tr>'''
count += 1
listhtml += '''</table>'''
listhtml += '''</div> </div>'''
html = ''
html += '''<div class="row"> <div class="col-md-8"> '''
if randomlist == 'false':
html += '''<h2><a href="#" onClick="frandom(name='%s', genre='%s', randomlist='true')">%d Results for '%s' + '%s'</a></h2>''' % (name, genre, count, name, genre)
else:
html += '''<h2><a href="#" onClick="fsearch(name='%s', genre='%s')">%d Random for '%s' + '%s'</a></h2>''' % (name, genre, count, name, genre)
html += listhtml
return html | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def i(self, name="", genre="", url=""):
html = "<h2>Insert</h2>"
if name == "" or name == None :
html += "Error no name"
return html
if insert(name, genre, url) == False:
html += "Error db "
return html
html += '''<h3>This radio has been inserted</h3>'''
html += '''<p><table class="table table-condensed">'''
html += ''' <tr> '''
html += ''' <td>radio: <strong>%s</strong></td> ''' % name
html += ''' <td>genre: <strong>%s</strong></td> ''' % genre
html += ''' <td>url: <strong><a href="%s" target="_blank">%s</a></strong></td> ''' % (url, url)
html += ''' <td width="300px"><a href="#" onClick="fplayradio('%s')"> Play ''' % url
html += '''<span class="glyphicon glyphicon-play"></span></a></td>'''
html += ''' </tr> '''
html += '''</table>'''
return html | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def d(self, id=""):
html = "<h2>Delete</h2>"
if id == "" or id == None :
html += "Error"
return html
if id == "0" :
html += "0 is reserved, sorry"
return html
#if delete(id) == False:
if nonexist(id) == False:
html += "Delete error in id" % id
html += getfooter()
return html
html += "Item %s set as non existent" % id
return html | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def p(self, id):
html = ""
if id == "" or id == None :
html += "Error no radio id"
return html
if id == "0" :
html += "0 is reserved, sorry"
return html
(radio, genre, url) = playradio(id)
if url == '':
html += "Error in parameter %s" % url
return html
cherrypy.session['playing'] = id
html += '''<h3>Now Playing: '''
html += '''<a href="%s">%s</a>''' % (url, radio)
html += '''<a href="#" onClick="fplayradio('%s')">''' % id
html += '''<span class="glyphicon glyphicon-play"></span></a>'''
html += ''' <a href="#" onClick="fmodradio('%s')"><span class="glyphicon glyphicon-pencil"></span></a></small> ''' % id
html += '''<a href="#" onClick="fdelradio('%s')"><span class="glyphicon glyphicon-trash"></span></a> ''' % id
html += '''<a href="#" onClick="faddfav('%s')"><span class="glyphicon glyphicon-star"></span></a>''' % id
html += '''</h3>'''
return html | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def v(self, vol=""):
html = ""
if vol == "" or vol == None :
html += "Error"
v = volume(vol)
html += "<h6>%s (%s) </h6>" % (v, vol)
return html | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def m(self, id):
html = '''<h2>Modify</h2>'''
if id == "" or id == None :
html += "Error"
return html
if id == "0" :
html += "0 is reserved, sorry"
return html
(name, genre, url) = getradio(id)
html += '<h3>%s | %s | %s</h3>' % (name, genre, url)
html += '''<input type="hidden" id="idm" name="id" value="%s">''' % id
html += '''<input type="text" id="namem" name="name" value="%s">''' % name
html += '''genre: <input type="text" id="genrem" name="genre" value="%s"> ''' % genre
html += '''url: <input type="text" style="min-width: 280px" id="urlm" name="url" value="%s"> ''' % url
html += '''<button id="button-modify">Change</button>'''
html += '''<h3><a href="#" onClick="fdelradio('%s')">Delete? <span class="glyphicon glyphicon-trash"></span></a></h3>''' % id
html += '''<h3><a href="%s" target="_blank">Play in browser <span class="glyphicon glyphicon-music"></span></a>''' % url
return html | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def f(self, id="", name="", genre="", url=""):
html = '''<h2>Modified</h2>'''
if id == "" or id == None :
html += "Error missing id"
return html
if id == "0" :
html += "0 is reserved, sorry"
return html
if modify(id, name, url, genre) == False:
html += "Error in DB"
return html
(name, genre, url) = getradio(id)
html += '''<p><table class="table table-condensed">'''
html += '''<tr>'''
html += '''<td width="100px"><a href="#" onClick="fmodradio('%s')">''' % id
html += '''Mod <span class="glyphicon glyphicon-pencil"></span></a></td>'''
html += '''<td width="200px">%s</td>''' % name
html += '''<td width="200px">%s</td>''' % genre
html += '''<td><a href="%s" target="_blank">%s</a></td>''' % (url, url)
html += '''<td width="300px"><a href="#" onClick="fplayradio('%s')">'''% url
html += '''Play <span class="glyphicon glyphicon-play"></span></a></td>'''
html += '''</tr>'''
html += '''</table>'''
return html | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def haddfav(self, id=""):
if id == "" or id == None :
html += "Error missing id"
return html
if id == "0" :
html += "0 is reserved, sorry"
return html
(name, genre, url) = getradio(id)
if 'Fav' in genre:
genre = genre.replace(', Fav', '')
star = False
else:
genre += ', Fav'
star = True
if addgen(id, genre) == False:
return ''
(name, genre, url) = getradio(id)
cherrypy.session['playing'] = id
html = '<h3>Now Playing: '
html += '''<a href="%s">%s</a>''' % (url, name)
html += '''<a href="#" onClick="fplayradio('%s')">''' % url
html += '''<span class="glyphicon glyphicon-play"></span></a>'''
html += ''' <a href="#" onClick="fmodradio('%s')"><span class="glyphicon glyphicon-pencil"></span></a></small> ''' % id
html += '''<a href="#" onClick="fdelradio('%s')"><span class="glyphicon glyphicon-trash"></span></a> ''' % id
html += '''<a href="#" onClick="faddfav('%s')"><span class="glyphicon glyphicon-star"></span></a>''' % id
if star:
html += '''Starred'''
html += '''</h3>'''
return html | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def k(self):
html = "<h2>Stopping</h2>"
killall()
return html | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def getfooter() :
global footer, version
db = cherrypy.session['database']
try:
con = lite.connect( db )
cur = con.cursor()
sql = "select radio, genre, url from Radio where id=0"
cur.execute(sql)
(radio, genre, url) = cur.fetchone()
except:
(radio, genre, url) = ('ERROR', sql, '')
con.close()
hostname = socket.gethostname()
f = '''<footer class="footer"> <div class="container">'''
f += '''<p class="text-muted">'''
f += '''Session id: %s - Session Database %s<br>''' % (cherrypy.session.id, cherrypy.session['database'])
f += '''Host: %s - Version: %s - Updated: %s // Last: %s''' % (hostname, version, genre, url)
f += '''</p>'''
f += '''</div></footer>'''
return f + footer | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def delete(id) :
db = cherrypy.session['database']
try:
con = lite.connect( db )
cur = con.cursor()
sql = "DELETE from Radio WHERE id = '%s'" % (id)
cur.execute(sql)
ret = True
except:
ret = False
updateversiondb(cur)
con.commit()
con.close()
return ret | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def insert(radio, genre, url) :
db = cherrypy.session['database']
sql = "INSERT INTO Radio (radio, genre, url, exist) VALUES('%s', '%s', '%s', 1)" % (radio, genre, url)
try:
con = lite.connect( db )
cur = con.cursor()
cur.execute(sql)
ret = True
except:
ret = False
updateversiondb(cur)
con.commit()
con.close()
return ret | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def addgen(id, genre) :
db = cherrypy.session['database']
sql = "UPDATE Radio SET genre='%s' WHERE id = %s" % (genre, id)
try:
con = lite.connect( db )
cur = con.cursor()
cur.execute(sql)
ret = True
except:
ret = False
updateversiondb(cur)
con.commit()
con.close()
return ret | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def searchradio(radio, genre) :
db = cherrypy.session['database']
#o = 'order by radio'
o = ''
sql = "select id, radio, genre, url from Radio where exist > 0 and radio like '%%%s%%' and genre like '%%%s%%' and id > 0 %s" % (radio, genre, o)
try:
con = lite.connect( db )
cur = con.cursor()
cur.execute(sql)
except:
return [(0, sql, o, genre)]
rows = cur.fetchall()
con.close()
return rows | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def userdatabase(user) :
db = database
if not os.path.isfile(db):
return None
return db | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def setplayer(p):
global player
player = p | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def killall():
global player
status = 0
if player == 'omxplayer':
control = "/usr/local/bin/omxcontrol"
status = subprocess.call([control, "stop"])
status = subprocess.call(["pkill", player])
return status | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def volume_alsa(vol):
# With ALSA on CHIP
if vol == 'up':
db = subprocess.check_output(["amixer set 'Power Amplifier' 5%+"], shell=True)
#db = os.system("amixer set 'Power Amplifier' 5%+")
if vol == 'down':
db = subprocess.check_output(["amixer set 'Power Amplifier' 5%-"], shell=True)
#db = os.system("amixer set 'Power Amplifier' 5%-")
i = db.rfind(':')
return db[i+1:] | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def writemypid(pidfile):
pid = str(os.getpid())
with open(pidfile, 'w') as f:
f.write(pid)
f.close | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def error_page_404(status, message, traceback, version):
html = header
html += "%s<br>" % (status)
html += "%s" % (traceback)
html += getfooter()
return html | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def secureheaders():
headers = cherrypy.response.headers
headers['X-Frame-Options'] = 'DENY'
headers['X-XSS-Protection'] = '1; mode=block'
headers['Content-Security-Policy'] = "default-src='self'" | ernitron/radio-server | [
8,
3,
8,
1,
1456010490
] |
def assertListEq(self, l1, l2, ignore):
''' succeed iff {l1} - {ignore} == {l2} - {ignore} '''
missing = (set(l1) ^ set(l2)) - set(ignore)
if missing:
print >>sys.stderr, "l1=%r\nl2=%r\nignore=%r" % (l1, l2, ignore)
self.fail("%r missing" % missing.pop()) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def assertHasattr(self, obj, attr, ignore):
''' succeed iff hasattr(obj,attr) or attr in ignore. '''
if attr in ignore: return
if not hasattr(obj, attr): print "???", attr
self.failUnless(hasattr(obj, attr),
'expected hasattr(%r, %r)' % (obj, attr)) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def assertHaskey(self, obj, key, ignore):
''' succeed iff key in obj or key in ignore. '''
if key in ignore: return
if key not in obj:
print >>sys.stderr, "***", key
self.assertTrue(key in obj) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def assertEqualsOrIgnored(self, a, b, ignore):
''' succeed iff a == b or a in ignore or b in ignore '''
if a not in ignore and b not in ignore:
self.assertEqual(a, b) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def checkModule(self, moduleName, module=None, ignore=()):
''' succeed iff pyclbr.readmodule_ex(modulename) corresponds
to the actual module object, module. Any identifiers in
ignore are ignored. If no module is provided, the appropriate
module is loaded with __import__.''' | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def ismethod(oclass, obj, name):
classdict = oclass.__dict__
if isinstance(obj, FunctionType):
if not isinstance(classdict[name], StaticMethodType):
return False
else:
if not isinstance(obj, MethodType):
return False
if obj.im_self is not None:
if (not isinstance(classdict[name], ClassMethodType) or
obj.im_self is not oclass):
return False
else:
if not isinstance(classdict[name], FunctionType):
return False | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def defined_in(item, module):
if isinstance(item, ClassType):
return item.__module__ == module.__name__
if isinstance(item, FunctionType):
return item.func_globals is module.__dict__
return False | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_easy(self):
self.checkModule('pyclbr')
self.checkModule('doctest')
# Silence Py3k warning
rfc822 = import_module('rfc822', deprecated=True)
self.checkModule('rfc822', rfc822)
self.checkModule('difflib') | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_decorators(self):
# XXX: See comment in pyclbr_input.py for a test that would fail
# if it were not commented out.
#
self.checkModule('test.pyclbr_input') | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_others(self):
cm = self.checkModule | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_main():
run_unittest(PyclbrTest) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def build_get_request(
resource_group_name: str,
managed_instance_name: str,
database_name: str,
query_id: str,
subscription_id: str,
**kwargs: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def build_list_by_query_request(
resource_group_name: str,
managed_instance_name: str,
database_name: str,
query_id: str,
subscription_id: str,
*,
start_time: Optional[str] = None,
end_time: Optional[str] = None,
interval: Optional[Union[str, "_models.QueryTimeGrainType"]] = None,
**kwargs: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get(
self,
resource_group_name: str,
managed_instance_name: str,
database_name: str,
query_id: str,
**kwargs: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def list_by_query(
self,
resource_group_name: str,
managed_instance_name: str,
database_name: str,
query_id: str,
start_time: Optional[str] = None,
end_time: Optional[str] = None,
interval: Optional[Union[str, "_models.QueryTimeGrainType"]] = None,
**kwargs: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
if not next_link: | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def extract_data(pipeline_response):
deserialized = self._deserialize("ManagedInstanceQueryStatistics", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link or None, iter(list_of_elem) | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |