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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3369a3926251fd182ecd59d70c903fa3b85b6eef
| 175
|
py
|
Python
|
test/app_config.py
|
timgates42/r3
|
cc6b4eb55c7ae30a8f75af2be165504565dbeb79
|
[
"Unlicense",
"MIT"
] | 49
|
2015-01-06T19:10:41.000Z
|
2021-08-01T03:39:39.000Z
|
test/app_config.py
|
timgates42/r3
|
cc6b4eb55c7ae30a8f75af2be165504565dbeb79
|
[
"Unlicense",
"MIT"
] | 3
|
2015-03-30T12:37:00.000Z
|
2021-06-09T20:31:54.000Z
|
test/app_config.py
|
timgates42/r3
|
cc6b4eb55c7ae30a8f75af2be165504565dbeb79
|
[
"Unlicense",
"MIT"
] | 12
|
2015-02-27T13:51:09.000Z
|
2021-06-09T20:30:59.000Z
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
INPUT_STREAMS = [
'test.count_words_stream.CountWordsStream'
]
REDUCERS = [
'test.count_words_reducer.CountWordsReducer'
]
| 15.909091
| 48
| 0.691429
| 19
| 175
| 6.105263
| 0.842105
| 0.155172
| 0.241379
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.006711
| 0.148571
| 175
| 10
| 49
| 17.5
| 0.771812
| 0.217143
| 0
| 0
| 0
| 0
| 0.607407
| 0.607407
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 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
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
6824a2fa9d80c6be254b1f38937236fb5bc57b90
| 3,667
|
py
|
Python
|
fonts/romfonts/vga1_8x8.py
|
slabua/st7789py_mpy
|
31e6f94592563e2b5ad716c48486e605ca3911bb
|
[
"MIT"
] | 153
|
2020-02-02T11:03:14.000Z
|
2022-03-30T05:47:07.000Z
|
fonts/bitmap/vga1_8x8.py
|
skylin008/st7789_mpy
|
f304991fc5558be653df5f0de928494b85cbc60d
|
[
"MIT"
] | 58
|
2020-04-11T23:23:02.000Z
|
2022-03-26T20:45:23.000Z
|
fonts/bitmap/vga1_8x8.py
|
skylin008/st7789_mpy
|
f304991fc5558be653df5f0de928494b85cbc60d
|
[
"MIT"
] | 50
|
2020-02-02T11:05:23.000Z
|
2022-03-22T15:24:42.000Z
|
"""converted from vga_8x8.bin """
WIDTH = 8
HEIGHT = 8
FIRST = 0x20
LAST = 0x7f
_FONT =\
b'\x00\x00\x00\x00\x00\x00\x00\x00'\
b'\x18\x3c\x3c\x18\x18\x00\x18\x00'\
b'\x66\x66\x24\x00\x00\x00\x00\x00'\
b'\x6c\x6c\xfe\x6c\xfe\x6c\x6c\x00'\
b'\x18\x3e\x60\x3c\x06\x7c\x18\x00'\
b'\x00\xc6\xcc\x18\x30\x66\xc6\x00'\
b'\x38\x6c\x38\x76\xdc\xcc\x76\x00'\
b'\x18\x18\x30\x00\x00\x00\x00\x00'\
b'\x0c\x18\x30\x30\x30\x18\x0c\x00'\
b'\x30\x18\x0c\x0c\x0c\x18\x30\x00'\
b'\x00\x66\x3c\xff\x3c\x66\x00\x00'\
b'\x00\x18\x18\x7e\x18\x18\x00\x00'\
b'\x00\x00\x00\x00\x00\x18\x18\x30'\
b'\x00\x00\x00\x7e\x00\x00\x00\x00'\
b'\x00\x00\x00\x00\x00\x18\x18\x00'\
b'\x06\x0c\x18\x30\x60\xc0\x80\x00'\
b'\x38\x6c\xc6\xd6\xc6\x6c\x38\x00'\
b'\x18\x38\x18\x18\x18\x18\x7e\x00'\
b'\x7c\xc6\x06\x1c\x30\x66\xfe\x00'\
b'\x7c\xc6\x06\x3c\x06\xc6\x7c\x00'\
b'\x1c\x3c\x6c\xcc\xfe\x0c\x1e\x00'\
b'\xfe\xc0\xc0\xfc\x06\xc6\x7c\x00'\
b'\x38\x60\xc0\xfc\xc6\xc6\x7c\x00'\
b'\xfe\xc6\x0c\x18\x30\x30\x30\x00'\
b'\x7c\xc6\xc6\x7c\xc6\xc6\x7c\x00'\
b'\x7c\xc6\xc6\x7e\x06\x0c\x78\x00'\
b'\x00\x18\x18\x00\x00\x18\x18\x00'\
b'\x00\x18\x18\x00\x00\x18\x18\x30'\
b'\x06\x0c\x18\x30\x18\x0c\x06\x00'\
b'\x00\x00\x7e\x00\x00\x7e\x00\x00'\
b'\x60\x30\x18\x0c\x18\x30\x60\x00'\
b'\x7c\xc6\x0c\x18\x18\x00\x18\x00'\
b'\x7c\xc6\xde\xde\xde\xc0\x78\x00'\
b'\x38\x6c\xc6\xfe\xc6\xc6\xc6\x00'\
b'\xfc\x66\x66\x7c\x66\x66\xfc\x00'\
b'\x3c\x66\xc0\xc0\xc0\x66\x3c\x00'\
b'\xf8\x6c\x66\x66\x66\x6c\xf8\x00'\
b'\xfe\x62\x68\x78\x68\x62\xfe\x00'\
b'\xfe\x62\x68\x78\x68\x60\xf0\x00'\
b'\x3c\x66\xc0\xc0\xce\x66\x3a\x00'\
b'\xc6\xc6\xc6\xfe\xc6\xc6\xc6\x00'\
b'\x3c\x18\x18\x18\x18\x18\x3c\x00'\
b'\x1e\x0c\x0c\x0c\xcc\xcc\x78\x00'\
b'\xe6\x66\x6c\x78\x6c\x66\xe6\x00'\
b'\xf0\x60\x60\x60\x62\x66\xfe\x00'\
b'\xc6\xee\xfe\xfe\xd6\xc6\xc6\x00'\
b'\xc6\xe6\xf6\xde\xce\xc6\xc6\x00'\
b'\x7c\xc6\xc6\xc6\xc6\xc6\x7c\x00'\
b'\xfc\x66\x66\x7c\x60\x60\xf0\x00'\
b'\x7c\xc6\xc6\xc6\xc6\xce\x7c\x0e'\
b'\xfc\x66\x66\x7c\x6c\x66\xe6\x00'\
b'\x3c\x66\x30\x18\x0c\x66\x3c\x00'\
b'\x7e\x7e\x5a\x18\x18\x18\x3c\x00'\
b'\xc6\xc6\xc6\xc6\xc6\xc6\x7c\x00'\
b'\xc6\xc6\xc6\xc6\xc6\x6c\x38\x00'\
b'\xc6\xc6\xc6\xd6\xd6\xfe\x6c\x00'\
b'\xc6\xc6\x6c\x38\x6c\xc6\xc6\x00'\
b'\x66\x66\x66\x3c\x18\x18\x3c\x00'\
b'\xfe\xc6\x8c\x18\x32\x66\xfe\x00'\
b'\x3c\x30\x30\x30\x30\x30\x3c\x00'\
b'\xc0\x60\x30\x18\x0c\x06\x02\x00'\
b'\x3c\x0c\x0c\x0c\x0c\x0c\x3c\x00'\
b'\x10\x38\x6c\xc6\x00\x00\x00\x00'\
b'\x00\x00\x00\x00\x00\x00\x00\xff'\
b'\x30\x18\x0c\x00\x00\x00\x00\x00'\
b'\x00\x00\x78\x0c\x7c\xcc\x76\x00'\
b'\xe0\x60\x7c\x66\x66\x66\xdc\x00'\
b'\x00\x00\x7c\xc6\xc0\xc6\x7c\x00'\
b'\x1c\x0c\x7c\xcc\xcc\xcc\x76\x00'\
b'\x00\x00\x7c\xc6\xfe\xc0\x7c\x00'\
b'\x3c\x66\x60\xf8\x60\x60\xf0\x00'\
b'\x00\x00\x76\xcc\xcc\x7c\x0c\xf8'\
b'\xe0\x60\x6c\x76\x66\x66\xe6\x00'\
b'\x18\x00\x38\x18\x18\x18\x3c\x00'\
b'\x06\x00\x06\x06\x06\x66\x66\x3c'\
b'\xe0\x60\x66\x6c\x78\x6c\xe6\x00'\
b'\x38\x18\x18\x18\x18\x18\x3c\x00'\
b'\x00\x00\xec\xfe\xd6\xd6\xd6\x00'\
b'\x00\x00\xdc\x66\x66\x66\x66\x00'\
b'\x00\x00\x7c\xc6\xc6\xc6\x7c\x00'\
b'\x00\x00\xdc\x66\x66\x7c\x60\xf0'\
b'\x00\x00\x76\xcc\xcc\x7c\x0c\x1e'\
b'\x00\x00\xdc\x76\x60\x60\xf0\x00'\
b'\x00\x00\x7e\xc0\x7c\x06\xfc\x00'\
b'\x30\x30\xfc\x30\x30\x36\x1c\x00'\
b'\x00\x00\xcc\xcc\xcc\xcc\x76\x00'\
b'\x00\x00\xc6\xc6\xc6\x6c\x38\x00'\
b'\x00\x00\xc6\xd6\xd6\xfe\x6c\x00'\
b'\x00\x00\xc6\x6c\x38\x6c\xc6\x00'\
b'\x00\x00\xc6\xc6\xc6\x7e\x06\xfc'\
b'\x00\x00\x7e\x4c\x18\x32\x7e\x00'\
b'\x0e\x18\x18\x70\x18\x18\x0e\x00'\
b'\x18\x18\x18\x18\x18\x18\x18\x00'\
b'\x70\x18\x18\x0e\x18\x18\x70\x00'\
b'\x76\xdc\x00\x00\x00\x00\x00\x00'\
b'\x00\x10\x38\x6c\xc6\xc6\xfe\x00'\
FONT = memoryview(_FONT)
| 34.92381
| 36
| 0.675484
| 881
| 3,667
| 2.808173
| 0.07151
| 0.139046
| 0.127324
| 0.116411
| 0.523444
| 0.363379
| 0.271221
| 0.139046
| 0.056589
| 0.036378
| 0
| 0.324317
| 0.032179
| 3,667
| 104
| 37
| 35.259615
| 0.372781
| 0.00709
| 0
| 0
| 0
| 0
| 0.845349
| 0.845349
| 0
| 0
| 0.002201
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
685046820784a9cb78c955dd0cd8a3379cf212b2
| 70,880
|
py
|
Python
|
src/test/subscriber/subscriberTest.py
|
huseyinbolt/cord-tester
|
ed9b79916e6326a45bfaf3227b8ff922d76df4f1
|
[
"ECL-2.0",
"Apache-2.0"
] | null | null | null |
src/test/subscriber/subscriberTest.py
|
huseyinbolt/cord-tester
|
ed9b79916e6326a45bfaf3227b8ff922d76df4f1
|
[
"ECL-2.0",
"Apache-2.0"
] | null | null | null |
src/test/subscriber/subscriberTest.py
|
huseyinbolt/cord-tester
|
ed9b79916e6326a45bfaf3227b8ff922d76df4f1
|
[
"ECL-2.0",
"Apache-2.0"
] | null | null | null |
# Copyright 2017-present Open Networking Foundation
#
# 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.
#
# Copyright 2016-present Ciena Corporation
#
# 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 unittest
from nose.tools import *
from nose.twistedtools import reactor, deferred
from twisted.internet import defer
import time, monotonic
import os, sys
import tempfile
import random
import threading
from Stats import Stats
from OnosCtrl import OnosCtrl
from DHCP import DHCPTest
from EapTLS import TLSAuthTest
from Channels import Channels, IgmpChannel
from subscriberDb import SubscriberDB
from threadPool import ThreadPool
from portmaps import g_subscriber_port_map
from OltConfig import *
from CordContainer import *
from CordTestServer import cord_test_radius_restart
from CordLogger import CordLogger
from CordTestUtils import log_test as log
import copy
log.setLevel('INFO')
DEFAULT_NO_CHANNELS = 1
class Subscriber(Channels):
PORT_TX_DEFAULT = 2
PORT_RX_DEFAULT = 1
INTF_TX_DEFAULT = 'veth2'
INTF_RX_DEFAULT = 'veth0'
STATS_RX = 0
STATS_TX = 1
STATS_JOIN = 2
STATS_LEAVE = 3
SUBSCRIBER_SERVICES = 'DHCP IGMP TLS'
def __init__(self, name = 'sub', service = SUBSCRIBER_SERVICES, port_map = None,
num = 1, channel_start = 0,
tx_port = PORT_TX_DEFAULT, rx_port = PORT_RX_DEFAULT,
iface = INTF_RX_DEFAULT, iface_mcast = INTF_TX_DEFAULT,
mcast_cb = None, loginType = 'wireless'):
self.tx_port = tx_port
self.rx_port = rx_port
self.port_map = port_map or g_subscriber_port_map
try:
self.tx_intf = self.port_map[tx_port]
self.rx_intf = self.port_map[rx_port]
except:
self.tx_intf = self.port_map[self.PORT_TX_DEFAULT]
self.rx_intf = self.port_map[self.PORT_RX_DEFAULT]
Channels.__init__(self, num, channel_start = channel_start,
iface = self.rx_intf, iface_mcast = self.tx_intf, mcast_cb = mcast_cb)
self.name = name
self.service = service
self.service_map = {}
services = self.service.strip().split(' ')
for s in services:
self.service_map[s] = True
self.loginType = loginType
##start streaming channels
self.join_map = {}
##accumulated join recv stats
self.join_rx_stats = Stats()
def has_service(self, service):
if self.service_map.has_key(service):
return self.service_map[service]
if self.service_map.has_key(service.upper()):
return self.service_map[service.upper()]
return False
def channel_join_update(self, chan, join_time):
self.join_map[chan] = ( Stats(), Stats(), Stats(), Stats() )
self.channel_update(chan, self.STATS_JOIN, 1, t = join_time)
def channel_join(self, chan = 0, delay = 2):
'''Join a channel and create a send/recv stats map'''
if self.join_map.has_key(chan):
del self.join_map[chan]
self.delay = delay
chan, join_time = self.join(chan)
self.channel_join_update(chan, join_time)
return chan
def channel_join_next(self, delay = 2):
'''Joins the next channel leaving the last channel'''
if self.last_chan:
if self.join_map.has_key(self.last_chan):
del self.join_map[self.last_chan]
self.delay = delay
chan, join_time = self.join_next()
self.channel_join_update(chan, join_time)
return chan
def channel_jump(self, delay = 2):
'''Jumps randomly to the next channel leaving the last channel'''
log.info("Jumps randomly to the next channel leaving the last channel")
if self.last_chan is not None:
if self.join_map.has_key(self.last_chan):
del self.join_map[self.last_chan]
self.delay = delay
chan, join_time = self.jump()
self.channel_join_update(chan, join_time)
return chan
def channel_leave(self, chan = 0):
if self.join_map.has_key(chan):
del self.join_map[chan]
self.leave(chan)
def channel_update(self, chan, stats_type, packets, t=0):
if type(chan) == type(0):
chan_list = (chan,)
else:
chan_list = chan
for c in chan_list:
if self.join_map.has_key(c):
self.join_map[c][stats_type].update(packets = packets, t = t)
def channel_receive(self, chan, cb = None, count = 1):
log.info('Subscriber %s receiving from group %s, channel %d' %(self.name, self.gaddr(chan), chan))
self.recv(chan, cb = cb, count = count)
def recv_channel_cb(self, pkt):
##First verify that we have received the packet for the joined instance
log.debug('Packet received for group %s, subscriber %s' %(pkt[IP].dst, self.name))
chan = self.caddr(pkt[IP].dst)
assert_equal(chan in self.join_map.keys(), True)
recv_time = monotonic.monotonic() * 1000000
join_time = self.join_map[chan][self.STATS_JOIN].start
delta = recv_time - join_time
self.join_rx_stats.update(packets=1, t = delta, usecs = True)
self.channel_update(chan, self.STATS_RX, 1, t = delta)
log.debug('Packet received in %.3f usecs for group %s after join' %(delta, pkt[IP].dst))
class subscriber_pool:
def __init__(self, subscriber, test_cbs, test_status):
self.subscriber = subscriber
self.test_cbs = test_cbs
self.test_status = test_status
def pool_cb(self):
for cb in self.test_cbs:
if cb:
self.test_status = cb(self.subscriber)
# cb(self.subscriber)
if self.test_status is not True:
log.info('This service is failed and other services will not run for this subscriber')
break
log.info('This Subscriber is tested for multiple service elgibility ')
self.test_status = True
class subscriber_exchange(CordLogger):
apps = [ 'org.opencord.aaa', 'org.onosproject.dhcp' ]
dhcp_app = 'org.onosproject.dhcp'
olt_apps = [ 'org.opencord.igmp', 'org.opencord.cordmcast' ]
dhcp_server_config = {
"ip": "10.1.11.50",
"mac": "ca:fe:ca:fe:ca:fe",
"subnet": "255.255.252.0",
"broadcast": "10.1.11.255",
"router": "10.1.8.1",
"domain": "8.8.8.8",
"ttl": "63",
"delay": "2",
"startip": "10.1.11.51",
"endip": "10.1.11.100"
}
aaa_loaded = False
INTF_TX_DEFAULT = 'veth2'
INTF_RX_DEFAULT = 'veth0'
SUBSCRIBER_TIMEOUT = 20
CLIENT_CERT = """-----BEGIN CERTIFICATE-----
MIICuDCCAiGgAwIBAgIBAjANBgkqhkiG9w0BAQUFADCBizELMAkGA1UEBhMCVVMx
CzAJBgNVBAgTAkNBMRIwEAYDVQQHEwlTb21ld2hlcmUxEzARBgNVBAoTCkNpZW5h
IEluYy4xHjAcBgkqhkiG9w0BCQEWD2FkbWluQGNpZW5hLmNvbTEmMCQGA1UEAxMd
RXhhbXBsZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMTYwNjA2MjExMjI3WhcN
MTcwNjAxMjExMjI3WjBnMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNV
BAoTCkNpZW5hIEluYy4xFzAVBgNVBAMUDnVzZXJAY2llbmEuY29tMR0wGwYJKoZI
hvcNAQkBFg51c2VyQGNpZW5hLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC
gYEAwvXiSzb9LZ6c7uNziUfKvoHO7wu/uiFC5YUpXbmVGuGZizbVrny0xnR85Dfe
+9R4diansfDhIhzOUl1XjN3YDeSS9OeF5YWNNE8XDhlz2d3rVzaN6hIhdotBkUjg
rUewjTg5OFR31QEyG3v8xR3CLgiE9xQELjZbSA07pD79zuUCAwEAAaNPME0wEwYD
VR0lBAwwCgYIKwYBBQUHAwIwNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL3d3dy5l
eGFtcGxlLmNvbS9leGFtcGxlX2NhLmNybDANBgkqhkiG9w0BAQUFAAOBgQDAjkrY
6tDChmKbvr8w6Du/t8vHjTCoCIocHTN0qzWOeb1YsAGX89+TrWIuO1dFyYd+Z0KC
PDKB5j/ygml9Na+AklSYAVJIjvlzXKZrOaPmhZqDufi+rXWti/utVqY4VMW2+HKC
nXp37qWeuFLGyR1519Y1d6F/5XzqmvbwURuEug==
-----END CERTIFICATE-----"""
CLIENT_CERT_INVALID = '''-----BEGIN CERTIFICATE-----
MIIDvTCCAqWgAwIBAgIBAjANBgkqhkiG9w0BAQUFADCBizELMAkGA1UEBhMCVVMx
CzAJBgNVBAgTAkNBMRIwEAYDVQQHEwlTb21ld2hlcmUxEzARBgNVBAoTCkNpZW5h
IEluYy4xHjAcBgkqhkiG9w0BCQEWD2FkbWluQGNpZW5hLmNvbTEmMCQGA1UEAxMd
RXhhbXBsZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMTYwMzExMTg1MzM2WhcN
MTcwMzA2MTg1MzM2WjBnMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNV
BAoTCkNpZW5hIEluYy4xFzAVBgNVBAMUDnVzZXJAY2llbmEuY29tMR0wGwYJKoZI
hvcNAQkBFg51c2VyQGNpZW5hLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAOxemcBsPn9tZsCa5o2JA6sQDC7A6JgCNXXl2VFzKLNNvB9PS6D7ZBsQ
5An0zEDMNzi51q7lnrYg1XyiE4S8FzMGAFr94RlGMQJUbRD9V/oqszMX4k++iAOK
tIA1gr3x7Zi+0tkjVSVzXTmgNnhChAamdMsjYUG5+CY9WAicXyy+VEV3zTphZZDR
OjcjEp4m/TSXVPYPgYDXI40YZKX5BdvqykWtT/tIgZb48RS1NPyN/XkCYzl3bv21
qx7Mc0fcEbsJBIIRYTUkfxnsilcnmLxSYO+p+DZ9uBLBzcQt+4Rd5pLSfi21WM39
2Z2oOi3vs/OYAPAqgmi2JWOv3mePa/8CAwEAAaNPME0wEwYDVR0lBAwwCgYIKwYB
BQUHAwIwNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL3d3dy5leGFtcGxlLmNvbS9l
eGFtcGxlX2NhLmNybDANBgkqhkiG9w0BAQUFAAOCAQEALBzMPDTIB6sLyPl0T6JV
MjOkyldAVhXWiQsTjaGQGJUUe1cmUJyZbUZEc13MygXMPOM4x7z6VpXGuq1c/Vxn
VzQ2fNnbJcIAHi/7G8W5/SQfPesIVDsHTEc4ZspPi5jlS/MVX3HOC+BDbOjdbwqP
RX0JEr+uOyhjO+lRxG8ilMRACoBUbw1eDuVDoEBgErSUC44pq5ioDw2xelc+Y6hQ
dmtYwfY0DbvwxHtA495frLyPcastDiT/zre7NL51MyUDPjjYjghNQEwvu66IKbQ3
T1tJBrgI7/WI+dqhKBFolKGKTDWIHsZXQvZ1snGu/FRYzg1l+R/jT8cRB9BDwhUt
yg==
-----END CERTIFICATE-----'''
def setUp(self):
'''Load the OLT config and activate relevant apps'''
super(subscriber_exchange, self).setUp()
self.olt = OltConfig()
self.port_map, _ = self.olt.olt_port_map()
##if no olt config, fall back to ovs port map
if not self.port_map:
self.port_map = g_subscriber_port_map
else:
log.info('Using OLT Port configuration for test setup')
log.info('Configuring CORD OLT access device information')
OnosCtrl.cord_olt_config(self.olt)
self.activate_apps(self.olt_apps)
self.activate_apps(self.apps)
def tearDown(self):
'''Deactivate the dhcp app'''
super(subscriber_exchange, self).tearDown()
for app in self.apps:
onos_ctrl = OnosCtrl(app)
onos_ctrl.deactivate()
log.info('Restarting the Radius container in the setup after running every subscriber test cases by default')
cord_test_radius_restart()
#os.system('ifconfig '+INTF_RX_DEFAULT+' up')
def activate_apps(self, apps):
for app in apps:
onos_ctrl = OnosCtrl(app)
status, _ = onos_ctrl.activate()
assert_equal(status, True)
time.sleep(2)
def onos_aaa_load(self):
if self.aaa_loaded:
return
OnosCtrl.aaa_load_config()
self.aaa_loaded = True
def onos_dhcp_table_load(self, config = None):
dhcp_dict = {'apps' : { 'org.onosproject.dhcp' : { 'dhcp' : copy.copy(self.dhcp_server_config) } } }
dhcp_config = dhcp_dict['apps']['org.onosproject.dhcp']['dhcp']
if config:
for k in config.keys():
if dhcp_config.has_key(k):
dhcp_config[k] = config[k]
self.onos_load_config('org.onosproject.dhcp', dhcp_dict)
def send_recv(self, mac = None, update_seed = False, validate = True):
cip, sip = self.dhcp.discover(mac = mac, update_seed = update_seed)
if validate:
assert_not_equal(cip, None)
assert_not_equal(sip, None)
log.info('Got dhcp client IP %s from server %s for mac %s' %
(cip, sip, self.dhcp.get_mac(cip)[0]))
return cip,sip
def onos_load_config(self, app, config):
status, code = OnosCtrl.config(config)
if status is False:
log.info('JSON config request for app %s returned status %d' %(app, code))
assert_equal(status, True)
time.sleep(2)
def dhcp_sndrcv(self, dhcp, update_seed = False):
cip, sip = dhcp.discover(update_seed = update_seed)
assert_not_equal(cip, None)
assert_not_equal(sip, None)
log.info('Got dhcp client IP %s from server %s for mac %s' %
(cip, sip, dhcp.get_mac(cip)[0]))
return cip,sip
def dhcp_request(self, subscriber, seed_ip = '10.10.10.1', update_seed = False):
config = {'startip':'10.10.10.20', 'endip':'10.10.10.200',
'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe",
'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'}
self.onos_dhcp_table_load(config)
dhcp = DHCPTest(seed_ip = seed_ip, iface = subscriber.iface)
cip, sip = self.dhcp_sndrcv(dhcp, update_seed = update_seed)
return cip, sip
def recv_channel_cb(self, pkt):
##First verify that we have received the packet for the joined instance
chan = self.subscriber.caddr(pkt[IP].dst)
assert_equal(chan in self.subscriber.join_map.keys(), True)
recv_time = monotonic.monotonic() * 1000000
join_time = self.subscriber.join_map[chan][self.subscriber.STATS_JOIN].start
delta = recv_time - join_time
self.subscriber.join_rx_stats.update(packets=1, t = delta, usecs = True)
self.subscriber.channel_update(chan, self.subscriber.STATS_RX, 1, t = delta)
log.debug('Packet received in %.3f usecs for group %s after join' %(delta, pkt[IP].dst))
self.test_status = True
def tls_verify(self, subscriber):
if subscriber.has_service('TLS'):
time.sleep(2)
tls = TLSAuthTest()
log.info('Running subscriber %s tls auth test' %subscriber.name)
tls.runTest()
self.test_status = True
return self.test_status
def dhcp_verify(self, subscriber):
cip, sip = self.dhcp_request(subscriber, update_seed = True)
log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip))
subscriber.src_list = [cip]
self.test_status = True
return self.test_status
def dhcp_jump_verify(self, subscriber):
cip, sip = self.dhcp_request(subscriber, seed_ip = '10.10.200.1')
log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip))
subscriber.src_list = [cip]
self.test_status = True
return self.test_status
def dhcp_next_verify(self, subscriber):
cip, sip = self.dhcp_request(subscriber, seed_ip = '10.10.150.1')
log.info('Subscriber %s got client ip %s from server %s' %(subscriber.name, cip, sip))
subscriber.src_list = [cip]
self.test_status = True
return self.test_status
def igmp_verify(self, subscriber):
chan = 0
if subscriber.has_service('IGMP'):
for i in range(5):
log.info('Joining channel %d for subscriber %s' %(chan, subscriber.name))
subscriber.channel_join(chan, delay = 0)
subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 1)
log.info('Leaving channel %d for subscriber %s' %(chan, subscriber.name))
subscriber.channel_leave(chan)
time.sleep(3)
log.info('Interface %s Join RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name,subscriber.join_rx_stats))
self.test_status = True
return self.test_status
def igmp_verify_multiChannel(self, subscriber):
if subscriber.has_service('IGMP'):
for chan in range(DEFAULT_NO_CHANNELS):
log.info('Joining channel %d for subscriber %s' %(chan, subscriber.name))
subscriber.channel_join(chan, delay = 0)
subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 1)
log.info('Leaving channel %d for subscriber %s' %(chan, subscriber.name))
subscriber.channel_leave(chan)
time.sleep(3)
log.info('Interface %s Join RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name,subscriber.join_rx_stats))
self.test_status = True
return self.test_status
def igmp_jump_verify(self, subscriber):
if subscriber.has_service('IGMP'):
for i in xrange(subscriber.num):
log.info('Subscriber %s jumping channel' %subscriber.name)
chan = subscriber.channel_jump(delay=0)
subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count = 1)
log.info('Verified receive for channel %d, subscriber %s' %(chan, subscriber.name))
time.sleep(3)
log.info('Interface %s Jump RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name, subscriber.join_rx_stats))
self.test_status = True
return self.test_status
def igmp_next_verify(self, subscriber):
if subscriber.has_service('IGMP'):
for i in xrange(subscriber.num):
if i:
chan = subscriber.channel_join_next(delay=0)
else:
chan = subscriber.channel_join(i, delay=0)
log.info('Joined next channel %d for subscriber %s' %(chan, subscriber.name))
subscriber.channel_receive(chan, cb = subscriber.recv_channel_cb, count=1)
log.info('Verified receive for channel %d, subscriber %s' %(chan, subscriber.name))
time.sleep(3)
log.info('Interface %s Join Next RX stats for subscriber %s, %s' %(subscriber.iface, subscriber.name, subscriber.join_rx_stats))
self.test_status = True
return self.test_status
def generate_port_list(self, subscribers, channels):
port_list = []
for i in xrange(subscribers):
if channels > 1:
rx_port = 2*i+1
tx_port = 2*i+2
else:
rx_port = Subscriber.PORT_RX_DEFAULT
tx_port = Subscriber.PORT_TX_DEFAULT
port_list.append((tx_port, rx_port))
return port_list
def subscriber_load(self, create = True, num = 10, num_channels = 1, channel_start = 0, port_list = []):
'''Load the subscriber from the database'''
self.subscriber_db = SubscriberDB(create = create)
if create is True:
self.subscriber_db.generate(num)
self.subscriber_info = self.subscriber_db.read(num)
self.subscriber_list = []
if not port_list:
port_list = self.generate_port_list(num, num_channels)
index = 0
for info in self.subscriber_info:
self.subscriber_list.append(Subscriber(name=info['Name'],
service=info['Service'],
port_map = self.port_map,
num=num_channels,
channel_start = channel_start,
tx_port = port_list[index][0],
rx_port = port_list[index][1]))
if num_channels > 1:
channel_start += num_channels
index += 1
#load the ssm list for all subscriber channels
igmpChannel = IgmpChannel()
ssm_groups = map(lambda sub: sub.channels, self.subscriber_list)
ssm_list = reduce(lambda ssm1, ssm2: ssm1+ssm2, ssm_groups)
igmpChannel.igmp_load_ssm_config(ssm_list)
#load the subscriber to mcast port map for cord
cord_port_map = {}
for sub in self.subscriber_list:
for chan in sub.channels:
cord_port_map[chan] = (sub.tx_port, sub.rx_port)
igmpChannel.cord_port_table_load(cord_port_map)
def subscriber_join_verify( self, num_subscribers = 10, num_channels = 1,
channel_start = 0, cbs = None, port_list = [], negative_subscriber_auth = None):
self.test_status = False
self.num_subscribers = num_subscribers
self.sub_loop_count = num_subscribers
self.subscriber_load(create = True, num = num_subscribers,
num_channels = num_channels, channel_start = channel_start, port_list = port_list)
self.onos_aaa_load()
self.thread_pool = ThreadPool(min(100, self.num_subscribers), queue_size=1, wait_timeout=1)
if cbs and negative_subscriber_auth is None:
cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify)
cbs_negative = cbs
for subscriber in self.subscriber_list:
subscriber.start()
if negative_subscriber_auth is 'half' and self.sub_loop_count%2 is not 0:
cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify)
elif negative_subscriber_auth is 'onethird' and self.sub_loop_count%3 is not 0:
cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify)
else:
cbs = cbs_negative
self.sub_loop_count = self.sub_loop_count - 1
pool_object = subscriber_pool(subscriber, cbs, self.test_status)
self.thread_pool.addTask(pool_object.pool_cb)
self.thread_pool.cleanUpThreads()
for subscriber in self.subscriber_list:
subscriber.stop()
print "self.test_status %s\n"%(self.test_status)
return self.test_status
def tls_invalid_cert(self, subscriber):
if subscriber.has_service('TLS'):
time.sleep(2)
log.info('Running subscriber %s tls auth test' %subscriber.name)
tls = TLSAuthTest(client_cert = self.CLIENT_CERT_INVALID)
tls.runTest()
if tls.failTest == True:
self.test_status = False
return self.test_status
def tls_no_cert(self, subscriber):
if subscriber.has_service('TLS'):
time.sleep(2)
log.info('Running subscriber %s tls auth test' %subscriber.name)
tls = TLSAuthTest(client_cert = '')
tls.runTest()
if tls.failTest == True:
self.test_status = False
return self.test_status
def tls_self_signed_cert(self, subscriber):
if subscriber.has_service('TLS'):
time.sleep(2)
log.info('Running subscriber %s tls auth test' %subscriber.name)
tls = TLSAuthTest(client_cert = self.CLIENT_CERT)
tls.runTest()
if tls.failTest == False:
self.test_status = True
return self.test_status
def tls_Nsubscribers_use_same_valid_cert(self, subscriber):
if subscriber.has_service('TLS'):
time.sleep(2)
log.info('Running subscriber %s tls auth test' %subscriber.name)
num_users = 3
for i in xrange(num_users):
tls = TLSAuthTest(intf = 'veth{}'.format(i*2))
tls.runTest()
if tls.failTest == False:
self.test_status = True
return self.test_status
def dhcp_discover_scenario(self, subscriber):
if subscriber.has_service('DHCP'):
time.sleep(2)
log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name)
t1 = self.subscriber_dhcp_1release()
self.test_status = True
return self.test_status
def subscriber_dhcp_1release(self, iface = INTF_RX_DEFAULT):
config = {'startip':'10.10.100.20', 'endip':'10.10.100.21',
'ip':'10.10.100.2', 'mac': "ca:fe:ca:fe:8a:fe",
'subnet': '255.255.255.0', 'broadcast':'10.10.100.255', 'router':'10.10.100.1'}
self.onos_dhcp_table_load(config)
self.dhcp = DHCPTest(seed_ip = '10.10.100.10', iface = iface)
cip, sip = self.send_recv()
log.info('Releasing ip %s to server %s' %(cip, sip))
assert_equal(self.dhcp.release(cip), True)
log.info('Triggering DHCP discover again after release')
cip2, sip2 = self.send_recv(update_seed = True)
log.info('Verifying released IP was given back on rediscover')
assert_equal(cip, cip2)
log.info('Test done. Releasing ip %s to server %s' %(cip2, sip2))
assert_equal(self.dhcp.release(cip2), True)
def dhcp_client_reboot_scenario(self, subscriber):
if subscriber.has_service('DHCP'):
time.sleep(2)
log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name)
tl = self.subscriber_dhcp_client_request_after_reboot()
self.test_status = True
return self.test_status
def subscriber_dhcp_client_request_after_reboot(self, iface = INTF_RX_DEFAULT):
#''' Client sends DHCP Request after reboot.'''
config = {'startip':'20.20.20.30', 'endip':'20.20.20.69',
'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe",
'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'}
self.onos_dhcp_table_load(config)
self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
cip, sip, mac, lval = self.dhcp.only_discover()
log.info('Got dhcp client IP %s from server %s for mac %s .' %
(cip, sip, mac) )
log.info("Verifying Client 's IP and mac in DHCP Offer packet. Those should not be none, which is expected.")
if (cip == None and mac != None):
log.info("Verified that Client 's IP and mac in DHCP Offer packet are none, which is not expected behavior.")
assert_not_equal(cip, None)
else:
new_cip, new_sip = self.dhcp.only_request(cip, mac)
if new_cip == None:
log.info("Got DHCP server NAK.")
os.system('ifconfig '+iface+' down')
log.info('Client goes down.')
log.info('Delay for 5 seconds.')
time.sleep(5)
os.system('ifconfig '+iface+' up')
log.info('Client is up now.')
new_cip, new_sip = self.dhcp.only_request(cip, mac)
if new_cip == None:
log.info("Got DHCP server NAK.")
assert_not_equal(new_cip, None)
elif new_cip != None:
log.info("Got DHCP ACK.")
def dhcp_client_renew_scenario(self, subscriber):
if subscriber.has_service('DHCP'):
time.sleep(2)
log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name)
tl = self.subscriber_dhcp_client_renew_time()
self.test_status = True
return self.test_status
def subscriber_dhcp_client_renew_time(self, iface = INTF_RX_DEFAULT):
config = {'startip':'20.20.20.30', 'endip':'20.20.20.69',
'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe",
'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'}
self.onos_dhcp_table_load(config)
self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
cip, sip, mac , lval = self.dhcp.only_discover()
log.info('Got dhcp client IP %s from server %s for mac %s .' %
(cip, sip, mac) )
log.info("Verifying Client 's IP and mac in DHCP Offer packet. Those should not be none, which is expected.")
if (cip == None and mac != None):
log.info("Verified that Client 's IP and mac in DHCP Offer packet are none, which is not expected behavior.")
assert_not_equal(cip, None)
elif cip and sip and mac:
log.info("Triggering DHCP Request.")
new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, renew_time = True)
if new_cip and new_sip and lval:
log.info("Client 's Renewal time is :%s",lval)
log.info("Generating delay till renewal time.")
time.sleep(lval)
log.info("Client Sending Unicast DHCP request.")
latest_cip, latest_sip = self.dhcp.only_request(new_cip, mac, unicast = True)
if latest_cip and latest_sip:
log.info("Got DHCP Ack. Lease Renewed for ip %s and mac %s from server %s." %
(latest_cip, mac, latest_sip) )
elif latest_cip == None:
log.info("Got DHCP NAK. Lease not renewed.")
elif new_cip == None or new_sip == None or lval == None:
log.info("Got DHCP NAK.")
def dhcp_server_reboot_scenario(self, subscriber):
if subscriber.has_service('DHCP'):
time.sleep(2)
log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name)
tl = self.subscriber_dhcp_server_after_reboot()
self.test_status = True
return self.test_status
def subscriber_dhcp_server_after_reboot(self, iface = INTF_RX_DEFAULT):
''' DHCP server goes down.'''
config = {'startip':'20.20.20.30', 'endip':'20.20.20.69',
'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe",
'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'}
self.onos_dhcp_table_load(config)
self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
cip, sip, mac, lval = self.dhcp.only_discover()
log.info('Got dhcp client IP %s from server %s for mac %s .' %
(cip, sip, mac) )
log.info("Verifying Client 's IP and mac in DHCP Offer packet. Those should not be none, which is expected.")
if (cip == None and mac != None):
log.info("Verified that Client 's IP and mac in DHCP Offer packet are none, which is not expected behavior.")
assert_not_equal(cip, None)
else:
new_cip, new_sip = self.dhcp.only_request(cip, mac)
if new_cip == None:
log.info("Got DHCP server NAK.")
assert_not_equal(new_cip, None)
log.info('Getting DHCP server Down.')
onos_ctrl = OnosCtrl(self.dhcp_app)
onos_ctrl.deactivate()
for i in range(0,4):
log.info("Sending DHCP Request.")
log.info('')
new_cip, new_sip = self.dhcp.only_request(cip, mac)
if new_cip == None and new_sip == None:
log.info('')
log.info("DHCP Request timed out.")
elif new_cip and new_sip:
log.info("Got Reply from DHCP server.")
assert_equal(new_cip,None) #Neagtive Test Case
log.info('Getting DHCP server Up.')
# self.activate_apps(self.dhcp_app)
onos_ctrl = OnosCtrl(self.dhcp_app)
status, _ = onos_ctrl.activate()
assert_equal(status, True)
time.sleep(3)
for i in range(0,4):
log.info("Sending DHCP Request after DHCP server is up.")
log.info('')
new_cip, new_sip = self.dhcp.only_request(cip, mac)
if new_cip == None and new_sip == None:
log.info('')
log.info("DHCP Request timed out.")
elif new_cip and new_sip:
log.info("Got Reply from DHCP server.")
assert_equal(new_cip,None) #Neagtive Test Case
def dhcp_client_rebind_scenario(self, subscriber):
if subscriber.has_service('DHCP'):
time.sleep(2)
log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name)
tl = self.subscriber_dhcp_client_rebind_time()
self.test_status = True
return self.test_status
def subscriber_dhcp_client_rebind_time(self, iface = INTF_RX_DEFAULT):
config = {'startip':'20.20.20.30', 'endip':'20.20.20.69',
'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe",
'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'}
self.onos_dhcp_table_load(config)
self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
cip, sip, mac, lval = self.dhcp.only_discover()
log.info('Got dhcp client IP %s from server %s for mac %s .' %
(cip, sip, mac) )
log.info("Verifying Client 's IP and mac in DHCP Offer packet. Those should not be none, which is expected.")
if (cip == None and mac != None):
log.info("Verified that Client 's IP and mac in DHCP Offer packet are none, which is not expected behavior.")
assert_not_equal(cip, None)
elif cip and sip and mac:
log.info("Triggering DHCP Request.")
new_cip, new_sip, lval = self.dhcp.only_request(cip, mac, rebind_time = True)
if new_cip and new_sip and lval:
log.info("Client 's Rebind time is :%s",lval)
log.info("Generating delay till rebind time.")
time.sleep(lval)
log.info("Client Sending broadcast DHCP requests for renewing lease or for getting new ip.")
self.dhcp.after_T2 = True
for i in range(0,4):
latest_cip, latest_sip = self.dhcp.only_request(new_cip, mac)
if latest_cip and latest_sip:
log.info("Got DHCP Ack. Lease Renewed for ip %s and mac %s from server %s." %
(latest_cip, mac, latest_sip) )
break
elif latest_cip == None:
log.info("Got DHCP NAK. Lease not renewed.")
assert_not_equal(latest_cip, None)
elif new_cip == None or new_sip == None or lval == None:
log.info("Got DHCP NAK.Lease not Renewed.")
def dhcp_starvation_scenario(self, subscriber):
if subscriber.has_service('DHCP'):
time.sleep(2)
log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name)
tl = self.subscriber_dhcp_starvation()
self.test_status = True
return self.test_status
def subscriber_dhcp_starvation(self, iface = INTF_RX_DEFAULT):
'''DHCP starve'''
config = {'startip':'182.17.0.20', 'endip':'182.17.0.69',
'ip':'182.17.0.2', 'mac': "ca:fe:c3:fe:ca:fe",
'subnet': '255.255.255.0', 'broadcast':'182.17.0.255', 'router':'182.17.0.1'}
self.onos_dhcp_table_load(config)
self.dhcp = DHCPTest(seed_ip = '182.17.0.1', iface = iface)
log.info('Verifying 1 ')
for x in xrange(50):
mac = RandMAC()._fix()
self.send_recv(mac = mac)
log.info('Verifying 2 ')
cip, sip = self.send_recv(update_seed = True, validate = False)
assert_equal(cip, None)
assert_equal(sip, None)
def dhcp_same_client_multi_discovers_scenario(self, subscriber):
if subscriber.has_service('DHCP'):
time.sleep(2)
log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name)
tl = self.subscriber_dhcp_same_client_multiple_discover()
self.test_status = True
return self.test_status
def subscriber_dhcp_same_client_multiple_discover(self, iface = INTF_RX_DEFAULT):
''' DHCP Client sending multiple discover . '''
config = {'startip':'10.10.10.20', 'endip':'10.10.10.69',
'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe",
'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'}
self.onos_dhcp_table_load(config)
self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
cip, sip, mac, lval = self.dhcp.only_discover()
log.info('Got dhcp client IP %s from server %s for mac %s . Not going to send DHCPREQUEST.' %
(cip, sip, mac) )
log.info('Triggering DHCP discover again.')
new_cip, new_sip, new_mac , lval = self.dhcp.only_discover()
if cip == new_cip:
log.info('Got same ip for 2nd DHCP discover for client IP %s from server %s for mac %s. Triggering DHCP Request. '
% (new_cip, new_sip, new_mac) )
elif cip != new_cip:
log.info('Ip after 1st discover %s' %cip)
log.info('Map after 2nd discover %s' %new_cip)
assert_equal(cip, new_cip)
def dhcp_same_client_multi_request_scenario(self, subscriber):
if subscriber.has_service('DHCP'):
time.sleep(2)
log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name)
tl = self.subscriber_dhcp_same_client_multiple_request()
self.test_status = True
return self.test_status
def subscriber_dhcp_same_client_multiple_request(self, iface = INTF_RX_DEFAULT):
''' DHCP Client sending multiple repeat DHCP requests. '''
config = {'startip':'10.10.10.20', 'endip':'10.10.10.69',
'ip':'10.10.10.2', 'mac': "ca:fe:ca:fe:ca:fe",
'subnet': '255.255.255.0', 'broadcast':'10.10.10.255', 'router':'10.10.10.1'}
self.onos_dhcp_table_load(config)
self.dhcp = DHCPTest(seed_ip = '10.10.10.1', iface = iface)
log.info('Sending DHCP discover and DHCP request.')
cip, sip = self.send_recv()
mac = self.dhcp.get_mac(cip)[0]
log.info("Sending DHCP request again.")
new_cip, new_sip = self.dhcp.only_request(cip, mac)
if (new_cip,new_sip) == (cip,sip):
log.info('Got same ip for 2nd DHCP Request for client IP %s from server %s for mac %s.'
% (new_cip, new_sip, mac) )
elif (new_cip,new_sip):
log.info('No DHCP ACK')
assert_equal(new_cip, None)
assert_equal(new_sip, None)
else:
print "Something went wrong."
def dhcp_client_desired_ip_scenario(self, subscriber):
if subscriber.has_service('DHCP'):
time.sleep(2)
log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name)
tl = self.subscriber_dhcp_client_desired_address()
self.test_status = True
return self.test_status
def subscriber_dhcp_client_desired_address(self, iface = INTF_RX_DEFAULT):
'''DHCP Client asking for desired IP address.'''
config = {'startip':'20.20.20.30', 'endip':'20.20.20.69',
'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe",
'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'}
self.onos_dhcp_table_load(config)
self.dhcp = DHCPTest(seed_ip = '20.20.20.31', iface = iface)
cip, sip, mac , lval = self.dhcp.only_discover(desired = True)
log.info('Got dhcp client IP %s from server %s for mac %s .' %
(cip, sip, mac) )
if cip == self.dhcp.seed_ip:
log.info('Got dhcp client IP %s from server %s for mac %s as desired .' %
(cip, sip, mac) )
elif cip != self.dhcp.seed_ip:
log.info('Got dhcp client IP %s from server %s for mac %s .' %
(cip, sip, mac) )
log.info('The desired ip was: %s .' % self.dhcp.seed_ip)
assert_equal(cip, self.dhcp.seed_ip)
def dhcp_client_request_pkt_with_non_offered_ip_scenario(self, subscriber):
if subscriber.has_service('DHCP'):
time.sleep(2)
log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name)
tl = self.subscriber_dhcp_server_nak_packet()
self.test_status = True
return self.test_status
def subscriber_dhcp_server_nak_packet(self, iface = INTF_RX_DEFAULT):
config = {'startip':'20.20.20.30', 'endip':'20.20.20.69',
'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe",
'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'}
self.onos_dhcp_table_load(config)
self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
cip, sip, mac, lval = self.dhcp.only_discover()
log.info('Got dhcp client IP %s from server %s for mac %s .' %
(cip, sip, mac) )
log.info("Verifying Client 's IP and mac in DHCP Offer packet. Those should not be none, which is expected.")
if (cip == None and mac != None):
log.info("Verified that Client 's IP and mac in DHCP Offer packet are none, which is not expected behavior.")
assert_not_equal(cip, None)
else:
new_cip, new_sip = self.dhcp.only_request('20.20.20.31', mac)
if new_cip == None:
log.info("Got DHCP server NAK.")
assert_equal(new_cip, None) #Negative Test Case
def dhcp_client_requested_out_pool_ip_scenario(self, subscriber):
if subscriber.has_service('DHCP'):
time.sleep(2)
log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name)
tl = self.subscriber_dhcp_client_desired_address_out_of_pool()
self.test_status = True
return self.test_status
def subscriber_dhcp_client_desired_address_out_of_pool(self, iface = INTF_RX_DEFAULT):
'''DHCP Client asking for desired IP address from out of pool.'''
config = {'startip':'20.20.20.30', 'endip':'20.20.20.69',
'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe",
'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'}
self.onos_dhcp_table_load(config)
self.dhcp = DHCPTest(seed_ip = '20.20.20.35', iface = iface)
cip, sip, mac, lval = self.dhcp.only_discover(desired = True)
log.info('Got dhcp client IP %s from server %s for mac %s .' %
(cip, sip, mac) )
if cip == self.dhcp.seed_ip:
log.info('Got dhcp client IP %s from server %s for mac %s as desired .' %
(cip, sip, mac) )
assert_equal(cip, self.dhcp.seed_ip) #Negative Test Case
elif cip != self.dhcp.seed_ip:
log.info('Got dhcp client IP %s from server %s for mac %s .' %
(cip, sip, mac) )
log.info('The desired ip was: %s .' % self.dhcp.seed_ip)
assert_not_equal(cip, self.dhcp.seed_ip)
elif cip == None:
log.info('Got DHCP NAK')
def dhcp_client_specific_lease_scenario(self, subscriber):
if subscriber.has_service('DHCP'):
time.sleep(2)
log.info('Running subscriber %s DHCP rediscover scenario test' %subscriber.name)
tl = self.subscriber_dhcp_specific_lease_packet()
self.test_status = True
return self.test_status
def subscriber_dhcp_specific_lease_packet(self, iface = INTF_RX_DEFAULT):
''' Client sends DHCP Discover packet for particular lease time.'''
config = {'startip':'20.20.20.30', 'endip':'20.20.20.69',
'ip':'20.20.20.2', 'mac': "ca:fe:ca:fe:ca:fe",
'subnet': '255.255.255.0', 'broadcast':'20.20.20.255', 'router':'20.20.20.1'}
self.onos_dhcp_table_load(config)
self.dhcp = DHCPTest(seed_ip = '20.20.20.45', iface = iface)
log.info('Sending DHCP discover with lease time of 700')
cip, sip, mac, lval = self.dhcp.only_discover(lease_time = True)
log.info("Verifying Client 's IP and mac in DHCP Offer packet.")
if (cip == None and mac != None):
log.info("Verified that Client 's IP and mac in DHCP Offer packet are none, which is not expected behavior.")
assert_not_equal(cip, None)
elif lval != 700:
log.info('Getting dhcp client IP %s from server %s for mac %s with lease time %s. That is not 700.' %
(cip, sip, mac, lval) )
assert_not_equal(lval, 700)
def test_subscriber_join_recv_channel(self):
###"""Test subscriber join and receive"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels))
assert_equal(test_status, True)
def test_subscriber_join_jump_channel(self):
###"""Test subscriber join and receive for channel surfing"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_jump_verify, self.igmp_jump_verify),
port_list = self.generate_port_list(num_subscribers, num_channels))
assert_equal(test_status, True)
def test_subscriber_join_next_channel(self):
###"""Test subscriber join next for channels"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_next_verify, self.igmp_next_verify),
port_list = self.generate_port_list(num_subscribers, num_channels))
assert_equal(test_status, True)
#@deferred(SUBSCRIBER_TIMEOUT)
def test_subscriber_authentication_with_invalid_certificate_and_channel_surfing(self):
### """Test subscriber to auth with invalidCertification and join channel"""
num_subscribers = 1
num_channels = 1
df = defer.Deferred()
def sub_auth_invalid_cert(df):
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_invalid_cert, self.dhcp_verify, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all')
assert_equal(test_status, False)
df.callback(0)
reactor.callLater(0, sub_auth_invalid_cert, df)
return df
#@deferred(SUBSCRIBER_TIMEOUT)
def test_subscriber_authentication_with_no_certificate_and_channel_surfing(self):
### """Test subscriber to auth with No Certification and join channel"""
num_subscribers = 1
num_channels = 1
df = defer.Deferred()
def sub_auth_no_cert(df):
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_no_cert, self.dhcp_verify, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, False)
df.callback(0)
reactor.callLater(0, sub_auth_no_cert, df)
return df
def test_subscriber_authentication_with_self_signed_certificate_and_channel_surfing(self):
### """Test subscriber to auth with Self Signed Certification and join channel"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_self_signed_cert, self.dhcp_verify, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_authentication_with_dhcp_discover_and_channel_surfing(self):
### """Test subscriber auth success, DHCP re-discover with DHCP server and join channel"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_discover_scenario, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_authentication_with_dhcp_client_reboot_scenario_and_channel_surfing(self):
### """Test subscriber auth success, DHCP client got re-booted and join channel"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_client_reboot_scenario, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_authentication_with_dhcp_server_reboot_scenario_and_channel_surfing(self):
### """Test subscriber auth , DHCP server re-boot during DHCP process and join channel"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_server_reboot_scenario, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_authentication_with_dhcp_client_rebind_and_channel_surfing(self):
### """Test subscriber auth , DHCP client rebind IP and join channel"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_client_rebind_scenario, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_authentication_with_dhcp_starvation_scenario_and_channel_surfing(self):
### """Test subscriber auth , DHCP starvation and join channel"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_starvation_scenario, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_authentication_with_multiple_dhcp_discover_for_same_subscriber_and_channel_surfing(self):
### """Test subscriber auth , sending same DHCP client discover multiple times and join channel"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_same_client_multi_discovers_scenario, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_authentication_with_multiple_dhcp_request_for_same_subscriber_and_channel_surfing(self):
### """Test subscriber auth , same DHCP client multiple requerts times and join channel"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_same_client_multi_request_scenario, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_authentication_with_dhcp_client_requested_ip_and_channel_surfing(self):
### """Test subscriber auth with DHCP client requesting ip and join channel"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_client_desired_ip_scenario, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_authentication_with_dhcp_non_offered_ip_and_channel_surfing(self):
### """Test subscriber auth with DHCP client request for non-offered ip and join channel"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_client_request_pkt_with_non_offered_ip_scenario, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_authentication_with_dhcp_request_out_of_pool_ip_by_client_and_channel_surfing(self):
### """Test subscriber auth with DHCP client requesting out of pool ip and join channel"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_client_requested_out_pool_ip_scenario, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_authentication_with_dhcp_specified_lease_time_functionality_and_channel_surfing(self):
### """Test subscriber auth with DHCP client specifying lease time and join channel"""
num_subscribers = 1
num_channels = 1
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_client_specific_lease_scenario, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_recv_100channels(self):
num_subscribers = 1
num_channels = 100
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_recv_400channels(self):
num_subscribers = 1
num_channels = 400
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_recv_800channels(self):
num_subscribers = 1
num_channels = 800
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_recv_1200channels(self):
num_subscribers = 1
num_channels = 1200
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_recv_1500channels(self):
num_subscribers = 1
num_channels = 1500
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_verify, self.igmp_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_jump_100channels(self):
num_subscribers = 1
num_channels = 100
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_jump_verify, self.igmp_jump_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_jump_400channels(self):
num_subscribers = 1
num_channels = 400
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_jump_verify, self.igmp_jump_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_jump_800channels(self):
num_subscribers = 1
num_channels = 800
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_jump_verify, self.igmp_jump_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_jump_1200channel(sself):
num_subscribers = 1
num_channels = 1200
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_jump_verify, self.igmp_jump_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_jump_1500channels(self):
num_subscribers = 1
num_channels = 1500
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_jump_verify, self.igmp_jump_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_next_100channels(self):
num_subscribers = 1
num_channels = 100
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_next_verify, self.igmp_next_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_next_400channels(self):
num_subscribers = 1
num_channels = 400
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_next_verify, self.igmp_next_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_next_800channels(self):
num_subscribers = 1
num_channels = 800
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_next_verify, self.igmp_next_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_next_1200channels(self):
num_subscribers = 1
num_channels = 1200
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_next_verify, self.igmp_next_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
def test_subscriber_join_next_1500channels(self):
num_subscribers = 1
num_channels = 1500
test_status = self.subscriber_join_verify(num_subscribers = num_subscribers,
num_channels = num_channels,
cbs = (self.tls_verify, self.dhcp_next_verify, self.igmp_next_verify),
port_list = self.generate_port_list(num_subscribers, num_channels),
negative_subscriber_auth = 'all')
assert_equal(test_status, True)
| 54.64919
| 238
| 0.568115
| 7,976
| 70,880
| 4.81181
| 0.067076
| 0.03898
| 0.043409
| 0.042341
| 0.740014
| 0.717345
| 0.695615
| 0.677949
| 0.658824
| 0.638657
| 0
| 0.029952
| 0.346205
| 70,880
| 1,296
| 239
| 54.691358
| 0.798235
| 0.042565
| 0
| 0.569991
| 0
| 0.013724
| 0.152739
| 0.033336
| 0
| 1
| 0
| 0
| 0.059469
| 0
| null | null | 0
| 0.021043
| null | null | 0.00183
| 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 | 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
6856ea4bef16b4aca6aca1ae6752ae8a328bbf4c
| 77
|
py
|
Python
|
_sadm/web/view/__init__.py
|
jrmsdev/pysadm
|
0d6b3f0c8d870d83ab499c8d9487ec8e3a89fc37
|
[
"BSD-3-Clause"
] | 1
|
2019-10-15T08:37:56.000Z
|
2019-10-15T08:37:56.000Z
|
_sadm/web/view/__init__.py
|
jrmsdev/pysadm
|
0d6b3f0c8d870d83ab499c8d9487ec8e3a89fc37
|
[
"BSD-3-Clause"
] | null | null | null |
_sadm/web/view/__init__.py
|
jrmsdev/pysadm
|
0d6b3f0c8d870d83ab499c8d9487ec8e3a89fc37
|
[
"BSD-3-Clause"
] | null | null | null |
# Copyright (c) Jeremías Casteglione <jrmsdev@gmail.com>
# See LICENSE file.
| 25.666667
| 56
| 0.753247
| 10
| 77
| 5.8
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.12987
| 77
| 2
| 57
| 38.5
| 0.865672
| 0.935065
| 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
|
68951276a486bb6455a3c6d4a9e61d81300ee697
| 99
|
py
|
Python
|
src/gcj/__init__.py
|
shang-lin/gcj
|
c5f34ecc4b63fc6a60c3ae3277c408d513cb53f1
|
[
"MIT"
] | null | null | null |
src/gcj/__init__.py
|
shang-lin/gcj
|
c5f34ecc4b63fc6a60c3ae3277c408d513cb53f1
|
[
"MIT"
] | null | null | null |
src/gcj/__init__.py
|
shang-lin/gcj
|
c5f34ecc4b63fc6a60c3ae3277c408d513cb53f1
|
[
"MIT"
] | null | null | null |
from .codejam import CodeJam
from .utils import CodeJamUtils
__all__ = ['CodeJam', 'CodeJamUtils']
| 24.75
| 37
| 0.777778
| 11
| 99
| 6.636364
| 0.545455
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.121212
| 99
| 4
| 37
| 24.75
| 0.83908
| 0
| 0
| 0
| 0
| 0
| 0.19
| 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
|
6896c343b9b9770905d2cd892b5c50ca66f4c02a
| 116
|
py
|
Python
|
d06p2.py
|
cahorn/aoc21
|
84c6da3cea0e07d7a673f69e5948bf845da78482
|
[
"WTFPL"
] | null | null | null |
d06p2.py
|
cahorn/aoc21
|
84c6da3cea0e07d7a673f69e5948bf845da78482
|
[
"WTFPL"
] | null | null | null |
d06p2.py
|
cahorn/aoc21
|
84c6da3cea0e07d7a673f69e5948bf845da78482
|
[
"WTFPL"
] | null | null | null |
from d06p1 import *
if __name__ == "__main__":
print(population(256, fish(map(int, stdin.read().split(",")))))
| 23.2
| 67
| 0.646552
| 15
| 116
| 4.466667
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.06
| 0.137931
| 116
| 4
| 68
| 29
| 0.61
| 0
| 0
| 0
| 0
| 0
| 0.077586
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.333333
| 0
| 0.333333
| 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
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
68ac5d7dde7fabacf149686798512e5fbbbc10c0
| 12,801
|
py
|
Python
|
test/test_base_mission_generation.py
|
eriksalt/blades_helper_proj
|
96e9d856b0e7f7a9cfc26c9f1bdc89c574eebdbc
|
[
"MIT"
] | null | null | null |
test/test_base_mission_generation.py
|
eriksalt/blades_helper_proj
|
96e9d856b0e7f7a9cfc26c9f1bdc89c574eebdbc
|
[
"MIT"
] | null | null | null |
test/test_base_mission_generation.py
|
eriksalt/blades_helper_proj
|
96e9d856b0e7f7a9cfc26c9f1bdc89c574eebdbc
|
[
"MIT"
] | null | null | null |
import pytest
import test.mock_data_gateway
from blades_helper.mission_generator import _get_next_mission_type, _can_use_mission_type, _generate_base_missions
from blades_helper.mission_generator_constants import MissionGeneratorConstants as con
def setup_one_mission_base_build(mock, note, type):
mock.mission_counts.append((1, note))
mock.mission_types.append(type)
def check_array(source, target):
assert len(source)==len(target)
for i in range(len(source)):
assert source[i]==target[i]
def check_mission_type(mission, mission_type):
assert mission.mission_type == mission_type
def check_note_len(mission, notes_len):
assert len(mission.notes) == notes_len
def check_for_note(mission, note_to_find):
for note in mission.notes:
if note_to_find in note:
return
assert False
def check_requirement(mission, specialist):
return specialist in mission.requirements
def check_for_note_plus_one_specialist(mission, specialist):
check_for_note(mission, "Mission can include one additional specialist")
check_requirement(mission, specialist)
def check_for_note_favor(mission, favor_type):
check_for_note(mission, con.FAVOR_NOTE[0:-3])
check_for_note(mission, favor_type)
def check_mission(mission, mission_type, target, rewards, penalties, notes_len, requirement, contained_notes):
check_mission_type(mission, mission_type)
assert mission.target == target
check_array(mission.rewards, rewards)
check_array(mission.penalties, penalties)
check_note_len(mission, notes_len)
if not requirement == con.NOTHING:
check_requirement(mission, requirement)
for contained_note in contained_notes:
check_for_note(mission, contained_note)
def test_get_next_mission_type():
assert _get_next_mission_type(con.ASSAULT) == con.RECON
assert _get_next_mission_type(con.RECON) == con.RELIGIOUS
assert _get_next_mission_type(con.RELIGIOUS)==con.SUPPLY
assert _get_next_mission_type(con.SUPPLY) == con.COMMANDER_FOCUS
with pytest.raises(AssertionError):
_get_next_mission_type(con.COMMANDER_FOCUS)
with pytest.raises(AssertionError):
_get_next_mission_type(con.GM_CHOICE)
def test_can_use_mission_type():
assert not _can_use_mission_type(con.SUPPLY, [con.ASSAULT])
assert _can_use_mission_type(con.SPECIAL, [con.SPECIAL])
assert _can_use_mission_type(con.GM_CHOICE, [con.GM_CHOICE])
assert not _can_use_mission_type(con.SUPPLY, [])
assert _can_use_mission_type(con.SUPPLY, [con.SUPPLY])
assert _can_use_mission_type(con.SUPPLY, [con.ASSAULT, con.SUPPLY])
assert _can_use_mission_type(con.SUPPLY, [con.SUPPLY, con.ASSAULT])
def test_make_one_mission():
mock = test.mock_data_gateway.MockDataGateway()
mock.titles.append('bunker hill')
setup_one_mission_base_build(mock, con.NOTHING, con.RELIGIOUS)
missions =_generate_base_missions(mock, False, False, False, con.SUPPLY, con.ASSAULT, [con.RELIGIOUS, con.SUPPLY, con.ASSAULT, con.RECON] )
assert len(missions)==1
mission = missions[0]
check_mission(mission, con.RELIGIOUS, con.NOTHING, [], [], 0, con.required_religious_specialists, [])
def test_one_has_favor():
mock = test.mock_data_gateway.MockDataGateway()
mock.favor_types.append(con.THE_WILD)
setup_one_mission_base_build(mock, con.ONE_HAS_FAVOR, con.SUPPLY)
missions =_generate_base_missions( mock, False, False, False, con.ASSAULT, con.ASSAULT, [con.RELIGIOUS, con.SUPPLY, con.ASSAULT, con.RECON] )
assert len(missions)==1
mission = missions[0]
check_mission(mission,con.SUPPLY,con.NOTHING,[],[],1,con.required_supply_specialists,[con.FAVOR_NOTE[0:-3], con.THE_WILD])
def test_one_extra_specialist():
mock = test.mock_data_gateway.MockDataGateway()
mock.specialists.append(con.SNIPER)
setup_one_mission_base_build(mock, con.PLUS_ONE_SPECIALIST, con.SUPPLY)
missions =_generate_base_missions( mock, False, False, False, con.ASSAULT, con.ASSAULT, [con.RELIGIOUS, con.SUPPLY, con.ASSAULT, con.RECON] )
mission = missions[0]
check_mission(mission, con.SUPPLY, con.NOTHING, [],[], 1, con.required_supply_specialists, ["Mission can include one additional specialist"])
check_for_note_plus_one_specialist(mission, con.SNIPER)
def test_commanders_focus():
mock = test.mock_data_gateway.MockDataGateway()
setup_one_mission_base_build(mock, con.NOTHING, con.COMMANDER_FOCUS)
missions =_generate_base_missions( mock, False, False, False, con.RECON, con.ASSAULT, [con.RELIGIOUS, con.SUPPLY, con.ASSAULT, con.RECON] )
mission = missions[0]
check_mission(mission, con.RECON, con.NOTHING, [],[], 0,con.required_recon_specialists,[])
def test_gm_choice():
mock = test.mock_data_gateway.MockDataGateway()
setup_one_mission_base_build(mock, con.NOTHING, con.GM_CHOICE)
missions =_generate_base_missions( mock, False, False, False, con.ASSAULT, con.RECON, [con.RELIGIOUS, con.SUPPLY, con.ASSAULT, con.RECON] )
mission = missions[0]
check_mission(mission, con.RECON, con.NOTHING, [],[], 0,con.required_recon_specialists,[])
def test_unavailable_mission():
#test simple unavailability
mock = test.mock_data_gateway.MockDataGateway()
setup_one_mission_base_build(mock, con.NOTHING, con.RECON)
missions =_generate_base_missions( mock, False, False, False, con.ASSAULT, con.RECON, [con.RELIGIOUS, con.SUPPLY, con.ASSAULT] )
mission = missions[0]
check_mission(mission, con.RELIGIOUS, con.NOTHING, [],[], 0,con.required_religious_specialists,[])
#test when mutiple missions unavailable
setup_one_mission_base_build(mock, con.NOTHING, con.ASSAULT)
missions =_generate_base_missions( mock, False, False, False, con.UNDEFINED, con.ASSAULT, [] )
mission = missions[0]
check_mission(mission, con.UNDEFINED, con.NOTHING, [],[], 0,con.NOTHING,[])
def test_special_missions_are_allowed():
# special
mock = test.mock_data_gateway.MockDataGateway()
setup_one_mission_base_build(mock, con.NOTHING, con.SPECIAL)
missions =_generate_base_missions( mock, False, False, False, con.ASSAULT, con.ASSAULT, [] )
mission = missions[0]
check_mission(mission, con.SPECIAL, con.NOTHING, [],[], 0,con.NOTHING,[])
def create_mission_with_gm_choice_and_note(mock, choice, note, spymaster_buy=False):
setup_one_mission_base_build(mock, note, con.GM_CHOICE)
missions =_generate_base_missions( mock, spymaster_buy, False, False, con.ASSAULT, choice, [con.RELIGIOUS, con.SUPPLY, con.ASSAULT] )
assert len(missions) == 1
return missions[0]
def create_mission_with_commander_focus_and_note(mock, focus,note, spymaster_buy=False):
setup_one_mission_base_build(mock, note, con.COMMANDER_FOCUS)
missions =_generate_base_missions( mock, spymaster_buy, False, False, focus, con.ASSAULT, [con.RELIGIOUS, con.SUPPLY, con.ASSAULT] )
assert len(missions) == 1
return missions[0]
def test_commander_focus_plus_one_specialist():
mock = test.mock_data_gateway.MockDataGateway()
mock.specialists.append(con.HEAVY)
focus=con.SUPPLY
note=con.PLUS_ONE_SPECIALIST
mission=create_mission_with_commander_focus_and_note(mock, focus, note)
check_mission_type(mission, focus)
check_note_len(mission, 1)
check_for_note_plus_one_specialist(mission, con.HEAVY)
def test_commander_focus_one_has_favor():
mock = test.mock_data_gateway.MockDataGateway()
mock.favor_types.append(con.HOLY)
focus=con.SUPPLY
note=con.ONE_HAS_FAVOR
mission=create_mission_with_commander_focus_and_note(mock, focus, note)
check_mission_type(mission, focus)
check_note_len(mission, 1)
check_for_note_favor(mission, con.HOLY)
def test_commander_focus_one_is_special():
mock = test.mock_data_gateway.MockDataGateway()
focus=con.SUPPLY
note=con.ONE_IS_SPECIAL
mission=create_mission_with_commander_focus_and_note(mock, focus, note)
check_mission_type(mission, con.SPECIAL)
check_note_len(mission, 0)
def test_gm_choice_plus_one_specialist():
mock = test.mock_data_gateway.MockDataGateway()
mock.specialists.append(con.HEAVY)
choice=con.SUPPLY
note=con.PLUS_ONE_SPECIALIST
mission=create_mission_with_gm_choice_and_note(mock, choice, note)
check_mission_type(mission, choice)
check_note_len(mission, 1)
check_for_note_plus_one_specialist(mission, con.HEAVY)
def test_gm_choice_one_has_favor():
mock = test.mock_data_gateway.MockDataGateway()
mock.favor_types.append(con.HOLY)
choice=con.SUPPLY
note=con.ONE_HAS_FAVOR
mission=create_mission_with_gm_choice_and_note(mock, choice, note)
check_mission_type(mission, choice)
check_note_len(mission, 1)
check_for_note_favor(mission, con.HOLY)
def test_gm_choice_one_is_special():
mock = test.mock_data_gateway.MockDataGateway()
choice=con.SUPPLY
note=con.ONE_IS_SPECIAL
mission=create_mission_with_gm_choice_and_note(mock, choice, note)
check_mission_type(mission, con.SPECIAL)
check_note_len(mission, 0)
def test_simple_spymaster_spend():
mock=test.mock_data_gateway.MockDataGateway()
setup_one_mission_base_build(mock, con.NOTHING, con.SUPPLY)
missions =_generate_base_missions( mock, True, False, False, con.ASSAULT,con.ASSAULT, [con.RELIGIOUS, con.SUPPLY, con.ASSAULT] )
assert len(missions) == 1
check_mission_type(missions[0], con.SPECIAL)
def test_one_mission_with_spymaster_and_one_is_special():
mock=test.mock_data_gateway.MockDataGateway()
setup_one_mission_base_build(mock, con.ONE_IS_SPECIAL, con.SUPPLY)
missions =_generate_base_missions( mock, True, False, False, con.ASSAULT,con.ASSAULT, [con.RELIGIOUS, con.SUPPLY, con.ASSAULT] )
assert len(missions) == 1
check_mission_type(missions[0], con.SPECIAL)
check_note_len(missions[0],0)
def test_two_missions_with_spymaster_and_one_is_special():
mock=test.mock_data_gateway.MockDataGateway()
mock.mission_counts.append((2, con.ONE_IS_SPECIAL))
mock.mission_types.append(con.RECON)
mock.mission_types.append(con.SUPPLY)
missions =_generate_base_missions( mock, True, False, False, con.ASSAULT,con.ASSAULT, [con.RELIGIOUS, con.SUPPLY, con.ASSAULT] )
assert len(missions) == 2
check_mission_type(missions[0], con.SPECIAL)
check_note_len(missions[0],0)
check_mission_type(missions[1], con.SPECIAL)
check_note_len(missions[1],0)
def setup_three_missions(mock, note, first_type, second_type, third_type, commanders_focus, gms_choice, spymaster_buy=False):
mock.mission_counts.append((3, note))
mock.mission_types.append(first_type)
mock.mission_types.append(second_type)
mock.mission_types.append(third_type)
missions = _generate_base_missions(mock, spymaster_buy, False, False, commanders_focus, gms_choice, [con.ASSAULT, con.RECON, con.SUPPLY, con.RELIGIOUS])
assert len(missions)==3
return missions
def test_three_simple_missions():
mock=test.mock_data_gateway.MockDataGateway()
note=con.NOTHING
first_type=con.RELIGIOUS
second_type=con.SUPPLY
third_type=con.RECON
spymaster_buy=False
commander_focus=con.ASSAULT
gm_choice=con.ASSAULT
missions=setup_three_missions(mock, note, first_type, second_type, third_type, commander_focus, gm_choice, spymaster_buy)
check_mission_type(missions[0], con.RELIGIOUS)
check_mission_type(missions[1], con.SUPPLY)
check_mission_type(missions[2], con.RECON)
def test_three_missions_with_one_is_special():
mock=test.mock_data_gateway.MockDataGateway()
mock.random_missions.append(1)
mock.specialists.append(con.HEAVY)
note=con.PLUS_ONE_SPECIALIST
first_type=con.RELIGIOUS
second_type=con.SUPPLY
third_type=con.RECON
spymaster_buy=False
commander_focus=con.ASSAULT
gm_choice=con.ASSAULT
missions=setup_three_missions(mock, note, first_type, second_type, third_type, commander_focus, gm_choice, spymaster_buy)
check_mission_type(missions[0], con.RELIGIOUS)
check_mission_type(missions[1], con.SUPPLY)
check_mission_type(missions[2], con.RECON)
check_for_note_plus_one_specialist(missions[1],con.HEAVY)
def test_three_missions_with_spymaster_buy_and_one_is_special():
mock=test.mock_data_gateway.MockDataGateway()
note=con.ONE_IS_SPECIAL
first_type=con.RELIGIOUS
second_type=con.SUPPLY
third_type=con.RECON
spymaster_buy=True
commander_focus=con.ASSAULT
gm_choice=con.ASSAULT
missions=setup_three_missions(mock, note, first_type, second_type, third_type, commander_focus, gm_choice, spymaster_buy)
check_mission_type(missions[0], con.SPECIAL)
check_mission_type(missions[1], con.SPECIAL)
check_mission_type(missions[2], con.RELIGIOUS)
| 44.447917
| 158
| 0.763847
| 1,791
| 12,801
| 5.120045
| 0.062535
| 0.051581
| 0.034024
| 0.041439
| 0.810251
| 0.755834
| 0.717557
| 0.692912
| 0.645911
| 0.582661
| 0
| 0.005413
| 0.13413
| 12,801
| 287
| 159
| 44.602787
| 0.821905
| 0.005625
| 0
| 0.502075
| 1
| 0
| 0.007938
| 0
| 0
| 0
| 0
| 0
| 0.112033
| 1
| 0.136929
| false
| 0
| 0.016598
| 0.004149
| 0.174274
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 1
| 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
|
d7c4b3adc0520c13dfffd5160f89ef9071d0d998
| 6,118
|
py
|
Python
|
dirigible/fts/tests/test_2734_ClearCells.py
|
EnoX1/dirigible-spreadsheet
|
9a3289c67a93c40190565ad5a555710c50c5f958
|
[
"MIT"
] | 168
|
2015-01-03T02:09:30.000Z
|
2022-03-31T22:28:00.000Z
|
dirigible/fts/tests/test_2734_ClearCells.py
|
EnoX1/dirigible-spreadsheet
|
9a3289c67a93c40190565ad5a555710c50c5f958
|
[
"MIT"
] | 4
|
2017-03-14T20:49:49.000Z
|
2020-04-02T16:13:00.000Z
|
dirigible/fts/tests/test_2734_ClearCells.py
|
EnoX1/dirigible-spreadsheet
|
9a3289c67a93c40190565ad5a555710c50c5f958
|
[
"MIT"
] | 46
|
2015-01-18T04:39:24.000Z
|
2022-02-17T22:33:05.000Z
|
# Copyright (c) 2010 Resolver Systems Ltd.
# All Rights Reserved
#
try:
import unittest2 as unittest
except ImportError:
import unittest
from functionaltest import FunctionalTest
import key_codes
from textwrap import dedent
class Test_2734_ClearCells(FunctionalTest):
def test_delete_key_clears_selected_cells(self):
self.assert_key_deletes_cells(key_codes.DELETE)
def test_backspace_key_clears_selected_cells(self):
self.assert_key_deletes_cells(key_codes.BACKSPACE)
def assert_key_deletes_cells(self, key_code):
# * Harold logs in and creates a new sheet
self.login_and_create_new_sheet()
# * He enters some data in A1:A3
self.enter_cell_text(1, 1, 'a1')
self.enter_cell_text(1, 2, 'a2')
self.enter_cell_text(1, 3, 'a3')
self.wait_for_cell_value(1, 3, 'a3')
# * He clicks on A1 and hits delete
self.click_on_cell(1, 1)
self.human_key_press(key_code)
# * He sees the value in A1 disappear while the others remain
self.wait_for_cell_value(1, 1, '')
self.wait_for_cell_value(1, 2, 'a2')
self.wait_for_cell_value(1, 3, 'a3')
# * He selects the range a2:a3
self.select_range_with_shift_click((1, 2), (1, 3))
# He hits delete
self.human_key_press(key_code)
# * He sees that all the cells are now cleared
self.wait_for_cell_value(1, 1, '')
self.wait_for_cell_value(1, 2, '')
self.wait_for_cell_value(1, 3, '')
def test_delete_key_while_editing_still_does_what_it_should(self):
# * Harold logs in and creates a new sheet
self.login_and_create_new_sheet()
# * He enters three characters in A1
self.open_cell_for_editing(1, 1)
self.human_key_press(key_codes.NUMBER_1)
self.human_key_press(key_codes.NUMBER_2)
self.human_key_press(key_codes.NUMBER_3)
# * He moves left twice
self.human_key_press(key_codes.LEFT)
self.human_key_press(key_codes.LEFT)
# He hits delete
self.human_key_press(key_codes.DELETE)
# the middle character is now missing
self.wait_for_cell_editor_content('13')
def test_backspace_key_while_editing_still_does_what_it_should(self):
# * Harold logs in and creates a new sheet
self.login_and_create_new_sheet()
# * He enters three characters in A1
self.open_cell_for_editing(1, 1)
self.human_key_press(key_codes.NUMBER_1)
self.human_key_press(key_codes.NUMBER_2)
self.human_key_press(key_codes.NUMBER_3)
# * He moves left once
self.human_key_press(key_codes.LEFT)
# He hits backspace
self.human_key_press(key_codes.BACKSPACE)
# the middle character is now missing
self.wait_for_cell_editor_content('13')
def test_can_clear_cell_from_usercode(self):
# * Harold logs in and creates a new sheet
self.login_and_create_new_sheet()
# * He enters some data in A1:A3
self.enter_cell_text(1, 1, 'a1')
self.enter_cell_text(1, 2, 'a2')
self.enter_cell_text(1, 3, 'a3')
self.wait_for_cell_value(1, 3, 'a3')
# * He tries to use the clear() function from usercode on a cell
# and then tries to access some of the supposedly cleared attributes of the cell
self.prepend_usercode(dedent('''
worksheet.a1.error = 'harold puts a deliberate pointless error in'
worksheet.a1.clear()
worksheet.b1.formula = str(worksheet.a1.value)
worksheet.b2.formula = str(worksheet.a1.formula)
worksheet.b3.formula = str(worksheet.a1.formatted_value)
worksheet.b4.formula = str(worksheet.a1.error)
'''))
# * He sees the value in a1 disappear
self.wait_for_cell_value(1, 1, '')
self.wait_for_cell_value(1, 2, 'a2')
self.wait_for_cell_value(1, 3, 'a3')
# * He sees his little investigations also produce the expected results
self.wait_for_cell_value(2, 1, '<undefined>')
self.wait_for_cell_value(2, 2, 'None')
self.wait_for_cell_value(2, 3, '')
self.wait_for_cell_value(2, 4, 'None')
def test_can_clear_cell_range_from_usercode(self):
# * Harold logs in and creates a new sheet
self.login_and_create_new_sheet()
# * He enters some data in A1:A3
self.enter_cell_text(1, 1, 'a1')
self.enter_cell_text(1, 2, 'a2')
self.enter_cell_text(1, 3, 'a3')
self.wait_for_cell_value(1, 3, 'a3')
# * He tries to use the clear() function from usercode on a cell range
self.prepend_usercode(dedent('''
worksheet.a1.error = 'harold puts a deliberate pointless error in'
worksheet.a2.error = 'harold puts another deliberate pointless error in'
worksheet.cell_range("a1:a2").clear()
worksheet.b1.formula = str(worksheet.a1.value)
worksheet.b2.formula = str(worksheet.a1.formula)
worksheet.b3.formula = str(worksheet.a1.formatted_value)
worksheet.b4.formula = str(worksheet.a1.error)
worksheet.c1.formula = str(worksheet.a2.value)
worksheet.c2.formula = str(worksheet.a2.formula)
worksheet.c3.formula = str(worksheet.a2.formatted_value)
worksheet.c4.formula = str(worksheet.a2.error)
'''))
# * He sees the value in a1 and a2 disappear
self.wait_for_cell_value(1, 1, '')
self.wait_for_cell_value(1, 2, '')
self.wait_for_cell_value(1, 3, 'a3')
# * He sees his little investigations also produce the expected results
self.wait_for_cell_value(2, 1, '<undefined>')
self.wait_for_cell_value(2, 2, 'None')
self.wait_for_cell_value(2, 3, '')
self.wait_for_cell_value(2, 4, 'None')
self.wait_for_cell_value(3, 1, '<undefined>')
self.wait_for_cell_value(3, 2, 'None')
self.wait_for_cell_value(3, 3, '')
self.wait_for_cell_value(3, 4, 'None')
| 35.364162
| 88
| 0.650866
| 897
| 6,118
| 4.167224
| 0.160535
| 0.062065
| 0.08534
| 0.116372
| 0.79374
| 0.776083
| 0.761905
| 0.716426
| 0.690209
| 0.671482
| 0
| 0.035667
| 0.253024
| 6,118
| 172
| 89
| 35.569767
| 0.782276
| 0.194345
| 0
| 0.663265
| 0
| 0
| 0.242393
| 0.071268
| 0
| 0
| 0
| 0
| 0.030612
| 1
| 0.071429
| false
| 0
| 0.061224
| 0
| 0.142857
| 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
|
d7e16d169c99996ba790fc5bd559f091602d1968
| 191
|
py
|
Python
|
07_calculation_game_on_web/01_multiplication.py
|
shakiyam/python4kids
|
39db55aabe8d02682aaad30080320f944b31258c
|
[
"MIT"
] | null | null | null |
07_calculation_game_on_web/01_multiplication.py
|
shakiyam/python4kids
|
39db55aabe8d02682aaad30080320f944b31258c
|
[
"MIT"
] | null | null | null |
07_calculation_game_on_web/01_multiplication.py
|
shakiyam/python4kids
|
39db55aabe8d02682aaad30080320f944b31258c
|
[
"MIT"
] | null | null | null |
import random
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
a = random.randrange(1, 10)
b = random.randrange(1, 10)
return f'{a} * {b} = {a * b}'
| 14.692308
| 33
| 0.591623
| 29
| 191
| 3.758621
| 0.551724
| 0.275229
| 0.293578
| 0.330275
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.040816
| 0.230366
| 191
| 12
| 34
| 15.916667
| 0.70068
| 0
| 0
| 0
| 0
| 0
| 0.104712
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.125
| false
| 0
| 0.25
| 0
| 0.5
| 0
| 1
| 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
| 0
| 0
| 0
| 0
|
0
| 4
|
d7ee0c1e3be65d8eaba71bbe86681e88e75f985b
| 156
|
py
|
Python
|
Aula 07/ex05.py
|
rafa-santana/Curso-Python
|
765c919e45449bd9364905e7a43204f2428fc087
|
[
"MIT"
] | 1
|
2021-07-20T16:29:50.000Z
|
2021-07-20T16:29:50.000Z
|
Aula 07/ex05.py
|
rafa-santana/Curso-Python
|
765c919e45449bd9364905e7a43204f2428fc087
|
[
"MIT"
] | null | null | null |
Aula 07/ex05.py
|
rafa-santana/Curso-Python
|
765c919e45449bd9364905e7a43204f2428fc087
|
[
"MIT"
] | null | null | null |
n = int(input('Digite um número e descubra o seu sucessor e antecesor: '))
print ('O seu sucessor é igual a {} e o antecessor é igual a {}'.format(n+1,n-1))
| 78
| 81
| 0.685897
| 31
| 156
| 3.451613
| 0.612903
| 0.074766
| 0.224299
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.015504
| 0.173077
| 156
| 2
| 81
| 78
| 0.813953
| 0
| 0
| 0
| 0
| 0
| 0.707006
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0.5
| 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
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
cc1b552bcf088199b39aca8551f159c12170a452
| 400
|
py
|
Python
|
test-data/unit/fixtures/module_all.py
|
ddfisher/mypy
|
be0e8f2f9e40b50de8219994867e0102e017129a
|
[
"PSF-2.0"
] | null | null | null |
test-data/unit/fixtures/module_all.py
|
ddfisher/mypy
|
be0e8f2f9e40b50de8219994867e0102e017129a
|
[
"PSF-2.0"
] | null | null | null |
test-data/unit/fixtures/module_all.py
|
ddfisher/mypy
|
be0e8f2f9e40b50de8219994867e0102e017129a
|
[
"PSF-2.0"
] | null | null | null |
from typing import Generic, Sequence, TypeVar
_T = TypeVar('_T')
class object:
def __init__(self) -> None: pass
class module: pass
class type: pass
class function: pass
class int: pass
class str: pass
class list(Generic[_T], Sequence[_T]):
def append(self, x: _T): pass
def extend(self, x: Sequence[_T]): pass
def __add__(self, rhs: Sequence[_T]) -> list[_T]: pass
class tuple: pass
| 25
| 58
| 0.6975
| 62
| 400
| 4.241935
| 0.419355
| 0.239544
| 0.060837
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.1775
| 400
| 15
| 59
| 26.666667
| 0.799392
| 0
| 0
| 0
| 0
| 0
| 0.005
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.285714
| false
| 0.714286
| 0.071429
| 0
| 0.928571
| 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
| 1
| 0
| 1
| 0
| 0
| 1
| 0
|
0
| 4
|
cc1b9bef8ca8d5acf42c5e4a92ae8cefc60c12e3
| 106
|
py
|
Python
|
dcl/tradegecko/fixerio/exceptions.py
|
OlamideD/zutron
|
42a3b360f7603fc4755d519904ecdb1712296ec2
|
[
"MIT"
] | 16
|
2017-05-31T19:11:10.000Z
|
2022-02-20T09:46:08.000Z
|
dcl/tradegecko/fixerio/exceptions.py
|
OlamideD/zutron
|
42a3b360f7603fc4755d519904ecdb1712296ec2
|
[
"MIT"
] | 42
|
2016-05-08T09:40:02.000Z
|
2021-06-01T22:29:03.000Z
|
dcl/tradegecko/fixerio/exceptions.py
|
OlamideD/zutron
|
42a3b360f7603fc4755d519904ecdb1712296ec2
|
[
"MIT"
] | 12
|
2016-05-08T09:28:15.000Z
|
2021-02-06T17:11:58.000Z
|
class FixerioException(BaseException):
""" Common base class for all fixerio exceptions. """
pass
| 26.5
| 57
| 0.716981
| 11
| 106
| 6.909091
| 0.909091
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.188679
| 106
| 3
| 58
| 35.333333
| 0.883721
| 0.424528
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.5
| 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
| 0
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
cc2a635b535d393f06204b8db1a07c31fd570805
| 22
|
py
|
Python
|
flaskapp/blueprints/users/__init__.py
|
crockmitnic/question-paper-generator
|
3f5339226aedd4332c562913945a08cdb45983b0
|
[
"MIT"
] | 6
|
2020-08-02T20:58:34.000Z
|
2022-03-23T20:33:20.000Z
|
flaskapp/blueprints/users/__init__.py
|
arushikhokhar/question-paper-generator
|
ed7c39e38b13c13c66c673bbde80511d96c2dae3
|
[
"MIT"
] | 209
|
2020-02-12T17:09:15.000Z
|
2021-06-03T20:34:35.000Z
|
flaskapp/blueprints/users/__init__.py
|
arushikhokhar/question-paper-generator
|
ed7c39e38b13c13c66c673bbde80511d96c2dae3
|
[
"MIT"
] | 54
|
2020-02-18T14:54:35.000Z
|
2021-09-05T06:31:12.000Z
|
"""users blueprint"""
| 11
| 21
| 0.636364
| 2
| 22
| 7
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.090909
| 22
| 1
| 22
| 22
| 0.7
| 0.681818
| 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
|
0bc7519a8826cc350f152e84810c561b1b2f1c19
| 829
|
py
|
Python
|
packages/gtmcore/gtmcore/exceptions/exceptions.py
|
jjwatts/gigantum-client
|
88ce0475fb6880322bdd06d987c494e29064f278
|
[
"MIT"
] | 60
|
2018-09-26T15:46:00.000Z
|
2021-10-10T02:37:14.000Z
|
packages/gtmcore/gtmcore/exceptions/exceptions.py
|
jjwatts/gigantum-client
|
88ce0475fb6880322bdd06d987c494e29064f278
|
[
"MIT"
] | 1,706
|
2018-09-26T16:11:22.000Z
|
2021-08-20T13:37:59.000Z
|
packages/gtmcore/gtmcore/exceptions/exceptions.py
|
jjwatts/gigantum-client
|
88ce0475fb6880322bdd06d987c494e29064f278
|
[
"MIT"
] | 11
|
2019-03-14T13:23:51.000Z
|
2022-01-25T01:29:16.000Z
|
# TODO: Finish exception implementation, with single exception used to manage hiding error details from user in UI
class GigantumException(Exception):
"""Any Exception arising from inside the Labbook class will be cast as a LabbookException.
This is to avoid having "except Exception" clauses in the client code, and to avoid
having to be aware of every sub-library that is used by the Labbook and the exceptions that those raise.
The principle idea behind this is to have a single catch for all Labbook-related errors. In the stack trace you
can still observe the origin of the problem."""
pass
class GigantumLockedException(GigantumException):
""" Raised when trying to acquire a Labbook lock when lock
is already acquired by another process and failfast flag is set to
True"""
pass
| 46.055556
| 115
| 0.761158
| 126
| 829
| 5.007937
| 0.634921
| 0.031696
| 0.025357
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.202654
| 829
| 17
| 116
| 48.764706
| 0.954614
| 0.814234
| 0
| 0.5
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.058824
| 0
| 1
| 0
| true
| 0.5
| 0
| 0
| 0.5
| 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
| 1
| 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
0403581092cb5a2783d8f97cdff8ad420b0ccd02
| 319
|
py
|
Python
|
Code Templates/Google.py
|
cnm06/Competitive-Programming
|
94242ae458570d503b8218f37624b88cc5020d23
|
[
"MIT"
] | 994
|
2017-02-28T06:13:47.000Z
|
2022-03-31T10:49:00.000Z
|
Code Templates/Google.py
|
Quadrified/Competitive-Programming
|
bccb69952cc5260fb3647b3301ddac1023dacac8
|
[
"MIT"
] | 16
|
2018-01-01T02:59:55.000Z
|
2021-11-22T12:49:16.000Z
|
Code Templates/Google.py
|
Quadrified/Competitive-Programming
|
bccb69952cc5260fb3647b3301ddac1023dacac8
|
[
"MIT"
] | 325
|
2017-06-15T03:32:43.000Z
|
2022-03-28T22:43:42.000Z
|
f = open('sample-input.txt')
o = open('sample-output.txt', 'w')
t = int(f.readline().strip())
for i in xrange(1, t + 1):
o.write("Case #{}: ".format(i))
n = int(f.readline().strip())
x = [int(j) for j in f.readline().strip().split()]
y = [int(j) for j in f.readline().strip().split()]
o.write("\n")
| 31.9
| 54
| 0.548589
| 56
| 319
| 3.125
| 0.446429
| 0.205714
| 0.32
| 0.194286
| 0.331429
| 0.331429
| 0.331429
| 0.331429
| 0.331429
| 0
| 0
| 0.007663
| 0.181818
| 319
| 9
| 55
| 35.444444
| 0.662835
| 0
| 0
| 0
| 0
| 0
| 0.144201
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 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
|
f0b99f071749a37dba9f666e50c8d1d226e08eaf
| 129
|
py
|
Python
|
0x06-python-classes/0-square.py
|
Dev-Loup/holbertonschool-higher_level_programming
|
af6fe9a05c87dcdbb88270eec4c7ec81d6a70d9b
|
[
"FSFAP"
] | null | null | null |
0x06-python-classes/0-square.py
|
Dev-Loup/holbertonschool-higher_level_programming
|
af6fe9a05c87dcdbb88270eec4c7ec81d6a70d9b
|
[
"FSFAP"
] | null | null | null |
0x06-python-classes/0-square.py
|
Dev-Loup/holbertonschool-higher_level_programming
|
af6fe9a05c87dcdbb88270eec4c7ec81d6a70d9b
|
[
"FSFAP"
] | null | null | null |
#!/usr/bin/python3
"""Square class creation
"""
class Square:
"""Bypass attributes or methods declaration
"""
pass
| 12.9
| 47
| 0.643411
| 14
| 129
| 5.928571
| 0.857143
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.009901
| 0.217054
| 129
| 9
| 48
| 14.333333
| 0.811881
| 0.658915
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.5
| 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
| 0
| 1
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
f0d38969e6e08260fdb1910aa2450219efe2e6d3
| 1,263
|
py
|
Python
|
write/models.py
|
power3247/project3
|
0702d4754b3cb2b570b1d01df77d412c51eb28a6
|
[
"Apache-2.0"
] | 1
|
2021-11-09T20:31:55.000Z
|
2021-11-09T20:31:55.000Z
|
write/models.py
|
power3247/project3
|
0702d4754b3cb2b570b1d01df77d412c51eb28a6
|
[
"Apache-2.0"
] | null | null | null |
write/models.py
|
power3247/project3
|
0702d4754b3cb2b570b1d01df77d412c51eb28a6
|
[
"Apache-2.0"
] | 3
|
2021-08-11T03:34:30.000Z
|
2021-10-05T05:12:01.000Z
|
from django.db import models
# Create your models here.
# class Essay(models.Model):
# score = models.IntegerField()
# essayA = models.TextField()
# essayQ = models.TextField()
# name = models.CharField(max_length=20)
#
# def __str__(self):
# return self.score
class choice(models.Model):
제목 = models.TextField()
점수 = models.IntegerField()
질문 = models.TextField()
답변 = models.TextField()
class lotto_data(models.Model):
a = models.DecimalField(max_digits=20,decimal_places=20)
b = models.DecimalField(max_digits=20,decimal_places=20)
c = models.DecimalField(max_digits=20,decimal_places=20)
d = models.DecimalField(max_digits=20,decimal_places=20)
e = models.DecimalField(max_digits=20,decimal_places=20)
f = models.DecimalField(max_digits=20,decimal_places=20)
g = models.DecimalField(max_digits=20,decimal_places=20)
h = models.DecimalField(max_digits=20,decimal_places=20)
i = models.DecimalField(max_digits=20,decimal_places=20)
j = models.DecimalField(max_digits=20,decimal_places=20)
k = models.DecimalField(max_digits=20,decimal_places=20)
l = models.DecimalField(max_digits=20,decimal_places=20)
m = models.DecimalField(max_digits=20,decimal_places=20)
| 35.083333
| 60
| 0.728424
| 172
| 1,263
| 5.162791
| 0.284884
| 0.263514
| 0.307432
| 0.39527
| 0.644144
| 0.644144
| 0.644144
| 0.644144
| 0
| 0
| 0
| 0.05042
| 0.152019
| 1,263
| 35
| 61
| 36.085714
| 0.778711
| 0.190816
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.05
| 0
| 1
| 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
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
f0f41930e66849decd7d4ea285445efddcac993e
| 176
|
py
|
Python
|
app/blueprints/question.py
|
rubberduckdebuggingtwitch/pond
|
ef574c53e3737b2a07cb368f07f3815514a17375
|
[
"MIT"
] | null | null | null |
app/blueprints/question.py
|
rubberduckdebuggingtwitch/pond
|
ef574c53e3737b2a07cb368f07f3815514a17375
|
[
"MIT"
] | null | null | null |
app/blueprints/question.py
|
rubberduckdebuggingtwitch/pond
|
ef574c53e3737b2a07cb368f07f3815514a17375
|
[
"MIT"
] | null | null | null |
from flask import Blueprint
from app import db
question = Blueprint('question', __name__)
@question.route('/question/create/<newquestion>')
def ask(newquestion):
| 22
| 49
| 0.721591
| 20
| 176
| 6.15
| 0.65
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.164773
| 176
| 8
| 50
| 22
| 0.836735
| 0
| 0
| 0
| 0
| 0
| 0.214689
| 0.169492
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0
| 0.4
| null | null | 0.4
| 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
|
f0fd45a8575ac9dfa8852c67edce9137c34ff558
| 105
|
py
|
Python
|
start.py
|
DennyDai/angr-management
|
8a4ba5dafbf2f4d2ba558528a0d1ae099a199a04
|
[
"BSD-2-Clause"
] | 474
|
2015-08-10T17:47:15.000Z
|
2022-03-31T21:10:55.000Z
|
start.py
|
DennyDai/angr-management
|
8a4ba5dafbf2f4d2ba558528a0d1ae099a199a04
|
[
"BSD-2-Clause"
] | 355
|
2015-08-17T09:35:53.000Z
|
2022-03-31T21:29:52.000Z
|
start.py
|
DennyDai/angr-management
|
8a4ba5dafbf2f4d2ba558528a0d1ae099a199a04
|
[
"BSD-2-Clause"
] | 95
|
2015-08-11T14:36:12.000Z
|
2022-03-31T23:01:01.000Z
|
#!/usr/bin/env python3
from angrmanagement.__main__ import main
if __name__ == '__main__':
main()
| 13.125
| 40
| 0.704762
| 13
| 105
| 4.769231
| 0.769231
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.011494
| 0.171429
| 105
| 7
| 41
| 15
| 0.701149
| 0.2
| 0
| 0
| 0
| 0
| 0.096386
| 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
|
0b073328b44a512f16e623fff28f545b42e6fd51
| 1,112
|
py
|
Python
|
contrib/drf_introspection/tests.py
|
hluk/product-definition-center
|
af79f73c30fa5f5709ba03d584b7a49b83166b81
|
[
"MIT"
] | 18
|
2015-12-15T17:56:18.000Z
|
2021-04-10T13:49:48.000Z
|
contrib/drf_introspection/tests.py
|
hluk/product-definition-center
|
af79f73c30fa5f5709ba03d584b7a49b83166b81
|
[
"MIT"
] | 303
|
2015-11-18T07:37:06.000Z
|
2021-05-26T12:34:01.000Z
|
contrib/drf_introspection/tests.py
|
hluk/product-definition-center
|
af79f73c30fa5f5709ba03d584b7a49b83166b81
|
[
"MIT"
] | 27
|
2015-11-19T20:33:54.000Z
|
2021-03-25T08:15:28.000Z
|
#
# Copyright (c) 2018 Red Hat
# Licensed under The MIT License (MIT)
# https://opensource.org/licenses/MIT
#
import unittest
from .serializers import _normalized_fields_set
class TestNormalizedFieldsSet(unittest.TestCase):
def test_normal(self):
self.assertEqual(_normalized_fields_set("a"), set(['a']))
self.assertEqual(_normalized_fields_set(["a"]), set(['a']))
self.assertEqual(_normalized_fields_set(["a", "b"]), set(['a', 'b']))
def test_empty(self):
self.assertEqual(_normalized_fields_set(None), set())
self.assertEqual(_normalized_fields_set([]), set())
self.assertEqual(_normalized_fields_set(['']), set())
def test_comma_separated(self):
self.assertEqual(_normalized_fields_set("a,b"), set(['a', 'b']))
self.assertEqual(_normalized_fields_set(["a,b"]), set(['a', 'b']))
self.assertEqual(_normalized_fields_set(["a,b", "c"]), set(['a', 'b', 'c']))
def test_trailing_comma(self):
self.assertEqual(_normalized_fields_set(','), set())
self.assertEqual(_normalized_fields_set('a,'), set(['a']))
| 35.870968
| 84
| 0.660971
| 137
| 1,112
| 5.058394
| 0.262774
| 0.080808
| 0.329004
| 0.492063
| 0.634921
| 0.634921
| 0.574315
| 0.554113
| 0.546898
| 0.546898
| 0
| 0.00426
| 0.155576
| 1,112
| 30
| 85
| 37.066667
| 0.733759
| 0.089029
| 0
| 0
| 0
| 0
| 0.028798
| 0
| 0
| 0
| 0
| 0
| 0.611111
| 1
| 0.222222
| false
| 0
| 0.111111
| 0
| 0.388889
| 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
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
9bc23169e0f63a1bbdb4498037d1aae47163bebf
| 7,203
|
py
|
Python
|
test/dataset_test.py
|
LFrancesco/pytorch_geometric_temporal
|
0964515a6041ce0cceb12e36ed640df22c046b4d
|
[
"MIT"
] | null | null | null |
test/dataset_test.py
|
LFrancesco/pytorch_geometric_temporal
|
0964515a6041ce0cceb12e36ed640df22c046b4d
|
[
"MIT"
] | null | null | null |
test/dataset_test.py
|
LFrancesco/pytorch_geometric_temporal
|
0964515a6041ce0cceb12e36ed640df22c046b4d
|
[
"MIT"
] | null | null | null |
import numpy as np
import networkx as nx
from torch_geometric_temporal.data.dataset import ChickenpoxDatasetLoader, METRLADatasetLoader, PemsBayDatasetLoader, PedalMeDatasetLoader
from torch_geometric_temporal.data.discrete.static_graph_discrete_signal import StaticGraphDiscreteSignal
from torch_geometric_temporal.data.discrete.dynamic_graph_discrete_signal import DynamicGraphDiscreteSignal
from torch_geometric_temporal.data.splitter import discrete_train_test_split
def get_edge_array(n_count):
return np.array([edge for edge in nx.gnp_random_graph(n_count, 0.1).edges()]).T
def generate_signal(snapshot_count, n_count, feature_count):
edge_indices = [get_edge_array(n_count) for _ in range(snapshot_count)]
edge_weights = [np.ones(edge_indices[t].shape[1]) for t in range(snapshot_count)]
features = [np.random.uniform(0,1,(n_count, feature_count)) for _ in range(snapshot_count)]
return edge_indices, edge_weights, features
def test_dynamic_graph_discrete_signal_real():
snapshot_count = 250
n_count = 100
feature_count = 32
edge_indices, edge_weights, features = generate_signal(250, 100, 32)
targets = [np.random.uniform(0,10,(n_count,)) for _ in range(snapshot_count)]
dataset = DynamicGraphDiscreteSignal(edge_indices, edge_weights, features, targets)
for epoch in range(2):
for snapshot in dataset:
assert snapshot.edge_index.shape[0] == 2
assert snapshot.edge_index.shape[1] == snapshot.edge_attr.shape[0]
assert snapshot.x.shape == (100, 32)
assert snapshot.y.shape == (100, )
targets = [np.floor(np.random.uniform(0,10,(n_count,))).astype(int) for _ in range(snapshot_count)]
dataset = DynamicGraphDiscreteSignal(edge_indices, edge_weights, features, targets)
for epoch in range(2):
for snapshot in dataset:
assert snapshot.edge_index.shape[0] == 2
assert snapshot.edge_index.shape[1] == snapshot.edge_attr.shape[0]
assert snapshot.x.shape == (100, 32)
assert snapshot.y.shape == (100, )
def test_static_graph_discrete_signal():
dataset = StaticGraphDiscreteSignal(None, None, [None, None],[None, None])
for snapshot in dataset:
assert snapshot.edge_index is None
assert snapshot.edge_attr is None
assert snapshot.x is None
assert snapshot.y is None
def test_dynamic_graph_discrete_signal():
dataset = DynamicGraphDiscreteSignal([None, None], [None, None], [None, None],[None, None])
for snapshot in dataset:
assert snapshot.edge_index is None
assert snapshot.edge_attr is None
assert snapshot.x is None
assert snapshot.y is None
def test_static_graph_discrete_signal_typing():
dataset = StaticGraphDiscreteSignal(None, None, [np.array([1])],[np.array([2])])
for snapshot in dataset:
assert snapshot.edge_index is None
assert snapshot.edge_attr is None
assert snapshot.x.shape == (1,)
assert snapshot.y.shape == (1,)
def test_chickenpox():
loader = ChickenpoxDatasetLoader()
dataset = loader.get_dataset()
for epoch in range(3):
for snapshot in dataset:
assert snapshot.edge_index.shape == (2, 102)
assert snapshot.edge_attr.shape == (102, )
assert snapshot.x.shape == (20, 4)
assert snapshot.y.shape == (20, )
def test_pedalme():
loader = PedalMeDatasetLoader()
dataset = loader.get_dataset()
for epoch in range(3):
for snapshot in dataset:
assert snapshot.edge_index.shape == (2, 225)
assert snapshot.edge_attr.shape == (225, )
assert snapshot.x.shape == (15, 4)
assert snapshot.y.shape == (15, )
def test_metrla():
loader = METRLADatasetLoader(raw_data_dir="/tmp/")
dataset = loader.get_dataset()
for epoch in range(3):
for snapshot in dataset:
assert snapshot.edge_index.shape == (2, 1722)
assert snapshot.edge_attr.shape == (1722, )
assert snapshot.x.shape == (207, 2, 12)
assert snapshot.y.shape == (207, 12)
def test_metrla_task_generator():
loader = METRLADatasetLoader(raw_data_dir="/tmp/")
dataset = loader.get_dataset(num_timesteps_in=6, num_timesteps_out=5)
for epoch in range(3):
for snapshot in dataset:
assert snapshot.edge_index.shape == (2, 1722)
assert snapshot.edge_attr.shape == (1722, )
assert snapshot.x.shape == (207, 2, 6)
assert snapshot.y.shape == (207, 5)
def test_pemsbay():
loader = PemsBayDatasetLoader(raw_data_dir="/tmp/")
dataset = loader.get_dataset()
for epoch in range(3):
for snapshot in dataset:
assert snapshot.edge_index.shape == (2, 2694)
assert snapshot.edge_attr.shape == (2694, )
assert snapshot.x.shape == (325, 2, 12)
assert snapshot.y.shape == (325, 2, 12)
def test_pemsbay_task_generator():
loader = PemsBayDatasetLoader(raw_data_dir="/tmp/")
dataset = loader.get_dataset(num_timesteps_in=6, num_timesteps_out=5)
for epoch in range(3):
for snapshot in dataset:
assert snapshot.edge_index.shape == (2, 2694)
assert snapshot.edge_attr.shape == (2694, )
assert snapshot.x.shape == (325, 2, 6)
assert snapshot.y.shape == (325, 2, 5)
def test_discrete_train_test_split_static():
loader = ChickenpoxDatasetLoader()
dataset = loader.get_dataset()
train_dataset, test_dataset = discrete_train_test_split(dataset, 0.8)
for epoch in range(2):
for snapshot in train_dataset:
assert snapshot.edge_index.shape == (2, 102)
assert snapshot.edge_attr.shape == (102, )
assert snapshot.x.shape == (20, 4)
assert snapshot.y.shape == (20, )
for epoch in range(2):
for snapshot in test_dataset:
assert snapshot.edge_index.shape == (2, 102)
assert snapshot.edge_attr.shape == (102, )
assert snapshot.x.shape == (20, 4)
assert snapshot.y.shape == (20, )
def test_discrete_train_test_split_dynamic():
snapshot_count = 250
n_count = 100
feature_count = 32
edge_indices, edge_weights, features = generate_signal(250, 100, 32)
targets = [np.random.uniform(0,10,(n_count,)) for _ in range(snapshot_count)]
dataset = DynamicGraphDiscreteSignal(edge_indices, edge_weights, features, targets)
train_dataset, test_dataset = discrete_train_test_split(dataset, 0.8)
for epoch in range(2):
for snapshot in test_dataset:
assert snapshot.edge_index.shape[0] == 2
assert snapshot.edge_index.shape[1] == snapshot.edge_attr.shape[0]
assert snapshot.x.shape == (100, 32)
assert snapshot.y.shape == (100, )
for epoch in range(2):
for snapshot in train_dataset:
assert snapshot.edge_index.shape[0] == 2
assert snapshot.edge_index.shape[1] == snapshot.edge_attr.shape[0]
assert snapshot.x.shape == (100, 32)
assert snapshot.y.shape == (100, )
| 38.725806
| 138
| 0.663196
| 933
| 7,203
| 4.92926
| 0.105038
| 0.182648
| 0.117417
| 0.095021
| 0.813438
| 0.775603
| 0.678626
| 0.665362
| 0.665362
| 0.665145
| 0
| 0.044107
| 0.231987
| 7,203
| 185
| 139
| 38.935135
| 0.787238
| 0
| 0
| 0.696552
| 0
| 0
| 0.002777
| 0
| 0
| 0
| 0
| 0
| 0.413793
| 1
| 0.096552
| false
| 0
| 0.041379
| 0.006897
| 0.151724
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 1
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
9beaceba19bfb9191d121bea874be4bb75b34444
| 108
|
py
|
Python
|
psdconvert/__init__.py
|
mrstephenneal/psdconvert
|
7e7d288e6db39067ecb6308cd24e45ff8ba01ab2
|
[
"MIT"
] | null | null | null |
psdconvert/__init__.py
|
mrstephenneal/psdconvert
|
7e7d288e6db39067ecb6308cd24e45ff8ba01ab2
|
[
"MIT"
] | 3
|
2018-09-25T23:30:39.000Z
|
2018-10-04T13:33:36.000Z
|
psdconvert/__init__.py
|
sfneal/psdconvert
|
7e7d288e6db39067ecb6308cd24e45ff8ba01ab2
|
[
"MIT"
] | null | null | null |
from psdconvert.psdconvert import BatchConvertPSD, ConvertPSD
__all__ = ["BatchConvertPSD", "ConvertPSD"]
| 21.6
| 61
| 0.805556
| 9
| 108
| 9.222222
| 0.666667
| 0.60241
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.101852
| 108
| 4
| 62
| 27
| 0.85567
| 0
| 0
| 0
| 0
| 0
| 0.231481
| 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
|
501e079318139adccd587d244ec440f8f2c88d8b
| 154
|
py
|
Python
|
N64RET/Loader/SegmentImpl.py
|
N64RET/decomp-framework
|
e74b13e365deae31dd1233642753af008bd2e1cf
|
[
"Beerware"
] | 1
|
2021-03-13T16:56:08.000Z
|
2021-03-13T16:56:08.000Z
|
N64RET/Loader/SegmentImpl.py
|
N64RET/decomp-framework
|
e74b13e365deae31dd1233642753af008bd2e1cf
|
[
"Beerware"
] | null | null | null |
N64RET/Loader/SegmentImpl.py
|
N64RET/decomp-framework
|
e74b13e365deae31dd1233642753af008bd2e1cf
|
[
"Beerware"
] | null | null | null |
from N64RET.Loader.Abstract.SegmentInterface import SegmentInterface
class Segment(SegmentInterface):
def processCallback(self):
return True
| 25.666667
| 68
| 0.792208
| 15
| 154
| 8.133333
| 0.866667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.015267
| 0.149351
| 154
| 5
| 69
| 30.8
| 0.916031
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.25
| 0.25
| 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
| 1
| 0
| 0
| 0
| 1
| 0
| 0
|
0
| 4
|
502602450de870086ebf09d9839bf3344c16fe6e
| 219
|
py
|
Python
|
python/loom_viewer/__init__.py
|
arao11/pattern_viz
|
3123f19a127c9775fadcca25f83aebfc8dc3b9f9
|
[
"BSD-2-Clause"
] | 34
|
2017-10-18T06:09:16.000Z
|
2022-03-21T18:53:16.000Z
|
python/loom_viewer/__init__.py
|
arao11/pattern_viz
|
3123f19a127c9775fadcca25f83aebfc8dc3b9f9
|
[
"BSD-2-Clause"
] | 52
|
2017-10-19T13:35:39.000Z
|
2021-06-03T08:54:55.000Z
|
python/loom_viewer/__init__.py
|
arao11/pattern_viz
|
3123f19a127c9775fadcca25f83aebfc8dc3b9f9
|
[
"BSD-2-Clause"
] | 6
|
2018-05-28T06:16:26.000Z
|
2020-08-17T11:49:34.000Z
|
from ._version import __version__
import loompy
from loompy import LoomConnection
from .loom_tiles import LoomTiles
from .loom_expand import LoomExpand
from .loom_datasets import LoomDatasets
from .loom_cli import main
| 27.375
| 39
| 0.858447
| 30
| 219
| 5.966667
| 0.466667
| 0.178771
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.118721
| 219
| 7
| 40
| 31.285714
| 0.927461
| 0
| 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
| 1
| 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
|
ac9f39a58c658ee1166883057bfe2de40db482b6
| 145
|
py
|
Python
|
baselines/mend/efk_hparams.py
|
kmeng01/rome
|
5ae38a91f384fbf2c526b2fb36406fb3c43262ac
|
[
"MIT"
] | 38
|
2022-02-11T01:49:00.000Z
|
2022-03-27T21:52:33.000Z
|
baselines/mend/efk_hparams.py
|
kmeng01/rome
|
5ae38a91f384fbf2c526b2fb36406fb3c43262ac
|
[
"MIT"
] | 3
|
2022-02-17T07:11:09.000Z
|
2022-03-28T19:39:04.000Z
|
baselines/mend/efk_hparams.py
|
kmeng01/rome
|
5ae38a91f384fbf2c526b2fb36406fb3c43262ac
|
[
"MIT"
] | 10
|
2022-02-11T09:30:09.000Z
|
2022-03-24T15:23:56.000Z
|
from util.hparams import HyperParams
class EFKHyperParams(HyperParams):
KEYS = ["lr_scale", "n_toks", "model_name", "counterfact", "zsre"]
| 24.166667
| 70
| 0.724138
| 17
| 145
| 6
| 0.941176
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.131034
| 145
| 5
| 71
| 29
| 0.809524
| 0
| 0
| 0
| 0
| 0
| 0.268966
| 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
|
acc7f190747ceb066cb3eafea0bad6c34e75ff3b
| 123
|
py
|
Python
|
wristband/stages/serializers.py
|
hmrc/wristband
|
35648a15b91dea4a927e486bfe0ace5e00b44dcc
|
[
"Apache-2.0"
] | 1
|
2015-07-14T14:32:17.000Z
|
2015-07-14T14:32:17.000Z
|
wristband/stages/serializers.py
|
hmrc/wristband
|
35648a15b91dea4a927e486bfe0ace5e00b44dcc
|
[
"Apache-2.0"
] | 4
|
2015-08-03T11:17:37.000Z
|
2015-09-24T10:06:02.000Z
|
wristband/stages/serializers.py
|
hmrc/wristband
|
35648a15b91dea4a927e486bfe0ace5e00b44dcc
|
[
"Apache-2.0"
] | 2
|
2020-05-05T13:56:47.000Z
|
2021-04-10T23:51:52.000Z
|
from rest_framework import serializers
class StageSerializer(serializers.Serializer):
name = serializers.CharField()
| 20.5
| 46
| 0.813008
| 12
| 123
| 8.25
| 0.833333
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.121951
| 123
| 5
| 47
| 24.6
| 0.916667
| 0
| 0
| 0
| 0
| 0
| 0
| 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
|
acf0fa0f42937c92e8479db335f4f6b6e27ae971
| 97
|
py
|
Python
|
lang/py/cookbook/v2/source/cb2_8_10_sol_3.py
|
ch1huizong/learning
|
632267634a9fd84a5f5116de09ff1e2681a6cc85
|
[
"MIT"
] | null | null | null |
lang/py/cookbook/v2/source/cb2_8_10_sol_3.py
|
ch1huizong/learning
|
632267634a9fd84a5f5116de09ff1e2681a6cc85
|
[
"MIT"
] | null | null | null |
lang/py/cookbook/v2/source/cb2_8_10_sol_3.py
|
ch1huizong/learning
|
632267634a9fd84a5f5116de09ff1e2681a6cc85
|
[
"MIT"
] | null | null | null |
.
----------------------------------------------------------------------
Ran 1 test in 0.003s
OK
| 19.4
| 70
| 0.175258
| 7
| 97
| 2.428571
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.05618
| 0.082474
| 97
| 4
| 71
| 24.25
| 0.134831
| 0
| 0
| 0
| 0
| 0
| 0
| 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
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
c588c772b7ba948e4224be62a4cc65eedc1d202b
| 248
|
py
|
Python
|
address_extractor/street_type.py
|
shaynem/address_extractor
|
5288c93780b00ef48c986e179d191f06c0f33d85
|
[
"MIT"
] | 1
|
2018-02-27T13:31:36.000Z
|
2018-02-27T13:31:36.000Z
|
address_extractor/street_type.py
|
shaynem/address_extractor
|
5288c93780b00ef48c986e179d191f06c0f33d85
|
[
"MIT"
] | 1
|
2017-12-17T06:53:42.000Z
|
2017-12-17T06:53:42.000Z
|
address_extractor/street_type.py
|
shaynem/address_extractor
|
5288c93780b00ef48c986e179d191f06c0f33d85
|
[
"MIT"
] | 3
|
2018-02-08T09:48:10.000Z
|
2021-09-08T08:47:45.000Z
|
from address_extractor import datafile
def load_street_types():
return set(line.strip().lower() for line in datafile.read_street_types())
STREET_TYPES = load_street_types()
def is_valid(token):
return token.lower() in STREET_TYPES
| 20.666667
| 81
| 0.754032
| 36
| 248
| 4.916667
| 0.555556
| 0.310734
| 0.169492
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.153226
| 248
| 11
| 82
| 22.545455
| 0.842857
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0.166667
| 0.333333
| 0.833333
| 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
| 1
| 0
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
c5986677f17ef21bd3c5262812a31cd734c014ba
| 5,398
|
py
|
Python
|
integration-tests/test_hub.py
|
MayeulC/the-littlest-jupyterhub
|
1bf50d6c203df7572066353734dfaddb889ced87
|
[
"BSD-3-Clause"
] | null | null | null |
integration-tests/test_hub.py
|
MayeulC/the-littlest-jupyterhub
|
1bf50d6c203df7572066353734dfaddb889ced87
|
[
"BSD-3-Clause"
] | null | null | null |
integration-tests/test_hub.py
|
MayeulC/the-littlest-jupyterhub
|
1bf50d6c203df7572066353734dfaddb889ced87
|
[
"BSD-3-Clause"
] | null | null | null |
import requests
from hubtraf.user import User
from hubtraf.auth.dummy import login_dummy
import secrets
import pytest
from functools import partial
import asyncio
import pwd
import grp
import sys
import subprocess
from tljh.normalize import generate_system_username
# Use sudo to invoke it, since this is how users invoke it.
# This catches issues with PATH
TLJH_CONFIG_PATH = ['sudo', 'tljh-config']
def test_hub_up():
r = requests.get('http://127.0.0.1')
r.raise_for_status()
@pytest.mark.asyncio
async def test_user_code_execute():
"""
User logs in, starts a server & executes code
"""
# This *must* be localhost, not an IP
# aiohttp throws away cookies if we are connecting to an IP!
hub_url = 'http://localhost'
username = secrets.token_hex(8)
assert 0 == await (await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, 'set', 'auth.type', 'dummyauthenticator.DummyAuthenticator')).wait()
assert 0 == await (await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, 'reload')).wait()
async with User(username, hub_url, partial(login_dummy, password='')) as u:
await u.login()
await u.ensure_server()
await u.start_kernel()
await u.assert_code_output("5 * 4", "20", 5, 5)
# Assert that the user exists
assert pwd.getpwnam(f'jupyter-{username}') is not None
@pytest.mark.asyncio
async def test_user_admin_add():
"""
User is made an admin, logs in and we check if they are in admin group
"""
# This *must* be localhost, not an IP
# aiohttp throws away cookies if we are connecting to an IP!
hub_url = 'http://localhost'
username = secrets.token_hex(8)
assert 0 == await (await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, 'set', 'auth.type', 'dummyauthenticator.DummyAuthenticator')).wait()
assert 0 == await (await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, 'add-item', 'users.admin', username)).wait()
assert 0 == await (await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, 'reload')).wait()
async with User(username, hub_url, partial(login_dummy, password='')) as u:
await u.login()
await u.ensure_server()
# Assert that the user exists
assert pwd.getpwnam(f'jupyter-{username}') is not None
# Assert that the user has admin rights
assert f'jupyter-{username}' in grp.getgrnam('jupyterhub-admins').gr_mem
# FIXME: Make this test pass
@pytest.mark.asyncio
@pytest.mark.xfail(reason="Unclear why this is failing")
async def test_user_admin_remove():
"""
User is made an admin, logs in and we check if they are in admin group.
Then we remove them from admin group, and check they *aren't* in admin group :D
"""
# This *must* be localhost, not an IP
# aiohttp throws away cookies if we are connecting to an IP!
hub_url = 'http://localhost'
username = secrets.token_hex(8)
assert 0 == await (await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, 'set', 'auth.type', 'dummyauthenticator.DummyAuthenticator')).wait()
assert 0 == await (await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, 'add-item', 'users.admin', username)).wait()
assert 0 == await (await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, 'reload')).wait()
async with User(username, hub_url, partial(login_dummy, password='')) as u:
await u.login()
await u.ensure_server()
# Assert that the user exists
assert pwd.getpwnam(f'jupyter-{username}') is not None
# Assert that the user has admin rights
assert f'jupyter-{username}' in grp.getgrnam('jupyterhub-admins').gr_mem
assert 0 == await (await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, 'remove-item', 'users.admin', username)).wait()
assert 0 == await (await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, 'reload')).wait()
await u.stop_server()
await u.ensure_server()
# Assert that the user does *not* have admin rights
assert f'jupyter-{username}' not in grp.getgrnam('jupyterhub-admins').gr_mem
@pytest.mark.asyncio
async def test_long_username():
"""
User with a long name logs in, and we check if their name is properly truncated.
"""
# This *must* be localhost, not an IP
# aiohttp throws away cookies if we are connecting to an IP!
hub_url = 'http://localhost'
username = secrets.token_hex(32)
assert 0 == await (await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, 'set', 'auth.type', 'dummyauthenticator.DummyAuthenticator')).wait()
assert 0 == await (await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, 'reload')).wait()
try:
async with User(username, hub_url, partial(login_dummy, password='')) as u:
await u.login()
await u.ensure_server()
# Assert that the user exists
system_username = generate_system_username(f'jupyter-{username}')
assert pwd.getpwnam(system_username) is not None
await u.stop_server()
except:
# If we have any errors, print jupyterhub logs before exiting
subprocess.check_call([
'journalctl',
'-u', 'jupyterhub',
'--no-pager'
])
raise
| 38.557143
| 147
| 0.667655
| 734
| 5,398
| 4.771117
| 0.208447
| 0.039977
| 0.05197
| 0.058252
| 0.735009
| 0.727584
| 0.70474
| 0.676185
| 0.666191
| 0.666191
| 0
| 0.006928
| 0.224528
| 5,398
| 140
| 148
| 38.557143
| 0.82967
| 0.146721
| 0
| 0.538462
| 0
| 0
| 0.149569
| 0.035475
| 0
| 0
| 0
| 0.007143
| 0.25641
| 1
| 0.012821
| false
| 0.051282
| 0.153846
| 0
| 0.166667
| 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
|
c5a349d6ba75afaef353f222b55adb68c887c175
| 847
|
py
|
Python
|
server/users/forms.py
|
NRshka/distconfig
|
8634fd7e245c649f00f97eda06a3c1d8a6d134d6
|
[
"Apache-2.0"
] | null | null | null |
server/users/forms.py
|
NRshka/distconfig
|
8634fd7e245c649f00f97eda06a3c1d8a6d134d6
|
[
"Apache-2.0"
] | null | null | null |
server/users/forms.py
|
NRshka/distconfig
|
8634fd7e245c649f00f97eda06a3c1d8a6d134d6
|
[
"Apache-2.0"
] | null | null | null |
from flask_wtf import FlaskForm
from wtforms import TextField, PasswordField
from wtforms.validators import DataRequired, Length, Email, EqualTo
class LoginForm(FlaskForm):
username = TextField("Login", validators=[DataRequired(), Length(min=6, max=20)])
password = PasswordField("Password", validators=[DataRequired(), Length(min=6, max=48)])
class RegisterForm(FlaskForm):
username = TextField("Login", validators=[DataRequired(), Length(min=6, max=20)])
email = TextField("Email", validators=[DataRequired(), Email()])
password = PasswordField(
"Password", validators=[DataRequired(), Length(min=6, max=48)]
)
confirm = PasswordField(
"Repeat Password", validators=[DataRequired(), EqualTo("password")]
)
fullname = TextField("Full Name", validators=[DataRequired()])
| 40.333333
| 93
| 0.693034
| 84
| 847
| 6.97619
| 0.345238
| 0.262799
| 0.191126
| 0.211604
| 0.457338
| 0.457338
| 0.457338
| 0.457338
| 0.457338
| 0.457338
| 0
| 0.016973
| 0.165289
| 847
| 20
| 94
| 42.35
| 0.811881
| 0
| 0
| 0.125
| 0
| 0
| 0.076179
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0.375
| 0.1875
| 0
| 0.75
| 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
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
|
0
| 4
|
c5a35f7509d7bdb7cccd692066cb93fa5ace99bd
| 178
|
py
|
Python
|
src/domain/component.py
|
gmdlba/simulation
|
d47b58417bf7380f2bbf552275f9b3e51253e1a5
|
[
"MIT"
] | null | null | null |
src/domain/component.py
|
gmdlba/simulation
|
d47b58417bf7380f2bbf552275f9b3e51253e1a5
|
[
"MIT"
] | null | null | null |
src/domain/component.py
|
gmdlba/simulation
|
d47b58417bf7380f2bbf552275f9b3e51253e1a5
|
[
"MIT"
] | null | null | null |
class Component:
def __init__(self, fail_ratio, repair_ratio, state):
self.fail_ratio = fail_ratio
self.repair_ratio = repair_ratio
self.state = state
| 35.6
| 56
| 0.685393
| 23
| 178
| 4.869565
| 0.391304
| 0.241071
| 0.232143
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.241573
| 178
| 5
| 57
| 35.6
| 0.82963
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| false
| 0
| 0
| 0
| 0.4
| 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
|
c5aa07220689d198ea5b80b2db2193cc3ab1e16c
| 315
|
py
|
Python
|
vega/core/__init__.py
|
wnov/vega
|
bf51cbe389d41033c4ae4bc02e5078c3c247c845
|
[
"MIT"
] | 6
|
2020-11-13T15:44:47.000Z
|
2021-12-02T08:14:06.000Z
|
vega/core/__init__.py
|
JacobLee121/vega
|
19256aca4d047bfad3b461f0a927e1c2abb9eb03
|
[
"MIT"
] | null | null | null |
vega/core/__init__.py
|
JacobLee121/vega
|
19256aca4d047bfad3b461f0a927e1c2abb9eb03
|
[
"MIT"
] | 2
|
2021-06-25T09:42:32.000Z
|
2021-08-06T18:00:09.000Z
|
from .run import run, env_args, init_local_cluster_args
from .backend_register import set_backend
from zeus import is_gpu_device, is_npu_device, is_torch_backend, is_tf_backend, is_ms_backend
from zeus.trainer import *
# from .evaluator import *
from zeus.common import FileOps, TaskOps, UserConfig, module_existed
| 45
| 93
| 0.838095
| 50
| 315
| 4.94
| 0.54
| 0.097166
| 0.121457
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.107937
| 315
| 6
| 94
| 52.5
| 0.879004
| 0.07619
| 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
| 1
| 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
|
c5fdc4383e9faab0f88e45a84bcc2b6b742f1722
| 128
|
py
|
Python
|
Curso_em_Video_py3/ex034.py
|
Rodrigo98Matos/Projetos_py
|
6428e2c09d28fd8a717743f4434bc788e7d7d3cc
|
[
"MIT"
] | 1
|
2021-05-11T12:39:43.000Z
|
2021-05-11T12:39:43.000Z
|
Curso_em_Video_py3/ex034.py
|
Rodrigo98Matos/Projetos_py
|
6428e2c09d28fd8a717743f4434bc788e7d7d3cc
|
[
"MIT"
] | null | null | null |
Curso_em_Video_py3/ex034.py
|
Rodrigo98Matos/Projetos_py
|
6428e2c09d28fd8a717743f4434bc788e7d7d3cc
|
[
"MIT"
] | null | null | null |
s = float(input('Salário: '))
if s <= 1250:
s = s * 1.15
if s > 1250:
s = s * 1.1
print('Novo salário: R${}'.format(s))
| 18.285714
| 37
| 0.507813
| 24
| 128
| 2.708333
| 0.5
| 0.092308
| 0.215385
| 0.246154
| 0.307692
| 0.307692
| 0
| 0
| 0
| 0
| 0
| 0.136842
| 0.257813
| 128
| 6
| 38
| 21.333333
| 0.547368
| 0
| 0
| 0
| 0
| 0
| 0.210938
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0.166667
| 1
| 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
| 0
| 0
| 0
| 0
|
0
| 4
|
680c38a3549fb1ad41a0acb314a27f4a18f29f46
| 155
|
py
|
Python
|
src/vision/utils.py
|
ncl-ROVers/surface-2019-20
|
209c06008803971d0430fd3993ef36f9a4686646
|
[
"MIT"
] | 3
|
2021-01-21T07:18:30.000Z
|
2021-12-20T11:09:29.000Z
|
src/vision/utils.py
|
ncl-ROVers/surface-2019-20
|
209c06008803971d0430fd3993ef36f9a4686646
|
[
"MIT"
] | null | null | null |
src/vision/utils.py
|
ncl-ROVers/surface-2019-20
|
209c06008803971d0430fd3993ef36f9a4686646
|
[
"MIT"
] | 3
|
2020-11-24T11:46:23.000Z
|
2021-08-05T18:02:07.000Z
|
"""
Computer vision Utils
=====================
Standard utils module storing common to the package classes, functions, constants, and other objects.
"""
| 22.142857
| 101
| 0.664516
| 17
| 155
| 6.058824
| 0.941176
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.135484
| 155
| 6
| 102
| 25.833333
| 0.768657
| 0.941935
| 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
|
a863b84feb4f230e620e16f0a251daaa8d5f40e2
| 23,270
|
py
|
Python
|
speclus4py/assembler.py
|
ml4py/speclus4py
|
6f70b9e052c2e06f45bd9a44aed2522ecbb84d2b
|
[
"BSD-2-Clause"
] | null | null | null |
speclus4py/assembler.py
|
ml4py/speclus4py
|
6f70b9e052c2e06f45bd9a44aed2522ecbb84d2b
|
[
"BSD-2-Clause"
] | 2
|
2021-02-02T16:34:31.000Z
|
2021-03-24T08:01:02.000Z
|
speclus4py/assembler.py
|
mpecha/speclus4py
|
6f70b9e052c2e06f45bd9a44aed2522ecbb84d2b
|
[
"BSD-2-Clause"
] | null | null | null |
import numpy as np
from numba import jit
import pyflann
from petsc4py import PETSc
from mpi4py import MPI
from speclus4py.types import DataObject, DataType, GraphType, OperatorType, OperatorContainer
@jit(nopython=True)
def get_global_index(x, y, ydim):
return y + x * ydim
@jit(nopython=True)
def get_global_index_volumetric(x, y, z, xdim, ydim):
return x + xdim * (y + z * ydim)
@jit(nopython=True)
def compute_gradient(v1, v2, sigma: float):
abs = np.abs(v1 - v2)
return np.exp(-abs * abs / (2. * sigma * sigma))
@jit(nopython=True)
def compute_gradient_norm(v1, v2, sigma: float):
norm = np.linalg.norm(v1 - v2)
return np.exp(-norm * norm / (2. * sigma * sigma))
class OperatorAssembler(DataObject, OperatorContainer):
def __init__(self, comm=MPI.COMM_WORLD, verbose=False):
DataObject.__init__(self, comm, verbose)
OperatorContainer.__init__(self)
self.__graph_type = GraphType.DIRECTED
@property
def graph_type(self) -> GraphType:
return self.__graph_type
@graph_type.setter
def graph_type(self, t: GraphType):
self.__graph_type = t
def setSimilarityFunc(self, fn, params):
self.__similarity_measure_fn = fn
self.__similarity_measure_params = params
def reset(self):
OperatorContainer.reset(self)
def __construct_adjacency_matrix_general_data(self):
data = self.getData()[0]
# determine dimension of a problem
N = data.shape[0]
# building index (FLANN - Fast Library for Approximate Nearest Neighbors)
pyflann.set_distance_type('euclidean')
flann = pyflann.FLANN()
flann.build_index(data)
# create matrix object
self.mat_adj = PETSc.Mat()
self.mat_adj.create(self.comm)
self.mat_adj.setSizes([N, N])
self.mat_adj.setType(self.mat_type)
if self.graph_type == GraphType.DIRECTED:
self.__construct_adjacency_matrix_general_data_directed_graph(flann)
else:
self.__construct_adjacency_matrix_general_data_undirected_graph(flann)
# finalizing assembly of adjacency matrix
self.mat_adj.assemble()
del flann
def __construct_adjacency_matrix_general_data_directed_graph(self, flann):
self.mat_adj.setPreallocationNNZ(self.connectivity)
self.mat_adj.setFromOptions()
self.mat_adj.setUp()
# Get function for measuring similarity and its parameters
sim_func, sim_func_params = self.getSimilarityMeasure()
if sim_func is None:
sim_func = compute_gradient_norm
if sim_func_params == PETSc.DEFAULT:
sim_func_params = 0.5
data = self.getData()[0]
# building adjacency matrix of similarity graph
i_start, i_end = self.mat_adj.getOwnershipRange()
for I in range(i_start, i_end):
v1 = data[I]
# find nearest neighbours to sample v1
# sometimes self-adjoint vertex is included, thus finding n+1 nearest neighbours
result, dist = flann.nn_index(v1, self.connectivity + 1)
used_nn = 0
for J in range(0, self.connectivity + 1):
idx = result[0, J]
if idx != I and used_nn < self.connectivity:
v2 = data[result[0, J]]
g = sim_func(v1, v2, sim_func_params)
if g > 0.:
self.mat_adj[I, idx] = g
used_nn += 1
elif used_nn >= self.connectivity:
break
def __construct_adjacency_matrix_general_data_undirected_graph(self, flann):
self.mat_adj.setFromOptions()
self.mat_adj.setUp()
# Get function for measuring similarity and its parameters
sim_func, sim_func_params = self.getSimilarityMeasure()
if sim_func is None:
sim_func = compute_gradient_norm
if sim_func_params == PETSc.DEFAULT:
sim_func_params = 0.5
data = self.getData()[0]
# building adjacency matrix of similarity graph
i_start, i_end = self.mat_adj.getOwnershipRange()
for I in range(i_start, i_end):
v1 = data[I]
# find nearest neighbours to sample v1
# sometimes self-adjoint vertex is included, thus finding n+1 nearest neighbours
result, dist = flann.nn_index(v1, self.connectivity + 1)
for J in range(0, self.connectivity + 1):
idx = result[0, J]
if idx != I:
v2 = data[result[0, J]]
g = sim_func(v1, v2, sim_func_params)
if g > 0.:
self.mat_adj[I, idx] = g
self.mat_adj[idx, I] = g
def __construct_adjacency_matrix_vol_img(self):
if self.connectivity != 6 and self.connectivity != 18 and self.connectivity != 26:
raise Exception('Connectivity (con) must be set to 6, 18, or 26')
# Get function for measuring similarity and its parameters
sim_func, sim_func_params = self.getSimilarityMeasure()
if sim_func is None:
sim_func = compute_gradient
if sim_func_params == PETSc.DEFAULT:
sim_func_params = 0.5
data = self.getData()[0]
# determine dimension of a problem
dims = data.GetDimensions()
dim_x = dims[0] - 1
dim_y = dims[1] - 1
dim_z = dims[2] - 1
N = dim_x * dim_y * dim_z
# create matrix object
self.mat_adj = PETSc.Mat()
self.mat_adj.create(self.comm)
self.mat_adj.setSizes([N, N])
self.mat_adj.setType(self.mat_type)
self.mat_adj.setPreallocationNNZ(self.connectivity)
self.mat_adj.setFromOptions()
self.mat_adj.setUp()
# compute local derivatives on structured non-uniform grid that is determined using sigma and
# connectivity of derivatives (6, 18, or 26)
data_scalars = data.GetCellData().GetScalars()
i_start, i_end = self.mat_adj.getOwnershipRange()
for I in range(i_start, i_end):
# determine (x, y, z)-coordinates
z = I // (dim_x * dim_y)
i = I - z * dim_x * dim_y
y = i // dim_x
x = i - y * dim_x
p1 = get_global_index_volumetric(x, y, z, dim_x, dim_y)
v1 = data_scalars.GetTuple1(p1) / 255.
if z > 0:
if self.connectivity > 6 and y > 0:
if self.connectivity == 26 and x > 0:
p2 = get_global_index_volumetric(x - 1, y - 1, z - 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
p2 = get_global_index_volumetric(x, y - 1, z - 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if self.connectivity == 26 and x < dim_x - 1:
p2 = get_global_index_volumetric(x + 1, y - 1, z - 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if self.connectivity > 6 and x > 0:
p2 = get_global_index_volumetric(x - 1, y, z - 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
p2 = get_global_index_volumetric(x, y, z - 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if self.connectivity > 6 and x < dim_x - 1:
p2 = get_global_index_volumetric(x + 1, y, z - 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if self.connectivity > 6 and y < dim_y - 1:
if self.connectivity == 26 and x > 0:
p2 = get_global_index_volumetric(x - 1, y + 1, z - 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
p2 = get_global_index_volumetric(x, y + 1, z - 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if self.connectivity == 26 and x < dim_x - 1:
p2 = get_global_index_volumetric(x + 1, y + 1, z - 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if y > 0:
if self.connectivity > 6 and x > 0:
p2 = get_global_index_volumetric(x - 1, y - 1, z, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
p2 = get_global_index_volumetric(x, y - 1, z, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if self.connectivity > 6 and x < dim_x - 1:
p2 = get_global_index_volumetric(x + 1, y - 1, z, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if x > 0:
p2 = get_global_index_volumetric(x - 1, y, z, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if x < dim_x - 1:
p2 = get_global_index_volumetric(x + 1, y, z, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if y < dim_y - 1:
if self.connectivity > 6 and x > 0:
p2 = get_global_index_volumetric(x - 1, y + 1, z, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
p2 = get_global_index_volumetric(x, y + 1, z, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if self.connectivity > 6 and x < dim_x - 1:
p2 = get_global_index_volumetric(x + 1, y + 1, z, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if z < dim_z - 1:
if self.connectivity > 6 and y > 0:
if self.connectivity == 26 and x > 0:
p2 = get_global_index_volumetric(x - 1, y - 1, z + 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
p2 = get_global_index_volumetric(x, y - 1, z + 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if self.connectivity == 26 and x < dim_x - 1:
p2 = get_global_index_volumetric(x + 1, y - 1, z + 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if self.connectivity > 6 and x > 0:
p2 = get_global_index_volumetric(x - 1, y, z + 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
p2 = get_global_index_volumetric(x, y, z + 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if self.connectivity > 6 and x < dim_x - 1:
p2 = get_global_index_volumetric(x + 1, y, z + 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if self.connectivity > 6 and y < dim_y - 1:
if self.connectivity == 26 and x > 0:
p2 = get_global_index_volumetric(x - 1, y + 1, z + 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
p2 = get_global_index_volumetric(x, y + 1, z + 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
if self.connectivity == 26 and x < dim_x - 1:
p2 = get_global_index_volumetric(x + 1, y + 1, z + 1, dim_x, dim_y)
v2 = data_scalars.GetTuple1(p2) / 255.
g = sim_func(v1, v2, sim_func_params)
self.mat_adj[p1, p2] = g
# finalizing assembly of adjacency matrix
self.mat_adj.assemble()
def __construct_adjacency_matrix_img(self):
if self.connectivity != 4 and self.connectivity != 8:
PETSc.Sys.Print('Connectivity (con) must be set to 4 or 8')
raise PETSc.Error(62)
rows = self.data.shape[0]
cols = self.data.shape[1]
N = rows * cols
# Get function for measuring similarity and its parameters
sim_func, sim_func_params = self.getSimilarityMeasure()
if sim_func is None:
if len(self.data.shape) == 3:
sim_func = compute_gradient_norm
else:
sim_func = compute_gradient
if sim_func_params == PETSc.DEFAULT:
sim_func_params = 0.5
data = self.getData()[0]
# create matrix object
self.mat_adj = PETSc.Mat()
self.mat_adj.create(self.comm)
self.mat_adj.setSizes([N, N])
self.mat_adj.setType(self.mat_type)
self.mat_adj.setPreallocationNNZ(self.connectivity)
self.mat_adj.setFromOptions()
self.mat_adj.setUp()
i_start, i_end = self.mat_adj.getOwnershipRange()
for I in range(i_start, i_end):
# determine (x, y) coordinates
x = I // cols
y = I - x * cols
p1 = I
v1 = self.data[x, y] / 255.
if x > 0:
if y > 0 and self.connectivity == 8:
p2 = get_global_index(x - 1, y - 1, cols)
v2 = data[x - 1, y - 1] / 255.
self.mat_adj[p1, p2] = sim_func(v1, v2, sim_func_params)
p2 = get_global_index(x - 1, y, cols)
v2 = data[x - 1, y] / 255.
self.mat_adj[p1, p2] = sim_func(v1, v2, sim_func_params)
if y < cols - 1 and self.connectivity == 8:
p2 = get_global_index(x - 1, y + 1, cols)
v2 = data[x - 1, y + 1] / 255.
self.mat_adj[p1, p2] = sim_func(v1, v2, sim_func_params)
if y > 0:
p2 = get_global_index(x, y - 1, cols)
v2 = data[x, y - 1] / 255.
self.mat_adj[p1, p2] = sim_func(v1, v2, sim_func_params)
if y < cols - 1:
p2 = get_global_index(x, y + 1, cols)
v2 = data[x, y + 1] / 255.
self.mat_adj[p1, p2] = sim_func(v1, v2, sim_func_params)
if x < rows - 1:
if y > 0 and self.connectivity == 8:
p2 = get_global_index(x + 1, y - 1, cols)
v2 = data[x + 1, y - 1] / 255.
self.mat_adj[p1, p2] = sim_func(v1, v2, sim_func_params)
p2 = get_global_index(x + 1, y, cols)
v2 = data[x + 1, y] / 255.
self.mat_adj[p1, p2] = sim_func(v1, v2, sim_func_params)
if y < cols - 1 and self.connectivity == 8:
p2 = get_global_index(x + 1, y + 1, cols)
v2 = data[x + 1, y + 1] / 255.
self.mat_adj[p1, p2] = sim_func(v1, v2, sim_func_params)
# finalizing assembly of adjacency matrix
self.mat_adj.assemble()
def assembly(self):
self.reset()
data_type = self.getData()[1]
if self.fn_similarity_params is not None and self.verbose:
if type(self.fn_similarity_params) == float:
str_params = ', param=%.2f' % self.fn_similarity_params
else:
str_params = ', params=['
str_params += ''.join('{}, '.format(k) for k in self.fn_similarity_params)
str_params = str_params[:-2] + ']'
else:
str_params = ''
if data_type == DataType.IMG:
if self.connectivity == PETSc.DEFAULT:
self.connectivity = 4
if self.verbose:
s = 'Construct operator (%s, GRAPH_%s) for image: connectivity=%d'
v = (self.operator_type.name, GraphType.UNDIRECTED.name, self.connectivity)
PETSc.Sys.Print(s % v + str_params)
self.__construct_adjacency_matrix_img()
elif data_type == DataType.VOL_IMG:
if self.connectivity == PETSc.DEFAULT:
self.connectivity = 6
if self.verbose:
s = 'Construct operator (%s, GRAPH_%s) for volumetric image: connectivity=%d'
v = (self.operator_type.name, self.graph_type.name, self.connectivity)
PETSc.Sys.Print(s % v + str_params)
self.__construct_adjacency_matrix_vol_img()
else:
if self.connectivity == PETSc.DEFAULT:
self.connectivity = 3
if self.verbose:
s = 'Construct operator (%s, GRAPH_%s) for general data: connectivity=%d'
v = (self.operator_type.name, self.graph_type.name, self.connectivity)
PETSc.Sys.Print(s % v + str_params)
self.__construct_adjacency_matrix_general_data()
# if data_type == DataType.IMG:
# if self.connectivity == PETSc.DEFAULT:
# self.connectivity = 4
#
# if self.verbose:
# PETSc.Sys.Print(
# 'Construct operator (%s) for image: connectivity=%d, sigma=%2g'
# % (self.operator_type.name, self.connectivity, self.sigma)
# )
#
# self.__construct_adjacency_matrix_img()
# elif data_type == DataType.VOL_IMG: # volumetric image
# if self.connectivity == PETSc.DEFAULT:
# self.connectivity = 6
#
# if self.verbose:
# if self.fn_similarity_params is not None:
# s = 'Construct operator (%s, GRAPH_ %s) for volumetric image: connectivity=%d, '
# v = (self.operator_type.name, self.graph_type.name, self.connectivity)
# sv = s % v
# if type(self.fn_similarity_params) == float:
# sp = 'param=%.2f' % self.fn_similarity_params
# else:
# sp = 'params=('
# sp += ''.join('{}, '.format(k) for k in self.fn_similarity_params)
# sp = sp[:-2] + ')'
# sv += sp
# else:
# s = 'Construct operator (%s, GRAPH_%s) for volumetric image: connectivity=%d params=None'
# v = (self.operator_type.name, self.graph_type.name, self.connectivity)
# sv = s % v
# PETSc.Sys.Print(sv)
#
# exit(-1)
#
# self.__construct_adjacency_matrix_vol_img()
# else:
# if self.connectivity == PETSc.DEFAULT:
# self.connectivity = 6
#
# if self.verbose:
# PETSc.Sys.Print(
# 'Construct operator (%s) for general data: connectivity=%d, params=%2g'
# % (self.operator_type.name, self.connectivity, self.__similarity_measure_params)
# )
#
# self.__construct_adjacency_matrix_general_data()
N = self.mat_adj.getSize()[0]
# compute degree matrix D_i = deg(v_i)
self.vec_diag = self.mat_adj.createVecLeft()
self.mat_adj.getRowSum(self.vec_diag)
if self.operator_type != OperatorType.MARKOV_1 or self.operator_type != OperatorType.MARKOV_2:
self.mat_op = PETSc.Mat().createAIJ((N, N), comm=self.comm)
self.mat_op.setPreallocationNNZ(self.connectivity + 1)
self.mat_op.setFromOptions()
self.mat_op.setUp()
self.mat_op.setDiagonal(self.vec_diag)
self.mat_op.assemble()
# L = D - A
self.mat_op.axpy(-1., self.mat_adj)
else: # P = D^-1 A (MARKOV_1) or Ng, Weiss (MARKOV_2)
self.mat_op = self.mat_adj.duplicate()
self.mat_op.setFromOptions()
self.mat_op.setType(self.mat_type)
self.mat_op.setUp()
self.mat_op.copy(self.mat_op)
if self.operator_type != OperatorType.LAPLACIAN_UNNORMALIZED:
tmp_vec = self.vec_diag.duplicate()
self.vec_diag.copy(tmp_vec)
if self.operator_type == OperatorType.LAPLACIAN_NORMALIZED or self.operator_type == OperatorType.MARKOV_2:
tmp_vec.sqrtabs()
tmp_vec.reciprocal()
self.mat_op.diagonalScale(tmp_vec, tmp_vec)
elif self.operator_type == OperatorType.MARKOV_1:
tmp_vec.reciprocal()
self.mat_op.diagonalScale(tmp_vec)
else: # L_rw
tmp_vec.reciprocal()
self.mat_op.diagonalScale(tmp_vec) # left diagonal scale
del tmp_vec
self.mat_op.assemble()
| 38.913043
| 118
| 0.527374
| 2,981
| 23,270
| 3.886951
| 0.077826
| 0.0586
| 0.062139
| 0.034176
| 0.816777
| 0.791059
| 0.756538
| 0.698887
| 0.682575
| 0.660395
| 0
| 0.042768
| 0.374001
| 23,270
| 597
| 119
| 38.978224
| 0.75266
| 0.125398
| 0
| 0.573265
| 0
| 0
| 0.015832
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.03856
| false
| 0
| 0.015424
| 0.007712
| 0.069409
| 0
| 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
|
a8684b12d8db872b37355b83fb5d31fea99930fd
| 120
|
py
|
Python
|
src/python_patterns/factory/rectangle.py
|
NostraDavid/python-patterns
|
35b4807b81c21ba9b53d61284edb76152d57e4bc
|
[
"MIT"
] | null | null | null |
src/python_patterns/factory/rectangle.py
|
NostraDavid/python-patterns
|
35b4807b81c21ba9b53d61284edb76152d57e4bc
|
[
"MIT"
] | null | null | null |
src/python_patterns/factory/rectangle.py
|
NostraDavid/python-patterns
|
35b4807b81c21ba9b53d61284edb76152d57e4bc
|
[
"MIT"
] | null | null | null |
from shape import IShape
class Rectangle(IShape):
def draw(self):
print("Inside Rectangle::draw() method.")
| 17.142857
| 47
| 0.683333
| 15
| 120
| 5.466667
| 0.8
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.191667
| 120
| 6
| 48
| 20
| 0.845361
| 0
| 0
| 0
| 0
| 0
| 0.266667
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.25
| 0
| 0.75
| 0.25
| 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
|
a87cfb5aa370c41f24696bc843b3043067992de7
| 147
|
py
|
Python
|
dnsimple/exceptions.py
|
mherrmann/dnsimple-python
|
a89127f0bafb2a001c902206fba87cbc4f3bc2d1
|
[
"MIT"
] | 12
|
2020-06-18T17:16:03.000Z
|
2022-03-23T08:35:49.000Z
|
dnsimple/exceptions.py
|
mherrmann/dnsimple-python
|
a89127f0bafb2a001c902206fba87cbc4f3bc2d1
|
[
"MIT"
] | 129
|
2020-06-25T12:15:51.000Z
|
2022-03-23T09:42:16.000Z
|
dnsimple/exceptions.py
|
mherrmann/dnsimple-python
|
a89127f0bafb2a001c902206fba87cbc4f3bc2d1
|
[
"MIT"
] | 6
|
2020-07-03T09:34:01.000Z
|
2021-12-20T04:29:59.000Z
|
class DNSimpleException(Exception):
def __init__(self, message=None, errors=None):
self.message = message
self.errors = errors
| 29.4
| 50
| 0.687075
| 16
| 147
| 6.0625
| 0.5625
| 0.226804
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.217687
| 147
| 4
| 51
| 36.75
| 0.843478
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0
| 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
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
a8a1665c318195b4381f9ac27cb7f849891f3922
| 1,146
|
py
|
Python
|
reg/models.py
|
saurabh00031/Coding-Avengers-007
|
fac90680f1a9cc96ce0c22e23b7081745b59eee9
|
[
"MIT"
] | 2
|
2021-11-18T20:34:26.000Z
|
2021-12-18T04:48:23.000Z
|
reg/models.py
|
saurabh00031/Coding-Avengers-007
|
fac90680f1a9cc96ce0c22e23b7081745b59eee9
|
[
"MIT"
] | null | null | null |
reg/models.py
|
saurabh00031/Coding-Avengers-007
|
fac90680f1a9cc96ce0c22e23b7081745b59eee9
|
[
"MIT"
] | null | null | null |
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class User(AbstractUser):
is_user = models.BooleanField(default=False)
is_hospital = models.BooleanField(default=False)
class hspinfo(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
hospital_Name = models.CharField(max_length=50)
phone = models.CharField(max_length=12)
email = models.CharField(max_length=30)
city = models.CharField(max_length=30)
address = models.CharField(max_length=120)
no_of_beds = models.CharField(max_length=10)
no_of_ventilators = models.CharField(max_length=10)
no_of_vaccines = models.CharField(max_length=10)
def __str__(self):
return self.user.username
class usrinfo(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
full_Name = models.CharField(max_length=50)
phone = models.CharField(max_length=12)
email = models.CharField(max_length=30)
city = models.CharField(max_length=30)
address = models.TextField()
def __str__(self):
return self.user.username
| 33.705882
| 63
| 0.740838
| 152
| 1,146
| 5.375
| 0.328947
| 0.220318
| 0.264382
| 0.352509
| 0.658507
| 0.626683
| 0.626683
| 0.474908
| 0.474908
| 0.474908
| 0
| 0.025934
| 0.158813
| 1,146
| 34
| 64
| 33.705882
| 0.821577
| 0.020942
| 0
| 0.461538
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.076923
| false
| 0
| 0.076923
| 0.076923
| 1
| 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
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
a8b20b0ac64e54937531f1210cdcc85a4cac8d6c
| 671
|
py
|
Python
|
modelchimp/migrations/0049_auto_20190516_0759.py
|
samzer/modelchimp-server
|
48668d0f73025b2cc967006b3193b67aaf970ad7
|
[
"BSD-2-Clause"
] | 134
|
2018-11-07T08:35:47.000Z
|
2022-01-09T00:39:40.000Z
|
modelchimp/migrations/0049_auto_20190516_0759.py
|
samzer/modelchimp-server
|
48668d0f73025b2cc967006b3193b67aaf970ad7
|
[
"BSD-2-Clause"
] | 841
|
2018-11-06T19:45:04.000Z
|
2022-03-31T13:07:16.000Z
|
modelchimp/migrations/0049_auto_20190516_0759.py
|
samzer/modelchimp-server
|
48668d0f73025b2cc967006b3193b67aaf970ad7
|
[
"BSD-2-Clause"
] | 16
|
2019-02-08T12:48:17.000Z
|
2021-02-18T22:11:38.000Z
|
# Generated by Django 2.2 on 2019-05-16 07:59
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('modelchimp', '0048_auto_20190515_1032'),
]
operations = [
migrations.RemoveField(
model_name='experiment',
name='algorithm',
),
migrations.RemoveField(
model_name='experiment',
name='features',
),
migrations.RemoveField(
model_name='experiment',
name='platform',
),
migrations.RemoveField(
model_name='experiment',
name='platform_library',
),
]
| 22.366667
| 50
| 0.551416
| 56
| 671
| 6.464286
| 0.553571
| 0.232044
| 0.287293
| 0.331492
| 0.530387
| 0.530387
| 0.287293
| 0
| 0
| 0
| 0
| 0.067873
| 0.341282
| 671
| 29
| 51
| 23.137931
| 0.751131
| 0.064083
| 0
| 0.521739
| 1
| 0
| 0.182109
| 0.036741
| 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
|
7634515bc4bcec09b8dbae019020677adfe3e362
| 76
|
py
|
Python
|
grr/server/grr_response_server/__init__.py
|
tsehori/grr
|
048506f22f74642bfe61749069a45ddf496fdab3
|
[
"Apache-2.0"
] | 1
|
2021-07-01T01:43:06.000Z
|
2021-07-01T01:43:06.000Z
|
grr/server/grr_response_server/__init__.py
|
tsehori/grr
|
048506f22f74642bfe61749069a45ddf496fdab3
|
[
"Apache-2.0"
] | 44
|
2021-05-14T22:49:24.000Z
|
2022-03-13T21:54:02.000Z
|
grr/server/grr_response_server/__init__.py
|
tsehori/grr
|
048506f22f74642bfe61749069a45ddf496fdab3
|
[
"Apache-2.0"
] | 1
|
2020-06-25T14:25:54.000Z
|
2020-06-25T14:25:54.000Z
|
#!/usr/bin/env python
# Lint as: python3
"""Server-specific GRR classes."""
| 19
| 34
| 0.684211
| 11
| 76
| 4.727273
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.014925
| 0.118421
| 76
| 3
| 35
| 25.333333
| 0.761194
| 0.868421
| 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
|
766c83b766f6f4e8f20059773bcc9f263122f800
| 84
|
py
|
Python
|
examples/__init__.py
|
gelijergensen/PermutationImportance
|
7a09a407e42745c223055e0597c5226ff64b2f3c
|
[
"MIT"
] | 4
|
2019-02-01T17:49:14.000Z
|
2020-06-25T15:09:56.000Z
|
examples/__init__.py
|
gelijergensen/PermutationImportance
|
7a09a407e42745c223055e0597c5226ff64b2f3c
|
[
"MIT"
] | 42
|
2018-09-27T19:35:32.000Z
|
2020-10-09T17:56:57.000Z
|
examples/__init__.py
|
gelijergensen/PermutationImportance
|
7a09a407e42745c223055e0597c5226ff64b2f3c
|
[
"MIT"
] | 4
|
2018-09-27T19:34:33.000Z
|
2021-02-12T19:41:31.000Z
|
"""These are just examples of using the various methods in PermutationImportance"""
| 42
| 83
| 0.797619
| 11
| 84
| 6.090909
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.130952
| 84
| 1
| 84
| 84
| 0.917808
| 0.916667
| 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
|
76b9536a1935368189da32f54e7611ec0e043a3f
| 103
|
py
|
Python
|
tavastiaevents/apps.py
|
dymesolutions/HameEvents
|
7962bb05af63695da79009fe1548e7094822b7e6
|
[
"MIT"
] | null | null | null |
tavastiaevents/apps.py
|
dymesolutions/HameEvents
|
7962bb05af63695da79009fe1548e7094822b7e6
|
[
"MIT"
] | null | null | null |
tavastiaevents/apps.py
|
dymesolutions/HameEvents
|
7962bb05af63695da79009fe1548e7094822b7e6
|
[
"MIT"
] | 1
|
2021-05-29T19:32:31.000Z
|
2021-05-29T19:32:31.000Z
|
from django.apps import AppConfig
class TavastiaeventsConfig(AppConfig):
name = 'tavastiaevents'
| 17.166667
| 38
| 0.786408
| 10
| 103
| 8.1
| 0.9
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.145631
| 103
| 5
| 39
| 20.6
| 0.920455
| 0
| 0
| 0
| 0
| 0
| 0.135922
| 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
|
4f11ef4ff178807475c9337e11e8da8dcdc831ab
| 107
|
py
|
Python
|
purchaseRequests/apps.py
|
MLavrentyev/TeamManager
|
cbddb49fb831c7c749253a017353fd04baebe4e4
|
[
"MIT"
] | 1
|
2019-10-24T21:20:49.000Z
|
2019-10-24T21:20:49.000Z
|
purchaseRequests/apps.py
|
MLavrentyev/TeamManager
|
cbddb49fb831c7c749253a017353fd04baebe4e4
|
[
"MIT"
] | 32
|
2018-12-22T17:33:30.000Z
|
2022-02-10T07:25:59.000Z
|
purchaseRequests/apps.py
|
MLavrentyev/TeamManager
|
cbddb49fb831c7c749253a017353fd04baebe4e4
|
[
"MIT"
] | null | null | null |
from django.apps import AppConfig
class PurchaserequestsConfig(AppConfig):
name = 'purchaseRequests'
| 17.833333
| 40
| 0.794393
| 10
| 107
| 8.5
| 0.9
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.140187
| 107
| 5
| 41
| 21.4
| 0.923913
| 0
| 0
| 0
| 0
| 0
| 0.149533
| 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
|
4f19ed3cc7c5a13779926c2a41c4c8722732bca6
| 248
|
py
|
Python
|
utils/warnings.py
|
Jakob-Unfried/msc-legacy
|
2c41f3f714936c25dd534bd66da802c26176fcfa
|
[
"MIT"
] | 1
|
2021-03-22T14:16:43.000Z
|
2021-03-22T14:16:43.000Z
|
utils/warnings.py
|
Jakob-Unfried/msc-legacy
|
2c41f3f714936c25dd534bd66da802c26176fcfa
|
[
"MIT"
] | null | null | null |
utils/warnings.py
|
Jakob-Unfried/msc-legacy
|
2c41f3f714936c25dd534bd66da802c26176fcfa
|
[
"MIT"
] | null | null | null |
import sys
def custom_warn(msg, category=UserWarning, filename='', lineno=-1, *args, **kwargs):
print(f'{category.__name__}: {msg}', file=sys.stderr, flush=True)
print(f' issued from: {filename}:{lineno}', file=sys.stderr, flush=True)
| 35.428571
| 84
| 0.681452
| 34
| 248
| 4.823529
| 0.647059
| 0.170732
| 0.158537
| 0.219512
| 0.268293
| 0
| 0
| 0
| 0
| 0
| 0
| 0.00463
| 0.129032
| 248
| 6
| 85
| 41.333333
| 0.75463
| 0
| 0
| 0
| 0
| 0
| 0.25
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.25
| 0
| 0.5
| 0.5
| 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
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
4f35f7f56df5326b780043fc6119c1ec046f05e0
| 171
|
py
|
Python
|
main.py
|
kamacizy/trading_bot
|
567bbecb4820d68ab65fc66788fcf28d6abd65da
|
[
"MIT"
] | null | null | null |
main.py
|
kamacizy/trading_bot
|
567bbecb4820d68ab65fc66788fcf28d6abd65da
|
[
"MIT"
] | null | null | null |
main.py
|
kamacizy/trading_bot
|
567bbecb4820d68ab65fc66788fcf28d6abd65da
|
[
"MIT"
] | null | null | null |
import robinhood
import reddit
import twitter
#prompt = input('What you want?')
def MAIN():
#reddit.CROSS_CHECK()
twitter.search()
MAIN()
| 10.058824
| 34
| 0.602339
| 19
| 171
| 5.368421
| 0.736842
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.28655
| 171
| 17
| 35
| 10.058824
| 0.836066
| 0.304094
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.166667
| true
| 0
| 0.5
| 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
| 0
| 1
| 0
| 1
| 0
| 1
| 0
|
0
| 4
|
4f68104ea263246e3c6b13c09eca0616b23d2185
| 53
|
py
|
Python
|
tasks.py
|
MinchinWeb/gpx-reader
|
772adff6c5803826f130286f8ec078aad7c49508
|
[
"MIT"
] | 1
|
2021-06-03T03:35:55.000Z
|
2021-06-03T03:35:55.000Z
|
tasks.py
|
MinchinWeb/gpx-reader
|
772adff6c5803826f130286f8ec078aad7c49508
|
[
"MIT"
] | null | null | null |
tasks.py
|
MinchinWeb/gpx-reader
|
772adff6c5803826f130286f8ec078aad7c49508
|
[
"MIT"
] | null | null | null |
from minchin.releaser import make_release, vendorize
| 26.5
| 52
| 0.867925
| 7
| 53
| 6.428571
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.09434
| 53
| 1
| 53
| 53
| 0.9375
| 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
|
4f69bcbd3a6250bc26d88e0b2c21491dd07d6260
| 60
|
py
|
Python
|
tests/__init__.py
|
paulross/typin
|
113224d868c95e93b9ae724b0a9d9cfe3e3c78f8
|
[
"MIT"
] | 7
|
2017-11-12T21:29:18.000Z
|
2019-01-30T01:50:47.000Z
|
tests/__init__.py
|
paulross/typin
|
113224d868c95e93b9ae724b0a9d9cfe3e3c78f8
|
[
"MIT"
] | null | null | null |
tests/__init__.py
|
paulross/typin
|
113224d868c95e93b9ae724b0a9d9cfe3e3c78f8
|
[
"MIT"
] | null | null | null |
# -*- coding: utf-8 -*-
"""Unit test package for typin."""
| 15
| 34
| 0.55
| 8
| 60
| 4.125
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.020408
| 0.183333
| 60
| 3
| 35
| 20
| 0.653061
| 0.85
| 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
|
4f759845bd0851030a881eca335acd085512ad0a
| 387
|
py
|
Python
|
TWLight/message_storage.py
|
aacaldwell/TWLight
|
68e6d0d81ddd52596025f15d2c9a75dcdf504734
|
[
"MIT"
] | 67
|
2017-12-14T22:27:48.000Z
|
2022-03-13T18:21:31.000Z
|
TWLight/message_storage.py
|
aacaldwell/TWLight
|
68e6d0d81ddd52596025f15d2c9a75dcdf504734
|
[
"MIT"
] | 433
|
2017-03-24T22:51:23.000Z
|
2022-03-31T19:36:22.000Z
|
TWLight/message_storage.py
|
Mahuton/TWLight
|
90b299d07b0479f21dc90e17b8d05f5a221b0de1
|
[
"MIT"
] | 105
|
2017-06-23T03:53:41.000Z
|
2022-03-30T17:24:29.000Z
|
from django.contrib.messages.storage.session import SessionStorage
from django.contrib.messages.storage.base import Message
from .view_mixins import DedupMessageMixin
class SessionDedupStorage(DedupMessageMixin, SessionStorage):
"""
Custom session storage to prevent storing duplicate messages.
cribbed directly from: https://stackoverflow.com/a/25157660
"""
pass
| 29.769231
| 66
| 0.793282
| 42
| 387
| 7.285714
| 0.666667
| 0.065359
| 0.111111
| 0.163399
| 0.20915
| 0
| 0
| 0
| 0
| 0
| 0
| 0.023952
| 0.136951
| 387
| 12
| 67
| 32.25
| 0.892216
| 0.312662
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0.2
| 0.6
| 0
| 0.8
| 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
| 0
| 1
| 1
| 1
| 0
| 0
| 0
|
0
| 4
|
4f9512e895e21e02b844a3b9adbea0b5edbaaa9f
| 114
|
py
|
Python
|
api/models/__init__.py
|
weng-lab/SCREEN
|
e8e7203e2f9baa2de70e2f75bdad3ae24b568367
|
[
"MIT"
] | 5
|
2020-07-30T02:35:20.000Z
|
2020-12-24T01:26:47.000Z
|
heatmaps/API/heatmaps/__init__.py
|
weng-lab/SCREEN
|
e8e7203e2f9baa2de70e2f75bdad3ae24b568367
|
[
"MIT"
] | 6
|
2021-03-04T10:30:11.000Z
|
2022-03-16T16:47:47.000Z
|
api/models/__init__.py
|
weng-lab/SCREEN
|
e8e7203e2f9baa2de70e2f75bdad3ae24b568367
|
[
"MIT"
] | 2
|
2020-12-08T10:05:02.000Z
|
2022-03-10T09:41:19.000Z
|
# SPDX-License-Identifier: MIT
# Copyright (c) 2016-2020 Michael Purcaro, Henry Pratt, Jill Moore, Zhiping Weng
| 22.8
| 80
| 0.754386
| 16
| 114
| 5.375
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.082474
| 0.149123
| 114
| 4
| 81
| 28.5
| 0.804124
| 0.938596
| 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
|
96ded746228047ffb5a146da8dc9983d122c408c
| 185
|
py
|
Python
|
src/shart/__init__.py
|
insert-username/shart
|
0ee05ff28c62371018211d7f2fc6b7cae9279760
|
[
"MIT"
] | null | null | null |
src/shart/__init__.py
|
insert-username/shart
|
0ee05ff28c62371018211d7f2fc6b7cae9279760
|
[
"MIT"
] | null | null | null |
src/shart/__init__.py
|
insert-username/shart
|
0ee05ff28c62371018211d7f2fc6b7cae9279760
|
[
"MIT"
] | null | null | null |
#!/usr/bin/env python3
import math
import numpy as np
import shapely as sh
import shapely.affinity
import shapely.geometry
__all__ = [ "box", "coordinates", "group", "utils" ]
| 10.882353
| 52
| 0.708108
| 25
| 185
| 5.08
| 0.72
| 0.307087
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.006579
| 0.178378
| 185
| 16
| 53
| 11.5625
| 0.828947
| 0.113514
| 0
| 0
| 0
| 0
| 0.152866
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.833333
| 0
| 0.833333
| 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
|
8c2a4c3e460876ef7e73c5d7ae105c1010689449
| 1,112
|
py
|
Python
|
groupdocsclassificationcloud/__init__.py
|
groupdocs-classification-cloud/groupdocs-classification-cloud-python
|
5538e34808be16d57fb7709194d5c8837c64ba80
|
[
"MIT"
] | 3
|
2019-10-31T09:32:24.000Z
|
2020-11-09T07:30:43.000Z
|
groupdocsclassificationcloud/__init__.py
|
groupdocs-classification-cloud/groupdocs-classification-cloud-python
|
5538e34808be16d57fb7709194d5c8837c64ba80
|
[
"MIT"
] | null | null | null |
groupdocsclassificationcloud/__init__.py
|
groupdocs-classification-cloud/groupdocs-classification-cloud-python
|
5538e34808be16d57fb7709194d5c8837c64ba80
|
[
"MIT"
] | 1
|
2020-04-17T13:39:44.000Z
|
2020-04-17T13:39:44.000Z
|
# coding: utf-8
# flake8: noqa
from __future__ import absolute_import
# import apis into sdk package
from groupdocsclassificationcloud.apis.classification_api import ClassificationApi
# import ApiClient
from groupdocsclassificationcloud.api_client import ApiClient
from groupdocsclassificationcloud.configuration import Configuration
# import models into sdk package
from groupdocsclassificationcloud.models.base_request import BaseRequest
from groupdocsclassificationcloud.models.base_response import BaseResponse
from groupdocsclassificationcloud.models.classification_result import ClassificationResult
from groupdocsclassificationcloud.models.file_info import FileInfo
from groupdocsclassificationcloud.models.format import Format
from groupdocsclassificationcloud.models.format_collection import FormatCollection
from groupdocsclassificationcloud.models.classification_response import ClassificationResponse
from groupdocsclassificationcloud.models.classify_request import ClassifyRequest
from groupdocsclassificationcloud.models.get_supported_file_formats_request import GetSupportedFileFormatsRequest
| 48.347826
| 113
| 0.903777
| 105
| 1,112
| 9.4
| 0.390476
| 0.389058
| 0.346505
| 0.036474
| 0.093212
| 0
| 0
| 0
| 0
| 0
| 0
| 0.001932
| 0.069245
| 1,112
| 23
| 113
| 48.347826
| 0.951691
| 0.092626
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 1
| 0
| 1
| 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
| 0
| 1
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
8c59db3fa2162dfc0679b03d66074f48ec6815e7
| 213
|
py
|
Python
|
ml/logistic/sklogistic.py
|
ruiyangio/ml-sentiment
|
2fd69d1289faa700b0298ec3dbce47eafe40b756
|
[
"MIT"
] | null | null | null |
ml/logistic/sklogistic.py
|
ruiyangio/ml-sentiment
|
2fd69d1289faa700b0298ec3dbce47eafe40b756
|
[
"MIT"
] | null | null | null |
ml/logistic/sklogistic.py
|
ruiyangio/ml-sentiment
|
2fd69d1289faa700b0298ec3dbce47eafe40b756
|
[
"MIT"
] | null | null | null |
from sklearn.linear_model import LogisticRegression
from modelbase import ModelBase
class SkLogistic(ModelBase):
def __init__(self):
ModelBase.__init__(self)
self.model = LogisticRegression()
| 26.625
| 51
| 0.760563
| 22
| 213
| 6.954545
| 0.545455
| 0.104575
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.173709
| 213
| 7
| 52
| 30.428571
| 0.869318
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.166667
| false
| 0
| 0.333333
| 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
|
8c5d370ab78decf9d091240d67c931a2029185b5
| 92
|
py
|
Python
|
pdbparse/construct/formats/filesystem/ext3.py
|
ax330d/ida_pdb_loader
|
051b6806810d8aaa40f973442b06c3c0e4c24131
|
[
"MIT"
] | 50
|
2016-12-16T17:33:33.000Z
|
2022-03-17T06:15:43.000Z
|
lib/honcore/lib/construct/formats/filesystem/ext3.py
|
keabard/KeaBot
|
b4c39c88a11b171738d3623a9cd234e2e4342b7d
|
[
"Unlicense"
] | null | null | null |
lib/honcore/lib/construct/formats/filesystem/ext3.py
|
keabard/KeaBot
|
b4c39c88a11b171738d3623a9cd234e2e4342b7d
|
[
"Unlicense"
] | 29
|
2016-12-17T04:17:10.000Z
|
2022-03-17T06:15:45.000Z
|
"""
Extension 3 (ext3)
Used primarily for concurrent Linux systems (ext2 + journalling)
"""
| 18.4
| 64
| 0.728261
| 11
| 92
| 6.090909
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.038462
| 0.152174
| 92
| 4
| 65
| 23
| 0.820513
| 0.902174
| 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
|
4fb4e16b295d6055651f45aa3baa0180ec3f88ad
| 131
|
py
|
Python
|
High School/9th Grade APCSP (Python)/Unit 8/08.01.01.py
|
SomewhereOutInSpace/Computer-Science-Class
|
f5d21850236a7a18dc53b4a650ecbe9a11781f1d
|
[
"Unlicense"
] | null | null | null |
High School/9th Grade APCSP (Python)/Unit 8/08.01.01.py
|
SomewhereOutInSpace/Computer-Science-Class
|
f5d21850236a7a18dc53b4a650ecbe9a11781f1d
|
[
"Unlicense"
] | null | null | null |
High School/9th Grade APCSP (Python)/Unit 8/08.01.01.py
|
SomewhereOutInSpace/Computer-Science-Class
|
f5d21850236a7a18dc53b4a650ecbe9a11781f1d
|
[
"Unlicense"
] | null | null | null |
lis = []
for i in range (10):
num = int(input())
lis.append(num)
print(lis)
for i in range (len(lis)):
print(lis[i])
| 13.1
| 26
| 0.557252
| 23
| 131
| 3.173913
| 0.521739
| 0.164384
| 0.191781
| 0.246575
| 0.383562
| 0
| 0
| 0
| 0
| 0
| 0
| 0.020408
| 0.251908
| 131
| 9
| 27
| 14.555556
| 0.72449
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0.285714
| 1
| 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
| 0
| 0
| 0
| 0
|
0
| 4
|
4fba10f6e9d901b7c8b62244cc83c46bc06cafd8
| 256
|
py
|
Python
|
python/sandbox.py
|
LightningDash1755/HE
|
5605b69400f9d91e951e71336e53c7040983d628
|
[
"MIT"
] | 61
|
2019-10-20T10:47:26.000Z
|
2022-03-10T13:26:27.000Z
|
python/sandbox.py
|
LightningDash1755/HE
|
5605b69400f9d91e951e71336e53c7040983d628
|
[
"MIT"
] | 13
|
2019-10-20T12:44:38.000Z
|
2022-02-24T21:41:49.000Z
|
python/sandbox.py
|
LightningDash1755/HE
|
5605b69400f9d91e951e71336e53c7040983d628
|
[
"MIT"
] | 40
|
2019-10-20T10:47:29.000Z
|
2022-03-02T16:51:19.000Z
|
# import gettext
# gettext.bindtextdomain('messages', '/var/www/locale')
# gettext.textdomain('messages')
# t = gettext.translation('pt', '/var/www/locale', fallback=True)
# _ = t.ugettext
# # ...
# print _('Missing fields.')
print _('Task Managerr')
| 18.285714
| 65
| 0.667969
| 28
| 256
| 6
| 0.678571
| 0.071429
| 0.142857
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.128906
| 256
| 14
| 66
| 18.285714
| 0.753363
| 0.820313
| 0
| 0
| 0
| 0
| 0.342105
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0
| 0
| null | null | 1
| 1
| 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
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
4fbc44da97883a048c56752c60a37296fd2d4117
| 127
|
py
|
Python
|
pycodeanalyzer/core/configuration/__init__.py
|
miong/pycodeanalyzer
|
6728d8f77385a1145db67952167710cf412b2343
|
[
"MIT"
] | 3
|
2022-03-25T16:13:16.000Z
|
2022-03-26T06:42:39.000Z
|
pycodeanalyzer/core/configuration/__init__.py
|
miong/pycodeanalyzer
|
6728d8f77385a1145db67952167710cf412b2343
|
[
"MIT"
] | null | null | null |
pycodeanalyzer/core/configuration/__init__.py
|
miong/pycodeanalyzer
|
6728d8f77385a1145db67952167710cf412b2343
|
[
"MIT"
] | null | null | null |
"""Configuration package.
This package handle all information that could be given to pycodeanalyzer in the configuration.
"""
| 25.4
| 95
| 0.795276
| 16
| 127
| 6.3125
| 0.875
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.141732
| 127
| 4
| 96
| 31.75
| 0.926606
| 0.937008
| 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
|
4fd2c5133d1128fe9577d0c92d73f1c1e8d7d664
| 244
|
py
|
Python
|
apiempleados/admin.py
|
acroooo/registroempleados-spa
|
77310967ef10dc769fc7ab60d51dfbb19504ff9e
|
[
"MIT"
] | null | null | null |
apiempleados/admin.py
|
acroooo/registroempleados-spa
|
77310967ef10dc769fc7ab60d51dfbb19504ff9e
|
[
"MIT"
] | null | null | null |
apiempleados/admin.py
|
acroooo/registroempleados-spa
|
77310967ef10dc769fc7ab60d51dfbb19504ff9e
|
[
"MIT"
] | null | null | null |
from django.contrib import admin
from .models import Empleado
# Register your models here.
class EmpleadoAdmin(admin.ModelAdmin):
lista = ['nombre_completo', 'email', 'contacto', 'direccion']
admin.site.register(Empleado, EmpleadoAdmin)
| 24.4
| 65
| 0.766393
| 28
| 244
| 6.642857
| 0.714286
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.122951
| 244
| 9
| 66
| 27.111111
| 0.869159
| 0.106557
| 0
| 0
| 0
| 0
| 0.171296
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.4
| 0
| 0.8
| 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
|
4fd523bc32c09da15a6aed54a6d883eb6ea0c576
| 10,189
|
py
|
Python
|
boating/tests.py
|
iago1460/pedal-boating
|
1ba1b66ff5177f12a75cd2d91e9ef6f5ac5d9526
|
[
"BSD-3-Clause"
] | null | null | null |
boating/tests.py
|
iago1460/pedal-boating
|
1ba1b66ff5177f12a75cd2d91e9ef6f5ac5d9526
|
[
"BSD-3-Clause"
] | null | null | null |
boating/tests.py
|
iago1460/pedal-boating
|
1ba1b66ff5177f12a75cd2d91e9ef6f5ac5d9526
|
[
"BSD-3-Clause"
] | null | null | null |
import datetime
from django.test import TestCase
from boating.choices import MONDAY, SATURDAY, SUNDAY
from boating.models import Booking, OpeningTimes, HirePoint, Boat
from boating.views import place_booking
class HirePointMixin(object):
hire_point1 = None
hire_point2 = None
def setUp(self):
hire_point1 = HirePoint.objects.create(name='HirePoint 1', description='Mon-Fri')
hire_point2 = HirePoint.objects.create(name='HirePoint 2', description='Weekend')
for day in range(MONDAY, SATURDAY):
OpeningTimes.objects.create(
hire_point=hire_point1, day=day, from_hour=datetime.time(hour=9), to_hour=datetime.time(hour=20)
)
for day in [SATURDAY, SUNDAY]:
OpeningTimes.objects.create(
hire_point=hire_point2, day=day, from_hour=datetime.time(hour=7), to_hour=datetime.time(hour=23)
)
self.hire_point1 = hire_point1
self.hire_point2 = hire_point2
class HirePointTestCase(HirePointMixin, TestCase):
def test_opening_hours(self):
# datetime.date(2016, 2, day) Monday is day one on February
for day in range(MONDAY, SATURDAY):
# hire_point 1
self.assertEqual(
self.hire_point1.get_start_time(datetime.date(2016, 2, day)),
datetime.datetime.combine(datetime.date(2016, 2, day), datetime.time(9, 0, 0))
)
self.assertEqual(
self.hire_point1.get_closing_time(datetime.date(2016, 2, day)),
datetime.datetime.combine(datetime.date(2016, 2, day), datetime.time(20, 0, 0))
)
# estaurant 2
self.assertIsNone(self.hire_point2.get_start_time(datetime.date(2016, 2, day)))
self.assertIsNone(self.hire_point2.get_closing_time(datetime.date(2016, 2, day)))
for day in [SATURDAY, SUNDAY]:
# hire_point 1
self.assertIsNone(self.hire_point1.get_start_time(datetime.date(2016, 2, day)))
self.assertIsNone(self.hire_point1.get_closing_time(datetime.date(2016, 2, day)))
# hire_point 2
self.assertEqual(
self.hire_point2.get_start_time(datetime.date(2016, 2, day)),
datetime.datetime.combine(datetime.date(2016, 2, day), datetime.time(7, 0, 0))
)
self.assertEqual(
self.hire_point2.get_closing_time(datetime.date(2016, 2, day)),
datetime.datetime.combine(datetime.date(2016, 2, day), datetime.time(23, 0, 0))
)
def test_is_open(self):
# datetime.date(2016, 2, day) Monday is day one on February
for day in range(MONDAY, SATURDAY):
# hire_point 1
self.assertFalse(
self.hire_point1.is_open(
datetime.datetime.combine(datetime.date(2016, 2, day), datetime.time(8, 59, 59))
)
)
self.assertTrue(
self.hire_point1.is_open(
datetime.datetime.combine(datetime.date(2016, 2, day), datetime.time(9, 0, 0))
)
)
self.assertTrue(
self.hire_point1.is_open(
datetime.datetime.combine(datetime.date(2016, 2, day), datetime.time(20, 0, 0))
)
)
self.assertFalse(
self.hire_point1.is_open(
datetime.datetime.combine(datetime.date(2016, 2, day), datetime.time(20, 0, 1))
)
)
# hire_point 2
self.assertFalse(
self.hire_point2.is_open(
datetime.datetime.combine(datetime.date(2016, 2, day), datetime.time(12, 0, 0))
)
)
for day in [SATURDAY, SUNDAY]:
# hire_point 1
self.assertFalse(
self.hire_point1.is_open(
datetime.datetime.combine(datetime.date(2016, 2, day), datetime.time(12, 0, 0))
)
)
# hire_point 2
self.assertFalse(
self.hire_point2.is_open(
datetime.datetime.combine(datetime.date(2016, 2, day), datetime.time(6, 59, 59))
)
)
self.assertTrue(
self.hire_point2.is_open(
datetime.datetime.combine(datetime.date(2016, 2, day), datetime.time(7, 0, 0))
)
)
self.assertTrue(
self.hire_point2.is_open(
datetime.datetime.combine(datetime.date(2016, 2, day), datetime.time(23, 0, 0))
)
)
self.assertFalse(
self.hire_point2.is_open(
datetime.datetime.combine(datetime.date(2016, 2, day), datetime.time(23, 0, 1))
)
)
class BookingTestCase(HirePointMixin, TestCase):
boats_in_hire_point1 = None
bookings_in_hire_point1 = None
def setUp(self):
super(BookingTestCase, self).setUp()
boats_in_hire_point1 = []
for seats in [2, 4, 4, 6]:
boats_in_hire_point1.append(
Boat.objects.create(hire_point=self.hire_point1, seats=seats)
)
self.boats_in_hire_point1 = boats_in_hire_point1
bookings_in_hire_point1 = []
booking1 = Booking.objects.create(
name='Client1', number_of_people=1, hire_point=self.hire_point1,
start_time=datetime.datetime(2016, 2, 1, 10, 0, 0), end_time=datetime.datetime(2016, 2, 1, 11, 0, 0)
)
booking1.boats.add(boats_in_hire_point1[0])
bookings_in_hire_point1.append(booking1)
booking2 = Booking.objects.create(
name='Client2', number_of_people=1, hire_point=self.hire_point1,
start_time=datetime.datetime(2016, 2, 2, 10, 0, 0), end_time=datetime.datetime(2016, 2, 2, 11, 0, 0)
)
booking2.boats.add(boats_in_hire_point1[0])
bookings_in_hire_point1.append(booking2)
self.bookings_in_hire_point1 = bookings_in_hire_point1
def _check_boat(self, hire_point, people, start_time, end_time, assert_list):
min_step = datetime.timedelta(minutes=15)
time = start_time
while time < end_time:
boats_available = hire_point.is_available(people=people, start_time=time, duration=min_step * 2)
time += min_step
self.assertListEqual(boats_available, assert_list)
def test_available_boats(self):
hire_point = self.hire_point1
for people in range(1, 3):
start_time = datetime.datetime(2016, 2, 1, 9, 45, 0)
end_time = datetime.datetime(2016, 2, 1, 9, 45, 0)
assert_list = [self.boats_in_hire_point1[1]]
self._check_boat(hire_point, people, start_time, end_time, assert_list)
start_time = datetime.datetime(2016, 2, 1, 11, 0, 0)
end_time = datetime.datetime(2016, 2, 1, 20, 0, 0)
assert_list = [self.boats_in_hire_point1[0]]
self._check_boat(hire_point, people, start_time, end_time, assert_list)
people = 5
start_time = datetime.datetime(2016, 2, 1, 9, 45, 0)
end_time = datetime.datetime(2016, 2, 1, 9, 45, 0)
assert_list = [self.boats_in_hire_point1[1], self.boats_in_hire_point1[2]]
self._check_boat(hire_point, people, start_time, end_time, assert_list)
start_time = datetime.datetime(2016, 2, 1, 11, 0, 0)
end_time = datetime.datetime(2016, 2, 1, 20, 0, 0)
assert_list = [self.boats_in_hire_point1[0], self.boats_in_hire_point1[1]]
self._check_boat(hire_point, people, start_time, end_time, assert_list)
def test_availability(self):
hire_point = self.hire_point1
date = datetime.date(2016, 2, 1)
duration = datetime.timedelta(minutes=30)
people = 5
slots, boats = hire_point.get_available_slots(date, people, duration)
self.assertEqual(len(slots), len(boats))
for index, slot in enumerate(slots):
if slot <= datetime.datetime(2016, 2, 1, 9, 30, 0):
self.assertListEqual(boats[index], [self.boats_in_hire_point1[0], self.boats_in_hire_point1[1]])
elif slot < datetime.datetime(2016, 2, 1, 11, 0, 0):
self.assertListEqual(boats[index], [self.boats_in_hire_point1[1], self.boats_in_hire_point1[2]])
else:
self.assertListEqual(boats[index], [self.boats_in_hire_point1[0], self.boats_in_hire_point1[1]])
def test_booking(self):
hire_point = self.hire_point1
start_time = datetime.datetime(2016, 2, 2, 9, 45, 0)
duration = datetime.timedelta(minutes=30)
people = 9
name = 'Morning Party'
booking = place_booking(hire_point, name, start_time, duration, people)
self.assertSequenceEqual(booking.boats.all(), self.boats_in_hire_point1[1:4])
start_time = datetime.datetime(2016, 2, 2, 10, 45, 0)
booking = place_booking(hire_point, name, start_time, duration, people)
self.assertSequenceEqual(booking.boats.all(), self.boats_in_hire_point1[1:4])
date = start_time.date()
people = 3
slots, boats = hire_point.get_available_slots(date, people, duration)
self.assertEqual(len(slots), len(boats))
for index, slot in enumerate(slots):
if slot < datetime.datetime(2016, 2, 2, 9, 30, 0):
self.assertListEqual(boats[index], [self.boats_in_hire_point1[0], self.boats_in_hire_point1[1]])
elif slot < datetime.datetime(2016, 2, 2, 10, 15, 0):
raise RuntimeError('Cannot be any schedule available')
elif slot == datetime.datetime(2016, 2, 2, 10, 15, 0):
self.assertListEqual(boats[index], [self.boats_in_hire_point1[1]])
elif slot < datetime.datetime(2016, 2, 2, 11, 15, 0):
raise RuntimeError('Cannot be any schedule available')
else:
self.assertListEqual(boats[index], [self.boats_in_hire_point1[0], self.boats_in_hire_point1[1]])
| 44.3
| 112
| 0.604574
| 1,289
| 10,189
| 4.577192
| 0.09775
| 0.088136
| 0.065085
| 0.074915
| 0.803898
| 0.77339
| 0.716949
| 0.695763
| 0.689492
| 0.645254
| 0
| 0.071016
| 0.286878
| 10,189
| 229
| 113
| 44.49345
| 0.740985
| 0.021396
| 0
| 0.426316
| 0
| 0
| 0.012751
| 0
| 0
| 0
| 0
| 0
| 0.2
| 1
| 0.042105
| false
| 0
| 0.026316
| 0
| 0.105263
| 0
| 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
|
4fd5b2339d55d9d09db8e7d9a3df98171104deed
| 166
|
py
|
Python
|
vampytest/core/result/__init__.py
|
HuyaneMatsu/vampytest
|
631fbab2d70665adb7b587e012e6e921a90c065c
|
[
"MIT"
] | 1
|
2022-02-24T14:01:28.000Z
|
2022-02-24T14:01:28.000Z
|
vampytest/core/result/__init__.py
|
HuyaneMatsu/vampytest
|
631fbab2d70665adb7b587e012e6e921a90c065c
|
[
"MIT"
] | null | null | null |
vampytest/core/result/__init__.py
|
HuyaneMatsu/vampytest
|
631fbab2d70665adb7b587e012e6e921a90c065c
|
[
"MIT"
] | null | null | null |
from .failures import *
from .result import *
from .result_group import *
__all__ = (
*failures.__all__,
*result.__all__,
*result_group.__all__,
)
| 13.833333
| 27
| 0.662651
| 18
| 166
| 5.111111
| 0.333333
| 0.217391
| 0.347826
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.228916
| 166
| 11
| 28
| 15.090909
| 0.71875
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.375
| 0
| 0.375
| 0
| 1
| 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
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
4fd9c9776f73cdbc6f8e76466ea58abfacad89e8
| 14,509
|
py
|
Python
|
suites/API/HistoryApi/GetRelativeAccountHistory.py
|
echoprotocol/pytests
|
5dce698558c2ba703aea03aab79906af1437da5d
|
[
"MIT"
] | 1
|
2021-03-12T05:17:02.000Z
|
2021-03-12T05:17:02.000Z
|
suites/API/HistoryApi/GetRelativeAccountHistory.py
|
echoprotocol/pytests
|
5dce698558c2ba703aea03aab79906af1437da5d
|
[
"MIT"
] | 1
|
2019-11-19T12:10:59.000Z
|
2019-11-19T12:10:59.000Z
|
suites/API/HistoryApi/GetRelativeAccountHistory.py
|
echoprotocol/pytests
|
5dce698558c2ba703aea03aab79906af1437da5d
|
[
"MIT"
] | 2
|
2019-04-29T10:46:48.000Z
|
2019-10-29T10:01:03.000Z
|
# -*- coding: utf-8 -*-
from common.base_test import BaseTest
import lemoncheesecake.api as lcc
from lemoncheesecake.matching import (
check_that, equal_to, has_length, is_, is_list, is_str, require_that, require_that_in
)
SUITE = {
"description": "Method 'get_relative_account_history'"
}
@lcc.prop("main", "type")
@lcc.prop("positive", "type")
@lcc.prop("negative", "type")
@lcc.tags("api", "history_api", "get_relative_account_history")
@lcc.suite("Check work of method 'get_relative_account_history'", rank=1)
class GetRelativeAccountHistory(BaseTest):
def __init__(self):
super().__init__()
self.__database_api_identifier = None
self.__registration_api_identifier = None
self.__history_api_identifier = None
self.echo_acc0 = None
def setup_suite(self):
super().setup_suite()
lcc.set_step("Setup for {}".format(self.__class__.__name__))
self.__database_api_identifier = self.get_identifier("database")
self.__registration_api_identifier = self.get_identifier("registration")
self.__history_api_identifier = self.get_identifier("history")
lcc.log_info(
"API identifiers are: database='{}', registration='{}', "
"history='{}'".format(
self.__database_api_identifier, self.__registration_api_identifier, self.__history_api_identifier
)
)
self.echo_acc0 = self.get_account_id(
self.accounts[0], self.__database_api_identifier, self.__registration_api_identifier
)
lcc.log_info("Echo account is '{}'".format(self.echo_acc0))
@lcc.test("Simple work of method 'get_relative_account_history'")
def method_main_check(self):
stop, start = 0, 0
limit = 1
lcc.set_step("Get relative account history")
params = [self.echo_acc0, stop, limit, start]
response_id = self.send_request(
self.get_request("get_relative_account_history", params), self.__history_api_identifier
)
response = self.get_response(response_id)
lcc.log_info(
"Call method 'get_relative_account_history' with: account='{}', stop='{}', limit='{}', start='{}' "
"parameters".format(self.echo_acc0, stop, limit, start)
)
lcc.set_step("Check response from method 'get_relative_account_history'")
results = response["result"]
check_that("'number of history results'", results, has_length(limit))
for result in results:
self.object_validator.validate_operation_history_object(self, result)
@lcc.prop("positive", "type")
@lcc.tags("api", "history_api", "get_relative_account_history")
@lcc.suite("Positive testing of method 'get_relative_account_history'", rank=2)
class PositiveTesting(BaseTest):
def __init__(self):
super().__init__()
self.__database_api_identifier = None
self.__registration_api_identifier = None
self.__history_api_identifier = None
self.echo_acc0 = None
self.echo_acc1 = None
def get_relative_account_history(self, account, stop, limit, start, negative=False):
lcc.log_info("Get relative '{}' account history".format(account))
params = [account, stop, limit, start]
response_id = self.send_request(
self.get_request("get_relative_account_history", params), self.__history_api_identifier
)
return self.get_response(response_id, negative=negative)
def setup_suite(self):
super().setup_suite()
self._connect_to_echopy_lib()
lcc.set_step("Setup for {}".format(self.__class__.__name__))
self.__database_api_identifier = self.get_identifier("database")
self.__registration_api_identifier = self.get_identifier("registration")
self.__history_api_identifier = self.get_identifier("history")
lcc.log_info(
"API identifiers are: database='{}', registration='{}', "
"history='{}'".format(
self.__database_api_identifier, self.__registration_api_identifier, self.__history_api_identifier
)
)
self.echo_acc0 = self.get_account_id(
self.accounts[0], self.__database_api_identifier, self.__registration_api_identifier
)
self.echo_acc1 = self.get_account_id(
self.accounts[1], self.__database_api_identifier, self.__registration_api_identifier
)
lcc.log_info("Echo accounts are: #1='{}', #2='{}'".format(self.echo_acc0, self.echo_acc1))
def teardown_suite(self):
self._disconnect_to_echopy_lib()
super().teardown_suite()
@lcc.test("Check new account history")
@lcc.depends_on("API.HistoryApi.GetRelativeAccountHistory.GetRelativeAccountHistory.method_main_check")
def new_account_history(self, get_random_valid_account_name):
new_account = get_random_valid_account_name
stop, start = 0, 0
limit = 100
lcc.set_step("Create and get new account")
new_account = self.get_account_id(
new_account, self.__database_api_identifier, self.__registration_api_identifier
)
lcc.log_info("New Echo account created, account_id='{}'".format(new_account))
lcc.set_step("Get new account history")
response = self.get_relative_account_history(new_account, stop, limit, start)
lcc.set_step("Check new account history")
expected_number_of_operations = 1
require_that("'new account history'", response["result"], has_length(expected_number_of_operations))
check_that(
"'id single operation'", response["result"][0]["op"][0], is_(self.echo.config.operation_ids.ACCOUNT_CREATE)
)
@lcc.test("Check limit number of operations to retrieve")
@lcc.depends_on("API.HistoryApi.GetRelativeAccountHistory.GetRelativeAccountHistory.method_main_check")
def limit_operations_to_retrieve(self, get_random_valid_account_name, get_random_integer_up_to_hundred):
new_account = get_random_valid_account_name
stop, start = 0, 0
min_limit = 1
max_limit = 100
default_account_create_operation = 1
operation_count = get_random_integer_up_to_hundred
lcc.set_step("Create and get new account")
new_account = self.get_account_id(
new_account, self.__database_api_identifier, self.__registration_api_identifier
)
lcc.log_info("New Echo account created, account_id='{}'".format(new_account))
lcc.set_step("Perform operations using a new account. Operation count equal to limit")
self.utils.perform_transfer_operations(
self,
new_account,
self.echo_acc0,
self.__database_api_identifier,
operation_count=operation_count,
only_in_history=True
)
lcc.log_info("Fill account history with '{}' number of transfer operations".format(operation_count))
lcc.set_step("Check that count of new account history with the maximum limit is equal to operation_count")
response = self.get_relative_account_history(new_account, stop, max_limit, start)
check_that(
"'number of history results'", response["result"],
has_length(operation_count + default_account_create_operation)
)
lcc.set_step("Check minimum list length account history")
response = self.get_relative_account_history(new_account, stop, min_limit, start)
check_that("'number of history results'", response["result"], has_length(min_limit))
lcc.set_step("Perform operations using a new account to create max_limit operations")
operation_count = max_limit - operation_count - default_account_create_operation
self.utils.perform_transfer_operations(
self,
new_account,
self.echo_acc0,
self.__database_api_identifier,
operation_count=operation_count,
only_in_history=True
)
lcc.log_info("Fill account history with '{}' number of transfer operations".format(operation_count))
lcc.set_step("Check that count of new account history with the limit = max_limit is equal to max_limit")
response = self.get_relative_account_history(new_account, stop, max_limit, start)
check_that("'number of history results'", response["result"], has_length(max_limit))
@lcc.test("Check stop and start IDs of the operations in account history")
@lcc.depends_on("API.HistoryApi.GetRelativeAccountHistory.GetRelativeAccountHistory.method_main_check")
def stop_and_start_operations(self, get_random_integer, get_random_integer_up_to_hundred):
transfer_amount_1 = get_random_integer
transfer_amount_2 = get_random_integer_up_to_hundred
stop = 0
start = 0
operations = []
operation_ids = []
lcc.set_step("Perform one operation")
broadcast_result = self.utils.perform_transfer_operations(
self,
self.echo_acc0,
self.echo_acc1,
self.__database_api_identifier,
transfer_amount=transfer_amount_1,
only_in_history=True
)
operations.append(broadcast_result["trx"]["operations"][0])
lcc.log_info("Fill account history with '{}' number of transfer operations".format(len(operations)))
limit = len(operations)
lcc.set_step("Get account history. Limit: '{}'".format(limit))
response = self.get_relative_account_history(self.echo_acc0, stop, limit, start)
lcc.set_step("Check account history to see added operation and store operation id")
require_that("'account history'", response["result"][0]["op"], is_list(operations[0]))
lcc.set_step("Perform another operations")
broadcast_result = self.utils.perform_transfer_operations(
self,
self.echo_acc0,
self.echo_acc1,
self.__database_api_identifier,
transfer_amount=transfer_amount_2,
only_in_history=True
)
operations.append(broadcast_result["trx"]["operations"][0])
lcc.log_info("Fill account history with '{}' number of transfer operations".format(len(operations)))
limit = len(operations)
stop = 1
lcc.set_step("Get account history. Stop: '{}', limit: '{}'".format(stop, limit))
response = self.get_relative_account_history(self.echo_acc0, stop, limit, start)
lcc.set_step("Check account history to see added operations and store operation ids")
operations.reverse()
for i in range(limit):
require_that("'account history'", response["result"][i]["op"], is_list(operations[i]))
operation_ids.append(response["result"][i]["id"])
start = 10000
stop = 0
lcc.set_step("Get account history. Stop: '{}', limit: '{}' and start: '{}'".format(stop, limit, start))
response = self.get_relative_account_history(self.echo_acc0, stop, limit, start)
lcc.set_step("Check account history to see operations from the selected ids interval")
for i in range(limit):
lcc.log_info("Check operation #{}:".format(i))
require_that_in(response["result"][i], ["id"], is_str(operation_ids[i]), ["op"], is_list(operations[i]))
@lcc.prop("negative", "type")
@lcc.tags("api", "history_api", "get_relative_account_history")
@lcc.suite("Negative testing of method 'get_relative_account_history'", rank=3)
class NegativeTesting(BaseTest):
def __init__(self):
super().__init__()
self.__database_api_identifier = None
self.echo_acc0 = None
def setup_suite(self):
super().setup_suite()
self._connect_to_echopy_lib()
lcc.set_step("Setup for {}".format(self.__class__.__name__))
self.__database_api_identifier = self.get_identifier("database")
self.__registration_api_identifier = self.get_identifier("registration")
self.__history_api_identifier = self.get_identifier("history")
lcc.log_info(
"API identifiers are: database='{}', registration='{}', "
"history='{}'".format(
self.__database_api_identifier, self.__registration_api_identifier, self.__history_api_identifier
)
)
self.echo_acc0 = self.get_account_id(
self.accounts[0], self.__database_api_identifier, self.__registration_api_identifier
)
def teardown_suite(self):
self._disconnect_to_echopy_lib()
super().teardown_suite()
@lcc.test("Check negative int value in get_relative_account_history")
@lcc.depends_on("API.HistoryApi.GetRelativeAccountHistory.GetRelativeAccountHistory.method_main_check")
def check_negative_int_value_in_get_relative_account_history(self):
error_message = "Assert Exception: result >= 0: Invalid cast from negative number to unsigned"
stop, start = 0, 0
limit = -1
lcc.set_step("Get 'get_relative_account_history' with negative limit")
params = [self.echo_acc0, stop, limit, start]
response_id = self.send_request(
self.get_request("get_relative_account_history", params), self.__history_api_identifier
)
message = self.get_response(response_id, negative=True)["error"]["message"]
check_that("error_message", message, equal_to(error_message), quiet=True)
stop, start = -1, 0
limit = 1
lcc.set_step("Get 'get_relative_account_history' with negative stop")
params = [self.echo_acc0, stop, limit, start]
response_id = self.send_request(
self.get_request("get_relative_account_history", params), self.__history_api_identifier
)
message = self.get_response(response_id, negative=True)["error"]["message"]
check_that("error_message", message, equal_to(error_message), quiet=True)
stop, start = 0, -1
limit = 1
lcc.set_step("Get 'get_relative_account_history' with negative start")
params = [self.echo_acc0, stop, limit, start]
response_id = self.send_request(
self.get_request("get_relative_account_history", params), self.__history_api_identifier
)
message = self.get_response(response_id, negative=True)["error"]["message"]
check_that("error_message", message, equal_to(error_message), quiet=True)
| 45.914557
| 119
| 0.678958
| 1,748
| 14,509
| 5.259725
| 0.090961
| 0.077659
| 0.058734
| 0.081575
| 0.795301
| 0.770285
| 0.712095
| 0.700348
| 0.682945
| 0.665869
| 0
| 0.007029
| 0.21559
| 14,509
| 315
| 120
| 46.060317
| 0.800808
| 0.001447
| 0
| 0.564103
| 0
| 0
| 0.240922
| 0.061301
| 0
| 0
| 0
| 0
| 0.003663
| 1
| 0.051282
| false
| 0
| 0.010989
| 0
| 0.076923
| 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
|
4fe99f05091fb7a5a87d16d772a00e961730b235
| 161
|
py
|
Python
|
f.py
|
Brzeczunio/nauka_gita
|
4d36e3f846869a6517bca976eed4229400a86eb8
|
[
"MIT"
] | null | null | null |
f.py
|
Brzeczunio/nauka_gita
|
4d36e3f846869a6517bca976eed4229400a86eb8
|
[
"MIT"
] | null | null | null |
f.py
|
Brzeczunio/nauka_gita
|
4d36e3f846869a6517bca976eed4229400a86eb8
|
[
"MIT"
] | null | null | null |
def wypisz(par1, par2):
print('{0} {1}'.format(par1, par2))
def sprawdz(arg1, arg2):
if arg1 > arg2:
return True
else:
return False
| 17.888889
| 39
| 0.565217
| 22
| 161
| 4.136364
| 0.727273
| 0.175824
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.087719
| 0.291925
| 161
| 8
| 40
| 20.125
| 0.710526
| 0
| 0
| 0
| 0
| 0
| 0.043478
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.285714
| false
| 0
| 0
| 0
| 0.571429
| 0.142857
| 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
|
4ff235573affd588670bc01f4a5af06f6590a28c
| 51
|
py
|
Python
|
sklearn_dummies/__init__.py
|
gsmafra/sklearn-dummies
|
ce9cffe9d8485bda969c098e8dc497e348dbaf8f
|
[
"MIT"
] | 1
|
2017-03-03T03:53:03.000Z
|
2017-03-03T03:53:03.000Z
|
sklearn_dummies/__init__.py
|
gsmafra/sklearn-dummies
|
ce9cffe9d8485bda969c098e8dc497e348dbaf8f
|
[
"MIT"
] | 2
|
2020-02-24T18:46:39.000Z
|
2020-03-24T16:36:31.000Z
|
sklearn_dummies/__init__.py
|
gsmafra/sklearn-dummies
|
ce9cffe9d8485bda969c098e8dc497e348dbaf8f
|
[
"MIT"
] | null | null | null |
from .base import DataFrameDummies, NPArrayDummies
| 25.5
| 50
| 0.862745
| 5
| 51
| 8.8
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.098039
| 51
| 1
| 51
| 51
| 0.956522
| 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
|
4ff32173a1a92ee8cfaca782c0ce93d928db2451
| 140
|
py
|
Python
|
PythonAdvance/re_example.py
|
JiaLei123/PythonCamp
|
3ff2cee00bc4d8e65f3cc5c7d687da7ecbf9a79e
|
[
"MIT"
] | null | null | null |
PythonAdvance/re_example.py
|
JiaLei123/PythonCamp
|
3ff2cee00bc4d8e65f3cc5c7d687da7ecbf9a79e
|
[
"MIT"
] | null | null | null |
PythonAdvance/re_example.py
|
JiaLei123/PythonCamp
|
3ff2cee00bc4d8e65f3cc5c7d687da7ecbf9a79e
|
[
"MIT"
] | null | null | null |
import re
pattern = re.compile(r'[0-9]+')
match = pattern.findall('hello world! hello')
print pattern.findall('station 1000 100 and 7')
| 15.555556
| 47
| 0.7
| 22
| 140
| 4.454545
| 0.772727
| 0.285714
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.083333
| 0.142857
| 140
| 8
| 48
| 17.5
| 0.733333
| 0
| 0
| 0
| 0
| 0
| 0.335766
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0
| 0.25
| null | null | 0.25
| 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
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
8b01701b2a81e834add2a1dbc31b166cc978f9a4
| 307
|
py
|
Python
|
sistem_ozellikleri.py
|
melihcemipek/python
|
a0e6e8e5fbffb481c158f19181c10de6e58a8a13
|
[
"MIT"
] | null | null | null |
sistem_ozellikleri.py
|
melihcemipek/python
|
a0e6e8e5fbffb481c158f19181c10de6e58a8a13
|
[
"MIT"
] | null | null | null |
sistem_ozellikleri.py
|
melihcemipek/python
|
a0e6e8e5fbffb481c158f19181c10de6e58a8a13
|
[
"MIT"
] | null | null | null |
import platform
# İşletim sistemi
print(platform.system())
# İşlemci bilgisi
print(platform.processor())
# Nesil bilgisi
print(platform.release())
# PC Bağlantı adı
print(platform.node())
# Python Versiyonu
print(platform.python_version())
# Python Compiler Bilgisi
print(platform.python_compiler())
| 14.619048
| 33
| 0.76873
| 40
| 307
| 5.9
| 0.525
| 0.330508
| 0.254237
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.114007
| 307
| 20
| 34
| 15.35
| 0.860294
| 0.332248
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0.142857
| 0
| 0.142857
| 0.857143
| 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
| 0
| 1
| 0
| 0
| 0
| 0
| 1
|
0
| 4
|
8b080076549f2a7e0cf11e53b20cbfd6201134d6
| 1,214
|
py
|
Python
|
CLI.py
|
smiteshz/YLYLDadJokes
|
32206aa4cf3450662c44d51403d81e65c8172da9
|
[
"MIT"
] | 1
|
2018-11-09T23:51:49.000Z
|
2018-11-09T23:51:49.000Z
|
CLI.py
|
smiteshz/YLYLDadJokes
|
32206aa4cf3450662c44d51403d81e65c8172da9
|
[
"MIT"
] | null | null | null |
CLI.py
|
smiteshz/YLYLDadJokes
|
32206aa4cf3450662c44d51403d81e65c8172da9
|
[
"MIT"
] | null | null | null |
import requests as req
print( " _ _ _____ _ ___ ___ ___ ___ ")
print( " | | | | / ____| | | |__ \ / _ \ / _ \ / _ \ ")
print( " | | ___ | | _____ | | __ ___ _ __ ___ _ __ __ _| |_ ___ _ __ ) | | | | | | | | | |")
print( " _ | |/ _ \| |/ / _ \ | | |_ |/ _ \ '_ \ / _ \ '__/ _\`| __/ _ \| '__| / /| | | | | | | | | |")
print( " | |__| | (_) | < __/ | |__| | __/ | | | __/ | | (_| | || (_) | | / /_| |_| | |_| | |_| |")
print( " \____/ \___/|_|\_\___| \_____|\___|_| |_|\___|_| \__,_|\__\___/|_| |____|\___/ \___/ \___/ ")
print( " ")
url = "https://icanhazdadjoke.com/"
choice = True
search_q = ""
ch = ""
while choice:
search_q = input("What do you want to seach for?(Press Enter for any random joke) ")
res = req.get(
url,
headers ={"Accept" : "application/json"}
).json()
print(res["joke"])
ch = input("One more ? (Press Enter for a joke or Type q to quit) ")
if ch == "q" or ch == "Q":
break
elif ch == "":
continue
else:
continue
| 39.16129
| 108
| 0.374794
| 76
| 1,214
| 4.105263
| 0.592105
| 0.192308
| 0.240385
| 0.25641
| 0.112179
| 0.112179
| 0
| 0
| 0
| 0
| 0
| 0
| 0.419275
| 1,214
| 30
| 109
| 40.466667
| 0.442553
| 0
| 0
| 0.076923
| 0
| 0.192308
| 0.708162
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.038462
| 0
| 0.038462
| 0.307692
| 0
| 0
| 0
| null | 0
| 1
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
8b3d19482a3a35ceeb6ed61b761157050dfecb10
| 22
|
py
|
Python
|
pymicropel/helper/__init__.py
|
vkorecky/pymicropel
|
9333ba1d691664a01d0ec63f89ae13956f37d633
|
[
"Apache-2.0"
] | null | null | null |
pymicropel/helper/__init__.py
|
vkorecky/pymicropel
|
9333ba1d691664a01d0ec63f89ae13956f37d633
|
[
"Apache-2.0"
] | null | null | null |
pymicropel/helper/__init__.py
|
vkorecky/pymicropel
|
9333ba1d691664a01d0ec63f89ae13956f37d633
|
[
"Apache-2.0"
] | null | null | null |
"""Helper classes."""
| 11
| 21
| 0.590909
| 2
| 22
| 6.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.090909
| 22
| 1
| 22
| 22
| 0.65
| 0.681818
| 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
|
8b4810f1d04024f8c5ea1d1a73bc2e482dfbee3f
| 201
|
py
|
Python
|
remotelogin/devices/base_db_named.py
|
filintod/pyremotelogin
|
e2a4df7fd69d21eccdf1aec55c33a839de9157f1
|
[
"MIT"
] | 1
|
2018-11-20T17:45:20.000Z
|
2018-11-20T17:45:20.000Z
|
remotelogin/devices/base_db_named.py
|
filintod/pyremotelogin
|
e2a4df7fd69d21eccdf1aec55c33a839de9157f1
|
[
"MIT"
] | 3
|
2018-10-16T18:07:50.000Z
|
2018-10-16T18:10:06.000Z
|
remotelogin/devices/base_db_named.py
|
filintod/pyremotelogin
|
e2a4df7fd69d21eccdf1aec55c33a839de9157f1
|
[
"MIT"
] | null | null | null |
from remotelogin.devices.base import DeviceWithEncryptionSettings
from fdutils import db
class TableNamedDevice(DeviceWithEncryptionSettings, db.DeclarativeBaseWithTableName):
__abstract__ = True
| 33.5
| 86
| 0.865672
| 17
| 201
| 10
| 0.764706
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.094527
| 201
| 6
| 87
| 33.5
| 0.934066
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 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
|
5070e6a753124a18a402c8dc2de530e44ae9e90d
| 14,153
|
py
|
Python
|
opp/sharpen_up_upper_test.py
|
heeryoncho/sensors2018cnnhar
|
2c0ae84b83a95bd5b5ab13df0fb3f5e8529df91f
|
[
"MIT"
] | 10
|
2018-09-25T07:55:30.000Z
|
2020-05-08T15:01:56.000Z
|
opp/sharpen_up_upper_test.py
|
heeryoncho/sensors2018cnnhar
|
2c0ae84b83a95bd5b5ab13df0fb3f5e8529df91f
|
[
"MIT"
] | null | null | null |
opp/sharpen_up_upper_test.py
|
heeryoncho/sensors2018cnnhar
|
2c0ae84b83a95bd5b5ab13df0fb3f5e8529df91f
|
[
"MIT"
] | 5
|
2018-12-12T16:40:26.000Z
|
2020-10-29T01:24:07.000Z
|
import numpy as np
from sklearn.metrics import accuracy_score, confusion_matrix
from keras.models import load_model
import select_data as sd
import warnings
warnings.simplefilter(action='ignore', category=UserWarning)
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
'''
See paper: Sensors 2018, 18(4), 1055; https://doi.org/10.3390/s18041055
"Divide and Conquer-Based 1D CNN Human Activity Recognition Using Test Data Sharpening"
by Heeryon Cho & Sang Min Yoon
This code investigates the effects of test data sharpening on
1D CNN UP position activity classification model using UPPER body TEST data.
The performance is measured using X_test, y_test dataset.
See right line graph in Figure 13 (Test Data Recognition Accuracy).
(Sensors 2018, 18(4), 1055, page 16 of 24)
'''
X_train, y_train, X_valid, y_valid, X_test, y_test = sd.load_data("upper", "up")
print "\n=== COMPARE ACCURACY: NO SHARPEN vs. SHARPENED ==="
print "=== [UPPER body sensors data] UP Class ==="
print "=== 1D CNN MODEL ==="
print "=== Evaluation on TEST DATA ===\n"
# Load model
model = load_model('model/upper_up.hdf5')
print ">>> RAW:"
pred = model.predict(np.expand_dims(X_test, axis=2), batch_size=32)
print accuracy_score(y_test, np.argmax(pred, axis=1))
print confusion_matrix(y_test, np.argmax(pred, axis=1)), '\n'
alpha = np.arange(0.5, 15.5, 0.5)
sigma = np.arange(3, 8, 1)
for s in sigma:
for a in alpha:
x_test_sharpen = sd.sharpen(X_test, s, a)
pred_sharpened = model.predict(np.expand_dims(x_test_sharpen, axis=2), batch_size=32)
print ">>> SHARPENED: sigma={}, alpha={:.2f}".format(s, a)
print accuracy_score(y_test, np.argmax(pred_sharpened, axis=1))
print confusion_matrix(y_test, np.argmax(pred_sharpened, axis=1))
'''
/usr/bin/python2.7 /home/hcilab/Documents/OSS/sensors2018cnnhar/opp/sharpen_up_upper_test.py
/home/hcilab/.local/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Using TensorFlow backend.
=== COMPARE ACCURACY: NO SHARPEN vs. SHARPENED ===
=== [UPPER body sensors data] UP Class ===
=== 1D CNN MODEL ===
=== Evaluation on TEST DATA ===
>>> RAW:
0.803821517751
[[5190 136]
[1671 2214]]
>>> SHARPENED: sigma=3, alpha=0.50
0.822820540658
[[5128 198]
[1434 2451]]
>>> SHARPENED: sigma=3, alpha=1.00
0.83020301813
[[5113 213]
[1351 2534]]
>>> SHARPENED: sigma=3, alpha=1.50
0.832482900879
[[5097 229]
[1314 2571]]
>>> SHARPENED: sigma=3, alpha=2.00
0.833242861796
[[5092 234]
[1302 2583]]
>>> SHARPENED: sigma=3, alpha=2.50
0.834219954402
[[5088 238]
[1289 2596]]
>>> SHARPENED: sigma=3, alpha=3.00
0.834762783628
[[5087 239]
[1283 2602]]
>>> SHARPENED: sigma=3, alpha=3.50
0.835305612854
[[5087 239]
[1278 2607]]
>>> SHARPENED: sigma=3, alpha=4.00
0.835522744545
[[5084 242]
[1273 2612]]
>>> SHARPENED: sigma=3, alpha=4.50
0.835305612854
[[5083 243]
[1274 2611]]
>>> SHARPENED: sigma=3, alpha=5.00
0.835739876235
[[5084 242]
[1271 2614]]
>>> SHARPENED: sigma=3, alpha=5.50
0.835414178699
[[5081 245]
[1271 2614]]
>>> SHARPENED: sigma=3, alpha=6.00
0.835522744545
[[5081 245]
[1270 2615]]
>>> SHARPENED: sigma=3, alpha=6.50
0.83563131039
[[5080 246]
[1268 2617]]
>>> SHARPENED: sigma=3, alpha=7.00
0.835739876235
[[5080 246]
[1267 2618]]
>>> SHARPENED: sigma=3, alpha=7.50
0.835739876235
[[5080 246]
[1267 2618]]
>>> SHARPENED: sigma=3, alpha=8.00
0.83563131039
[[5079 247]
[1267 2618]]
>>> SHARPENED: sigma=3, alpha=8.50
0.835957007925
[[5079 247]
[1264 2621]]
>>> SHARPENED: sigma=3, alpha=9.00
0.83606557377
[[5079 247]
[1263 2622]]
>>> SHARPENED: sigma=3, alpha=9.50
0.836174139616
[[5079 247]
[1262 2623]]
>>> SHARPENED: sigma=3, alpha=10.00
0.836391271306
[[5079 247]
[1260 2625]]
>>> SHARPENED: sigma=3, alpha=10.50
0.836499837151
[[5079 247]
[1259 2626]]
>>> SHARPENED: sigma=3, alpha=11.00
0.836499837151
[[5079 247]
[1259 2626]]
>>> SHARPENED: sigma=3, alpha=11.50
0.836391271306
[[5078 248]
[1259 2626]]
>>> SHARPENED: sigma=3, alpha=12.00
0.836608402996
[[5079 247]
[1258 2627]]
>>> SHARPENED: sigma=3, alpha=12.50
0.836499837151
[[5079 247]
[1259 2626]]
>>> SHARPENED: sigma=3, alpha=13.00
0.836825534687
[[5080 246]
[1257 2628]]
>>> SHARPENED: sigma=3, alpha=13.50
0.836934100532
[[5080 246]
[1256 2629]]
>>> SHARPENED: sigma=3, alpha=14.00
0.837042666377
[[5080 246]
[1255 2630]]
>>> SHARPENED: sigma=3, alpha=14.50
0.837042666377
[[5080 246]
[1255 2630]]
>>> SHARPENED: sigma=3, alpha=15.00
0.837042666377
[[5080 246]
[1255 2630]]
>>> SHARPENED: sigma=4, alpha=0.50
0.821517750516
[[5126 200]
[1444 2441]]
>>> SHARPENED: sigma=4, alpha=1.00
0.828683096298
[[5107 219]
[1359 2526]]
>>> SHARPENED: sigma=4, alpha=1.50
0.831397242428
[[5092 234]
[1319 2566]]
>>> SHARPENED: sigma=4, alpha=2.00
0.833242861796
[[5088 238]
[1298 2587]]
>>> SHARPENED: sigma=4, alpha=2.50
0.83313429595
[[5083 243]
[1294 2591]]
>>> SHARPENED: sigma=4, alpha=3.00
0.833351427641
[[5080 246]
[1289 2596]]
>>> SHARPENED: sigma=4, alpha=3.50
0.833894256867
[[5077 249]
[1281 2604]]
>>> SHARPENED: sigma=4, alpha=4.00
0.833785691022
[[5073 253]
[1278 2607]]
>>> SHARPENED: sigma=4, alpha=4.50
0.833894256867
[[5071 255]
[1275 2610]]
>>> SHARPENED: sigma=4, alpha=5.00
0.833894256867
[[5069 257]
[1273 2612]]
>>> SHARPENED: sigma=4, alpha=5.50
0.834002822712
[[5069 257]
[1272 2613]]
>>> SHARPENED: sigma=4, alpha=6.00
0.833894256867
[[5069 257]
[1273 2612]]
>>> SHARPENED: sigma=4, alpha=6.50
0.833785691022
[[5068 258]
[1273 2612]]
>>> SHARPENED: sigma=4, alpha=7.00
0.834111388557
[[5068 258]
[1270 2615]]
>>> SHARPENED: sigma=4, alpha=7.50
0.834545651938
[[5069 257]
[1267 2618]]
>>> SHARPENED: sigma=4, alpha=8.00
0.834328520248
[[5069 257]
[1269 2616]]
>>> SHARPENED: sigma=4, alpha=8.50
0.834545651938
[[5069 257]
[1267 2618]]
>>> SHARPENED: sigma=4, alpha=9.00
0.834545651938
[[5068 258]
[1266 2619]]
>>> SHARPENED: sigma=4, alpha=9.50
0.834437086093
[[5068 258]
[1267 2618]]
>>> SHARPENED: sigma=4, alpha=10.00
0.834654217783
[[5068 258]
[1265 2620]]
>>> SHARPENED: sigma=4, alpha=10.50
0.834654217783
[[5068 258]
[1265 2620]]
>>> SHARPENED: sigma=4, alpha=11.00
0.834654217783
[[5067 259]
[1264 2621]]
>>> SHARPENED: sigma=4, alpha=11.50
0.834654217783
[[5066 260]
[1263 2622]]
>>> SHARPENED: sigma=4, alpha=12.00
0.834654217783
[[5066 260]
[1263 2622]]
>>> SHARPENED: sigma=4, alpha=12.50
0.834654217783
[[5066 260]
[1263 2622]]
>>> SHARPENED: sigma=4, alpha=13.00
0.834762783628
[[5066 260]
[1262 2623]]
>>> SHARPENED: sigma=4, alpha=13.50
0.834871349473
[[5067 259]
[1262 2623]]
>>> SHARPENED: sigma=4, alpha=14.00
0.834871349473
[[5067 259]
[1262 2623]]
>>> SHARPENED: sigma=4, alpha=14.50
0.834871349473
[[5067 259]
[1262 2623]]
>>> SHARPENED: sigma=4, alpha=15.00
0.834979915319
[[5067 259]
[1261 2624]]
>>> SHARPENED: sigma=5, alpha=0.50
0.820866355445
[[5122 204]
[1446 2439]]
>>> SHARPENED: sigma=5, alpha=1.00
0.828031701227
[[5103 223]
[1361 2524]]
>>> SHARPENED: sigma=5, alpha=1.50
0.830528715666
[[5087 239]
[1322 2563]]
>>> SHARPENED: sigma=5, alpha=2.00
0.831722939963
[[5080 246]
[1304 2581]]
>>> SHARPENED: sigma=5, alpha=2.50
0.831614374118
[[5072 254]
[1297 2588]]
>>> SHARPENED: sigma=5, alpha=3.00
0.831397242428
[[5072 254]
[1299 2586]]
>>> SHARPENED: sigma=5, alpha=3.50
0.831940071653
[[5069 257]
[1291 2594]]
>>> SHARPENED: sigma=5, alpha=4.00
0.83270003257
[[5068 258]
[1283 2602]]
>>> SHARPENED: sigma=5, alpha=4.50
0.833351427641
[[5068 258]
[1277 2608]]
>>> SHARPENED: sigma=5, alpha=5.00
0.833351427641
[[5066 260]
[1275 2610]]
>>> SHARPENED: sigma=5, alpha=5.50
0.833785691022
[[5066 260]
[1271 2614]]
>>> SHARPENED: sigma=5, alpha=6.00
0.833785691022
[[5066 260]
[1271 2614]]
>>> SHARPENED: sigma=5, alpha=6.50
0.833894256867
[[5066 260]
[1270 2615]]
>>> SHARPENED: sigma=5, alpha=7.00
0.834002822712
[[5065 261]
[1268 2617]]
>>> SHARPENED: sigma=5, alpha=7.50
0.833894256867
[[5064 262]
[1268 2617]]
>>> SHARPENED: sigma=5, alpha=8.00
0.833785691022
[[5064 262]
[1269 2616]]
>>> SHARPENED: sigma=5, alpha=8.50
0.833785691022
[[5062 264]
[1267 2618]]
>>> SHARPENED: sigma=5, alpha=9.00
0.833785691022
[[5061 265]
[1266 2619]]
>>> SHARPENED: sigma=5, alpha=9.50
0.833894256867
[[5061 265]
[1265 2620]]
>>> SHARPENED: sigma=5, alpha=10.00
0.834219954402
[[5061 265]
[1262 2623]]
>>> SHARPENED: sigma=5, alpha=10.50
0.834219954402
[[5060 266]
[1261 2624]]
>>> SHARPENED: sigma=5, alpha=11.00
0.834219954402
[[5059 267]
[1260 2625]]
>>> SHARPENED: sigma=5, alpha=11.50
0.834328520248
[[5060 266]
[1260 2625]]
>>> SHARPENED: sigma=5, alpha=12.00
0.834328520248
[[5060 266]
[1260 2625]]
>>> SHARPENED: sigma=5, alpha=12.50
0.834437086093
[[5060 266]
[1259 2626]]
>>> SHARPENED: sigma=5, alpha=13.00
0.834545651938
[[5060 266]
[1258 2627]]
>>> SHARPENED: sigma=5, alpha=13.50
0.834545651938
[[5060 266]
[1258 2627]]
>>> SHARPENED: sigma=5, alpha=14.00
0.834437086093
[[5059 267]
[1258 2627]]
>>> SHARPENED: sigma=5, alpha=14.50
0.834545651938
[[5059 267]
[1257 2628]]
>>> SHARPENED: sigma=5, alpha=15.00
0.834654217783
[[5059 267]
[1256 2629]]
>>> SHARPENED: sigma=6, alpha=0.50
0.820323526219
[[5122 204]
[1451 2434]]
>>> SHARPENED: sigma=6, alpha=1.00
0.827380306156
[[5103 223]
[1367 2518]]
>>> SHARPENED: sigma=6, alpha=1.50
0.830420149821
[[5090 236]
[1326 2559]]
>>> SHARPENED: sigma=6, alpha=2.00
0.830854413202
[[5082 244]
[1314 2571]]
>>> SHARPENED: sigma=6, alpha=2.50
0.831288676582
[[5077 249]
[1305 2580]]
>>> SHARPENED: sigma=6, alpha=3.00
0.831722939963
[[5073 253]
[1297 2588]]
>>> SHARPENED: sigma=6, alpha=3.50
0.831831505808
[[5071 255]
[1294 2591]]
>>> SHARPENED: sigma=6, alpha=4.00
0.831831505808
[[5070 256]
[1293 2592]]
>>> SHARPENED: sigma=6, alpha=4.50
0.832265769189
[[5070 256]
[1289 2596]]
>>> SHARPENED: sigma=6, alpha=5.00
0.832808598415
[[5069 257]
[1283 2602]]
>>> SHARPENED: sigma=6, alpha=5.50
0.832808598415
[[5069 257]
[1283 2602]]
>>> SHARPENED: sigma=6, alpha=6.00
0.83270003257
[[5066 260]
[1281 2604]]
>>> SHARPENED: sigma=6, alpha=6.50
0.83291716426
[[5066 260]
[1279 2606]]
>>> SHARPENED: sigma=6, alpha=7.00
0.833242861796
[[5065 261]
[1275 2610]]
>>> SHARPENED: sigma=6, alpha=7.50
0.833568559331
[[5065 261]
[1272 2613]]
>>> SHARPENED: sigma=6, alpha=8.00
0.833351427641
[[5062 264]
[1271 2614]]
>>> SHARPENED: sigma=6, alpha=8.50
0.83313429595
[[5060 266]
[1271 2614]]
>>> SHARPENED: sigma=6, alpha=9.00
0.83313429595
[[5060 266]
[1271 2614]]
>>> SHARPENED: sigma=6, alpha=9.50
0.833242861796
[[5060 266]
[1270 2615]]
>>> SHARPENED: sigma=6, alpha=10.00
0.833242861796
[[5060 266]
[1270 2615]]
>>> SHARPENED: sigma=6, alpha=10.50
0.833242861796
[[5060 266]
[1270 2615]]
>>> SHARPENED: sigma=6, alpha=11.00
0.833242861796
[[5060 266]
[1270 2615]]
>>> SHARPENED: sigma=6, alpha=11.50
0.83313429595
[[5059 267]
[1270 2615]]
>>> SHARPENED: sigma=6, alpha=12.00
0.833025730105
[[5057 269]
[1269 2616]]
>>> SHARPENED: sigma=6, alpha=12.50
0.833025730105
[[5058 268]
[1270 2615]]
>>> SHARPENED: sigma=6, alpha=13.00
0.83313429595
[[5058 268]
[1269 2616]]
>>> SHARPENED: sigma=6, alpha=13.50
0.833242861796
[[5058 268]
[1268 2617]]
>>> SHARPENED: sigma=6, alpha=14.00
0.833242861796
[[5058 268]
[1268 2617]]
>>> SHARPENED: sigma=6, alpha=14.50
0.83313429595
[[5057 269]
[1268 2617]]
>>> SHARPENED: sigma=6, alpha=15.00
0.833025730105
[[5057 269]
[1269 2616]]
>>> SHARPENED: sigma=7, alpha=0.50
0.819020736076
[[5124 202]
[1465 2420]]
>>> SHARPENED: sigma=7, alpha=1.00
0.825643252633
[[5105 221]
[1385 2500]]
>>> SHARPENED: sigma=7, alpha=1.50
0.828465964608
[[5095 231]
[1349 2536]]
>>> SHARPENED: sigma=7, alpha=2.00
0.830420149821
[[5086 240]
[1322 2563]]
>>> SHARPENED: sigma=7, alpha=2.50
0.831288676582
[[5084 242]
[1312 2573]]
>>> SHARPENED: sigma=7, alpha=3.00
0.830854413202
[[5076 250]
[1308 2577]]
>>> SHARPENED: sigma=7, alpha=3.50
0.831288676582
[[5072 254]
[1300 2585]]
>>> SHARPENED: sigma=7, alpha=4.00
0.831722939963
[[5071 255]
[1295 2590]]
>>> SHARPENED: sigma=7, alpha=4.50
0.831940071653
[[5071 255]
[1293 2592]]
>>> SHARPENED: sigma=7, alpha=5.00
0.832265769189
[[5071 255]
[1290 2595]]
>>> SHARPENED: sigma=7, alpha=5.50
0.832482900879
[[5071 255]
[1288 2597]]
>>> SHARPENED: sigma=7, alpha=6.00
0.832808598415
[[5071 255]
[1285 2600]]
>>> SHARPENED: sigma=7, alpha=6.50
0.832808598415
[[5070 256]
[1284 2601]]
>>> SHARPENED: sigma=7, alpha=7.00
0.832808598415
[[5070 256]
[1284 2601]]
>>> SHARPENED: sigma=7, alpha=7.50
0.832808598415
[[5070 256]
[1284 2601]]
>>> SHARPENED: sigma=7, alpha=8.00
0.833025730105
[[5071 255]
[1283 2602]]
>>> SHARPENED: sigma=7, alpha=8.50
0.833025730105
[[5068 258]
[1280 2605]]
>>> SHARPENED: sigma=7, alpha=9.00
0.83270003257
[[5065 261]
[1280 2605]]
>>> SHARPENED: sigma=7, alpha=9.50
0.832482900879
[[5064 262]
[1281 2604]]
>>> SHARPENED: sigma=7, alpha=10.00
0.832591466725
[[5064 262]
[1280 2605]]
>>> SHARPENED: sigma=7, alpha=10.50
0.832591466725
[[5064 262]
[1280 2605]]
>>> SHARPENED: sigma=7, alpha=11.00
0.832808598415
[[5064 262]
[1278 2607]]
>>> SHARPENED: sigma=7, alpha=11.50
0.83270003257
[[5063 263]
[1278 2607]]
>>> SHARPENED: sigma=7, alpha=12.00
0.83270003257
[[5063 263]
[1278 2607]]
>>> SHARPENED: sigma=7, alpha=12.50
0.83270003257
[[5063 263]
[1278 2607]]
>>> SHARPENED: sigma=7, alpha=13.00
0.832808598415
[[5062 264]
[1276 2609]]
>>> SHARPENED: sigma=7, alpha=13.50
0.832808598415
[[5062 264]
[1276 2609]]
>>> SHARPENED: sigma=7, alpha=14.00
0.83291716426
[[5061 265]
[1274 2611]]
>>> SHARPENED: sigma=7, alpha=14.50
0.832808598415
[[5060 266]
[1274 2611]]
>>> SHARPENED: sigma=7, alpha=15.00
0.83270003257
[[5059 267]
[1274 2611]]
Process finished with exit code 0
'''
| 21.029718
| 247
| 0.668551
| 2,187
| 14,153
| 4.303155
| 0.202103
| 0.224631
| 0.047816
| 0.063755
| 0.550632
| 0.363617
| 0.289342
| 0.269897
| 0.260015
| 0.245776
| 0
| 0.411427
| 0.150427
| 14,153
| 673
| 248
| 21.029718
| 0.371257
| 0.000707
| 0
| 0
| 0
| 0
| 0.235654
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | null | 0
| 0.222222
| null | null | 0.37037
| 0
| 0
| 0
| null | 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
5081c85d7d28dea6d50eb9f876b393cb23572e7a
| 170
|
py
|
Python
|
Networking/Packets/Incoming/PingPacket.py
|
henriquelino/pyrelay
|
b448cca3accc9a566616b756a03958ba096a5ebf
|
[
"MIT"
] | 26
|
2020-07-24T05:47:02.000Z
|
2022-03-31T16:03:13.000Z
|
Networking/Packets/Incoming/PingPacket.py
|
henriquelino/pyrelay
|
b448cca3accc9a566616b756a03958ba096a5ebf
|
[
"MIT"
] | 17
|
2020-07-27T08:11:19.000Z
|
2022-03-29T05:26:16.000Z
|
Networking/Packets/Incoming/PingPacket.py
|
henriquelino/pyrelay
|
b448cca3accc9a566616b756a03958ba096a5ebf
|
[
"MIT"
] | 16
|
2021-01-20T14:30:37.000Z
|
2022-03-18T05:31:51.000Z
|
class PingPacket:
def __init__(self):
self.type = "PING"
self.serial = 0
def read(self, reader):
self.serial = reader.readInt32()
| 21.25
| 41
| 0.558824
| 19
| 170
| 4.789474
| 0.631579
| 0.21978
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.026316
| 0.329412
| 170
| 7
| 42
| 24.285714
| 0.77193
| 0
| 0
| 0
| 0
| 0
| 0.02454
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.333333
| false
| 0
| 0
| 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
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
50b03b82d482234c29dbd70a6a8dca15681e0ad1
| 105,199
|
py
|
Python
|
trove/tests/unittests/guestagent/test_dbaas.py
|
zhujzhuo/openstack-trove
|
e9d073762732ba405828fd54c86a27dcac95cd25
|
[
"Apache-2.0"
] | null | null | null |
trove/tests/unittests/guestagent/test_dbaas.py
|
zhujzhuo/openstack-trove
|
e9d073762732ba405828fd54c86a27dcac95cd25
|
[
"Apache-2.0"
] | null | null | null |
trove/tests/unittests/guestagent/test_dbaas.py
|
zhujzhuo/openstack-trove
|
e9d073762732ba405828fd54c86a27dcac95cd25
|
[
"Apache-2.0"
] | null | null | null |
# Copyright 2012 OpenStack Foundation
#
# 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 ConfigParser
import os
import subprocess
import tempfile
from uuid import uuid4
import time
from mock import Mock
from mock import MagicMock
from mock import PropertyMock
from mock import patch
from mock import ANY
from oslo_utils import netutils
import sqlalchemy
import testtools
from testtools.matchers import Is
from testtools.matchers import Equals
from testtools.matchers import Not
from trove.common import cfg
from trove.common.exception import ProcessExecutionError
from trove.common.exception import GuestError
from trove.common import utils
from trove.common import instance as rd_instance
from trove.conductor import api as conductor_api
import trove.guestagent.datastore.mysql.service as dbaas
from trove.guestagent import dbaas as dbaas_sr
from trove.guestagent import pkg
from trove.guestagent.common import operating_system
from trove.guestagent.dbaas import to_gb
from trove.guestagent.dbaas import get_filesystem_volume_stats
from trove.guestagent.datastore.service import BaseDbStatus
from trove.guestagent.datastore.experimental.redis import service as rservice
from trove.guestagent.datastore.experimental.redis.service import RedisApp
from trove.guestagent.datastore.experimental.redis import system as RedisSystem
from trove.guestagent.datastore.experimental.cassandra import (
service as cass_service)
from trove.guestagent.datastore.experimental.cassandra import (
system as cass_system)
from trove.guestagent.datastore.mysql.service import MySqlAdmin
from trove.guestagent.datastore.mysql.service import MySqlRootAccess
from trove.guestagent.datastore.mysql.service import MySqlApp
from trove.guestagent.datastore.mysql.service import MySqlAppStatus
from trove.guestagent.datastore.mysql.service import KeepAliveConnection
from trove.guestagent.datastore.experimental.couchbase import (
service as couchservice)
from trove.guestagent.datastore.experimental.couchdb import (
service as couchdb_service)
from trove.guestagent.datastore.experimental.mongodb import (
service as mongo_service)
from trove.guestagent.datastore.experimental.mongodb import (
system as mongo_system)
from trove.guestagent.datastore.experimental.vertica.service import VerticaApp
from trove.guestagent.datastore.experimental.vertica.service import (
VerticaAppStatus)
from trove.guestagent.datastore.experimental.vertica import (
system as vertica_system)
from trove.guestagent.datastore.experimental.db2 import (
service as db2service)
from trove.guestagent.db import models
from trove.guestagent.volume import VolumeDevice
from trove.instance.models import InstanceServiceStatus
from trove.tests.unittests.util import util
CONF = cfg.CONF
"""
Unit tests for the classes and functions in dbaas.py.
"""
FAKE_DB = {"_name": "testDB", "_character_set": "latin2",
"_collate": "latin2_general_ci"}
FAKE_DB_2 = {"_name": "testDB2", "_character_set": "latin2",
"_collate": "latin2_general_ci"}
FAKE_USER = [{"_name": "random", "_password": "guesswhat",
"_databases": [FAKE_DB]}]
conductor_api.API.get_client = Mock()
conductor_api.API.heartbeat = Mock()
class FakeAppStatus(BaseDbStatus):
def __init__(self, id, status):
self.id = id
self.next_fake_status = status
def _get_actual_db_status(self):
return self.next_fake_status
def set_next_status(self, next_status):
self.next_fake_status = next_status
def _is_query_router(self):
return False
class DbaasTest(testtools.TestCase):
def setUp(self):
super(DbaasTest, self).setUp()
self.orig_utils_execute_with_timeout = dbaas.utils.execute_with_timeout
self.orig_utils_execute = dbaas.utils.execute
def tearDown(self):
super(DbaasTest, self).tearDown()
dbaas.utils.execute_with_timeout = self.orig_utils_execute_with_timeout
dbaas.utils.execute = self.orig_utils_execute
def test_get_auth_password(self):
dbaas.utils.execute_with_timeout = Mock(
return_value=("password ", None))
password = dbaas.get_auth_password()
self.assertEqual("password", password)
def test_get_auth_password_error(self):
dbaas.utils.execute_with_timeout = Mock(
return_value=("password", "Error"))
self.assertRaises(RuntimeError, dbaas.get_auth_password)
def test_service_discovery(self):
with patch.object(os.path, 'isfile', return_value=True):
mysql_service = dbaas.operating_system.service_discovery(["mysql"])
self.assertIsNotNone(mysql_service['cmd_start'])
self.assertIsNotNone(mysql_service['cmd_enable'])
def test_load_mysqld_options(self):
output = "mysqld would've been started with the these args:\n"\
"--user=mysql --port=3306 --basedir=/usr "\
"--tmpdir=/tmp --skip-external-locking"
with patch.object(os.path, 'isfile', return_value=True):
dbaas.utils.execute = Mock(return_value=(output, None))
options = dbaas.load_mysqld_options()
self.assertEqual(5, len(options))
self.assertEqual(options["user"], ["mysql"])
self.assertEqual(options["port"], ["3306"])
self.assertEqual(options["basedir"], ["/usr"])
self.assertEqual(options["tmpdir"], ["/tmp"])
self.assertTrue("skip-external-locking" in options)
def test_load_mysqld_options_contains_plugin_loads_options(self):
output = ("mysqld would've been started with the these args:\n"
"--plugin-load=blackhole=ha_blackhole.so "
"--plugin-load=federated=ha_federated.so")
with patch.object(os.path, 'isfile', return_value=True):
dbaas.utils.execute = Mock(return_value=(output, None))
options = dbaas.load_mysqld_options()
self.assertEqual(1, len(options))
self.assertEqual(options["plugin-load"],
["blackhole=ha_blackhole.so",
"federated=ha_federated.so"])
def test_load_mysqld_options_error(self):
dbaas.utils.execute = Mock(side_effect=ProcessExecutionError())
self.assertFalse(dbaas.load_mysqld_options())
class ResultSetStub(object):
def __init__(self, rows):
self._rows = rows
def __iter__(self):
return self._rows.__iter__()
@property
def rowcount(self):
return len(self._rows)
def __repr__(self):
return self._rows.__repr__()
class MySqlAdminMockTest(testtools.TestCase):
def tearDown(self):
super(MySqlAdminMockTest, self).tearDown()
def test_list_databases(self):
mock_conn = mock_sql_connection()
with patch.object(mock_conn, 'execute',
return_value=ResultSetStub(
[('db1', 'utf8', 'utf8_bin'),
('db2', 'utf8', 'utf8_bin'),
('db3', 'utf8', 'utf8_bin')])):
databases, next_marker = MySqlAdmin().list_databases(limit=10)
self.assertThat(next_marker, Is(None))
self.assertThat(len(databases), Is(3))
class MySqlAdminTest(testtools.TestCase):
def setUp(self):
super(MySqlAdminTest, self).setUp()
self.orig_get_engine = dbaas.get_engine
self.orig_LocalSqlClient = dbaas.LocalSqlClient
self.orig_LocalSqlClient_enter = dbaas.LocalSqlClient.__enter__
self.orig_LocalSqlClient_exit = dbaas.LocalSqlClient.__exit__
self.orig_LocalSqlClient_execute = dbaas.LocalSqlClient.execute
self.orig_MySQLUser_is_valid_user_name = (
models.MySQLUser._is_valid_user_name)
dbaas.get_engine = MagicMock(name='get_engine')
dbaas.LocalSqlClient = Mock
dbaas.LocalSqlClient.__enter__ = Mock()
dbaas.LocalSqlClient.__exit__ = Mock()
dbaas.LocalSqlClient.execute = Mock()
self.mySqlAdmin = MySqlAdmin()
def tearDown(self):
super(MySqlAdminTest, self).tearDown()
dbaas.get_engine = self.orig_get_engine
dbaas.LocalSqlClient = self.orig_LocalSqlClient
dbaas.LocalSqlClient.__enter__ = self.orig_LocalSqlClient_enter
dbaas.LocalSqlClient.__exit__ = self.orig_LocalSqlClient_exit
dbaas.LocalSqlClient.execute = self.orig_LocalSqlClient_execute
models.MySQLUser._is_valid_user_name = (
self.orig_MySQLUser_is_valid_user_name)
def test_create_database(self):
databases = []
databases.append(FAKE_DB)
self.mySqlAdmin.create_database(databases)
args, _ = dbaas.LocalSqlClient.execute.call_args_list[0]
expected = ("CREATE DATABASE IF NOT EXISTS "
"`testDB` CHARACTER SET = 'latin2' "
"COLLATE = 'latin2_general_ci';")
self.assertEqual(args[0].text, expected,
"Create database queries are not the same")
self.assertEqual(1, dbaas.LocalSqlClient.execute.call_count,
"The client object was not called exactly once, " +
"it was called %d times"
% dbaas.LocalSqlClient.execute.call_count)
def test_create_database_more_than_1(self):
databases = []
databases.append(FAKE_DB)
databases.append(FAKE_DB_2)
self.mySqlAdmin.create_database(databases)
args, _ = dbaas.LocalSqlClient.execute.call_args_list[0]
expected = ("CREATE DATABASE IF NOT EXISTS "
"`testDB` CHARACTER SET = 'latin2' "
"COLLATE = 'latin2_general_ci';")
self.assertEqual(args[0].text, expected,
"Create database queries are not the same")
args, _ = dbaas.LocalSqlClient.execute.call_args_list[1]
expected = ("CREATE DATABASE IF NOT EXISTS "
"`testDB2` CHARACTER SET = 'latin2' "
"COLLATE = 'latin2_general_ci';")
self.assertEqual(args[0].text, expected,
"Create database queries are not the same")
self.assertEqual(2, dbaas.LocalSqlClient.execute.call_count,
"The client object was not called exactly twice, " +
"it was called %d times"
% dbaas.LocalSqlClient.execute.call_count)
def test_create_database_no_db(self):
databases = []
self.mySqlAdmin.create_database(databases)
self.assertFalse(dbaas.LocalSqlClient.execute.called,
"The client object was called when it wasn't " +
"supposed to")
def test_delete_database(self):
database = {"_name": "testDB"}
self.mySqlAdmin.delete_database(database)
args, _ = dbaas.LocalSqlClient.execute.call_args
expected = "DROP DATABASE `testDB`;"
self.assertEqual(args[0].text, expected,
"Delete database queries are not the same")
self.assertTrue(dbaas.LocalSqlClient.execute.called,
"The client object was not called")
def test_delete_user(self):
user = {"_name": "testUser", "_host": None}
self.mySqlAdmin.delete_user(user)
# For some reason, call_args is None.
call_args = dbaas.LocalSqlClient.execute.call_args
if call_args is not None:
args, _ = call_args
expected = "DROP USER `testUser`@`%`;"
self.assertEqual(args[0].text, expected,
"Delete user queries are not the same")
self.assertTrue(dbaas.LocalSqlClient.execute.called,
"The client object was not called")
def test_create_user(self):
self.mySqlAdmin.create_user(FAKE_USER)
expected = ("GRANT ALL PRIVILEGES ON `testDB`.* TO `random`@`%` "
"IDENTIFIED BY 'guesswhat' "
"WITH GRANT OPTION;")
# For some reason, call_args is None.
call_args = dbaas.LocalSqlClient.execute.call_args
if call_args is not None:
args, _ = call_args
self.assertEqual(args[0].text.strip(), expected,
"Create user queries are not the same")
self.assertEqual(2, dbaas.LocalSqlClient.execute.call_count)
def test_list_databases(self):
self.mySqlAdmin.list_databases()
args, _ = dbaas.LocalSqlClient.execute.call_args
expected = ["SELECT schema_name as name,",
"default_character_set_name as charset,",
"default_collation_name as collation",
"FROM information_schema.schemata",
("schema_name NOT IN ('" + "', '".join(CONF.ignore_dbs) +
"')"),
"ORDER BY schema_name ASC",
]
for text in expected:
self.assertTrue(text in args[0].text, "%s not in query." % text)
self.assertFalse("LIMIT " in args[0].text)
def test_list_databases_with_limit(self):
limit = 2
self.mySqlAdmin.list_databases(limit)
args, _ = dbaas.LocalSqlClient.execute.call_args
expected = ["SELECT schema_name as name,",
"default_character_set_name as charset,",
"default_collation_name as collation",
"FROM information_schema.schemata",
("schema_name NOT IN ('" + "', '".join(CONF.ignore_dbs) +
"')"),
"ORDER BY schema_name ASC",
]
for text in expected:
self.assertTrue(text in args[0].text, "%s not in query." % text)
self.assertTrue("LIMIT " + str(limit + 1) in args[0].text)
def test_list_databases_with_marker(self):
marker = "aMarker"
self.mySqlAdmin.list_databases(marker=marker)
args, _ = dbaas.LocalSqlClient.execute.call_args
expected = ["SELECT schema_name as name,",
"default_character_set_name as charset,",
"default_collation_name as collation",
"FROM information_schema.schemata",
("schema_name NOT IN ('" + "', '".join(CONF.ignore_dbs) +
"')"),
"ORDER BY schema_name ASC",
]
for text in expected:
self.assertTrue(text in args[0].text, "%s not in query." % text)
self.assertFalse("LIMIT " in args[0].text)
self.assertTrue("AND schema_name > '" + marker + "'" in args[0].text)
def test_list_databases_with_include_marker(self):
marker = "aMarker"
self.mySqlAdmin.list_databases(marker=marker, include_marker=True)
args, _ = dbaas.LocalSqlClient.execute.call_args
expected = ["SELECT schema_name as name,",
"default_character_set_name as charset,",
"default_collation_name as collation",
"FROM information_schema.schemata",
("schema_name NOT IN ('" + "', '".join(CONF.ignore_dbs) +
"')"),
"ORDER BY schema_name ASC",
]
for text in expected:
self.assertTrue(text in args[0].text, "%s not in query." % text)
self.assertFalse("LIMIT " in args[0].text)
self.assertTrue(("AND schema_name >= '%s'" % marker) in args[0].text)
def test_list_users(self):
self.mySqlAdmin.list_users()
args, _ = dbaas.LocalSqlClient.execute.call_args
expected = ["SELECT User, Host",
"FROM mysql.user",
"WHERE Host != 'localhost'",
"ORDER BY User",
]
for text in expected:
self.assertTrue(text in args[0].text, "%s not in query." % text)
self.assertFalse("LIMIT " in args[0].text)
self.assertFalse("AND Marker > '" in args[0].text)
def test_list_users_with_limit(self):
limit = 2
self.mySqlAdmin.list_users(limit)
args, _ = dbaas.LocalSqlClient.execute.call_args
expected = ["SELECT User, Host",
"FROM mysql.user",
"WHERE Host != 'localhost'",
"ORDER BY User",
("LIMIT " + str(limit + 1)),
]
for text in expected:
self.assertTrue(text in args[0].text, "%s not in query." % text)
def test_list_users_with_marker(self):
marker = "aMarker"
self.mySqlAdmin.list_users(marker=marker)
args, _ = dbaas.LocalSqlClient.execute.call_args
expected = ["SELECT User, Host, Marker",
"FROM mysql.user",
"WHERE Host != 'localhost'",
"ORDER BY User",
]
for text in expected:
self.assertTrue(text in args[0].text, "%s not in query." % text)
self.assertFalse("LIMIT " in args[0].text)
self.assertTrue("AND Marker > '" + marker + "'" in args[0].text)
def test_list_users_with_include_marker(self):
marker = "aMarker"
self.mySqlAdmin.list_users(marker=marker, include_marker=True)
args, _ = dbaas.LocalSqlClient.execute.call_args
expected = ["SELECT User, Host",
"FROM mysql.user",
"WHERE Host != 'localhost'",
"ORDER BY User",
]
for text in expected:
self.assertTrue(text in args[0].text, "%s not in query." % text)
self.assertFalse("LIMIT " in args[0].text)
self.assertTrue("AND Marker >= '" + marker + "'" in args[0].text)
def test_get_user(self):
"""
Unit tests for mySqlAdmin.get_user.
This test case checks if the sql query formed by the get_user method
is correct or not by checking with expected query.
"""
username = "user1"
hostname = "host"
self.mySqlAdmin.get_user(username, hostname)
args, _ = dbaas.LocalSqlClient.execute.call_args
expected = ["SELECT User, Host",
"FROM mysql.user",
"WHERE Host != 'localhost' AND User = 'user1'",
"ORDER BY User, Host",
]
for text in expected:
self.assertTrue(text in args[0].text, "%s not in query." % text)
class MySqlAppTest(testtools.TestCase):
def setUp(self):
super(MySqlAppTest, self).setUp()
self.orig_utils_execute_with_timeout = dbaas.utils.execute_with_timeout
self.orig_time_sleep = time.sleep
self.orig_unlink = os.unlink
self.orig_get_auth_password = dbaas.get_auth_password
util.init_db()
self.FAKE_ID = str(uuid4())
InstanceServiceStatus.create(instance_id=self.FAKE_ID,
status=rd_instance.ServiceStatuses.NEW)
self.appStatus = FakeAppStatus(self.FAKE_ID,
rd_instance.ServiceStatuses.NEW)
self.mySqlApp = MySqlApp(self.appStatus)
mysql_service = {'cmd_start': Mock(),
'cmd_stop': Mock(),
'cmd_enable': Mock(),
'cmd_disable': Mock(),
'bin': Mock()}
dbaas.operating_system.service_discovery = Mock(return_value=
mysql_service)
time.sleep = Mock()
os.unlink = Mock()
dbaas.get_auth_password = Mock()
def tearDown(self):
super(MySqlAppTest, self).tearDown()
dbaas.utils.execute_with_timeout = self.orig_utils_execute_with_timeout
time.sleep = self.orig_time_sleep
os.unlink = self.orig_unlink
dbaas.get_auth_password = self.orig_get_auth_password
InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete()
def assert_reported_status(self, expected_status):
service_status = InstanceServiceStatus.find_by(
instance_id=self.FAKE_ID)
self.assertEqual(expected_status, service_status.status)
def mysql_starts_successfully(self):
def start(update_db=False):
self.appStatus.set_next_status(
rd_instance.ServiceStatuses.RUNNING)
self.mySqlApp.start_mysql.side_effect = start
def mysql_starts_unsuccessfully(self):
def start():
raise RuntimeError("MySQL failed to start!")
self.mySqlApp.start_mysql.side_effect = start
def mysql_stops_successfully(self):
def stop():
self.appStatus.set_next_status(
rd_instance.ServiceStatuses.SHUTDOWN)
self.mySqlApp.stop_db.side_effect = stop
def mysql_stops_unsuccessfully(self):
def stop():
raise RuntimeError("MySQL failed to stop!")
self.mySqlApp.stop_db.side_effect = stop
def test_stop_mysql(self):
dbaas.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(
rd_instance.ServiceStatuses.SHUTDOWN)
self.mySqlApp.stop_db()
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_stop_mysql_with_db_update(self):
dbaas.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(
rd_instance.ServiceStatuses.SHUTDOWN)
self.mySqlApp.stop_db(True)
self.assertTrue(conductor_api.API.heartbeat.called_once_with(
self.FAKE_ID,
{'service_status':
rd_instance.ServiceStatuses.SHUTDOWN.description}))
def test_stop_mysql_error(self):
dbaas.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.mySqlApp.state_change_wait_time = 1
self.assertRaises(RuntimeError, self.mySqlApp.stop_db)
def test_restart_is_successful(self):
self.mySqlApp.start_mysql = Mock()
self.mySqlApp.stop_db = Mock()
self.mysql_stops_successfully()
self.mysql_starts_successfully()
self.mySqlApp.restart()
self.assertTrue(self.mySqlApp.stop_db.called)
self.assertTrue(self.mySqlApp.start_mysql.called)
self.assertTrue(conductor_api.API.heartbeat.called_once_with(
self.FAKE_ID,
{'service_status':
rd_instance.ServiceStatuses.RUNNING.description}))
def test_restart_mysql_wont_start_up(self):
self.mySqlApp.start_mysql = Mock()
self.mySqlApp.stop_db = Mock()
self.mysql_stops_unsuccessfully()
self.mysql_starts_unsuccessfully()
self.assertRaises(RuntimeError, self.mySqlApp.restart)
self.assertTrue(self.mySqlApp.stop_db.called)
self.assertFalse(self.mySqlApp.start_mysql.called)
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_wipe_ib_logfiles_error(self):
mocked = Mock(side_effect=ProcessExecutionError('Error'))
dbaas.utils.execute_with_timeout = mocked
self.assertRaises(ProcessExecutionError,
self.mySqlApp.wipe_ib_logfiles)
def test_start_mysql(self):
dbaas.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.mySqlApp._enable_mysql_on_boot = Mock()
self.mySqlApp.start_mysql()
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_start_mysql_with_db_update(self):
dbaas.utils.execute_with_timeout = Mock()
self.mySqlApp._enable_mysql_on_boot = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.mySqlApp.start_mysql(update_db=True)
self.assertTrue(conductor_api.API.heartbeat.called_once_with(
self.FAKE_ID,
{'service_status':
rd_instance.ServiceStatuses.RUNNING.description}))
def test_start_mysql_runs_forever(self):
dbaas.utils.execute_with_timeout = Mock()
self.mySqlApp._enable_mysql_on_boot = Mock()
self.mySqlApp.state_change_wait_time = 1
self.appStatus.set_next_status(rd_instance.ServiceStatuses.SHUTDOWN)
self.assertRaises(RuntimeError, self.mySqlApp.start_mysql)
self.assertTrue(conductor_api.API.heartbeat.called_once_with(
self.FAKE_ID,
{'service_status':
rd_instance.ServiceStatuses.SHUTDOWN.description}))
def test_start_mysql_error(self):
self.mySqlApp._enable_mysql_on_boot = Mock()
mocked = Mock(side_effect=ProcessExecutionError('Error'))
dbaas.utils.execute_with_timeout = mocked
self.assertRaises(RuntimeError, self.mySqlApp.start_mysql)
def test_start_db_with_conf_changes(self):
self.mySqlApp.start_mysql = Mock()
self.mySqlApp._write_mycnf = Mock()
self.mysql_starts_successfully()
self.appStatus.status = rd_instance.ServiceStatuses.SHUTDOWN
self.mySqlApp.start_db_with_conf_changes(Mock())
self.assertTrue(self.mySqlApp._write_mycnf.called)
self.assertTrue(self.mySqlApp.start_mysql.called)
self.assertEqual(self.appStatus._get_actual_db_status(),
rd_instance.ServiceStatuses.RUNNING)
def test_start_db_with_conf_changes_mysql_is_running(self):
self.mySqlApp.start_mysql = Mock()
self.mySqlApp._write_mycnf = Mock()
self.appStatus.status = rd_instance.ServiceStatuses.RUNNING
self.assertRaises(RuntimeError,
self.mySqlApp.start_db_with_conf_changes,
Mock())
def test_remove_overrides(self):
from trove.common.exception import ProcessExecutionError
mocked = Mock(side_effect=ProcessExecutionError('Error'))
dbaas.utils.execute_with_timeout = mocked
self.assertRaises(ProcessExecutionError, self.mySqlApp.start_mysql)
def test_mysql_error_in_write_config_verify_unlink(self):
configuration = {'config_contents': 'some junk'}
from trove.common.exception import ProcessExecutionError
dbaas.utils.execute_with_timeout = (
Mock(side_effect=ProcessExecutionError('something')))
self.assertRaises(ProcessExecutionError,
self.mySqlApp.reset_configuration,
configuration=configuration)
self.assertEqual(dbaas.utils.execute_with_timeout.call_count, 1)
self.assertEqual(os.unlink.call_count, 1)
self.assertEqual(dbaas.get_auth_password.call_count, 1)
def test_mysql_error_in_write_config(self):
configuration = {'config_contents': 'some junk'}
from trove.common.exception import ProcessExecutionError
dbaas.utils.execute_with_timeout = (
Mock(side_effect=ProcessExecutionError('something')))
self.assertRaises(ProcessExecutionError,
self.mySqlApp.reset_configuration,
configuration=configuration)
self.assertEqual(dbaas.utils.execute_with_timeout.call_count, 1)
self.assertEqual(dbaas.get_auth_password.call_count, 1)
class MySqlAppInstallTest(MySqlAppTest):
def setUp(self):
super(MySqlAppInstallTest, self).setUp()
self.orig_create_engine = sqlalchemy.create_engine
self.orig_pkg_version = dbaas.packager.pkg_version
self.orig_utils_execute_with_timeout = utils.execute_with_timeout
def tearDown(self):
super(MySqlAppInstallTest, self).tearDown()
sqlalchemy.create_engine = self.orig_create_engine
dbaas.packager.pkg_version = self.orig_pkg_version
utils.execute_with_timeout = self.orig_utils_execute_with_timeout
def test_install(self):
self.mySqlApp._install_mysql = Mock()
pkg.Package.pkg_is_installed = Mock(return_value=False)
utils.execute_with_timeout = Mock()
pkg.Package.pkg_install = Mock()
self.mySqlApp._clear_mysql_config = Mock()
self.mySqlApp._create_mysql_confd_dir = Mock()
self.mySqlApp.start_mysql = Mock()
self.mySqlApp.install_if_needed(["package"])
self.assertTrue(pkg.Package.pkg_install.called)
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_secure(self):
dbaas.clear_expired_password = Mock()
self.mySqlApp.start_mysql = Mock()
self.mySqlApp.stop_db = Mock()
self.mySqlApp._write_mycnf = Mock()
self.mysql_stops_successfully()
self.mysql_starts_successfully()
sqlalchemy.create_engine = Mock()
self.mySqlApp.secure('contents', None)
self.assertTrue(self.mySqlApp.stop_db.called)
self.assertTrue(self.mySqlApp._write_mycnf.called)
self.assertTrue(self.mySqlApp.start_mysql.called)
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_install_install_error(self):
from trove.guestagent import pkg
self.mySqlApp.start_mysql = Mock()
self.mySqlApp.stop_db = Mock()
pkg.Package.pkg_is_installed = Mock(return_value=False)
self.mySqlApp._clear_mysql_config = Mock()
self.mySqlApp._create_mysql_confd_dir = Mock()
pkg.Package.pkg_install = \
Mock(side_effect=pkg.PkgPackageStateError("Install error"))
self.assertRaises(pkg.PkgPackageStateError,
self.mySqlApp.install_if_needed, ["package"])
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_secure_write_conf_error(self):
dbaas.clear_expired_password = Mock()
self.mySqlApp.start_mysql = Mock()
self.mySqlApp.stop_db = Mock()
self.mySqlApp._write_mycnf = Mock(
side_effect=IOError("Could not write file"))
self.mysql_stops_successfully()
self.mysql_starts_successfully()
sqlalchemy.create_engine = Mock()
self.assertRaises(IOError, self.mySqlApp.secure, "foo", None)
self.assertTrue(self.mySqlApp.stop_db.called)
self.assertTrue(self.mySqlApp._write_mycnf.called)
self.assertFalse(self.mySqlApp.start_mysql.called)
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
class TextClauseMatcher(object):
def __init__(self, text):
self.text = text
def __repr__(self):
return "TextClause(%s)" % self.text
def __eq__(self, arg):
print("Matching %s" % arg.text)
return self.text in arg.text
def mock_sql_connection():
utils.execute_with_timeout = MagicMock(return_value=['fake_password',
None])
mock_engine = MagicMock()
sqlalchemy.create_engine = MagicMock(return_value=mock_engine)
mock_conn = MagicMock()
dbaas.LocalSqlClient.__enter__ = MagicMock(return_value=mock_conn)
dbaas.LocalSqlClient.__exit__ = MagicMock(return_value=None)
return mock_conn
class MySqlAppMockTest(testtools.TestCase):
def setUp(self):
super(MySqlAppMockTest, self).setUp()
self.orig_utils_execute_with_timeout = utils.execute_with_timeout
def tearDown(self):
super(MySqlAppMockTest, self).tearDown()
utils.execute_with_timeout = self.orig_utils_execute_with_timeout
def test_secure_keep_root(self):
mock_conn = mock_sql_connection()
with patch.object(mock_conn, 'execute', return_value=None):
utils.execute_with_timeout = MagicMock(return_value=None)
# skip writing the file for now
with patch.object(os.path, 'isfile', return_value=False):
mock_status = MagicMock()
mock_status.wait_for_real_status_to_change_to = MagicMock(
return_value=True)
dbaas.clear_expired_password = MagicMock(return_value=None)
app = MySqlApp(mock_status)
app._write_mycnf = MagicMock(return_value=True)
app.start_mysql = MagicMock(return_value=None)
app.stop_db = MagicMock(return_value=None)
app.secure('foo', None)
self.assertTrue(mock_conn.execute.called)
def test_secure_with_mycnf_error(self):
mock_conn = mock_sql_connection()
with patch.object(mock_conn, 'execute', return_value=None):
operating_system.service_discovery = Mock(return_value={
'cmd_stop': 'service mysql stop'})
utils.execute_with_timeout = MagicMock(return_value=None)
# skip writing the file for now
with patch.object(os.path, 'isfile', return_value=False):
mock_status = MagicMock()
mock_status.wait_for_real_status_to_change_to = MagicMock(
return_value=True)
dbaas.clear_expired_password = MagicMock(return_value=None)
app = MySqlApp(mock_status)
dbaas.clear_expired_password = MagicMock(return_value=None)
self.assertRaises(TypeError, app.secure, None, None)
self.assertTrue(mock_conn.execute.called)
# At least called twice
self.assertTrue(mock_conn.execute.call_count >= 2)
(mock_status.wait_for_real_status_to_change_to.
assert_called_with(rd_instance.ServiceStatuses.SHUTDOWN,
app.state_change_wait_time, False))
class MySqlRootStatusTest(testtools.TestCase):
def setUp(self):
super(MySqlRootStatusTest, self).setUp()
self.orig_utils_execute_with_timeout = utils.execute_with_timeout
def tearDown(self):
super(MySqlRootStatusTest, self).tearDown()
utils.execute_with_timeout = self.orig_utils_execute_with_timeout
def test_root_is_enabled(self):
mock_conn = mock_sql_connection()
mock_rs = MagicMock()
mock_rs.rowcount = 1
with patch.object(mock_conn, 'execute', return_value=mock_rs):
self.assertThat(MySqlRootAccess().is_root_enabled(), Is(True))
def test_root_is_not_enabled(self):
mock_conn = mock_sql_connection()
mock_rs = MagicMock()
mock_rs.rowcount = 0
with patch.object(mock_conn, 'execute', return_value=mock_rs):
self.assertThat(MySqlRootAccess.is_root_enabled(), Equals(False))
def test_enable_root(self):
mock_conn = mock_sql_connection()
with patch.object(mock_conn, 'execute', return_value=None):
# invocation
user_ser = MySqlRootAccess.enable_root()
# verification
self.assertThat(user_ser, Not(Is(None)))
mock_conn.execute.assert_any_call(TextClauseMatcher('CREATE USER'),
user='root', host='%')
mock_conn.execute.assert_any_call(TextClauseMatcher(
'GRANT ALL PRIVILEGES ON *.*'))
mock_conn.execute.assert_any_call(TextClauseMatcher(
'UPDATE mysql.user'))
def test_enable_root_failed(self):
with patch.object(models.MySQLUser, '_is_valid_user_name',
return_value=False):
self.assertRaises(ValueError, MySqlAdmin().enable_root)
class MockStats:
f_blocks = 1024 ** 2
f_bsize = 4096
f_bfree = 512 * 1024
class InterrogatorTest(testtools.TestCase):
def tearDown(self):
super(InterrogatorTest, self).tearDown()
def test_to_gb(self):
result = to_gb(123456789)
self.assertEqual(result, 0.11)
def test_to_gb_zero(self):
result = to_gb(0)
self.assertEqual(result, 0.0)
def test_get_filesystem_volume_stats(self):
with patch.object(os, 'statvfs', return_value=MockStats):
result = get_filesystem_volume_stats('/some/path/')
self.assertEqual(result['block_size'], 4096)
self.assertEqual(result['total_blocks'], 1048576)
self.assertEqual(result['free_blocks'], 524288)
self.assertEqual(result['total'], 4.0)
self.assertEqual(result['free'], 2147483648)
self.assertEqual(result['used'], 2.0)
def test_get_filesystem_volume_stats_error(self):
with patch.object(os, 'statvfs', side_effect=OSError):
self.assertRaises(
RuntimeError,
get_filesystem_volume_stats, '/nonexistent/path')
class ServiceRegistryTest(testtools.TestCase):
def setUp(self):
super(ServiceRegistryTest, self).setUp()
def tearDown(self):
super(ServiceRegistryTest, self).tearDown()
def test_datastore_registry_with_extra_manager(self):
datastore_registry_ext_test = {
'test': 'trove.guestagent.datastore.test.manager.Manager',
}
dbaas_sr.get_custom_managers = Mock(return_value=
datastore_registry_ext_test)
test_dict = dbaas_sr.datastore_registry()
self.assertEqual(test_dict.get('test'),
datastore_registry_ext_test.get('test', None))
self.assertEqual(test_dict.get('mysql'),
'trove.guestagent.datastore.mysql.'
'manager.Manager')
self.assertEqual(test_dict.get('percona'),
'trove.guestagent.datastore.mysql.'
'manager.Manager')
self.assertEqual(test_dict.get('redis'),
'trove.guestagent.datastore.experimental.redis.'
'manager.Manager')
self.assertEqual(test_dict.get('cassandra'),
'trove.guestagent.datastore.experimental.cassandra.'
'manager.Manager')
self.assertEqual(test_dict.get('couchbase'),
'trove.guestagent.datastore.experimental.'
'couchbase.manager.Manager')
self.assertEqual('trove.guestagent.datastore.experimental.mongodb.'
'manager.Manager',
test_dict.get('mongodb'))
self.assertEqual(test_dict.get('couchdb'),
'trove.guestagent.datastore.experimental.couchdb.'
'manager.Manager')
self.assertEqual('trove.guestagent.datastore.experimental.db2.'
'manager.Manager',
test_dict.get('db2'))
def test_datastore_registry_with_existing_manager(self):
datastore_registry_ext_test = {
'mysql': 'trove.guestagent.datastore.mysql.'
'manager.Manager123',
}
dbaas_sr.get_custom_managers = Mock(return_value=
datastore_registry_ext_test)
test_dict = dbaas_sr.datastore_registry()
self.assertEqual(test_dict.get('mysql'),
'trove.guestagent.datastore.mysql.'
'manager.Manager123')
self.assertEqual(test_dict.get('percona'),
'trove.guestagent.datastore.mysql.'
'manager.Manager')
self.assertEqual(test_dict.get('redis'),
'trove.guestagent.datastore.experimental.redis.'
'manager.Manager')
self.assertEqual(test_dict.get('cassandra'),
'trove.guestagent.datastore.experimental.cassandra.'
'manager.Manager')
self.assertEqual(test_dict.get('couchbase'),
'trove.guestagent.datastore.experimental.couchbase.'
'manager.Manager')
self.assertEqual('trove.guestagent.datastore.experimental.mongodb.'
'manager.Manager',
test_dict.get('mongodb'))
self.assertEqual(test_dict.get('couchdb'),
'trove.guestagent.datastore.experimental.couchdb.'
'manager.Manager')
self.assertEqual('trove.guestagent.datastore.experimental.vertica.'
'manager.Manager',
test_dict.get('vertica'))
self.assertEqual('trove.guestagent.datastore.experimental.db2.'
'manager.Manager',
test_dict.get('db2'))
def test_datastore_registry_with_blank_dict(self):
datastore_registry_ext_test = dict()
dbaas_sr.get_custom_managers = Mock(return_value=
datastore_registry_ext_test)
test_dict = dbaas_sr.datastore_registry()
self.assertEqual(test_dict.get('mysql'),
'trove.guestagent.datastore.mysql.'
'manager.Manager')
self.assertEqual(test_dict.get('percona'),
'trove.guestagent.datastore.mysql.'
'manager.Manager')
self.assertEqual(test_dict.get('redis'),
'trove.guestagent.datastore.experimental.redis.'
'manager.Manager')
self.assertEqual(test_dict.get('cassandra'),
'trove.guestagent.datastore.experimental.cassandra.'
'manager.Manager')
self.assertEqual(test_dict.get('couchbase'),
'trove.guestagent.datastore.experimental.couchbase.'
'manager.Manager')
self.assertEqual('trove.guestagent.datastore.experimental.mongodb.'
'manager.Manager',
test_dict.get('mongodb'))
self.assertEqual(test_dict.get('couchdb'),
'trove.guestagent.datastore.experimental.couchdb.'
'manager.Manager')
self.assertEqual('trove.guestagent.datastore.experimental.vertica.'
'manager.Manager',
test_dict.get('vertica'))
self.assertEqual('trove.guestagent.datastore.experimental.db2.'
'manager.Manager',
test_dict.get('db2'))
class KeepAliveConnectionTest(testtools.TestCase):
class OperationalError(Exception):
def __init__(self, value):
self.args = [value]
def __str__(self):
return repr(self.value)
def setUp(self):
super(KeepAliveConnectionTest, self).setUp()
self.orig_utils_execute_with_timeout = dbaas.utils.execute_with_timeout
self.orig_LOG_err = dbaas.LOG
def tearDown(self):
super(KeepAliveConnectionTest, self).tearDown()
dbaas.utils.execute_with_timeout = self.orig_utils_execute_with_timeout
dbaas.LOG = self.orig_LOG_err
def test_checkout_type_error(self):
dbapi_con = Mock()
dbapi_con.ping = Mock(side_effect=TypeError("Type Error"))
self.keepAliveConn = KeepAliveConnection()
self.assertRaises(TypeError, self.keepAliveConn.checkout,
dbapi_con, Mock(), Mock())
def test_checkout_disconnection_error(self):
from sqlalchemy import exc
dbapi_con = Mock()
dbapi_con.OperationalError = self.OperationalError
dbapi_con.ping = Mock(side_effect=dbapi_con.OperationalError(2013))
self.keepAliveConn = KeepAliveConnection()
self.assertRaises(exc.DisconnectionError, self.keepAliveConn.checkout,
dbapi_con, Mock(), Mock())
def test_checkout_operation_error(self):
dbapi_con = Mock()
dbapi_con.OperationalError = self.OperationalError
dbapi_con.ping = Mock(side_effect=dbapi_con.OperationalError(1234))
self.keepAliveConn = KeepAliveConnection()
self.assertRaises(self.OperationalError, self.keepAliveConn.checkout,
dbapi_con, Mock(), Mock())
class BaseDbStatusTest(testtools.TestCase):
def setUp(self):
super(BaseDbStatusTest, self).setUp()
util.init_db()
self.orig_dbaas_time_sleep = time.sleep
self.FAKE_ID = str(uuid4())
InstanceServiceStatus.create(instance_id=self.FAKE_ID,
status=rd_instance.ServiceStatuses.NEW)
dbaas.CONF.guest_id = self.FAKE_ID
def tearDown(self):
super(BaseDbStatusTest, self).tearDown()
time.sleep = self.orig_dbaas_time_sleep
InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete()
dbaas.CONF.guest_id = None
def test_begin_install(self):
self.baseDbStatus = BaseDbStatus()
self.baseDbStatus.begin_install()
self.assertEqual(self.baseDbStatus.status,
rd_instance.ServiceStatuses.BUILDING)
def test_begin_restart(self):
self.baseDbStatus = BaseDbStatus()
self.baseDbStatus.restart_mode = False
self.baseDbStatus.begin_restart()
self.assertTrue(self.baseDbStatus.restart_mode)
def test_end_install_or_restart(self):
self.baseDbStatus = BaseDbStatus()
self.baseDbStatus._get_actual_db_status = Mock(
return_value=rd_instance.ServiceStatuses.SHUTDOWN)
self.baseDbStatus.end_install_or_restart()
self.assertEqual(rd_instance.ServiceStatuses.SHUTDOWN,
self.baseDbStatus.status)
self.assertFalse(self.baseDbStatus.restart_mode)
def test_is_installed(self):
self.baseDbStatus = BaseDbStatus()
self.baseDbStatus.status = rd_instance.ServiceStatuses.RUNNING
self.assertTrue(self.baseDbStatus.is_installed)
def test_is_installed_none(self):
self.baseDbStatus = BaseDbStatus()
self.baseDbStatus.status = None
self.assertTrue(self.baseDbStatus.is_installed)
def test_is_installed_building(self):
self.baseDbStatus = BaseDbStatus()
self.baseDbStatus.status = rd_instance.ServiceStatuses.BUILDING
self.assertFalse(self.baseDbStatus.is_installed)
def test_is_installed_new(self):
self.baseDbStatus = BaseDbStatus()
self.baseDbStatus.status = rd_instance.ServiceStatuses.NEW
self.assertFalse(self.baseDbStatus.is_installed)
def test_is_installed_failed(self):
self.baseDbStatus = BaseDbStatus()
self.baseDbStatus.status = rd_instance.ServiceStatuses.FAILED
self.assertFalse(self.baseDbStatus.is_installed)
def test_is_restarting(self):
self.baseDbStatus = BaseDbStatus()
self.baseDbStatus.restart_mode = True
self.assertTrue(self.baseDbStatus._is_restarting)
def test_is_running(self):
self.baseDbStatus = BaseDbStatus()
self.baseDbStatus.status = rd_instance.ServiceStatuses.RUNNING
self.assertTrue(self.baseDbStatus.is_running)
def test_is_running_not(self):
self.baseDbStatus = BaseDbStatus()
self.baseDbStatus.status = rd_instance.ServiceStatuses.SHUTDOWN
self.assertFalse(self.baseDbStatus.is_running)
def test_wait_for_real_status_to_change_to(self):
self.baseDbStatus = BaseDbStatus()
self.baseDbStatus._get_actual_db_status = Mock(
return_value=rd_instance.ServiceStatuses.RUNNING)
time.sleep = Mock()
self.assertTrue(self.baseDbStatus.
wait_for_real_status_to_change_to
(rd_instance.ServiceStatuses.RUNNING, 10))
def test_wait_for_real_status_to_change_to_timeout(self):
self.baseDbStatus = BaseDbStatus()
self.baseDbStatus._get_actual_db_status = Mock(
return_value=rd_instance.ServiceStatuses.RUNNING)
time.sleep = Mock()
self.assertFalse(self.baseDbStatus.
wait_for_real_status_to_change_to
(rd_instance.ServiceStatuses.SHUTDOWN, 10))
class MySqlAppStatusTest(testtools.TestCase):
def setUp(self):
super(MySqlAppStatusTest, self).setUp()
util.init_db()
self.orig_utils_execute_with_timeout = dbaas.utils.execute_with_timeout
self.orig_load_mysqld_options = dbaas.load_mysqld_options
self.orig_dbaas_os_path_exists = dbaas.os.path.exists
self.orig_dbaas_time_sleep = time.sleep
self.FAKE_ID = str(uuid4())
InstanceServiceStatus.create(instance_id=self.FAKE_ID,
status=rd_instance.ServiceStatuses.NEW)
dbaas.CONF.guest_id = self.FAKE_ID
def tearDown(self):
super(MySqlAppStatusTest, self).tearDown()
dbaas.utils.execute_with_timeout = self.orig_utils_execute_with_timeout
dbaas.load_mysqld_options = self.orig_load_mysqld_options
dbaas.os.path.exists = self.orig_dbaas_os_path_exists
time.sleep = self.orig_dbaas_time_sleep
InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete()
dbaas.CONF.guest_id = None
def test_get_actual_db_status(self):
dbaas.utils.execute_with_timeout = Mock(return_value=(None, None))
self.mySqlAppStatus = MySqlAppStatus()
status = self.mySqlAppStatus._get_actual_db_status()
self.assertEqual(rd_instance.ServiceStatuses.RUNNING, status)
def test_get_actual_db_status_error_shutdown(self):
mocked = Mock(side_effect=ProcessExecutionError())
dbaas.utils.execute_with_timeout = mocked
dbaas.load_mysqld_options = Mock(return_value={})
dbaas.os.path.exists = Mock(return_value=False)
self.mySqlAppStatus = MySqlAppStatus()
status = self.mySqlAppStatus._get_actual_db_status()
self.assertEqual(rd_instance.ServiceStatuses.SHUTDOWN, status)
def test_get_actual_db_status_error_crashed(self):
dbaas.utils.execute_with_timeout = MagicMock(
side_effect=[ProcessExecutionError(), ("some output", None)])
dbaas.load_mysqld_options = Mock()
dbaas.os.path.exists = Mock(return_value=True)
self.mySqlAppStatus = MySqlAppStatus()
status = self.mySqlAppStatus._get_actual_db_status()
self.assertEqual(rd_instance.ServiceStatuses.BLOCKED, status)
class TestRedisApp(testtools.TestCase):
def setUp(self):
super(TestRedisApp, self).setUp()
self.FAKE_ID = 1000
self.appStatus = FakeAppStatus(self.FAKE_ID,
rd_instance.ServiceStatuses.NEW)
self.app = RedisApp(self.appStatus)
self.orig_os_path_isfile = os.path.isfile
self.orig_utils_execute_with_timeout = utils.execute_with_timeout
utils.execute_with_timeout = Mock()
rservice.utils.execute_with_timeout = Mock()
def tearDown(self):
super(TestRedisApp, self).tearDown()
self.app = None
os.path.isfile = self.orig_os_path_isfile
utils.execute_with_timeout = self.orig_utils_execute_with_timeout
rservice.utils.execute_with_timeout = \
self.orig_utils_execute_with_timeout
def test_install_if_needed_installed(self):
with patch.object(pkg.Package, 'pkg_is_installed', return_value=True):
with patch.object(RedisApp, '_install_redis', return_value=None):
self.app.install_if_needed('bar')
pkg.Package.pkg_is_installed.assert_any_call('bar')
self.assertEqual(RedisApp._install_redis.call_count, 0)
def test_install_if_needed_not_installed(self):
with patch.object(pkg.Package, 'pkg_is_installed', return_value=False):
with patch.object(RedisApp, '_install_redis', return_value=None):
self.app.install_if_needed('asdf')
pkg.Package.pkg_is_installed.assert_any_call('asdf')
RedisApp._install_redis.assert_any_call('asdf')
def test_install_redis(self):
with patch.object(utils, 'execute_with_timeout'):
with patch.object(pkg.Package, 'pkg_install', return_value=None):
with patch.object(RedisApp, 'start_redis', return_value=None):
self.app._install_redis('redis')
pkg.Package.pkg_install.assert_any_call('redis', {}, 1200)
RedisApp.start_redis.assert_any_call()
self.assertTrue(utils.execute_with_timeout.called)
def test_enable_redis_on_boot_without_upstart(self):
cmd = '123'
with patch.object(operating_system, 'service_discovery',
return_value={'cmd_enable': cmd}):
with patch.object(utils, 'execute_with_timeout',
return_value=None):
self.app._enable_redis_on_boot()
operating_system.service_discovery.assert_any_call(
RedisSystem.SERVICE_CANDIDATES)
utils.execute_with_timeout.assert_any_call(
cmd, shell=True)
def test_enable_redis_on_boot_with_upstart(self):
cmd = '123'
with patch.object(operating_system, 'service_discovery',
return_value={'cmd_enable': cmd}):
with patch.object(utils, 'execute_with_timeout',
return_value=None):
self.app._enable_redis_on_boot()
operating_system.service_discovery.assert_any_call(
RedisSystem.SERVICE_CANDIDATES)
utils.execute_with_timeout.assert_any_call(
cmd, shell=True)
def test_disable_redis_on_boot_with_upstart(self):
cmd = '123'
with patch.object(operating_system, 'service_discovery',
return_value={'cmd_disable': cmd}):
with patch.object(utils, 'execute_with_timeout',
return_value=None):
self.app._disable_redis_on_boot()
operating_system.service_discovery.assert_any_call(
RedisSystem.SERVICE_CANDIDATES)
utils.execute_with_timeout.assert_any_call(
cmd, shell=True)
def test_disable_redis_on_boot_without_upstart(self):
cmd = '123'
with patch.object(operating_system, 'service_discovery',
return_value={'cmd_disable': cmd}):
with patch.object(utils, 'execute_with_timeout',
return_value=None):
self.app._disable_redis_on_boot()
operating_system.service_discovery.assert_any_call(
RedisSystem.SERVICE_CANDIDATES)
utils.execute_with_timeout.assert_any_call(
cmd, shell=True)
def test_stop_db_without_fail(self):
mock_status = MagicMock()
mock_status.wait_for_real_status_to_change_to = MagicMock(
return_value=True)
app = RedisApp(mock_status, state_change_wait_time=0)
RedisApp._disable_redis_on_boot = MagicMock(
return_value=None)
with patch.object(utils, 'execute_with_timeout', return_value=None):
mock_status.wait_for_real_status_to_change_to = MagicMock(
return_value=True)
app.stop_db(do_not_start_on_reboot=True)
utils.execute_with_timeout.assert_any_call(
'sudo ' + RedisSystem.REDIS_CMD_STOP,
shell=True)
self.assertTrue(RedisApp._disable_redis_on_boot.called)
self.assertTrue(
mock_status.wait_for_real_status_to_change_to.called)
def test_stop_db_with_failure(self):
mock_status = MagicMock()
mock_status.wait_for_real_status_to_change_to = MagicMock(
return_value=True)
app = RedisApp(mock_status, state_change_wait_time=0)
RedisApp._disable_redis_on_boot = MagicMock(
return_value=None)
with patch.object(utils, 'execute_with_timeout', return_value=None):
mock_status.wait_for_real_status_to_change_to = MagicMock(
return_value=False)
app.stop_db(do_not_start_on_reboot=True)
utils.execute_with_timeout.assert_any_call(
'sudo ' + RedisSystem.REDIS_CMD_STOP,
shell=True)
self.assertTrue(RedisApp._disable_redis_on_boot.called)
self.assertTrue(mock_status.end_install_or_restart.called)
self.assertTrue(
mock_status.wait_for_real_status_to_change_to.called)
def test_restart(self):
mock_status = MagicMock()
app = RedisApp(mock_status, state_change_wait_time=0)
mock_status.begin_restart = MagicMock(return_value=None)
with patch.object(RedisApp, 'stop_db', return_value=None):
with patch.object(RedisApp, 'start_redis', return_value=None):
mock_status.end_install_or_restart = MagicMock(
return_value=None)
app.restart()
mock_status.begin_restart.assert_any_call()
RedisApp.stop_db.assert_any_call()
RedisApp.start_redis.assert_any_call()
mock_status.end_install_or_restart.assert_any_call()
def test_start_redis(self):
mock_status = MagicMock()
app = RedisApp(mock_status, state_change_wait_time=0)
with patch.object(RedisApp, '_enable_redis_on_boot',
return_value=None):
with patch.object(utils, 'execute_with_timeout',
return_value=None):
mock_status.wait_for_real_status_to_change_to = MagicMock(
return_value=None)
mock_status.end_install_or_restart = MagicMock(
return_value=None)
app.start_redis()
utils.execute_with_timeout.assert_any_call(
'sudo ' + RedisSystem.REDIS_CMD_START,
shell=True)
utils.execute_with_timeout.assert_any_call('pkill', '-9',
'redis-server',
run_as_root=True,
root_helper='sudo')
self.assertTrue(RedisApp._enable_redis_on_boot.called)
self.assertTrue(mock_status.end_install_or_restart.called)
self.assertTrue(
mock_status.wait_for_real_status_to_change_to.callled)
class CassandraDBAppTest(testtools.TestCase):
def setUp(self):
super(CassandraDBAppTest, self).setUp()
self.utils_execute_with_timeout = (
cass_service.utils.execute_with_timeout)
self.sleep = time.sleep
self.pkg_version = cass_service.packager.pkg_version
self.pkg = cass_service.packager
util.init_db()
self.FAKE_ID = str(uuid4())
InstanceServiceStatus.create(instance_id=self.FAKE_ID,
status=rd_instance.ServiceStatuses.NEW)
self.appStatus = FakeAppStatus(self.FAKE_ID,
rd_instance.ServiceStatuses.NEW)
self.cassandra = cass_service.CassandraApp(self.appStatus)
self.orig_unlink = os.unlink
def tearDown(self):
super(CassandraDBAppTest, self).tearDown()
cass_service.utils.execute_with_timeout = (self.
utils_execute_with_timeout)
time.sleep = self.sleep
cass_service.packager.pkg_version = self.pkg_version
cass_service.packager = self.pkg
InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete()
def assert_reported_status(self, expected_status):
service_status = InstanceServiceStatus.find_by(
instance_id=self.FAKE_ID)
self.assertEqual(expected_status, service_status.status)
def test_stop_db(self):
cass_service.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(
rd_instance.ServiceStatuses.SHUTDOWN)
self.cassandra.stop_db()
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_stop_db_with_db_update(self):
cass_service.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(
rd_instance.ServiceStatuses.SHUTDOWN)
self.cassandra.stop_db(True)
self.assertTrue(conductor_api.API.heartbeat.called_once_with(
self.FAKE_ID,
{'service_status':
rd_instance.ServiceStatuses.SHUTDOWN.description}))
def test_stop_db_error(self):
cass_service.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.cassandra.state_change_wait_time = 1
self.assertRaises(RuntimeError, self.cassandra.stop_db)
def test_restart(self):
self.cassandra.stop_db = Mock()
self.cassandra.start_db = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.cassandra.restart()
self.assertTrue(conductor_api.API.heartbeat.called_once_with(
self.FAKE_ID,
{'service_status':
rd_instance.ServiceStatuses.RUNNING.description}))
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_start_cassandra(self):
cass_service.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.cassandra.start_db()
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_start_cassandra_runs_forever(self):
cass_service.utils.execute_with_timeout = Mock()
(self.cassandra.status.
wait_for_real_status_to_change_to) = Mock(return_value=False)
self.appStatus.set_next_status(rd_instance.ServiceStatuses.SHUTDOWN)
self.assertRaises(RuntimeError, self.cassandra.stop_db)
self.assertTrue(conductor_api.API.heartbeat.called_once_with(
self.FAKE_ID,
{'service_status':
rd_instance.ServiceStatuses.SHUTDOWN.description}))
def test_start_db_with_db_update(self):
cass_service.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(
rd_instance.ServiceStatuses.RUNNING)
self.cassandra.start_db(True)
self.assertTrue(conductor_api.API.heartbeat.called_once_with(
self.FAKE_ID,
{'service_status':
rd_instance.ServiceStatuses.RUNNING.description}))
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_start_cassandra_error(self):
self.cassandra._enable_db_on_boot = Mock()
self.cassandra.state_change_wait_time = 1
cass_service.utils.execute_with_timeout = Mock(
side_effect=ProcessExecutionError('Error'))
self.assertRaises(RuntimeError, self.cassandra.start_db)
def test_install(self):
self.cassandra._install_db = Mock()
self.pkg.pkg_is_installed = Mock(return_value=False)
self.cassandra.install_if_needed(['cassandra'])
self.assertTrue(self.cassandra._install_db.called)
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_install_install_error(self):
from trove.guestagent import pkg
self.cassandra.start_db = Mock()
self.cassandra.stop_db = Mock()
self.pkg.pkg_is_installed = Mock(return_value=False)
self.cassandra._install_db = Mock(
side_effect=pkg.PkgPackageStateError("Install error"))
self.assertRaises(pkg.PkgPackageStateError,
self.cassandra.install_if_needed,
['cassandra=1.2.10'])
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_cassandra_error_in_write_config_verify_unlink(self):
# this test verifies not only that the write_config
# method properly invoked execute, but also that it properly
# attempted to unlink the file (as a result of the exception)
from trove.common.exception import ProcessExecutionError
execute_with_timeout = Mock(
side_effect=ProcessExecutionError('some exception'))
mock_unlink = Mock(return_value=0)
# We call tempfile.mkstemp() here and Mock() the mkstemp()
# parameter to write_config for testability.
(temp_handle, temp_config_name) = tempfile.mkstemp()
mock_mkstemp = MagicMock(return_value=(temp_handle, temp_config_name))
configuration = 'this is my configuration'
self.assertRaises(ProcessExecutionError,
self.cassandra.write_config,
config_contents=configuration,
execute_function=execute_with_timeout,
mkstemp_function=mock_mkstemp,
unlink_function=mock_unlink)
self.assertEqual(mock_unlink.call_count, 1)
# really delete the temporary_config_file
os.unlink(temp_config_name)
def test_cassandra_write_config(self):
# ensure that write_config creates a temporary file, and then
# moves the file to the final place. Also validate the
# contents of the file written.
# We call tempfile.mkstemp() here and Mock() the mkstemp()
# parameter to write_config for testability.
(temp_handle, temp_config_name) = tempfile.mkstemp()
mock_mkstemp = MagicMock(return_value=(temp_handle, temp_config_name))
configuration = 'some arbitrary configuration text'
mock_execute = MagicMock(return_value=('', ''))
self.cassandra.write_config(configuration,
execute_function=mock_execute,
mkstemp_function=mock_mkstemp)
mv, chown, chmod = mock_execute.call_args_list
mv.assert_called_with("sudo", "mv",
temp_config_name,
cass_system.CASSANDRA_CONF)
chown.assert_called_with("sudo", "chown", "cassandra:cassandra",
cass_system.CASSANDRA_CONF)
chmod.assert_called_with("sudo", "chmod", "a+r",
cass_system.CASSANDRA_CONF)
mock_mkstemp.assert_called_once()
with open(temp_config_name, 'r') as config_file:
configuration_data = config_file.read()
self.assertEqual(configuration, configuration_data)
# really delete the temporary_config_file
os.unlink(temp_config_name)
class CouchbaseAppTest(testtools.TestCase):
def fake_couchbase_service_discovery(self, candidates):
return {
'cmd_start': 'start',
'cmd_stop': 'stop',
'cmd_enable': 'enable',
'cmd_disable': 'disable'
}
def setUp(self):
super(CouchbaseAppTest, self).setUp()
self.orig_utils_execute_with_timeout = (
couchservice.utils.execute_with_timeout)
self.orig_time_sleep = time.sleep
time.sleep = Mock()
self.orig_service_discovery = operating_system.service_discovery
self.orig_get_ip = netutils.get_my_ipv4
operating_system.service_discovery = (
self.fake_couchbase_service_discovery)
netutils.get_my_ipv4 = Mock()
self.FAKE_ID = str(uuid4())
InstanceServiceStatus.create(instance_id=self.FAKE_ID,
status=rd_instance.ServiceStatuses.NEW)
self.appStatus = FakeAppStatus(self.FAKE_ID,
rd_instance.ServiceStatuses.NEW)
self.couchbaseApp = couchservice.CouchbaseApp(self.appStatus)
dbaas.CONF.guest_id = self.FAKE_ID
def tearDown(self):
super(CouchbaseAppTest, self).tearDown()
couchservice.utils.execute_with_timeout = (
self.orig_utils_execute_with_timeout)
netutils.get_my_ipv4 = self.orig_get_ip
operating_system.service_discovery = self.orig_service_discovery
time.sleep = self.orig_time_sleep
InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete()
dbaas.CONF.guest_id = None
def assert_reported_status(self, expected_status):
service_status = InstanceServiceStatus.find_by(
instance_id=self.FAKE_ID)
self.assertEqual(expected_status, service_status.status)
def test_stop_db(self):
couchservice.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.SHUTDOWN)
self.couchbaseApp.stop_db()
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_stop_db_error(self):
couchservice.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.couchbaseApp.state_change_wait_time = 1
self.assertRaises(RuntimeError, self.couchbaseApp.stop_db)
def test_restart(self):
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.couchbaseApp.stop_db = Mock()
self.couchbaseApp.start_db = Mock()
self.couchbaseApp.restart()
self.assertTrue(self.couchbaseApp.stop_db.called)
self.assertTrue(self.couchbaseApp.start_db.called)
self.assertTrue(conductor_api.API.heartbeat.called)
def test_start_db(self):
couchservice.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.couchbaseApp._enable_db_on_boot = Mock()
self.couchbaseApp.start_db()
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_start_db_error(self):
from trove.common.exception import ProcessExecutionError
mocked = Mock(side_effect=ProcessExecutionError('Error'))
couchservice.utils.execute_with_timeout = mocked
self.couchbaseApp._enable_db_on_boot = Mock()
self.assertRaises(RuntimeError, self.couchbaseApp.start_db)
def test_start_db_runs_forever(self):
couchservice.utils.execute_with_timeout = Mock()
self.couchbaseApp._enable_db_on_boot = Mock()
self.couchbaseApp.state_change_wait_time = 1
self.appStatus.set_next_status(rd_instance.ServiceStatuses.SHUTDOWN)
self.assertRaises(RuntimeError, self.couchbaseApp.start_db)
self.assertTrue(conductor_api.API.heartbeat.called)
def test_install_when_couchbase_installed(self):
couchservice.packager.pkg_is_installed = Mock(return_value=True)
couchservice.utils.execute_with_timeout = Mock()
self.couchbaseApp.install_if_needed(["package"])
self.assertTrue(couchservice.packager.pkg_is_installed.called)
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
class CouchDBAppTest(testtools.TestCase):
def fake_couchdb_service_discovery(self, candidates):
return {
'cmd_start': 'start',
'cmd_stop': 'stop',
'cmd_enable': 'enable',
'cmd_disable': 'disable'
}
def setUp(self):
super(CouchDBAppTest, self).setUp()
self.orig_utils_execute_with_timeout = (
couchdb_service.utils.execute_with_timeout)
self.orig_time_sleep = time.sleep
time.sleep = Mock()
self.orig_service_discovery = operating_system.service_discovery
self.orig_get_ip = netutils.get_my_ipv4
operating_system.service_discovery = (
self.fake_couchdb_service_discovery)
netutils.get_my_ipv4 = Mock()
util.init_db()
self.FAKE_ID = str(uuid4())
InstanceServiceStatus.create(instance_id=self.FAKE_ID,
status=rd_instance.ServiceStatuses.NEW)
self.appStatus = FakeAppStatus(self.FAKE_ID,
rd_instance.ServiceStatuses.NEW)
self.couchdbApp = couchdb_service.CouchDBApp(self.appStatus)
dbaas.CONF.guest_id = self.FAKE_ID
def tearDown(self):
super(CouchDBAppTest, self).tearDown()
couchdb_service.utils.execute_with_timeout = (
self.orig_utils_execute_with_timeout)
netutils.get_my_ipv4 = self.orig_get_ip
operating_system.service_discovery = self.orig_service_discovery
time.sleep = self.orig_time_sleep
InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete()
dbaas.CONF.guest_id = None
def assert_reported_status(self, expected_status):
service_status = InstanceServiceStatus.find_by(
instance_id=self.FAKE_ID)
self.assertEqual(expected_status, service_status.status)
def test_stop_db(self):
couchdb_service.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.SHUTDOWN)
self.couchdbApp.stop_db()
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_stop_db_error(self):
couchdb_service.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.couchdbApp.state_change_wait_time = 1
self.assertRaises(RuntimeError, self.couchdbApp.stop_db)
def test_restart(self):
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.couchdbApp.stop_db = Mock()
self.couchdbApp.start_db = Mock()
self.couchdbApp.restart()
self.assertTrue(self.couchdbApp.stop_db.called)
self.assertTrue(self.couchdbApp.start_db.called)
self.assertTrue(conductor_api.API.heartbeat.called)
def test_start_db(self):
couchdb_service.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.couchdbApp._enable_db_on_boot = Mock()
self.couchdbApp.start_db()
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_start_db_error(self):
from trove.common.exception import ProcessExecutionError
couchdb_service.utils.execute_with_timeout = Mock(
side_effect=ProcessExecutionError('Error'))
self.couchdbApp._enable_db_on_boot = Mock()
self.assertRaises(RuntimeError, self.couchdbApp.start_db)
def test_install_when_couchdb_installed(self):
couchdb_service.packager.pkg_is_installed = Mock(return_value=True)
couchdb_service.utils.execute_with_timeout = Mock()
self.couchdbApp.install_if_needed(["package"])
self.assertTrue(couchdb_service.packager.pkg_is_installed.called)
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
class MongoDBAppTest(testtools.TestCase):
def fake_mongodb_service_discovery(self, candidates):
return {
'cmd_start': 'start',
'cmd_stop': 'stop',
'cmd_enable': 'enable',
'cmd_disable': 'disable'
}
def setUp(self):
super(MongoDBAppTest, self).setUp()
self.orig_utils_execute_with_timeout = (mongo_service.
utils.execute_with_timeout)
self.orig_time_sleep = time.sleep
self.orig_packager = mongo_system.PACKAGER
self.orig_service_discovery = operating_system.service_discovery
self.orig_os_unlink = os.unlink
operating_system.service_discovery = (
self.fake_mongodb_service_discovery)
util.init_db()
self.FAKE_ID = str(uuid4())
InstanceServiceStatus.create(instance_id=self.FAKE_ID,
status=rd_instance.ServiceStatuses.NEW)
self.appStatus = FakeAppStatus(self.FAKE_ID,
rd_instance.ServiceStatuses.NEW)
self.mongoDbApp = mongo_service.MongoDBApp(self.appStatus)
time.sleep = Mock()
os.unlink = Mock()
def tearDown(self):
super(MongoDBAppTest, self).tearDown()
mongo_service.utils.execute_with_timeout = (
self.orig_utils_execute_with_timeout)
time.sleep = self.orig_time_sleep
mongo_system.PACKAGER = self.orig_packager
operating_system.service_discovery = self.orig_service_discovery
os.unlink = self.orig_os_unlink
InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete()
def assert_reported_status(self, expected_status):
service_status = InstanceServiceStatus.find_by(
instance_id=self.FAKE_ID)
self.assertEqual(expected_status, service_status.status)
def test_stopdb(self):
mongo_service.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(
rd_instance.ServiceStatuses.SHUTDOWN)
self.mongoDbApp.stop_db()
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_stop_db_with_db_update(self):
mongo_service.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(
rd_instance.ServiceStatuses.SHUTDOWN)
self.mongoDbApp.stop_db(True)
self.assertTrue(conductor_api.API.heartbeat.called_once_with(
self.FAKE_ID, {'service_status': 'shutdown'}))
def test_stop_db_error(self):
mongo_service.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.mongoDbApp.state_change_wait_time = 1
self.assertRaises(RuntimeError, self.mongoDbApp.stop_db)
def test_restart(self):
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.mongoDbApp.stop_db = Mock()
self.mongoDbApp.start_db = Mock()
self.mongoDbApp.restart()
self.assertTrue(self.mongoDbApp.stop_db.called)
self.assertTrue(self.mongoDbApp.start_db.called)
self.assertTrue(conductor_api.API.heartbeat.called_once_with(
self.FAKE_ID, {'service_status': 'shutdown'}))
self.assertTrue(conductor_api.API.heartbeat.called_once_with(
self.FAKE_ID, {'service_status': 'running'}))
def test_start_db(self):
mongo_service.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.mongoDbApp.start_db()
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_start_db_with_update(self):
mongo_service.utils.execute_with_timeout = Mock()
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
self.mongoDbApp.start_db(True)
self.assertTrue(conductor_api.API.heartbeat.called_once_with(
self.FAKE_ID, {'service_status': 'running'}))
def test_start_db_runs_forever(self):
mongo_service.utils.execute_with_timeout = Mock(
return_value=["ubuntu 17036 0.0 0.1 618960 "
"29232 pts/8 Sl+ Jan29 0:07 mongod", ""])
self.mongoDbApp.state_change_wait_time = 1
self.appStatus.set_next_status(rd_instance.ServiceStatuses.SHUTDOWN)
self.assertRaises(RuntimeError, self.mongoDbApp.start_db)
self.assertTrue(conductor_api.API.heartbeat.called_once_with(
self.FAKE_ID, {'service_status': 'shutdown'}))
def test_start_db_error(self):
self.mongoDbApp._enable_db_on_boot = Mock()
from trove.common.exception import ProcessExecutionError
mocked = Mock(side_effect=ProcessExecutionError('Error'))
mongo_service.utils.execute_with_timeout = mocked
self.assertRaises(RuntimeError, self.mongoDbApp.start_db)
def test_mongodb_error_in_write_config_verify_unlink(self):
configuration = {'config_contents': 'some junk'}
from trove.common.exception import ProcessExecutionError
mongo_service.utils.execute_with_timeout = (
Mock(side_effect=ProcessExecutionError('some exception')))
self.assertRaises(ProcessExecutionError,
self.mongoDbApp.reset_configuration,
configuration=configuration)
self.assertEqual(
mongo_service.utils.execute_with_timeout.call_count, 1)
self.assertEqual(os.unlink.call_count, 1)
def test_mongodb_error_in_write_config(self):
configuration = {'config_contents': 'some junk'}
from trove.common.exception import ProcessExecutionError
mongo_service.utils.execute_with_timeout = (
Mock(side_effect=ProcessExecutionError('some exception')))
self.assertRaises(ProcessExecutionError,
self.mongoDbApp.reset_configuration,
configuration=configuration)
self.assertEqual(
mongo_service.utils.execute_with_timeout.call_count, 1)
def test_start_db_with_conf_changes_db_is_running(self):
self.mongoDbApp.start_db = Mock()
self.appStatus.status = rd_instance.ServiceStatuses.RUNNING
self.assertRaises(RuntimeError,
self.mongoDbApp.start_db_with_conf_changes,
Mock())
def test_install_when_db_installed(self):
packager_mock = MagicMock()
packager_mock.pkg_is_installed = MagicMock(return_value=True)
mongo_system.PACKAGER = packager_mock
self.mongoDbApp.install_if_needed(['package'])
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_install_when_db_not_installed(self):
packager_mock = MagicMock()
packager_mock.pkg_is_installed = MagicMock(return_value=False)
mongo_system.PACKAGER = packager_mock
self.mongoDbApp.install_if_needed(['package'])
packager_mock.pkg_install.assert_any_call(ANY, {}, ANY)
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
class VerticaAppStatusTest(testtools.TestCase):
def setUp(self):
super(VerticaAppStatusTest, self).setUp()
util.init_db()
self.FAKE_ID = str(uuid4())
InstanceServiceStatus.create(instance_id=self.FAKE_ID,
status=rd_instance.ServiceStatuses.NEW)
self.appStatus = FakeAppStatus(self.FAKE_ID,
rd_instance.ServiceStatuses.NEW)
def tearDown(self):
super(VerticaAppStatusTest, self).tearDown()
InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete()
def test_get_actual_db_status(self):
self.verticaAppStatus = VerticaAppStatus()
with patch.object(vertica_system, 'shell_execute',
MagicMock(return_value=['db_srvr', None])):
status = self.verticaAppStatus._get_actual_db_status()
self.assertEqual(rd_instance.ServiceStatuses.RUNNING, status)
def test_get_actual_db_status_shutdown(self):
self.verticaAppStatus = VerticaAppStatus()
with patch.object(vertica_system, 'shell_execute',
MagicMock(side_effect=[['', None],
['db_srvr', None]])):
status = self.verticaAppStatus._get_actual_db_status()
self.assertEqual(rd_instance.ServiceStatuses.SHUTDOWN, status)
def test_get_actual_db_status_error_crashed(self):
self.verticaAppStatus = VerticaAppStatus()
with patch.object(vertica_system, 'shell_execute',
MagicMock(side_effect=ProcessExecutionError('problem'
))):
status = self.verticaAppStatus._get_actual_db_status()
self.assertEqual(rd_instance.ServiceStatuses.CRASHED, status)
class VerticaAppTest(testtools.TestCase):
def setUp(self):
super(VerticaAppTest, self).setUp()
self.FAKE_ID = 1000
self.appStatus = FakeAppStatus(self.FAKE_ID,
rd_instance.ServiceStatuses.NEW)
self.app = VerticaApp(self.appStatus)
self.setread = VolumeDevice.set_readahead_size
self.Popen = subprocess.Popen
vertica_system.shell_execute = MagicMock(return_value=('', ''))
VolumeDevice.set_readahead_size = Mock()
subprocess.Popen = Mock()
self.test_config = ConfigParser.ConfigParser()
self.test_config.add_section('credentials')
self.test_config.set('credentials',
'dbadmin_password', 'some_password')
def tearDown(self):
super(VerticaAppTest, self).tearDown()
self.app = None
VolumeDevice.set_readahead_size = self.setread
subprocess.Popen = self.Popen
def test_install_if_needed_installed(self):
with patch.object(pkg.Package, 'pkg_is_installed', return_value=True):
with patch.object(pkg.Package, 'pkg_install', return_value=None):
self.app.install_if_needed('vertica')
pkg.Package.pkg_is_installed.assert_any_call('vertica')
self.assertEqual(pkg.Package.pkg_install.call_count, 0)
def test_install_if_needed_not_installed(self):
with patch.object(pkg.Package, 'pkg_is_installed', return_value=False):
with patch.object(pkg.Package, 'pkg_install', return_value=None):
self.app.install_if_needed('vertica')
pkg.Package.pkg_is_installed.assert_any_call('vertica')
self.assertEqual(pkg.Package.pkg_install.call_count, 1)
def test_prepare_for_install_vertica(self):
self.app.prepare_for_install_vertica()
arguments = vertica_system.shell_execute.call_args_list[0]
self.assertEqual(VolumeDevice.set_readahead_size.call_count, 1)
expected_command = (
"VERT_DBA_USR=dbadmin VERT_DBA_HOME=/home/dbadmin "
"VERT_DBA_GRP=verticadba /opt/vertica/oss/python/bin/python"
" -m vertica.local_coerce")
arguments.assert_called_with(expected_command)
def test_install_vertica(self):
with patch.object(self.app, 'write_config',
return_value=None):
self.app.install_vertica(members='10.0.0.2')
arguments = vertica_system.shell_execute.call_args_list[0]
expected_command = (
vertica_system.INSTALL_VERTICA % ('10.0.0.2', '/var/lib/vertica'))
arguments.assert_called_with(expected_command)
def test_create_db(self):
with patch.object(self.app, 'read_config',
return_value=self.test_config):
self.app.create_db(members='10.0.0.2')
arguments = vertica_system.shell_execute.call_args_list[0]
expected_command = (vertica_system.CREATE_DB % ('10.0.0.2', 'db_srvr',
'/var/lib/vertica',
'/var/lib/vertica',
'some_password'))
arguments.assert_called_with(expected_command, 'dbadmin')
def test_vertica_write_config(self):
temp_file_handle = tempfile.NamedTemporaryFile(delete=False)
mock_mkstemp = MagicMock(return_value=(temp_file_handle))
mock_unlink = Mock(return_value=0)
self.app.write_config(config=self.test_config,
temp_function=mock_mkstemp,
unlink_function=mock_unlink)
arguments = vertica_system.shell_execute.call_args_list[0]
expected_command = (
("install -o root -g root -m 644 %(source)s %(target)s"
) % {'source': temp_file_handle.name,
'target': vertica_system.VERTICA_CONF})
arguments.assert_called_with(expected_command)
mock_mkstemp.assert_called_once()
configuration_data = ConfigParser.ConfigParser()
configuration_data.read(temp_file_handle.name)
self.assertEqual(
self.test_config.get('credentials', 'dbadmin_password'),
configuration_data.get('credentials', 'dbadmin_password'))
self.assertEqual(mock_unlink.call_count, 1)
# delete the temporary_config_file
os.unlink(temp_file_handle.name)
def test_vertica_error_in_write_config_verify_unlink(self):
mock_unlink = Mock(return_value=0)
temp_file_handle = tempfile.NamedTemporaryFile(delete=False)
mock_mkstemp = MagicMock(return_value=temp_file_handle)
with patch.object(vertica_system, 'shell_execute',
side_effect=ProcessExecutionError('some exception')):
self.assertRaises(ProcessExecutionError,
self.app.write_config,
config=self.test_config,
temp_function=mock_mkstemp,
unlink_function=mock_unlink)
self.assertEqual(mock_unlink.call_count, 1)
# delete the temporary_config_file
os.unlink(temp_file_handle.name)
def test_restart(self):
mock_status = MagicMock()
app = VerticaApp(mock_status)
mock_status.begin_restart = MagicMock(return_value=None)
with patch.object(VerticaApp, 'stop_db', return_value=None):
with patch.object(VerticaApp, 'start_db', return_value=None):
mock_status.end_install_or_restart = MagicMock(
return_value=None)
app.restart()
mock_status.begin_restart.assert_any_call()
VerticaApp.stop_db.assert_any_call()
VerticaApp.start_db.assert_any_call()
def test_start_db(self):
mock_status = MagicMock()
type(mock_status)._is_restarting = PropertyMock(return_value=False)
app = VerticaApp(mock_status)
with patch.object(app, '_enable_db_on_boot', return_value=None):
with patch.object(app, 'read_config',
return_value=self.test_config):
mock_status.end_install_or_restart = MagicMock(
return_value=None)
app.start_db()
agent_start, db_start = subprocess.Popen.call_args_list
agent_expected_command = [
'sudo', 'su', '-', 'root', '-c',
(vertica_system.VERTICA_AGENT_SERVICE_COMMAND % 'start')]
db_expected_cmd = [
'sudo', 'su', '-', 'dbadmin', '-c',
(vertica_system.START_DB % ('db_srvr', 'some_password'))]
self.assertTrue(mock_status.end_install_or_restart.called)
agent_start.assert_called_with(agent_expected_command)
db_start.assert_called_with(db_expected_cmd)
def test_start_db_failure(self):
mock_status = MagicMock()
app = VerticaApp(mock_status)
with patch.object(app, '_enable_db_on_boot',
side_effect=RuntimeError()):
with patch.object(app, 'read_config',
return_value=self.test_config):
self.assertRaises(RuntimeError, app.start_db)
def test_stop_db(self):
mock_status = MagicMock()
type(mock_status)._is_restarting = PropertyMock(return_value=False)
app = VerticaApp(mock_status)
with patch.object(app, '_disable_db_on_boot', return_value=None):
with patch.object(app, 'read_config',
return_value=self.test_config):
with patch.object(vertica_system, 'shell_execute',
MagicMock(side_effect=[['', ''],
['db_srvr', None],
['', '']])):
mock_status.wait_for_real_status_to_change_to = MagicMock(
return_value=True)
mock_status.end_install_or_restart = MagicMock(
return_value=None)
app.stop_db()
self.assertEqual(vertica_system.shell_execute.call_count,
3)
# There are 3 shell-executions:
# a) stop vertica-agent service
# b) check daatabase status
# c) stop_db
# We are matcing that 3rd command called was stop_db
arguments = vertica_system.shell_execute.call_args_list[2]
expected_cmd = (vertica_system.STOP_DB % ('db_srvr',
'some_password'))
self.assertTrue(
mock_status.wait_for_real_status_to_change_to.called)
arguments.assert_called_with(expected_cmd, 'dbadmin')
def test_stop_db_failure(self):
mock_status = MagicMock()
type(mock_status)._is_restarting = PropertyMock(return_value=False)
app = VerticaApp(mock_status)
with patch.object(app, '_disable_db_on_boot', return_value=None):
with patch.object(app, 'read_config',
return_value=self.test_config):
with patch.object(vertica_system, 'shell_execute',
MagicMock(side_effect=[['', ''],
['db_srvr', None],
['', '']])):
mock_status.wait_for_real_status_to_change_to = MagicMock(
return_value=None)
mock_status.end_install_or_restart = MagicMock(
return_value=None)
self.assertRaises(RuntimeError, app.stop_db)
def test_export_conf_to_members(self):
self.app._export_conf_to_members(members=['member1', 'member2'])
self.assertEqual(vertica_system.shell_execute.call_count, 2)
def test_authorize_public_keys(self):
user = 'test_user'
keys = ['test_key@machine1', 'test_key@machine2']
with patch.object(os.path, 'expanduser',
return_value=('/home/' + user)):
self.app.authorize_public_keys(user=user, public_keys=keys)
self.assertEqual(vertica_system.shell_execute.call_count, 2)
vertica_system.shell_execute.assert_any_call(
'cat ' + '/home/' + user + '/.ssh/authorized_keys')
def test_get_public_keys(self):
user = 'test_user'
with patch.object(os.path, 'expanduser',
return_value=('/home/' + user)):
self.app.get_public_keys(user=user)
self.assertEqual(vertica_system.shell_execute.call_count, 2)
vertica_system.shell_execute.assert_any_call(
(vertica_system.SSH_KEY_GEN % ('/home/' + user)), user)
vertica_system.shell_execute.assert_any_call(
'cat ' + '/home/' + user + '/.ssh/id_rsa.pub')
def test_install_cluster(self):
with patch.object(self.app, 'read_config',
return_value=self.test_config):
self.app.install_cluster(members=['member1', 'member2'])
# Verifying nu,ber of shell calls,
# as command has already been tested in preceeding tests
self.assertEqual(vertica_system.shell_execute.call_count, 5)
class DB2AppTest(testtools.TestCase):
def setUp(self):
super(DB2AppTest, self).setUp()
self.orig_utils_execute_with_timeout = (
db2service.utils.execute_with_timeout)
util.init_db()
self.FAKE_ID = str(uuid4())
InstanceServiceStatus.create(instance_id=self.FAKE_ID,
status=rd_instance.ServiceStatuses.NEW)
self.appStatus = FakeAppStatus(self.FAKE_ID,
rd_instance.ServiceStatuses.NEW)
self.db2App = db2service.DB2App(self.appStatus)
dbaas.CONF.guest_id = self.FAKE_ID
def tearDown(self):
super(DB2AppTest, self).tearDown()
db2service.utils.execute_with_timeout = (
self.orig_utils_execute_with_timeout)
InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete()
dbaas.CONF.guest_id = None
self.db2App = None
def assert_reported_status(self, expected_status):
service_status = InstanceServiceStatus.find_by(
instance_id=self.FAKE_ID)
self.assertEqual(expected_status, service_status.status)
def test_stop_db(self):
db2service.utils.execute_with_timeout = MagicMock(return_value=None)
self.appStatus.set_next_status(rd_instance.ServiceStatuses.SHUTDOWN)
self.db2App.stop_db()
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
def test_restart_server(self):
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
mock_status = MagicMock(return_value=None)
app = db2service.DB2App(mock_status)
mock_status.begin_restart = MagicMock(return_value=None)
app.stop_db = MagicMock(return_value=None)
app.start_db = MagicMock(return_value=None)
app.restart()
self.assertTrue(mock_status.begin_restart.called)
self.assertTrue(app.stop_db.called)
self.assertTrue(app.start_db.called)
def test_start_db(self):
db2service.utils.execute_with_timeout = MagicMock(return_value=None)
self.appStatus.set_next_status(rd_instance.ServiceStatuses.RUNNING)
with patch.object(self.db2App, '_enable_db_on_boot',
return_value=None):
self.db2App.start_db()
self.assert_reported_status(rd_instance.ServiceStatuses.NEW)
class DB2AdminTest(testtools.TestCase):
def setUp(self):
super(DB2AdminTest, self).setUp()
self.db2Admin = db2service.DB2Admin()
self.orig_utils_execute_with_timeout = (
db2service.utils.execute_with_timeout)
def tearDown(self):
super(DB2AdminTest, self).tearDown()
db2service.utils.execute_with_timeout = (
self.orig_utils_execute_with_timeout)
def test_delete_database(self):
with patch.object(
db2service, 'run_command',
MagicMock(
return_value=None,
side_effect=ProcessExecutionError('Error'))):
self.assertRaises(GuestError,
self.db2Admin.delete_database,
FAKE_DB)
self.assertTrue(db2service.run_command.called)
args, _ = db2service.run_command.call_args_list[0]
expected = "db2 drop database testDB"
self.assertEqual(args[0], expected,
"Delete database queries are not the same")
def test_list_databases(self):
with patch.object(db2service, 'run_command', MagicMock(
side_effect=ProcessExecutionError('Error'))):
self.db2Admin.list_databases()
self.assertTrue(db2service.run_command.called)
args, _ = db2service.run_command.call_args_list[0]
expected = "db2 list database directory " \
"| grep -B6 -i indirect | grep 'Database name' | " \
"sed 's/.*= //'"
self.assertEqual(args[0], expected,
"Delete database queries are not the same")
def test_create_users(self):
with patch.object(db2service, 'run_command', MagicMock(
return_value=None)):
db2service.utils.execute_with_timeout = MagicMock(
return_value=None)
self.db2Admin.create_user(FAKE_USER)
self.assertTrue(db2service.utils.execute_with_timeout.called)
self.assertTrue(db2service.run_command.called)
args, _ = db2service.run_command.call_args_list[0]
expected = "db2 connect to testDB; " \
"db2 GRANT DBADM,CREATETAB,BINDADD,CONNECT,DATAACCESS " \
"ON DATABASE TO USER random; db2 connect reset"
self.assertEqual(
args[0], expected,
"Granting database access queries are not the same")
self.assertEqual(db2service.run_command.call_count, 1)
def test_delete_users_with_db(self):
with patch.object(db2service, 'run_command',
MagicMock(return_value=None)):
with patch.object(db2service.DB2Admin, 'list_access',
MagicMock(return_value=None)):
utils.execute_with_timeout = MagicMock(return_value=None)
self.db2Admin.delete_user(FAKE_USER[0])
self.assertTrue(db2service.run_command.called)
self.assertTrue(db2service.utils.execute_with_timeout.called)
self.assertFalse(db2service.DB2Admin.list_access.called)
args, _ = db2service.run_command.call_args_list[0]
expected = "db2 connect to testDB; " \
"db2 REVOKE DBADM,CREATETAB,BINDADD,CONNECT,DATAACCESS " \
"ON DATABASE FROM USER random; db2 connect reset"
self.assertEqual(
args[0], expected,
"Revoke database access queries are not the same")
self.assertEqual(db2service.run_command.call_count, 1)
def test_delete_users_without_db(self):
FAKE_USER.append(
{"_name": "random2", "_password": "guesswhat", "_databases": []})
with patch.object(db2service, 'run_command',
MagicMock(return_value=None)):
with patch.object(db2service.DB2Admin, 'list_access',
MagicMock(return_value=[FAKE_DB])):
utils.execute_with_timeout = MagicMock(return_value=None)
self.db2Admin.delete_user(FAKE_USER[1])
self.assertTrue(db2service.run_command.called)
self.assertTrue(db2service.DB2Admin.list_access.called)
self.assertTrue(
db2service.utils.execute_with_timeout.called)
args, _ = db2service.run_command.call_args_list[0]
expected = "db2 connect to testDB; " \
"db2 REVOKE DBADM,CREATETAB,BINDADD,CONNECT," \
"DATAACCESS ON DATABASE FROM USER random2; " \
"db2 connect reset"
self.assertEqual(
args[0], expected,
"Revoke database access queries are not the same")
self.assertEqual(db2service.run_command.call_count, 1)
def test_list_users(self):
databases = []
databases.append(FAKE_DB)
with patch.object(db2service, 'run_command', MagicMock(
side_effect=ProcessExecutionError('Error'))):
with patch.object(self.db2Admin, "list_databases",
MagicMock(return_value=(databases, None))):
self.db2Admin.list_users()
self.assertTrue(db2service.run_command.called)
args, _ = db2service.run_command.call_args_list[0]
expected = "db2 +o connect to testDB; " \
"db2 -x select grantee, dataaccessauth " \
"from sysibm.sysdbauth; db2 connect reset"
self.assertEqual(args[0], expected,
"List database queries are not the same")
def test_get_user(self):
databases = []
databases.append(FAKE_DB)
with patch.object(db2service, 'run_command', MagicMock(
side_effect=ProcessExecutionError('Error'))):
with patch.object(self.db2Admin, "list_databases",
MagicMock(return_value=(databases, None))):
self.db2Admin._get_user('random', None)
self.assertTrue(db2service.run_command.called)
args, _ = db2service.run_command.call_args_list[0]
expected = "db2 +o connect to testDB; " \
"db2 -x select grantee, dataaccessauth " \
"from sysibm.sysdbauth; db2 connect reset"
self.assertEqual(args[0], expected,
"Delete database queries are not the same")
| 41.729076
| 79
| 0.641803
| 11,428
| 105,199
| 5.614193
| 0.056003
| 0.016475
| 0.038716
| 0.048754
| 0.805359
| 0.760844
| 0.709893
| 0.667997
| 0.636559
| 0.607086
| 0
| 0.005538
| 0.268795
| 105,199
| 2,520
| 80
| 41.745635
| 0.828541
| 0.017272
| 0
| 0.598684
| 0
| 0
| 0.085857
| 0.018994
| 0
| 0
| 0
| 0
| 0.16498
| 1
| 0.112348
| false
| 0.013158
| 0.032389
| 0.005061
| 0.165486
| 0.000506
| 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
|
50b769c05cd39943ee087b82aa3b0b860d748dcd
| 358
|
bzl
|
Python
|
dependencies.bzl
|
todaypp/bazel-template
|
6cd87fc595f86e55a7a92aabca07af6a47f543ec
|
[
"MIT"
] | null | null | null |
dependencies.bzl
|
todaypp/bazel-template
|
6cd87fc595f86e55a7a92aabca07af6a47f543ec
|
[
"MIT"
] | 2
|
2022-02-02T08:16:31.000Z
|
2022-02-02T11:17:00.000Z
|
dependencies.bzl
|
todaypp/bazel-template
|
6cd87fc595f86e55a7a92aabca07af6a47f543ec
|
[
"MIT"
] | null | null | null |
"""Define nodejs and yarn dependencies"""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "a09edc4ba3931a856a5ac6836f248c302d55055d35d36e390a0549799c33145b",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.0.0/rules_nodejs-5.0.0.tar.gz"],
)
| 35.8
| 108
| 0.76257
| 44
| 358
| 6
| 0.659091
| 0.125
| 0.022727
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.165644
| 0.089385
| 358
| 9
| 109
| 39.777778
| 0.644172
| 0.097765
| 0
| 0
| 0
| 0.166667
| 0.74448
| 0.416404
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 0
| 0
| 0
| 0
| 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
| 1
| 1
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
50cba86588fc72c1a7e823bb2be4d9ee03cd2965
| 190
|
py
|
Python
|
Module 3/Chapter 4/ch4_30.py
|
PacktPublishing/Natural-Language-Processing-Python-and-NLTK
|
bb7fd9a3071b4247d13accfbf0a48eefec76e925
|
[
"MIT"
] | 50
|
2016-12-11T13:49:01.000Z
|
2022-03-20T19:47:55.000Z
|
Module 3/Chapter 4/ch4_30.py
|
PacktPublishing/Natural-Language-Processing-Python-and-NLTK
|
bb7fd9a3071b4247d13accfbf0a48eefec76e925
|
[
"MIT"
] | null | null | null |
Module 3/Chapter 4/ch4_30.py
|
PacktPublishing/Natural-Language-Processing-Python-and-NLTK
|
bb7fd9a3071b4247d13accfbf0a48eefec76e925
|
[
"MIT"
] | 40
|
2017-06-14T14:02:48.000Z
|
2021-10-14T06:25:00.000Z
|
import nltk
noun1=[("financial","NN"),("year","NN"),("account","NN"),("summary","NN")]
gram="NP:{<NN>+}"
find = nltk.RegexpParser(gram)
print(find.parse(noun1))
x=find.parse(noun1)
x.draw()
| 23.75
| 74
| 0.636842
| 28
| 190
| 4.321429
| 0.571429
| 0.14876
| 0.231405
| 0.247934
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.016667
| 0.052632
| 190
| 7
| 75
| 27.142857
| 0.655556
| 0
| 0
| 0
| 0
| 0
| 0.236842
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.142857
| 0
| 0.142857
| 0.142857
| 1
| 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
| 0
| 0
| 0
| 0
|
0
| 4
|
0f98097ead8f71ec8a5b6f0a7002f11c19efbfb2
| 348
|
py
|
Python
|
release/stubs.min/Rhino/DocObjects/__init___parts/PointCloudObject.py
|
htlcnn/ironpython-stubs
|
780d829e2104b2789d5f4d6f32b0ec9f2930ca03
|
[
"MIT"
] | 182
|
2017-06-27T02:26:15.000Z
|
2022-03-30T18:53:43.000Z
|
release/stubs.min/Rhino/DocObjects/__init___parts/PointCloudObject.py
|
htlcnn/ironpython-stubs
|
780d829e2104b2789d5f4d6f32b0ec9f2930ca03
|
[
"MIT"
] | 28
|
2017-06-27T13:38:23.000Z
|
2022-03-15T11:19:44.000Z
|
release/stubs.min/Rhino/DocObjects/__init___parts/PointCloudObject.py
|
htlcnn/ironpython-stubs
|
780d829e2104b2789d5f4d6f32b0ec9f2930ca03
|
[
"MIT"
] | 67
|
2017-06-28T09:43:59.000Z
|
2022-03-20T21:17:10.000Z
|
class PointCloudObject(RhinoObject):
# no doc
def DuplicatePointCloudGeometry(self):
""" DuplicatePointCloudGeometry(self: PointCloudObject) -> PointCloud """
pass
PointCloudGeometry=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Get: PointCloudGeometry(self: PointCloudObject) -> PointCloud
"""
| 24.857143
| 90
| 0.729885
| 30
| 348
| 8.466667
| 0.566667
| 0.11811
| 0.23622
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.152299
| 348
| 13
| 91
| 26.769231
| 0.861017
| 0.212644
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0.25
| 0
| 0
| 0.75
| 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
| 1
| 0
| 0
| 1
| 0
|
0
| 4
|
0f9abccd81979113ea564e184842cc72e720d799
| 260
|
py
|
Python
|
setup.py
|
rpavlik/edid-json-tools
|
0b44cfd477df3333e09dea278810eeb3926dedd9
|
[
"BSD-3-Clause"
] | 2
|
2021-04-04T15:47:14.000Z
|
2021-07-11T04:04:23.000Z
|
setup.py
|
rpavlik/edid-json-tools
|
0b44cfd477df3333e09dea278810eeb3926dedd9
|
[
"BSD-3-Clause"
] | null | null | null |
setup.py
|
rpavlik/edid-json-tools
|
0b44cfd477df3333e09dea278810eeb3926dedd9
|
[
"BSD-3-Clause"
] | null | null | null |
#!/usr/bin/env python3
# Copyright (c) 2019-2021 The EDID JSON Tools authors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
# We need this stub of a script to be able to handle `pip install --editable .`
import setuptools
setuptools.setup()
| 26
| 79
| 0.742308
| 41
| 260
| 4.707317
| 0.95122
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.045455
| 0.153846
| 260
| 9
| 80
| 28.888889
| 0.831818
| 0.811538
| 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
| 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
| 1
| 0
| 0
| 0
|
0
| 4
|
0fba08ac93cfa33092a88eca9845ed8123638097
| 186
|
py
|
Python
|
utils.py
|
Leaniz/gordologo
|
fcd8b8a3bfea1fb6e597dfd1701884ddd07db107
|
[
"MIT"
] | 1
|
2021-08-03T20:06:42.000Z
|
2021-08-03T20:06:42.000Z
|
utils.py
|
Leaniz/gordologo
|
fcd8b8a3bfea1fb6e597dfd1701884ddd07db107
|
[
"MIT"
] | null | null | null |
utils.py
|
Leaniz/gordologo
|
fcd8b8a3bfea1fb6e597dfd1701884ddd07db107
|
[
"MIT"
] | null | null | null |
from unidecode import unidecode
def compare_name(name_1, name_2):
name_1 = unidecode(name_1).lower()
name_2 = unidecode(name_2).lower()
return name_1 == name_2
| 23.25
| 42
| 0.672043
| 28
| 186
| 4.142857
| 0.357143
| 0.172414
| 0.155172
| 0.172414
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.055944
| 0.231183
| 186
| 7
| 43
| 26.571429
| 0.755245
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.2
| false
| 0
| 0.2
| 0
| 0.6
| 0
| 1
| 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
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
0fc313dd312cc4be6b6d09f8fe8d54c934571758
| 75
|
py
|
Python
|
Algorithms/implementation_drawing_book.py
|
suketm/hackerrank
|
1af471f6f88c40995c67d897ef22bc92b3162bdb
|
[
"MIT"
] | null | null | null |
Algorithms/implementation_drawing_book.py
|
suketm/hackerrank
|
1af471f6f88c40995c67d897ef22bc92b3162bdb
|
[
"MIT"
] | null | null | null |
Algorithms/implementation_drawing_book.py
|
suketm/hackerrank
|
1af471f6f88c40995c67d897ef22bc92b3162bdb
|
[
"MIT"
] | null | null | null |
n = int(input())
p = int(input())
print (min(p//2, ((n + (n+1)%2)-p)//2 ))
| 18.75
| 40
| 0.453333
| 16
| 75
| 2.125
| 0.5
| 0.470588
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.063492
| 0.16
| 75
| 4
| 40
| 18.75
| 0.47619
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0
| 0
| 0
| 0.333333
| 1
| 0
| 0
| null | 1
| 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
|
0fd0bf63ef900c73648d42d204e377ca905a8f17
| 19
|
py
|
Python
|
contrib/ruamel/__init__.py
|
reuterbal/ecbundle
|
94118ffa4384795ceed9d54cf886c975db4af9af
|
[
"Apache-2.0"
] | null | null | null |
contrib/ruamel/__init__.py
|
reuterbal/ecbundle
|
94118ffa4384795ceed9d54cf886c975db4af9af
|
[
"Apache-2.0"
] | 2
|
2022-01-12T10:02:57.000Z
|
2022-02-22T21:11:29.000Z
|
contrib/ruamel/__init__.py
|
reuterbal/ecbundle
|
94118ffa4384795ceed9d54cf886c975db4af9af
|
[
"Apache-2.0"
] | 1
|
2022-02-22T20:39:14.000Z
|
2022-02-22T20:39:14.000Z
|
__all__ = ["yaml"]
| 9.5
| 18
| 0.578947
| 2
| 19
| 3.5
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.157895
| 19
| 1
| 19
| 19
| 0.4375
| 0
| 0
| 0
| 0
| 0
| 0.210526
| 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
|
0fea3c7d4c5def8381fb9f14db9a030a6e779a23
| 2,044
|
py
|
Python
|
brainfuck.py
|
MineRobber9000/pyfiles
|
ad2f2fc3ed827e8891a7d82c13e3e961bacc3294
|
[
"MIT"
] | null | null | null |
brainfuck.py
|
MineRobber9000/pyfiles
|
ad2f2fc3ed827e8891a7d82c13e3e961bacc3294
|
[
"MIT"
] | null | null | null |
brainfuck.py
|
MineRobber9000/pyfiles
|
ad2f2fc3ed827e8891a7d82c13e3e961bacc3294
|
[
"MIT"
] | null | null | null |
import sys
major = sys.version_info.major
def six(two,three):
return lambda: two if major==2 else three
def newmodule():
if major==2:
return __import__("new").classobj
elif major==3:
return lambda name,base,ns: __import__("types").new_class(name,base,dict(),lambda d: d.update(ns))
def wh(cond,func):
while cond():
func()
class BrainfuckManual:
def __init__(self):
self.mem = {}
self.dp = 0
self.globals = globals()
def add(self):
return eval("mem.__setitem__(dp,(mem.get(dp,0)+1))",self.globals,self.__dict__)
def sub(self):
return eval("mem.__setitem__(dp,(mem.get(dp,0)-1))",self.globals,self.__dict__)
def left(self):
return eval("locals().__setitem__('dp',dp-1)",self.globals,self.__dict__)
def right(self):
return eval("locals().__setitem__('dp',dp+1)",self.globals,self.__dict__)
def out(self):
return eval(six("print chr(mem[dp]),","print(chr(mem[dp]),end='')")(),self.globals,self.__dict__)
def run(self,p):
self.i = 0
self.p = p
wh(lambda: self.i<len(p),self.tick)
def tick(self):
self.c = self.p[self.i]
{"+":self.add,"-":self.sub,">":self.right,"<":self.left,".":self.out}[self.c]()
self.i = self.i+1
Brainfuck = (lambda new,globals: new("Brainfuck",(),dict(__init__=lambda self: self.__dict__.update(dict(mem={},dp=0,globals=globals)),add=lambda self: eval("mem.__setitem__(dp,(mem.get(dp,0)+1))",self.globals,self.__dict__),sub=lambda self: eval("mem.__setitem__(dp,(mem.get(dp,0)-1))",self.globals,self.__dict__),left=lambda self: eval("locals().__setitem__('dp',dp-1)",self.globals,self.__dict__),right=lambda self: eval("locals().__setitem__('dp',dp+1)",self.globals,self.__dict__),out=lambda self: eval(six("print chr(mem[dp]),","print(chr(mem[dp]),end='')")(),self.globals,self.__dict__),run=lambda self,p: (self.__dict__.update(dict(i=0,p=p)),wh(lambda: self.i<len(p),self.tick))[0],tick=lambda self: ({"+":self.add,"-":self.sub,"<":self.left,">":self.right}[self.p[self.i]](),eval("locals().__setitem__('i',i+1)",self.globals,self.__dict__))[0])))(newmodule(),globals())
| 47.534884
| 878
| 0.682485
| 337
| 2,044
| 3.824926
| 0.172107
| 0.080683
| 0.128006
| 0.162141
| 0.511249
| 0.465477
| 0.465477
| 0.465477
| 0.465477
| 0.465477
| 0
| 0.012215
| 0.078767
| 2,044
| 42
| 879
| 48.666667
| 0.672331
| 0
| 0
| 0
| 0
| 0
| 0.204012
| 0.172701
| 0.027778
| 0
| 0
| 0
| 0
| 1
| 0.305556
| false
| 0
| 0.083333
| 0.166667
| 0.638889
| 0.055556
| 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
| 0
| 0
| 1
| 1
| 0
|
0
| 4
|
0ff2b8d4b1464c2a121865dfaf3769de5e32ff5e
| 37
|
py
|
Python
|
src/internal_api/v1/__init__.py
|
hvuhsg/OpenAPIGateway
|
76413c69e2f35a2febf899f161ddc4da4b0ea354
|
[
"MIT"
] | 1
|
2022-01-29T17:50:38.000Z
|
2022-01-29T17:50:38.000Z
|
src/internal_api/v1/__init__.py
|
hvuhsg/OpenAPIGateway
|
76413c69e2f35a2febf899f161ddc4da4b0ea354
|
[
"MIT"
] | null | null | null |
src/internal_api/v1/__init__.py
|
hvuhsg/OpenAPIGateway
|
76413c69e2f35a2febf899f161ddc4da4b0ea354
|
[
"MIT"
] | null | null | null |
from .v1 import v1
__all__ = ["v1"]
| 9.25
| 18
| 0.621622
| 6
| 37
| 3.166667
| 0.666667
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.103448
| 0.216216
| 37
| 3
| 19
| 12.333333
| 0.551724
| 0
| 0
| 0
| 0
| 0
| 0.054054
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.5
| 0
| 0.5
| 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
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
|
0
| 4
|
ba06c030d9ecf7761ad0a90684cb772000561a09
| 151
|
py
|
Python
|
lib/test/vot20/stark_st50_lt.py
|
tzhhhh123/Stark
|
eaf7df3baf27ac064938f831211ae64659bc6808
|
[
"MIT"
] | 376
|
2021-03-27T12:29:17.000Z
|
2022-03-29T01:22:15.000Z
|
lib/test/vot20/stark_st50_lt.py
|
wp8733684/Stark
|
ba59f9596b06bc687d726f991e1e7fce8af6b5a5
|
[
"MIT"
] | 75
|
2021-03-31T12:44:45.000Z
|
2022-03-28T09:02:57.000Z
|
lib/test/vot20/stark_st50_lt.py
|
wp8733684/Stark
|
ba59f9596b06bc687d726f991e1e7fce8af6b5a5
|
[
"MIT"
] | 82
|
2021-03-26T10:07:57.000Z
|
2022-03-29T11:08:27.000Z
|
from lib.test.vot20.stark_vot20lt import run_vot_exp
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '6'
run_vot_exp('stark_st', 'baseline', vis=False)
| 30.2
| 52
| 0.788079
| 26
| 151
| 4.269231
| 0.769231
| 0.108108
| 0.162162
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.035971
| 0.07947
| 151
| 4
| 53
| 37.75
| 0.76259
| 0
| 0
| 0
| 0
| 0
| 0.245033
| 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
|
ba0ad95385f821e6b19ef33e9e83dc825873cae7
| 137
|
py
|
Python
|
ehmatthes-pcc_2e-078318e/beyond_pcc/chess_game/settings.py
|
charliechocho/py-crash-course
|
b42b8a4c1cb8d76e8316f55c1565ff42d920ee63
|
[
"Apache-2.0"
] | 12
|
2020-10-22T14:03:27.000Z
|
2022-03-28T08:14:22.000Z
|
ehmatthes-pcc_2e-078318e/beyond_pcc/chess_game/settings.py
|
charliechocho/py-crash-course
|
b42b8a4c1cb8d76e8316f55c1565ff42d920ee63
|
[
"Apache-2.0"
] | null | null | null |
ehmatthes-pcc_2e-078318e/beyond_pcc/chess_game/settings.py
|
charliechocho/py-crash-course
|
b42b8a4c1cb8d76e8316f55c1565ff42d920ee63
|
[
"Apache-2.0"
] | 9
|
2020-12-22T10:22:12.000Z
|
2022-03-28T08:14:53.000Z
|
class Settings:
def __init__(self):
self.screen_width, self.screen_height = 800, 300
self.bg_color = (225, 225, 225)
| 27.4
| 56
| 0.642336
| 19
| 137
| 4.263158
| 0.684211
| 0.246914
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.145631
| 0.248175
| 137
| 5
| 57
| 27.4
| 0.640777
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0
| 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
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
ba2e645b37b60d7b52958ab04d4411563d3151fc
| 97
|
py
|
Python
|
backend/instruments/apps.py
|
codepanda64/logs-and-metas-for-stations
|
c2fca7b149eaea25b4df45e6cb4af01cc8ad7204
|
[
"Apache-2.0"
] | null | null | null |
backend/instruments/apps.py
|
codepanda64/logs-and-metas-for-stations
|
c2fca7b149eaea25b4df45e6cb4af01cc8ad7204
|
[
"Apache-2.0"
] | null | null | null |
backend/instruments/apps.py
|
codepanda64/logs-and-metas-for-stations
|
c2fca7b149eaea25b4df45e6cb4af01cc8ad7204
|
[
"Apache-2.0"
] | null | null | null |
from django.apps import AppConfig
class InstrumentsConfig(AppConfig):
name = 'instruments'
| 16.166667
| 35
| 0.773196
| 10
| 97
| 7.5
| 0.9
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.154639
| 97
| 5
| 36
| 19.4
| 0.914634
| 0
| 0
| 0
| 0
| 0
| 0.113402
| 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
|
e84840babcba7ce0494e2d3b2cc9cac26d71a4f6
| 209
|
py
|
Python
|
dxtorchutils/utils/__init__.py
|
Ian-Dx/DxTorchUtils
|
af1d522f58f1b7baed8f661757dd45c13343ddcd
|
[
"MIT"
] | 4
|
2020-12-14T15:35:11.000Z
|
2021-05-26T07:16:10.000Z
|
build/lib/dxtorchutils/utils/__init__.py
|
Ian-Dx/DxTorchUtils
|
af1d522f58f1b7baed8f661757dd45c13343ddcd
|
[
"MIT"
] | null | null | null |
build/lib/dxtorchutils/utils/__init__.py
|
Ian-Dx/DxTorchUtils
|
af1d522f58f1b7baed8f661757dd45c13343ddcd
|
[
"MIT"
] | null | null | null |
__all__ = ["train", "utils", "optimizers", "metrics", "layers", "blocks", "losses", "info_logger"]
from .train import *
from .utils import *
from .metrics import *
from .layers import *
from .blocks import *
| 26.125
| 98
| 0.679426
| 25
| 209
| 5.48
| 0.48
| 0.291971
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.148325
| 209
| 7
| 99
| 29.857143
| 0.769663
| 0
| 0
| 0
| 0
| 0
| 0.267943
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.833333
| 0
| 0.833333
| 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
|
e88748f3d293f443b08796c40bcfa41178207f00
| 435
|
py
|
Python
|
samples/django/echo/views.py
|
potykion/drel
|
d19033654b1bd1bf51a8965c49342e7ba919a49e
|
[
"MIT"
] | 1
|
2018-12-21T16:59:40.000Z
|
2018-12-21T16:59:40.000Z
|
samples/django/echo/views.py
|
potykion/drel
|
d19033654b1bd1bf51a8965c49342e7ba919a49e
|
[
"MIT"
] | null | null | null |
samples/django/echo/views.py
|
potykion/drel
|
d19033654b1bd1bf51a8965c49342e7ba919a49e
|
[
"MIT"
] | null | null | null |
from django.http import HttpResponse, HttpRequest, JsonResponse
from rest_framework.decorators import api_view
from rest_framework.request import Request
@api_view(["POST"])
def success_view(request: Request) -> HttpResponse:
return JsonResponse({"status": "success", "body": request.data.get("field")})
def server_error_view(request: HttpRequest) -> HttpResponse:
return HttpResponse("Internal server error.", status=500)
| 33.461538
| 81
| 0.777011
| 52
| 435
| 6.365385
| 0.5
| 0.048338
| 0.102719
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.007732
| 0.108046
| 435
| 12
| 82
| 36.25
| 0.845361
| 0
| 0
| 0
| 0
| 0
| 0.110345
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.25
| false
| 0
| 0.375
| 0.25
| 0.875
| 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
| 0
| 1
| 1
| 1
| 0
|
0
| 4
|
e8915c7ad323f66418bcd7c0379e593253f92bb2
| 133
|
py
|
Python
|
scripts/npc/shammos2.py
|
G00dBye/YYMS
|
1de816fc842b6598d5b4b7896b6ab0ee8f7cdcfb
|
[
"MIT"
] | 54
|
2019-04-16T23:24:48.000Z
|
2021-12-18T11:41:50.000Z
|
scripts/npc/shammos2.py
|
G00dBye/YYMS
|
1de816fc842b6598d5b4b7896b6ab0ee8f7cdcfb
|
[
"MIT"
] | 3
|
2019-05-19T15:19:41.000Z
|
2020-04-27T16:29:16.000Z
|
scripts/npc/shammos2.py
|
G00dBye/YYMS
|
1de816fc842b6598d5b4b7896b6ab0ee8f7cdcfb
|
[
"MIT"
] | 49
|
2020-11-25T23:29:16.000Z
|
2022-03-26T16:20:24.000Z
|
# Message from Shammos (2022006) | Shammos PQ
sm.sendNext("Haha! FOOLS! I have betrayed you and have unsealed Rex, the Hoblin King!")
| 66.5
| 87
| 0.75188
| 21
| 133
| 4.761905
| 0.904762
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.061947
| 0.150376
| 133
| 2
| 87
| 66.5
| 0.823009
| 0.323308
| 0
| 0
| 0
| 0
| 0.808989
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| true
| 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
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
e8bc0c3f111cc2a107ee919475e05e40fa86bc70
| 136
|
py
|
Python
|
imagepy/menus/Image/Lookup table/Others/lookuptables_plg.py
|
Pad0y/imagepy
|
23f41b64ade02f94b566b0d23a4b6459c1a1578d
|
[
"BSD-4-Clause"
] | null | null | null |
imagepy/menus/Image/Lookup table/Others/lookuptables_plg.py
|
Pad0y/imagepy
|
23f41b64ade02f94b566b0d23a4b6459c1a1578d
|
[
"BSD-4-Clause"
] | null | null | null |
imagepy/menus/Image/Lookup table/Others/lookuptables_plg.py
|
Pad0y/imagepy
|
23f41b64ade02f94b566b0d23a4b6459c1a1578d
|
[
"BSD-4-Clause"
] | null | null | null |
from ..lookuptables_plg import LUT
from imagepy.app import ColorManager
plgs = [LUT(i, j) for i, j, _ in ColorManager.gets(tag="adv")]
| 27.2
| 62
| 0.735294
| 22
| 136
| 4.454545
| 0.727273
| 0.040816
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.139706
| 136
| 4
| 63
| 34
| 0.837607
| 0
| 0
| 0
| 0
| 0
| 0.022059
| 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
|
e8c1887de428a5e7a25c1230fdc3b4945fd8d3b3
| 91
|
py
|
Python
|
fasttask/apps.py
|
huanjoyous/FasterRunner20190716
|
1702c7afd9548769bc1e7ed4fc04e0321659a89b
|
[
"MIT"
] | 2
|
2021-05-07T06:58:16.000Z
|
2021-11-06T07:49:56.000Z
|
fasttask/apps.py
|
huanjoyous/FasterRunner20190716
|
1702c7afd9548769bc1e7ed4fc04e0321659a89b
|
[
"MIT"
] | 2
|
2020-02-11T23:38:06.000Z
|
2020-07-31T10:18:35.000Z
|
fasttask/apps.py
|
huanjoyous/FasterRunner20190716
|
1702c7afd9548769bc1e7ed4fc04e0321659a89b
|
[
"MIT"
] | 1
|
2019-07-04T12:47:28.000Z
|
2019-07-04T12:47:28.000Z
|
from django.apps import AppConfig
class FasttaskConfig(AppConfig):
name = 'fasttask'
| 15.166667
| 33
| 0.758242
| 10
| 91
| 6.9
| 0.9
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.164835
| 91
| 5
| 34
| 18.2
| 0.907895
| 0
| 0
| 0
| 0
| 0
| 0.087912
| 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
|
e8c9f522d511af7ccdc119a49cb745229b0f6a72
| 7,404
|
py
|
Python
|
bindings/python/test/time/test_time.py
|
robinpdm/open-space-toolkit-physics
|
b53e5d4287fa6568d700cb8942c9a56d57b8d7cf
|
[
"Apache-2.0"
] | 7
|
2020-03-30T11:51:11.000Z
|
2022-02-02T15:20:44.000Z
|
bindings/python/test/time/test_time.py
|
robinpdm/open-space-toolkit-physics
|
b53e5d4287fa6568d700cb8942c9a56d57b8d7cf
|
[
"Apache-2.0"
] | 24
|
2018-06-25T08:06:39.000Z
|
2020-01-05T20:34:02.000Z
|
bindings/python/test/time/test_time.py
|
robinpdm/open-space-toolkit-physics
|
b53e5d4287fa6568d700cb8942c9a56d57b8d7cf
|
[
"Apache-2.0"
] | 3
|
2020-03-05T18:18:38.000Z
|
2020-07-02T05:06:53.000Z
|
################################################################################################################################################################
# @project Open Space Toolkit ▸ Physics
# @file bindings/python/test/time/test_time.py
# @author Lucas Brémond <lucas@loftorbital.com>
# @license Apache License 2.0
################################################################################################################################################################
import pytest
from ostk.core.types import String
from ostk.physics.time import Time
################################################################################################################################################################
def test_time_constructors ():
assert Time(0, 0, 0) is not None
################################################################################################################################################################
def test_time_undefined ():
assert Time.undefined() is not None
################################################################################################################################################################
def test_time_midnight ():
assert Time.midnight() is not None
################################################################################################################################################################
def test_time_noon ():
assert Time.noon() is not None
################################################################################################################################################################
def test_time_parse ():
## Using python strings
# Testing with default format argument (Time::Format::Undefined)
time: Time = Time.parse('00:00:00')
assert time is not None
assert isinstance(time, Time)
assert time.is_defined()
# Testing with Time.Format.Standard
time: Time = Time.parse('00:00:00', Time.Format.Standard)
assert time is not None
assert isinstance(time, Time)
assert time.is_defined()
# Testing with Time.Format.ISO8601
time: Time = Time.parse('00:00:00', Time.Format.ISO8601)
assert time is not None
assert isinstance(time, Time)
assert time.is_defined()
## Using String class
# Testing with default format argument (Time::Format::Undefined)
time: Time = Time.parse(String('00:00:00'))
assert time is not None
assert isinstance(time, Time)
assert time.is_defined()
# Testing with Time.Format.Standard
time: Time = Time.parse(String('00:00:00'), Time.Format.Standard)
assert time is not None
assert isinstance(time, Time)
assert time.is_defined()
# Testing with Time.Format.ISO8601
time: Time = Time.parse(String('00:00:00'), Time.Format.ISO8601)
assert time is not None
assert isinstance(time, Time)
assert time.is_defined()
################################################################################################################################################################
def test_time_operators ():
time = Time(0, 0, 0)
assert (time == time) is not None
assert (time != time) is not None
################################################################################################################################################################
def test_time_is_defined ():
time = Time(0, 0, 0)
assert time.is_defined() is not None
################################################################################################################################################################
def test_time_get_hour ():
time = Time(0, 0, 0)
assert time.get_hour() is not None
################################################################################################################################################################
def test_time_get_minute ():
time = Time(0, 0, 0)
assert time.get_minute() is not None
################################################################################################################################################################
def test_time_get_second ():
time = Time(0, 0, 0)
assert time.get_second() is not None
################################################################################################################################################################
def test_time_get_millisecond ():
time = Time(0, 0, 0)
assert time.get_millisecond() is not None
################################################################################################################################################################
def test_time_get_microsecond ():
time = Time(0, 0, 0)
assert time.get_microsecond() is not None
################################################################################################################################################################
def test_time_get_nanosecond ():
time = Time(0, 0, 0)
assert time.get_nanosecond() is not None
################################################################################################################################################################
def test_time_get_floating_seconds ():
time = Time(0, 0, 0)
assert time.get_floating_seconds() is not None
################################################################################################################################################################
def test_time_to_string ():
time = Time(0, 0, 0)
assert time.to_string() is not None
assert time.to_string(Time.Format.Standard) is not None
assert time.to_string(Time.Format.ISO8601) is not None
################################################################################################################################################################
def test_time_set_hour ():
time = Time(0, 0, 0)
time.set_hour(1)
################################################################################################################################################################
def test_time_set_minute ():
time = Time(0, 0, 0)
time.set_minute(1)
################################################################################################################################################################
def test_time_set_second ():
time = Time(0, 0, 0)
time.set_second(1)
################################################################################################################################################################
def test_time_set_millisecond ():
time = Time(0, 0, 0)
time.set_millisecond(1)
################################################################################################################################################################
def test_time_set_microsecond ():
time = Time(0, 0, 0)
time.set_microsecond(1)
################################################################################################################################################################
def test_time_set_nanosecond ():
time = Time(0, 0, 0)
time.set_nanosecond(1)
################################################################################################################################################################
| 33.351351
| 160
| 0.317396
| 542
| 7,404
| 4.184502
| 0.118081
| 0.126984
| 0.09127
| 0.052469
| 0.761023
| 0.727954
| 0.611993
| 0.465608
| 0.388889
| 0.356261
| 0
| 0.017504
| 0.112642
| 7,404
| 221
| 161
| 33.502262
| 0.327549
| 0.06591
| 0
| 0.390805
| 0
| 0
| 0.015681
| 0
| 0
| 0
| 0
| 0
| 0.402299
| 1
| 0.241379
| false
| 0
| 0.034483
| 0
| 0.275862
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 1
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
2cddcf9c2df6ea64aa9f49645ac9ad58d8061477
| 3,592
|
py
|
Python
|
footy/domain/Result.py
|
dallinb/footy
|
d6879481a85b4a84023805bf29bd7dff32afa67f
|
[
"BSD-3-Clause"
] | 2
|
2020-08-27T17:59:13.000Z
|
2021-10-10T02:26:20.000Z
|
footy/domain/Result.py
|
FootyStats/footy
|
d6879481a85b4a84023805bf29bd7dff32afa67f
|
[
"BSD-3-Clause"
] | 32
|
2020-08-24T15:01:57.000Z
|
2022-03-12T00:47:02.000Z
|
footy/domain/Result.py
|
dallinb/footy
|
d6879481a85b4a84023805bf29bd7dff32afa67f
|
[
"BSD-3-Clause"
] | null | null | null |
"""Result - Data structure for a result."""
# Is prediction before game is played, then actual once game ahs been played
# Return the outcome Briers score, home/away goals scored, Predictions if available, and actual
# result if game has been played
class Result:
"""Result - Data structure for a result."""
def __init__(self, status='SCHEDULED', home_team_goals_scored=0, away_team_goals_scored=0):
"""
Construct a Result object.
Parameters
----------
status : str, optional
The status of the result of the result. SCHEDULED or FINISHED. Defaults to SCHEDULED
home_team_goals_scored : int, optional
The number of goals scored by the home team. Defaults to 0.
away_team_goals_scored : int, optional
The number of goals scored by the away team. Defaults to 0.
"""
self._status = status # TODO: Can we use an enum?
self._home_team_goals_scored = home_team_goals_scored
self._away_team_goals_scored = away_team_goals_scored
def __eq__(self, other):
"""
Override the __eq__ method for the Result class to allow for object value comparison.
Parameters
----------
other : footy.domain.Result.Result
The result object to compare to.
Returns
-------
bool
True/False if the values in the two objects are equal.
"""
return (
self.__class__ == other.__class__ and
self._status == other._status and
self._home_team_goals_scored == other._home_team_goals_scored and
self._away_team_goals_scored == other._away_team_goals_scored
)
@property
def status(self):
"""
Getter method for property status.
Returns
-------
str
The value of property status.
"""
return self._status
@status.setter
def status(self, status):
"""
Getter method for property status.
Parameters
----------
status : str
The value you wish to set the status property to.
"""
self._status = status
@property
def home_team_goals_scored(self):
"""
Getter method for property home_team_goals_scored.
Returns
-------
int
The value of property home_team_goals_scored.
"""
return self._home_team_goals_scored
@home_team_goals_scored.setter
def home_team_goals_scored(self, home_team_goals_scored):
"""
Getter method for property home_team_goals_scored.
Parameters
----------
home_team_goals_scored : int
The value you wish to set the home_team_goals_scored property to.
"""
self._home_team_goals_scored = home_team_goals_scored
@property
def away_team_goals_scored(self):
"""
Getter method for property away_team_goals_scored.
Returns
-------
int
The value of property away_team_goals_scored.
"""
return self._away_team_goals_scored
@away_team_goals_scored.setter
def away_team_goals_scored(self, away_team_goals_scored):
"""
Getter method for property away_team_goals_scored.
Parameters
----------
away_team_goals_scored : int
The value you wish to set the away_team_goals_scored property to.
"""
self._away_team_goals_scored = away_team_goals_scored
| 30.184874
| 96
| 0.609967
| 432
| 3,592
| 4.740741
| 0.189815
| 0.209473
| 0.263672
| 0.166992
| 0.599121
| 0.455566
| 0.379883
| 0.361328
| 0.256836
| 0.091797
| 0
| 0.001627
| 0.315423
| 3,592
| 118
| 97
| 30.440678
| 0.831232
| 0.483575
| 0
| 0.3
| 0
| 0
| 0.006731
| 0
| 0
| 0
| 0
| 0.008475
| 0
| 1
| 0.266667
| false
| 0
| 0
| 0
| 0.433333
| 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
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
2cde45ab9cc8837898e8a0114856bf050e1d4382
| 175
|
py
|
Python
|
core/apps.py
|
techacademypython/hackaton_amada
|
407726b26296c842be2c0962c34994878e41868c
|
[
"MIT"
] | null | null | null |
core/apps.py
|
techacademypython/hackaton_amada
|
407726b26296c842be2c0962c34994878e41868c
|
[
"MIT"
] | null | null | null |
core/apps.py
|
techacademypython/hackaton_amada
|
407726b26296c842be2c0962c34994878e41868c
|
[
"MIT"
] | null | null | null |
from django.apps import AppConfig
class CoreConfig(AppConfig):
name = 'core'
def ready(self):
from mqtt.mqtt_file import client
client.loop_start()
| 17.5
| 41
| 0.674286
| 22
| 175
| 5.272727
| 0.772727
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.245714
| 175
| 9
| 42
| 19.444444
| 0.878788
| 0
| 0
| 0
| 0
| 0
| 0.022857
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.166667
| false
| 0
| 0.333333
| 0
| 0.833333
| 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
|
2cf5a05fd5d744d717f189e6462876e36c6bdacf
| 423
|
py
|
Python
|
tests/test_models.py
|
mishbahr/djangocms-responsive-wrapper
|
d12c1d6830fab204f812b00de3be46e14c101a5d
|
[
"BSD-3-Clause"
] | 18
|
2015-01-01T17:43:55.000Z
|
2018-04-21T17:44:09.000Z
|
tests/test_models.py
|
mishbahr/djangocms-responsive-wrapper
|
d12c1d6830fab204f812b00de3be46e14c101a5d
|
[
"BSD-3-Clause"
] | null | null | null |
tests/test_models.py
|
mishbahr/djangocms-responsive-wrapper
|
d12c1d6830fab204f812b00de3be46e14c101a5d
|
[
"BSD-3-Clause"
] | null | null | null |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_djangocms-responsive-wrapper
------------
Tests for `djangocms-responsive-wrapper` models module.
"""
from django.conf import settings
from django.test import TestCase
from responsive_wrapper import models
class TestResponsive_wrapper(TestCase):
def setUp(self):
pass
def test_something(self):
pass
def tearDown(self):
pass
| 16.269231
| 55
| 0.678487
| 50
| 423
| 5.66
| 0.58
| 0.180212
| 0.183746
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.002941
| 0.196217
| 423
| 26
| 56
| 16.269231
| 0.829412
| 0.345154
| 0
| 0.3
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.3
| false
| 0.3
| 0.3
| 0
| 0.7
| 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
| 1
| 0
| 0
| 1
| 0
|
0
| 4
|
2cf685e058c00fbe4dcaab5552d5864cfd20b879
| 63
|
py
|
Python
|
backend/moderation/__init__.py
|
ranwise/djangochannel
|
9c719d292b5c1d0fd008a16a64509a309bdd642e
|
[
"BSD-3-Clause"
] | 45
|
2019-10-04T10:12:54.000Z
|
2022-03-29T18:12:34.000Z
|
backend/moderation/__init__.py
|
ranwise/djangochannel
|
9c719d292b5c1d0fd008a16a64509a309bdd642e
|
[
"BSD-3-Clause"
] | 6
|
2019-10-09T07:37:14.000Z
|
2022-01-27T16:41:16.000Z
|
backend/moderation/__init__.py
|
ranwise/djangochannel
|
9c719d292b5c1d0fd008a16a64509a309bdd642e
|
[
"BSD-3-Clause"
] | 35
|
2019-10-04T10:18:48.000Z
|
2022-01-14T22:40:38.000Z
|
default_app_config = "backend.moderation.apps.ModerationConfig"
| 63
| 63
| 0.873016
| 7
| 63
| 7.571429
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.031746
| 63
| 1
| 63
| 63
| 0.868852
| 0
| 0
| 0
| 0
| 0
| 0.625
| 0.625
| 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
|
fa14e7f5897b9b0717744dcd31075cf946191d43
| 51
|
py
|
Python
|
crabageprediction/venv/Lib/site-packages/mpl_toolkits/axes_grid/angle_helper.py
|
13rianlucero/CrabAgePrediction
|
92bc7fbe1040f49e820473e33cc3902a5a7177c7
|
[
"MIT"
] | 603
|
2020-12-23T13:49:32.000Z
|
2022-03-31T23:38:03.000Z
|
venv/lib/python3.7/site-packages/mpl_toolkits/axes_grid/angle_helper.py
|
John1001Song/Big-Data-Robo-Adviser
|
9444dce96954c546333d5aecc92a06c3bfd19aa5
|
[
"MIT"
] | 387
|
2020-12-15T14:54:04.000Z
|
2022-03-31T07:00:21.000Z
|
venv/lib/python3.7/site-packages/mpl_toolkits/axes_grid/angle_helper.py
|
John1001Song/Big-Data-Robo-Adviser
|
9444dce96954c546333d5aecc92a06c3bfd19aa5
|
[
"MIT"
] | 64
|
2018-04-25T08:51:57.000Z
|
2022-01-29T14:13:57.000Z
|
from mpl_toolkits.axisartist.angle_helper import *
| 25.5
| 50
| 0.862745
| 7
| 51
| 6
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.078431
| 51
| 1
| 51
| 51
| 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
|
fa1bb9549ad6de849cde791f46c839fe51734529
| 1,272
|
py
|
Python
|
tests/load/test_load_case.py
|
mhkc/scout
|
a7162f28c0f3490c3f3376268118fa8e6072a9db
|
[
"BSD-3-Clause"
] | 111
|
2015-01-15T11:53:20.000Z
|
2022-03-26T19:55:24.000Z
|
tests/load/test_load_case.py
|
mhkc/scout
|
a7162f28c0f3490c3f3376268118fa8e6072a9db
|
[
"BSD-3-Clause"
] | 2,995
|
2015-01-15T16:14:20.000Z
|
2022-03-31T13:36:32.000Z
|
tests/load/test_load_case.py
|
mhkc/scout
|
a7162f28c0f3490c3f3376268118fa8e6072a9db
|
[
"BSD-3-Clause"
] | 55
|
2015-05-31T19:09:49.000Z
|
2021-11-01T10:50:31.000Z
|
def test_load_case(case_obj, adapter):
## GIVEN a database with no cases
assert adapter.case_collection.find_one() is None
## WHEN loading a case
adapter._add_case(case_obj)
## THEN assert that the case have been loaded with correct info
assert adapter.case_collection.find_one()
def test_load_case_rank_model_version(case_obj, adapter):
## GIVEN a database with no cases
assert adapter.case_collection.find_one() is None
## WHEN loading a case
adapter._add_case(case_obj)
## THEN assert that the case have been loaded with rank_model
loaded_case = adapter.case_collection.find_one({"_id": case_obj["_id"]})
assert loaded_case["rank_model_version"] == case_obj["rank_model_version"]
assert loaded_case["sv_rank_model_version"] == case_obj["sv_rank_model_version"]
def test_load_case_limsid(case_obj, adapter):
"""Test loading a case with lims_id"""
## GIVEN a database with no cases
assert adapter.case_collection.find_one() is None
## WHEN loading a case
adapter._add_case(case_obj)
## THEN assert that the case have been loaded with lims id
loaded_case = adapter.case_collection.find_one({"_id": case_obj["_id"]})
assert loaded_case["lims_id"] == case_obj["lims_id"]
| 31.02439
| 84
| 0.728774
| 195
| 1,272
| 4.435897
| 0.184615
| 0.089017
| 0.145665
| 0.17341
| 0.787283
| 0.760694
| 0.671676
| 0.671676
| 0.671676
| 0.671676
| 0
| 0
| 0.177673
| 1,272
| 40
| 85
| 31.8
| 0.82696
| 0.284591
| 0
| 0.533333
| 0
| 0
| 0.117249
| 0.047351
| 0
| 0
| 0
| 0
| 0.466667
| 1
| 0.2
| false
| 0
| 0
| 0
| 0.2
| 0
| 0
| 0
| 0
| null | 0
| 0
| 1
| 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
| 1
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
fa3386171405ac0ad3704cea6b057acc4f2dfa2b
| 1,126
|
py
|
Python
|
cngi/vis/ddijoin.py
|
wxiongccnu1990/cngi_prototype
|
7a7230485acc9f8f2be534a832522339153d521e
|
[
"Apache-2.0"
] | null | null | null |
cngi/vis/ddijoin.py
|
wxiongccnu1990/cngi_prototype
|
7a7230485acc9f8f2be534a832522339153d521e
|
[
"Apache-2.0"
] | null | null | null |
cngi/vis/ddijoin.py
|
wxiongccnu1990/cngi_prototype
|
7a7230485acc9f8f2be534a832522339153d521e
|
[
"Apache-2.0"
] | null | null | null |
# Copyright 2019 AUI, Inc. Washington DC, USA
#
# 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.
########################
def ddijoin(xds1, xds2):
"""
.. todo::
This function is not yet implemented
Concatenate together two Visibility Datasets of compatible shape
Parameters
----------
xds1 : xarray.core.dataset.Dataset
first Visibility Dataset to join
xds2 : xarray.core.dataset.Dataset
second Visibility Dataset to join
Returns
-------
xarray.core.dataset.Dataset
New Visibility Dataset with combined contents
"""
return {}
| 30.432432
| 76
| 0.674956
| 145
| 1,126
| 5.241379
| 0.641379
| 0.078947
| 0.067105
| 0.094737
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.013825
| 0.22913
| 1,126
| 36
| 77
| 31.277778
| 0.861751
| 0.857904
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.027778
| 0
| 1
| 0.5
| false
| 0
| 0
| 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
| 1
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
fa59227269fda3e5057637124e05fefe7f6da527
| 1,312
|
py
|
Python
|
TopQuarkAnalysis/TopEventProducers/python/sequences/ttSemiLepEvtHypotheses_cff.py
|
ckamtsikis/cmssw
|
ea19fe642bb7537cbf58451dcf73aa5fd1b66250
|
[
"Apache-2.0"
] | 852
|
2015-01-11T21:03:51.000Z
|
2022-03-25T21:14:00.000Z
|
TopQuarkAnalysis/TopEventProducers/python/sequences/ttSemiLepEvtHypotheses_cff.py
|
ckamtsikis/cmssw
|
ea19fe642bb7537cbf58451dcf73aa5fd1b66250
|
[
"Apache-2.0"
] | 30,371
|
2015-01-02T00:14:40.000Z
|
2022-03-31T23:26:05.000Z
|
TopQuarkAnalysis/TopEventProducers/python/sequences/ttSemiLepEvtHypotheses_cff.py
|
ckamtsikis/cmssw
|
ea19fe642bb7537cbf58451dcf73aa5fd1b66250
|
[
"Apache-2.0"
] | 3,240
|
2015-01-02T05:53:18.000Z
|
2022-03-31T17:24:21.000Z
|
import FWCore.ParameterSet.Config as cms
#
# produce ttSemiLep event hypotheses
#
## geom hypothesis
from TopQuarkAnalysis.TopJetCombination.TtSemiLepHypGeom_cff import *
## wMassDeltaTopMass hypothesis
from TopQuarkAnalysis.TopJetCombination.TtSemiLepHypWMassDeltaTopMass_cff import *
## wMassMaxSumPt hypothesis
from TopQuarkAnalysis.TopJetCombination.TtSemiLepHypWMassMaxSumPt_cff import *
## maxSumPtWMass hypothesis
from TopQuarkAnalysis.TopJetCombination.TtSemiLepHypMaxSumPtWMass_cff import *
## genMatch hypothesis
from TopQuarkAnalysis.TopJetCombination.TtSemiLepHypGenMatch_cff import *
## mvaDisc hypothesis
from TopQuarkAnalysis.TopJetCombination.TtSemiLepHypMVADisc_cff import *
## kinFit hypothesis
from TopQuarkAnalysis.TopJetCombination.TtSemiLepHypKinFit_cff import *
## hitFit hypothesis
from TopQuarkAnalysis.TopJetCombination.TtSemiLepHypHitFit_cff import *
## make all considered event hypotheses
makeTtSemiLepHypothesesTask = cms.Task(
makeHypothesis_geomTask,
makeHypothesis_wMassDeltaTopMassTask,
makeHypothesis_wMassMaxSumPtTask,
makeHypothesis_maxSumPtWMassTask,
makeHypothesis_genMatchTask,
makeHypothesis_mvaDiscTask,
makeHypothesis_kinFitTask,
makeHypothesis_hitFitTask
)
makeTtSemiLepHypotheses = cms.Sequence(makeTtSemiLepHypothesesTask)
| 30.511628
| 82
| 0.852896
| 102
| 1,312
| 10.813725
| 0.460784
| 0.101541
| 0.217588
| 0.340888
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.099848
| 1,312
| 42
| 83
| 31.238095
| 0.933954
| 0.183689
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.45
| 0
| 0.45
| 0
| 0
| 0
| 1
| 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
| 1
| 0
| 0
| 0
|
0
| 4
|
d703bccc4b9a54b81a135ef537232beef8457c0b
| 42,137
|
py
|
Python
|
swamp/search/tests/test_searchtarget.py
|
rigdenlab/SWAMP
|
3e93ab27f4acf0124f7cb2d78a151cc3352b9c6e
|
[
"BSD-3-Clause"
] | 2
|
2020-02-15T11:06:34.000Z
|
2020-04-10T08:48:49.000Z
|
swamp/search/tests/test_searchtarget.py
|
rigdenlab/SWAMP
|
3e93ab27f4acf0124f7cb2d78a151cc3352b9c6e
|
[
"BSD-3-Clause"
] | 15
|
2020-02-04T10:56:07.000Z
|
2021-02-12T09:11:03.000Z
|
swamp/search/tests/test_searchtarget.py
|
rigdenlab/SWAMP
|
3e93ab27f4acf0124f7cb2d78a151cc3352b9c6e
|
[
"BSD-3-Clause"
] | 4
|
2020-02-04T13:25:09.000Z
|
2022-03-23T13:44:17.000Z
|
import os
import swamp
import unittest
import joblib
from operator import itemgetter
from swamp.utils import remove, create_tempfile
from swamp.search.searchtarget import SearchTarget
TOPCONS_DUMY = """TOPCONS predicted topology:
iiiiiiiiiiiiiiMMMMMMMMMMMMMMMMMMMMMooooooMMMMMMMMMMMMMMMMMMMMMiiiiiiiiiiMMMMMMMMMMMMMMMMMMMMMooooooMMMMMMMMMMMMMMMMMMMMMiiiiiiiiiiiMMMMMMMMMMMMMMMMMMMMMoooooooooooMMMMMMMMMMMMMMMMMMMMMiiiiiiiiiiiiiiMMMMMMMMMMMMMMMMMMMMMoooooooMMMMMMMMMMMMMMMMMMMMMiiiiiiiiiiiiiiiiiiiiiiMMMMMMMMMMMMMMMMMMMMMoMMMMMMMMMMMMMMMMMMMMMiiiiiiiiiiiiiiiiiiii
"""
PDB_DUMY = """CRYST1 73.330 73.330 163.520 90.00 90.00 90.00 P 41 2 2 8
REMARK 465
REMARK 465 MISSING RESIDUES
REMARK 465 THE FOLLOWING RESIDUES WERE NOT LOCATED IN THE
REMARK 465 EXPERIMENT. (M=MODEL NUMBER; RES=RESIDUE NAME; C=CHAIN
REMARK 465 IDENTIFIER; SSSEQ=SEQUENCE NUMBER; I=INSERTION CODE.)
REMARK 465
REMARK 465 M RES C SSSEQI
REMARK 465 MET A -4
REMARK 465 VAL A -3
REMARK 465 ALA A -2
REMARK 465 ALA A -1
REMARK 465 SER A 0
REMARK 465 MET A 1
REMARK 465 GLY A 98
REMARK 465 LYS A 99
REMARK 465 HIS A 212
REMARK 465 LYS A 215
ATOM 760 N VAL A 100 17.668 61.385 96.142 1.00 36.12 N
ANISOU 760 N VAL A 100 4189 5832 3703 370 -20 96 N
ATOM 761 CA VAL A 100 16.510 62.175 95.720 1.00 34.76 C
ANISOU 761 CA VAL A 100 3981 5676 3550 300 62 84 C
ATOM 762 C VAL A 100 16.924 63.214 94.641 1.00 39.15 C
ANISOU 762 C VAL A 100 4461 6274 4139 307 77 -9 C
ATOM 763 O VAL A 100 16.205 63.379 93.656 1.00 38.11 O
ANISOU 763 O VAL A 100 4288 6134 4059 275 108 -15 O
ATOM 764 CB VAL A 100 15.715 62.769 96.916 1.00 37.75 C
ANISOU 764 CB VAL A 100 4379 6111 3852 257 129 130 C
ATOM 765 CG1 VAL A 100 14.623 63.727 96.450 1.00 36.89 C
ANISOU 765 CG1 VAL A 100 4216 6025 3776 215 217 110 C
ATOM 766 CG2 VAL A 100 15.112 61.661 97.786 1.00 38.05 C
ANISOU 766 CG2 VAL A 100 4485 6113 3858 228 124 244 C
ATOM 767 N GLY A 101 18.105 63.825 94.809 1.00 36.09 N
ANISOU 767 N GLY A 101 4052 5944 3718 343 50 -70 N
ATOM 768 CA GLY A 101 18.670 64.791 93.867 1.00 34.68 C
ANISOU 768 CA GLY A 101 3805 5805 3566 340 63 -145 C
ATOM 769 C GLY A 101 18.998 64.193 92.514 1.00 37.41 C
ANISOU 769 C GLY A 101 4110 6137 3967 361 26 -177 C
ATOM 770 O GLY A 101 18.818 64.843 91.481 1.00 35.74 O
ANISOU 770 O GLY A 101 3843 5954 3784 335 57 -198 O
ATOM 771 N VAL A 102 19.463 62.931 92.513 1.00 34.96 N
ANISOU 771 N VAL A 102 3830 5784 3671 410 -36 -177 N
ATOM 772 CA VAL A 102 19.819 62.187 91.297 1.00 34.18 C
ANISOU 772 CA VAL A 102 3699 5666 3623 436 -67 -233 C
ATOM 773 C VAL A 102 18.531 61.710 90.593 1.00 37.41 C
ANISOU 773 C VAL A 102 4118 6023 4073 373 -37 -212 C
ATOM 774 O VAL A 102 18.409 61.831 89.370 1.00 35.53 O
ANISOU 774 O VAL A 102 3822 5829 3850 347 -28 -263 O
ATOM 775 CB VAL A 102 20.820 61.047 91.624 1.00 38.45 C
ANISOU 775 CB VAL A 102 4268 6161 4180 528 -137 -249 C
ATOM 776 CG1 VAL A 102 21.126 60.185 90.399 1.00 38.40 C
ANISOU 776 CG1 VAL A 102 4237 6117 4236 561 -155 -331 C
ATOM 777 CG2 VAL A 102 22.111 61.608 92.229 1.00 37.89 C
ANISOU 777 CG2 VAL A 102 4155 6188 4054 582 -172 -273 C
ATOM 778 N ILE A 103 17.542 61.236 91.381 1.00 34.36 N
ANISOU 778 N ILE A 103 3794 5569 3692 337 -19 -133 N
ATOM 779 CA ILE A 103 16.260 60.794 90.844 1.00 33.66 C
ANISOU 779 CA ILE A 103 3704 5449 3636 259 10 -110 C
ATOM 780 C ILE A 103 15.544 61.966 90.187 1.00 37.70 C
ANISOU 780 C ILE A 103 4134 6061 4131 214 61 -102 C
ATOM 781 O ILE A 103 15.031 61.813 89.070 1.00 37.84 O
ANISOU 781 O ILE A 103 4097 6118 4163 169 63 -129 O
ATOM 782 CB ILE A 103 15.417 60.020 91.896 1.00 37.07 C
ANISOU 782 CB ILE A 103 4214 5798 4074 220 22 -17 C
ATOM 783 CG1 ILE A 103 16.062 58.633 92.170 1.00 37.34 C
ANISOU 783 CG1 ILE A 103 4330 5703 4156 266 -32 -15 C
ATOM 784 CG2 ILE A 103 13.920 59.876 91.451 1.00 37.66 C
ANISOU 784 CG2 ILE A 103 4258 5883 4167 115 67 14 C
ATOM 785 CD1 ILE A 103 15.598 57.949 93.432 1.00 47.42 C
ANISOU 785 CD1 ILE A 103 5694 6900 5425 246 -28 105 C
ATOM 786 N LEU A 104 15.594 63.153 90.831 1.00 33.68 N
ANISOU 786 N LEU A 104 3611 5596 3591 231 101 -71 N
ATOM 787 CA LEU A 104 14.977 64.376 90.307 1.00 33.36 C
ANISOU 787 CA LEU A 104 3499 5623 3552 211 157 -47 C
ATOM 788 C LEU A 104 15.511 64.746 88.917 1.00 34.07 C
ANISOU 788 C LEU A 104 3518 5780 3648 214 139 -90 C
ATOM 789 O LEU A 104 14.708 65.012 88.027 1.00 32.90 O
ANISOU 789 O LEU A 104 3303 5692 3505 182 158 -56 O
ATOM 790 CB LEU A 104 15.136 65.530 91.310 1.00 33.69 C
ANISOU 790 CB LEU A 104 3558 5667 3576 234 207 -34 C
ATOM 791 CG LEU A 104 14.360 66.816 91.054 1.00 38.02 C
ANISOU 791 CG LEU A 104 4051 6243 4152 231 283 6 C
ATOM 792 CD1 LEU A 104 12.849 66.546 90.864 1.00 37.78 C
ANISOU 792 CD1 LEU A 104 3981 6236 4138 203 317 79 C
ATOM 793 CD2 LEU A 104 14.564 67.790 92.218 1.00 40.00 C
ANISOU 793 CD2 LEU A 104 4341 6468 4390 248 340 -14 C
ATOM 794 N VAL A 105 16.858 64.715 88.727 1.00 31.14 N
ANISOU 794 N VAL A 105 3147 5419 3264 251 101 -159 N
ATOM 795 CA VAL A 105 17.526 64.969 87.443 1.00 30.96 C
ANISOU 795 CA VAL A 105 3053 5478 3231 250 87 -207 C
ATOM 796 C VAL A 105 17.042 63.944 86.411 1.00 35.03 C
ANISOU 796 C VAL A 105 3543 6022 3746 218 59 -243 C
ATOM 797 O VAL A 105 16.709 64.332 85.295 1.00 35.34 O
ANISOU 797 O VAL A 105 3507 6161 3761 183 71 -233 O
ATOM 798 CB VAL A 105 19.074 64.920 87.574 1.00 35.01 C
ANISOU 798 CB VAL A 105 3565 6008 3728 296 51 -284 C
ATOM 799 CG1 VAL A 105 19.755 64.761 86.208 1.00 34.91 C
ANISOU 799 CG1 VAL A 105 3479 6090 3696 293 33 -351 C
ATOM 800 CG2 VAL A 105 19.596 66.143 88.285 1.00 34.55 C
ANISOU 800 CG2 VAL A 105 3509 5958 3662 295 82 -268 C
ATOM 801 N GLY A 106 17.024 62.660 86.802 1.00 31.90 N
ANISOU 801 N GLY A 106 3210 5538 3374 226 26 -284 N
ATOM 802 CA GLY A 106 16.603 61.553 85.954 1.00 32.79 C
ANISOU 802 CA GLY A 106 3316 5644 3498 184 4 -348 C
ATOM 803 C GLY A 106 15.165 61.656 85.488 1.00 38.66 C
ANISOU 803 C GLY A 106 4015 6444 4230 96 28 -295 C
ATOM 804 O GLY A 106 14.840 61.246 84.373 1.00 39.30 O
ANISOU 804 O GLY A 106 4041 6603 4287 40 16 -354 O
ATOM 805 N CYS A 107 14.292 62.202 86.336 1.00 34.66 N
ANISOU 805 N CYS A 107 3520 5918 3732 83 64 -190 N
ATOM 806 CA CYS A 107 12.871 62.327 86.029 1.00 33.96 C
ANISOU 806 CA CYS A 107 3372 5898 3635 11 89 -126 C
ATOM 807 C CYS A 107 12.559 63.546 85.180 1.00 36.79 C
ANISOU 807 C CYS A 107 3622 6399 3958 17 112 -65 C
ATOM 808 O CYS A 107 11.462 63.650 84.641 1.00 34.93 O
ANISOU 808 O CYS A 107 3306 6262 3703 -34 121 -13 O
ATOM 809 CB CYS A 107 12.047 62.300 87.309 1.00 34.50 C
ANISOU 809 CB CYS A 107 3487 5894 3726 0 126 -44 C
ATOM 810 SG CYS A 107 12.085 60.707 88.159 1.00 39.40 S
ANISOU 810 SG CYS A 107 4227 6357 4386 -36 99 -71 S
ATOM 811 N CYS A 108 13.515 64.471 85.058 1.00 35.29 N
ANISOU 811 N CYS A 108 3424 6224 3761 77 122 -62 N
ATOM 812 CA CYS A 108 13.303 65.682 84.256 1.00 35.81 C
ANISOU 812 CA CYS A 108 3398 6402 3805 88 148 20 C
ATOM 813 C CYS A 108 13.248 65.386 82.748 1.00 39.76 C
ANISOU 813 C CYS A 108 3808 7060 4239 38 113 -8 C
ATOM 814 O CYS A 108 13.805 64.369 82.295 1.00 39.23 O
ANISOU 814 O CYS A 108 3760 7001 4146 8 73 -131 O
ATOM 815 CB CYS A 108 14.373 66.725 84.577 1.00 35.44 C
ANISOU 815 CB CYS A 108 3377 6313 3777 143 174 28 C
ATOM 816 SG CYS A 108 14.063 67.645 86.106 1.00 38.80 S
ANISOU 816 SG CYS A 108 3867 6613 4263 189 240 86 S
ATOM 817 N PRO A 109 12.626 66.278 81.941 1.00 36.74 N
ANISOU 817 N PRO A 109 3324 6811 3825 33 128 102 N
ATOM 818 CA PRO A 109 12.651 66.072 80.487 1.00 36.54 C
ANISOU 818 CA PRO A 109 3203 6973 3707 -19 92 82 C
ATOM 819 C PRO A 109 14.051 66.355 79.917 1.00 39.90 C
ANISOU 819 C PRO A 109 3632 7433 4096 -2 88 25 C
ATOM 820 O PRO A 109 14.984 66.720 80.652 1.00 38.31 O
ANISOU 820 O PRO A 109 3500 7110 3946 47 109 3 O
ATOM 821 CB PRO A 109 11.626 67.086 79.984 1.00 38.91 C
ANISOU 821 CB PRO A 109 3395 7399 3989 -7 112 256 C
ATOM 822 CG PRO A 109 11.709 68.211 80.953 1.00 43.16 C
ANISOU 822 CG PRO A 109 3985 7792 4623 78 173 354 C
ATOM 823 CD PRO A 109 11.921 67.533 82.291 1.00 38.62 C
ANISOU 823 CD PRO A 109 3527 7039 4109 85 182 254 C
ATOM 824 N GLY A 110 14.178 66.209 78.606 1.00 36.96 N
ANISOU 824 N GLY A 110 3172 7251 3622 -51 63 1 N
ATOM 825 CA GLY A 110 15.412 66.500 77.896 1.00 36.79 C
ANISOU 825 CA GLY A 110 3125 7311 3543 -47 66 -43 C
ATOM 826 C GLY A 110 15.754 67.977 77.871 1.00 39.68 C
ANISOU 826 C GLY A 110 3468 7678 3930 -11 108 116 C
ATOM 827 O GLY A 110 14.932 68.832 78.237 1.00 37.90 O
ANISOU 827 O GLY A 110 3235 7404 3761 20 137 269 O
ATOM 828 N GLY A 111 16.997 68.255 77.492 1.00 37.57 N
ANISOU 828 N GLY A 111 3192 7452 3630 -14 120 73 N
ATOM 829 CA GLY A 111 17.524 69.610 77.421 1.00 38.32 C
ANISOU 829 CA GLY A 111 3273 7535 3751 -3 166 207 C
ATOM 830 C GLY A 111 17.587 70.139 76.005 1.00 45.38 C
ANISOU 830 C GLY A 111 4057 8656 4530 -51 169 312 C
ATOM 831 O GLY A 111 17.838 69.373 75.069 1.00 44.83 O
ANISOU 831 O GLY A 111 3925 8771 4339 -97 138 211 O
ATOM 832 N THR A 112 17.360 71.460 75.849 1.00 44.03 N
ANISOU 832 N THR A 112 3865 8469 4397 -38 211 517 N
ATOM 833 CA THR A 112 17.408 72.178 74.572 1.00 46.06 C
ANISOU 833 CA THR A 112 4021 8928 4552 -78 221 676 C
ATOM 834 C THR A 112 18.755 71.978 73.857 1.00 50.30 C
ANISOU 834 C THR A 112 4519 9608 4985 -142 226 577 C
ATOM 835 O THR A 112 18.772 71.719 72.654 1.00 51.95 O
ANISOU 835 O THR A 112 4629 10072 5039 -195 206 587 O
ATOM 836 CB THR A 112 17.000 73.648 74.806 1.00 62.92 C
ANISOU 836 CB THR A 112 6172 10938 6798 -35 277 915 C
ATOM 837 OG1 THR A 112 15.573 73.736 74.755 1.00 69.65 O
ANISOU 837 OG1 THR A 112 6981 11815 7666 17 260 1043 O
ATOM 838 CG2 THR A 112 17.610 74.618 73.802 1.00 64.44 C
ANISOU 838 CG2 THR A 112 6303 11251 6931 -82 311 1083 C
ATOM 839 N ALA A 113 19.873 72.042 74.608 1.00 44.39 N
ANISOU 839 N ALA A 113 3836 8720 4311 -139 253 467 N
ATOM 840 CA ALA A 113 21.222 71.889 74.071 1.00 44.43 C
ANISOU 840 CA ALA A 113 3795 8854 4234 -190 266 364 C
ATOM 841 C ALA A 113 21.413 70.625 73.231 1.00 47.29 C
ANISOU 841 C ALA A 113 4088 9428 4452 -211 225 186 C
ATOM 842 O ALA A 113 22.263 70.622 72.346 1.00 49.14 O
ANISOU 842 O ALA A 113 4242 9859 4571 -263 243 147 O
ATOM 843 CB ALA A 113 22.253 71.957 75.192 1.00 44.42 C
ANISOU 843 CB ALA A 113 3868 8672 4339 -172 285 250 C
ATOM 844 N SER A 114 20.592 69.580 73.459 1.00 42.02 N
ANISOU 844 N SER A 114 3449 8728 3789 -181 179 77 N
ATOM 845 CA SER A 114 20.643 68.338 72.676 1.00 42.09 C
ANISOU 845 CA SER A 114 3406 8907 3678 -208 146 -113 C
ATOM 846 C SER A 114 20.318 68.595 71.190 1.00 48.23 C
ANISOU 846 C SER A 114 4059 9997 4271 -285 144 -27 C
ATOM 847 O SER A 114 20.812 67.864 70.334 1.00 49.03 O
ANISOU 847 O SER A 114 4094 10295 4241 -326 141 -189 O
ATOM 848 CB SER A 114 19.694 67.294 73.251 1.00 42.07 C
ANISOU 848 CB SER A 114 3468 8782 3735 -182 104 -217 C
ATOM 849 OG SER A 114 18.338 67.653 73.046 1.00 40.48 O
ANISOU 849 OG SER A 114 3237 8626 3517 -204 85 -61 O
ATOM 850 N ASN A 115 19.509 69.644 70.892 1.00 45.56 N
ANISOU 850 N ASN A 115 3683 9708 3919 -299 148 228 N
ATOM 851 CA ASN A 115 19.145 70.032 69.522 1.00 47.16 C
ANISOU 851 CA ASN A 115 3760 10222 3938 -367 140 364 C
ATOM 852 C ASN A 115 20.388 70.481 68.749 1.00 52.79 C
ANISOU 852 C ASN A 115 4408 11108 4543 -421 186 376 C
ATOM 853 O ASN A 115 20.575 70.064 67.608 1.00 53.35 O
ANISOU 853 O ASN A 115 4376 11476 4418 -488 179 307 O
ATOM 854 CB ASN A 115 18.077 71.140 69.504 1.00 44.25 C
ANISOU 854 CB ASN A 115 3369 9833 3610 -341 138 667 C
ATOM 855 CG ASN A 115 16.800 70.842 70.247 1.00 49.80 C
ANISOU 855 CG ASN A 115 4113 10392 4415 -288 102 684 C
ATOM 856 OD1 ASN A 115 16.532 69.712 70.684 1.00 42.29 O
ANISOU 856 OD1 ASN A 115 3203 9378 3486 -290 71 477 O
ATOM 857 ND2 ASN A 115 15.969 71.870 70.401 1.00 36.54 N
ANISOU 857 ND2 ASN A 115 2419 8656 2807 -236 113 942 N
ATOM 858 N VAL A 116 21.239 71.306 69.392 1.00 50.44 N
ANISOU 858 N VAL A 116 4165 10635 4366 -402 236 447 N
ATOM 859 CA VAL A 116 22.505 71.841 68.853 1.00 52.16 C
ANISOU 859 CA VAL A 116 4326 10981 4511 -463 290 468 C
ATOM 860 C VAL A 116 23.544 70.715 68.752 1.00 54.64 C
ANISOU 860 C VAL A 116 4613 11384 4763 -465 293 166 C
ATOM 861 O VAL A 116 24.294 70.673 67.783 1.00 55.35 O
ANISOU 861 O VAL A 116 4601 11734 4694 -529 323 124 O
ATOM 862 CB VAL A 116 23.071 73.022 69.706 1.00 56.89 C
ANISOU 862 CB VAL A 116 4998 11337 5279 -457 344 609 C
ATOM 863 CG1 VAL A 116 24.071 73.845 68.896 1.00 58.16 C
ANISOU 863 CG1 VAL A 116 5080 11672 5348 -553 403 725 C
ATOM 864 CG2 VAL A 116 21.955 73.923 70.239 1.00 56.78 C
ANISOU 864 CG2 VAL A 116 5052 11120 5402 -409 344 840 C
ATOM 865 N MET A 117 23.610 69.824 69.766 1.00 49.13 N
ANISOU 865 N MET A 117 4004 10473 4191 -388 266 -33 N
ATOM 866 CA MET A 117 24.552 68.701 69.767 1.00 48.45 C
ANISOU 866 CA MET A 117 3899 10430 4078 -358 268 -314 C
ATOM 867 C MET A 117 24.254 67.711 68.648 1.00 52.17 C
ANISOU 867 C MET A 117 4293 11152 4378 -393 252 -474 C
ATOM 868 O MET A 117 25.194 67.215 68.028 1.00 52.50 O
ANISOU 868 O MET A 117 4257 11371 4319 -405 284 -646 O
ATOM 869 CB MET A 117 24.629 68.000 71.128 1.00 49.33 C
ANISOU 869 CB MET A 117 4128 10247 4370 -260 239 -453 C
ATOM 870 CG MET A 117 25.150 68.879 72.238 1.00 52.66 C
ANISOU 870 CG MET A 117 4613 10460 4935 -235 258 -352 C
ATOM 871 SD MET A 117 26.786 69.586 71.949 1.00 59.01 S
ANISOU 871 SD MET A 117 5326 11401 5696 -287 317 -356 S
ATOM 872 CE MET A 117 26.451 71.275 72.409 1.00 55.97 C
ANISOU 872 CE MET A 117 4993 10867 5406 -350 352 -71 C
ATOM 873 N THR A 118 22.954 67.453 68.369 1.00 48.22 N
ANISOU 873 N THR A 118 3801 10684 3838 -416 208 -425 N
ATOM 874 CA THR A 118 22.510 66.589 67.261 1.00 49.35 C
ANISOU 874 CA THR A 118 3864 11087 3801 -477 189 -573 C
ATOM 875 C THR A 118 22.875 67.211 65.915 1.00 54.31 C
ANISOU 875 C THR A 118 4351 12081 4202 -570 221 -475 C
ATOM 876 O THR A 118 23.249 66.476 64.997 1.00 55.68 O
ANISOU 876 O THR A 118 4443 12501 4211 -616 237 -677 O
ATOM 877 CB THR A 118 21.012 66.325 67.336 1.00 50.39 C
ANISOU 877 CB THR A 118 4022 11182 3942 -497 131 -513 C
ATOM 878 OG1 THR A 118 20.724 65.778 68.612 1.00 43.18 O
ANISOU 878 OG1 THR A 118 3238 9934 3233 -419 110 -590 O
ATOM 879 CG2 THR A 118 20.537 65.369 66.270 1.00 47.96 C
ANISOU 879 CG2 THR A 118 3636 11134 3454 -578 107 -697 C
ATOM 880 N TYR A 119 22.760 68.554 65.795 1.00 51.06 N
ANISOU 880 N TYR A 119 3914 11704 3783 -598 236 -166 N
ATOM 881 CA TYR A 119 23.117 69.271 64.566 1.00 53.65 C
ANISOU 881 CA TYR A 119 4114 12372 3900 -691 271 -16 C
ATOM 882 C TYR A 119 24.628 69.129 64.296 1.00 59.16 C
ANISOU 882 C TYR A 119 4757 13180 4541 -710 338 -173 C
ATOM 883 O TYR A 119 25.034 68.875 63.162 1.00 59.37 O
ANISOU 883 O TYR A 119 4665 13547 4347 -783 366 -255 O
ATOM 884 CB TYR A 119 22.679 70.751 64.632 1.00 55.51 C
ANISOU 884 CB TYR A 119 4355 12551 4185 -703 279 366 C
ATOM 885 CG TYR A 119 23.166 71.571 63.454 1.00 60.61 C
ANISOU 885 CG TYR A 119 4880 13516 4633 -800 322 559 C
ATOM 886 CD1 TYR A 119 22.548 71.478 62.209 1.00 63.65 C
ANISOU 886 CD1 TYR A 119 5144 14271 4768 -873 293 637 C
ATOM 887 CD2 TYR A 119 24.279 72.401 63.569 1.00 62.92 C
ANISOU 887 CD2 TYR A 119 5170 13763 4972 -833 393 656 C
ATOM 888 CE1 TYR A 119 23.026 72.193 61.109 1.00 66.91 C
ANISOU 888 CE1 TYR A 119 5441 15003 4978 -968 334 824 C
ATOM 889 CE2 TYR A 119 24.753 73.132 62.484 1.00 65.74 C
ANISOU 889 CE2 TYR A 119 5416 14418 5143 -936 440 843 C
ATOM 890 CZ TYR A 119 24.127 73.022 61.255 1.00 76.19 C
ANISOU 890 CZ TYR A 119 6624 16110 6213 -999 411 933 C
ATOM 891 OH TYR A 119 24.601 73.748 60.192 1.00 84.36 O
ANISOU 891 OH TYR A 119 7548 17454 7051 -1105 458 1138 O
ATOM 892 N LEU A 120 25.443 69.243 65.355 1.00 56.13 N
ANISOU 892 N LEU A 120 4451 12528 4349 -644 363 -228 N
ATOM 893 CA LEU A 120 26.885 69.097 65.249 1.00 57.63 C
ANISOU 893 CA LEU A 120 4579 12807 4510 -648 422 -379 C
ATOM 894 C LEU A 120 27.279 67.646 64.978 1.00 60.25 C
ANISOU 894 C LEU A 120 4879 13229 4783 -599 423 -735 C
ATOM 895 O LEU A 120 28.129 67.411 64.125 1.00 61.78 O
ANISOU 895 O LEU A 120 4956 13698 4819 -639 477 -862 O
ATOM 896 CB LEU A 120 27.592 69.691 66.475 1.00 57.46 C
ANISOU 896 CB LEU A 120 4636 12495 4700 -601 440 -323 C
ATOM 897 CG LEU A 120 27.363 71.209 66.696 1.00 63.48 C
ANISOU 897 CG LEU A 120 5431 13154 5533 -661 461 9 C
ATOM 898 CD1 LEU A 120 27.684 71.611 68.123 1.00 62.41 C
ANISOU 898 CD1 LEU A 120 5407 12675 5630 -606 459 21 C
ATOM 899 CD2 LEU A 120 28.144 72.063 65.682 1.00 68.31 C
ANISOU 899 CD2 LEU A 120 5923 14043 5990 -782 529 157 C
ATOM 1976 N ALA A 270 17.395 71.560 89.366 1.00 35.38 N
ANISOU 1976 N ALA A 270 3622 5894 3926 228 397 -64 N
ATOM 1977 CA ALA A 270 17.973 72.447 90.379 1.00 35.08 C
ANISOU 1977 CA ALA A 270 3634 5791 3903 205 443 -136 C
ATOM 1978 C ALA A 270 16.885 73.370 90.924 1.00 38.15 C
ANISOU 1978 C ALA A 270 4048 6088 4360 230 542 -100 C
ATOM 1979 O ALA A 270 16.822 73.575 92.129 1.00 38.62 O
ANISOU 1979 O ALA A 270 4161 6109 4402 225 578 -172 O
ATOM 1980 CB ALA A 270 19.128 73.259 89.793 1.00 35.65 C
ANISOU 1980 CB ALA A 270 3680 5870 3995 157 449 -165 C
ATOM 1981 N ALA A 271 15.997 73.864 90.048 1.00 34.42 N
ANISOU 1981 N ALA A 271 3528 5596 3955 265 584 11 N
ATOM 1982 CA ALA A 271 14.866 74.726 90.424 1.00 34.94 C
ANISOU 1982 CA ALA A 271 3597 5575 4102 317 682 61 C
ATOM 1983 C ALA A 271 13.844 73.999 91.306 1.00 38.84 C
ANISOU 1983 C ALA A 271 4101 6101 4557 346 691 53 C
ATOM 1984 O ALA A 271 13.371 74.567 92.293 1.00 38.92 O
ANISOU 1984 O ALA A 271 4146 6047 4593 369 773 7 O
ATOM 1985 CB ALA A 271 14.180 75.270 89.179 1.00 35.46 C
ANISOU 1985 CB ALA A 271 3588 5648 4238 361 705 211 C
ATOM 1986 N LEU A 272 13.492 72.752 90.934 1.00 35.78 N
ANISOU 1986 N LEU A 272 3680 5809 4104 337 616 91 N
ATOM 1987 CA LEU A 272 12.516 71.931 91.663 1.00 35.50 C
ANISOU 1987 CA LEU A 272 3648 5811 4029 343 620 101 C
ATOM 1988 C LEU A 272 13.015 71.552 93.053 1.00 39.08 C
ANISOU 1988 C LEU A 272 4184 6252 4414 316 617 5 C
ATOM 1989 O LEU A 272 12.231 71.522 93.998 1.00 40.15 O
ANISOU 1989 O LEU A 272 4334 6392 4529 325 673 0 O
ATOM 1990 CB LEU A 272 12.119 70.681 90.845 1.00 34.66 C
ANISOU 1990 CB LEU A 272 3494 5793 3881 317 540 155 C
ATOM 1991 CG LEU A 272 11.233 70.919 89.606 1.00 38.06 C
ANISOU 1991 CG LEU A 272 3821 6290 4350 336 544 263 C
ATOM 1992 CD1 LEU A 272 10.998 69.623 88.830 1.00 36.79 C
ANISOU 1992 CD1 LEU A 272 3620 6223 4134 283 461 273 C
ATOM 1993 CD2 LEU A 272 9.888 71.527 89.980 1.00 39.50 C
ANISOU 1993 CD2 LEU A 272 3951 6476 4583 389 629 334 C
ATOM 1994 N ALA A 273 14.325 71.313 93.181 1.00 35.62 N
ANISOU 1994 N ALA A 273 3787 5818 3930 284 555 -67 N
ATOM 1995 CA ALA A 273 14.977 70.980 94.446 1.00 35.61 C
ANISOU 1995 CA ALA A 273 3851 5833 3846 260 535 -149 C
ATOM 1996 C ALA A 273 15.034 72.213 95.357 1.00 41.32 C
ANISOU 1996 C ALA A 273 4608 6511 4582 252 627 -233 C
ATOM 1997 O ALA A 273 14.832 72.086 96.566 1.00 41.96 O
ANISOU 1997 O ALA A 273 4729 6623 4590 240 654 -281 O
ATOM 1998 CB ALA A 273 16.385 70.473 94.176 1.00 35.68 C
ANISOU 1998 CB ALA A 273 3867 5876 3813 240 441 -195 C
ATOM 1999 N ALA A 274 15.306 73.400 94.773 1.00 37.99 N
ANISOU 1999 N ALA A 274 4172 6014 4250 253 679 -252 N
ATOM 2000 CA ALA A 274 15.361 74.677 95.495 1.00 38.62 C
ANISOU 2000 CA ALA A 274 4289 6011 4372 241 781 -348 C
ATOM 2001 C ALA A 274 13.976 75.054 96.014 1.00 40.49 C
ANISOU 2001 C ALA A 274 4522 6213 4650 298 887 -328 C
ATOM 2002 O ALA A 274 13.870 75.527 97.136 1.00 42.06 O
ANISOU 2002 O ALA A 274 4764 6399 4817 285 958 -435 O
ATOM 2003 CB ALA A 274 15.902 75.778 94.584 1.00 39.90 C
ANISOU 2003 CB ALA A 274 4439 6076 4645 227 814 -342 C
ATOM 2004 N ALA A 275 12.917 74.808 95.219 1.00 35.17 N
ANISOU 2004 N ALA A 275 3785 5545 4034 358 895 -198 N
ATOM 2005 CA ALA A 275 11.534 75.127 95.578 1.00 35.50 C
ANISOU 2005 CA ALA A 275 3792 5576 4119 425 993 -162 C
ATOM 2006 C ALA A 275 10.891 74.133 96.544 1.00 41.37 C
ANISOU 2006 C ALA A 275 4539 6428 4750 407 987 -168 C
ATOM 2007 O ALA A 275 10.161 74.562 97.441 1.00 41.44 O
ANISOU 2007 O ALA A 275 4550 6440 4754 435 1088 -219 O
ATOM 2008 CB ALA A 275 10.682 75.243 94.323 1.00 35.94 C
ANISOU 2008 CB ALA A 275 3756 5631 4267 491 994 -11 C
ATOM 2009 N HIS A 276 11.151 72.806 96.365 1.00 37.48 N
ANISOU 2009 N HIS A 276 4048 6022 4172 360 877 -116 N
ATOM 2010 CA HIS A 276 10.514 71.766 97.173 1.00 36.82 C
ANISOU 2010 CA HIS A 276 3970 6029 3991 331 867 -88 C
ATOM 2011 C HIS A 276 11.327 71.079 98.243 1.00 39.86 C
ANISOU 2011 C HIS A 276 4431 6468 4246 274 814 -146 C
ATOM 2012 O HIS A 276 10.741 70.470 99.133 1.00 40.60 O
ANISOU 2012 O HIS A 276 4537 6634 4256 250 835 -122 O
ATOM 2013 CB HIS A 276 9.784 70.774 96.275 1.00 37.80 C
ANISOU 2013 CB HIS A 276 4031 6199 4131 322 810 33 C
ATOM 2014 CG HIS A 276 8.828 71.460 95.363 1.00 41.63 C
ANISOU 2014 CG HIS A 276 4421 6676 4720 382 864 104 C
ATOM 2015 ND1 HIS A 276 7.594 71.905 95.817 1.00 44.10 N
ANISOU 2015 ND1 HIS A 276 4674 7023 5060 428 967 129 N
ATOM 2016 CD2 HIS A 276 8.988 71.835 94.071 1.00 43.54 C
ANISOU 2016 CD2 HIS A 276 4613 6894 5037 410 830 160 C
ATOM 2017 CE1 HIS A 276 7.034 72.512 94.787 1.00 44.28 C
ANISOU 2017 CE1 HIS A 276 4609 7036 5180 492 987 207 C
ATOM 2018 NE2 HIS A 276 7.819 72.471 93.702 1.00 44.20 N
ANISOU 2018 NE2 HIS A 276 4602 6997 5195 478 903 236 N
"""
CONPRED_DUMMY = """PFRMAT RR
TARGET 536987
AUTHOR RaptorX-Contact
METHOD deep dilated residual networks (one variant of deep CNN). Consult jinboxu@gmail.com for details.
MODEL 1
MVAASMNILSKISSFIGKTFSLWAALFAAAAFFAPDTFKWAGPYIPWLLG
IIMFGMGLTLKPSDFDILFKHPKVVIIGVIAQFAIMPATAWCLSKLLNLP
AEIAVGVILVGCCPGGTASNVMTYLARGNVALSVAVTSVSTLTSPLLTPA
IFLMLAGEMLEIQAAGMLMSIVKMVLLPIVLGLIVHKVLGSKTEKLTDAL
PLVSVAAIVLIIGAVVGASKGKIMESGLLIFAVVVLHNGIGYLLGFFAAK
WTGLPYDAQKALTIEVGMQNSGLAAALAAAHFAAAPVVAVPGALFSVWHN
ISGSLLATYWAAKAGKHKKPLDRAGSENLYFQ
53 178 0 8 0.9999614
57 182 0 8 0.9999346
58 182 0 8 0.9999014
54 181 0 8 0.9998163
54 182 0 8 0.9997769
54 178 0 8 0.9996910
249 259 0 8 0.9989253
58 185 0 8 0.9979285
58 186 0 8 0.9977884
249 262 0 8 0.9974785
94 104 0 8 0.9972718
123 133 0 8 0.9972159
57 179 0 8 0.9963613
246 263 0 8 0.9962631
50 178 0 8 0.9946589
106 288 0 8 0.9932054
57 183 0 8 0.9925978
123 261 0 8 0.9922032
102 288 0 8 0.9917381
27 212 0 8 0.9908113
103 291 0 8 0.9907801
75 136 0 8 0.9905434
31 216 0 8 0.9904293
89 240 0 8 0.9902470
27 213 0 8 0.9900678
110 292 0 8 0.9887912
85 244 0 8 0.9886514
90 108 0 8 0.9883336
109 278 0 8 0.9877242
94 107 0 8 0.9875522
78 262 0 8 0.9875078
48 207 0 8 0.9874308
74 262 0 8 0.9874212
28 216 0 8 0.9870313
245 263 0 8 0.9866461
78 136 0 8 0.9865698
106 291 0 8 0.9861109
79 139 0 8 0.9859405
133 265 0 8 0.9857825
77 252 0 8 0.9857346
109 274 0 8 0.9857225
110 295 0 8 0.9855377
81 248 0 8 0.9851450
81 266 0 8 0.9848748
74 258 0 8 0.9841593
106 292 0 8 0.9837796
31 213 0 8 0.9835263
68 135 0 8 0.9834397
48 211 0 8 0.9833449
113 274 0 8 0.9828007
52 207 0 8 0.9818235
128 261 0 8 0.9814836
90 107 0 8 0.9814461
119 265 0 8 0.9814367
105 288 0 8 0.9791791
271 296 0 8 0.9788657
90 111 0 8 0.9781752
31 217 0 8 0.9776807
53 175 0 8 0.9772123
77 262 0 8 0.9764582
129 258 0 8 0.9764170
234 298 0 8 0.9763948
133 261 0 8 0.9759184
79 140 0 8 0.9759070
55 182 0 8 0.9758528
246 259 0 8 0.9756561
27 209 0 8 0.9746038
234 295 0 8 0.9741930
112 148 0 8 0.9737659
102 287 0 8 0.9732612
132 258 0 8 0.9728087
82 266 0 8 0.9718467
242 263 0 8 0.9710815
245 266 0 8 0.9700539
91 108 0 8 0.9698529
75 139 0 8 0.9698042
48 210 0 8 0.9697683
24 212 0 8 0.9695854
107 233 0 8 0.9683198
136 262 0 8 0.9669924
107 291 0 8 0.9663849
79 136 0 8 0.9657449
94 108 0 8 0.9650769
125 307 0 8 0.9650706
77 248 0 8 0.9650462
120 133 0 8 0.9647374
93 233 0 8 0.9635152
51 207 0 8 0.9634590
"""
class SearchTargetTestCase(unittest.TestCase):
def test_1(self):
pdb_fname = create_tempfile(PDB_DUMY)
self.addCleanup(remove, pdb_fname)
conpred_fname = create_tempfile(CONPRED_DUMMY)
self.addCleanup(remove, conpred_fname)
topcons_fname = create_tempfile(TOPCONS_DUMY)
self.addCleanup(remove, topcons_fname)
search = SearchTarget(workdir=os.path.join(os.environ['CCP4_SCR'], 'test'), conpred=conpred_fname,
sspred=topcons_fname, target_pdb_benchmark=PDB_DUMY, queue_environment='environ',
platform='local', queue_name='queue', n_contacts_threshold=0)
self.addCleanup(remove, os.path.join(os.environ['CCP4_SCR'], 'test'))
self.assertTrue(os.path.isdir(os.path.join(os.environ['CCP4_SCR'], 'test')))
self.assertEqual(search.search_header, """**********************************************************************
***************** SWAMP SEARCH *****************
**********************************************************************
""")
self.assertEqual(os.path.join(os.environ['CCP4_SCR'], 'test', "tmp_cmap_{}.map"), search._tmp_cmap)
self.assertEqual(os.path.join(os.environ['CCP4_SCR'], 'test', "search_{}"), search._search_workdir)
self.assertIsNone(search._tmp_pdb)
search.target.split()
self.assertFalse(search.target.error)
self.assertEqual(swamp.FRAG_MAPALIGN_DB, search.template_library)
self.assertEqual('mapalign', search.library_format)
self.assertDictEqual({'directory': os.path.join(os.environ['CCP4_SCR'], 'test'), 'shell': '/bin/bash',
'name': 'swamp', 'queue': 'queue', 'environment': 'environ', 'processes': 1},
search._other_task_info)
self.assertListEqual(["SUBTRGT_RANK", "SUBTRGT_ID", "N_CON_MAP_A", "MAP_A", "MAP_B", "CON_SCO", "GAP_SCO",
"TOTAL_SCO", "ALI_LEN", "QSCORE", "RMSD", "SEQ_ID", "N_ALIGN"], search._column_reference)
self.assertIsNone(search.scripts)
self.assertIsNone(search.search_pickle_dict)
search._create_scripts()
self.assertEqual(12, len(search.scripts))
self.assertListEqual(
['%s/search_1/search_1_results.pckl' % os.path.join(os.environ['CCP4_SCR'], 'test'),
'%s/search_10/search_10_results.pckl' % os.path.join(os.environ['CCP4_SCR'], 'test'),
'%s/search_11/search_11_results.pckl' % os.path.join(os.environ['CCP4_SCR'], 'test'),
'%s/search_12/search_12_results.pckl' % os.path.join(os.environ['CCP4_SCR'], 'test'),
'%s/search_2/search_2_results.pckl' % os.path.join(os.environ['CCP4_SCR'], 'test'),
'%s/search_3/search_3_results.pckl' % os.path.join(os.environ['CCP4_SCR'], 'test'),
'%s/search_4/search_4_results.pckl' % os.path.join(os.environ['CCP4_SCR'], 'test'),
'%s/search_5/search_5_results.pckl' % os.path.join(os.environ['CCP4_SCR'], 'test'),
'%s/search_6/search_6_results.pckl' % os.path.join(os.environ['CCP4_SCR'], 'test'),
'%s/search_7/search_7_results.pckl' % os.path.join(os.environ['CCP4_SCR'], 'test'),
'%s/search_8/search_8_results.pckl' % os.path.join(os.environ['CCP4_SCR'], 'test'),
'%s/search_9/search_9_results.pckl' % os.path.join(os.environ['CCP4_SCR'], 'test')],
sorted(list(search.search_pickle_dict.keys())))
def test_2(self):
pdb_fname = create_tempfile(PDB_DUMY)
self.addCleanup(remove, pdb_fname)
conpred_fname = create_tempfile(CONPRED_DUMMY)
self.addCleanup(remove, conpred_fname)
topcons_fname = create_tempfile(TOPCONS_DUMY)
self.addCleanup(remove, topcons_fname)
search = SearchTarget(workdir=os.path.join(os.environ['CCP4_SCR'], 'test_2'), conpred=conpred_fname,
sspred=topcons_fname, platform='sge', n_contacts_threshold=0,
alignment_algorithm_name='mapalign')
self.addCleanup(remove, os.path.join(os.environ['CCP4_SCR'], 'test_2'))
search.target.split()
self.assertDictEqual({'directory': os.path.join(os.environ['CCP4_SCR'], 'test_2'), 'shell': '/bin/bash',
'name': 'swamp', 'max_array_size': 1}, search._other_task_info)
search._create_scripts()
for idx, pickle in enumerate(sorted(search.search_pickle_dict.keys())):
if not os.path.isdir(os.path.dirname(pickle)):
os.makedirs(os.path.dirname(pickle))
self.addCleanup(remove, os.path.dirname(pickle))
joblib.dump([["MAP_A_%s" % idx, "MAP_B_%s" % idx, "CON_SCO_%s" % idx, "GAP_SCO_%s" % idx,
"TOTAL_SCO_%s" % idx, "ALI_LEN_%s" % idx, "QSCORE_%s" % idx, "RMSD_%s" % idx,
"SEQ_ID_%s" % idx, "N_ALIGN_%s" % idx]],
pickle)
self.assertIsNone(search.results)
search.results = search.recover_results()
self.assertListEqual([[1, '2_6', 11, 'MAP_A_0', 'MAP_B_0', 'CON_SCO_0', 'GAP_SCO_0', 'TOTAL_SCO_0', 'ALI_LEN_0',
'QSCORE_0', 'RMSD_0', 'SEQ_ID_0', 'N_ALIGN_0'],
[2, '1_7', 8, 'MAP_A_4', 'MAP_B_4', 'CON_SCO_4', 'GAP_SCO_4', 'TOTAL_SCO_4', 'ALI_LEN_4',
'QSCORE_4', 'RMSD_4', 'SEQ_ID_4', 'N_ALIGN_4'],
[3, '4_9', 7, 'MAP_A_5', 'MAP_B_5', 'CON_SCO_5', 'GAP_SCO_5', 'TOTAL_SCO_5', 'ALI_LEN_5',
'QSCORE_5', 'RMSD_5', 'SEQ_ID_5', 'N_ALIGN_5'],
[4, '3_5', 6, 'MAP_A_6', 'MAP_B_6', 'CON_SCO_6', 'GAP_SCO_6', 'TOTAL_SCO_6', 'ALI_LEN_6',
'QSCORE_6', 'RMSD_6', 'SEQ_ID_6', 'N_ALIGN_6'],
[5, '2_7', 5, 'MAP_A_7', 'MAP_B_7', 'CON_SCO_7', 'GAP_SCO_7', 'TOTAL_SCO_7', 'ALI_LEN_7',
'QSCORE_7', 'RMSD_7', 'SEQ_ID_7', 'N_ALIGN_7'],
[6, '3_4', 4, 'MAP_A_8', 'MAP_B_8', 'CON_SCO_8', 'GAP_SCO_8', 'TOTAL_SCO_8', 'ALI_LEN_8',
'QSCORE_8', 'RMSD_8', 'SEQ_ID_8', 'N_ALIGN_8'],
[7, '3_8', 3, 'MAP_A_9', 'MAP_B_9', 'CON_SCO_9', 'GAP_SCO_9', 'TOTAL_SCO_9', 'ALI_LEN_9',
'QSCORE_9', 'RMSD_9', 'SEQ_ID_9', 'N_ALIGN_9'],
[8, '4_10', 3, 'MAP_A_10', 'MAP_B_10', 'CON_SCO_10', 'GAP_SCO_10', 'TOTAL_SCO_10',
'ALI_LEN_10', 'QSCORE_10', 'RMSD_10', 'SEQ_ID_10', 'N_ALIGN_10'],
[9, '4_5', 2, 'MAP_A_11', 'MAP_B_11', 'CON_SCO_11', 'GAP_SCO_11', 'TOTAL_SCO_11',
'ALI_LEN_11', 'QSCORE_11', 'RMSD_11', 'SEQ_ID_11', 'N_ALIGN_11'],
[10, '8_10', 2, 'MAP_A_1', 'MAP_B_1', 'CON_SCO_1', 'GAP_SCO_1', 'TOTAL_SCO_1',
'ALI_LEN_1', 'QSCORE_1', 'RMSD_1', 'SEQ_ID_1', 'N_ALIGN_1'],
[11, '4_8', 1, 'MAP_A_2', 'MAP_B_2', 'CON_SCO_2', 'GAP_SCO_2', 'TOTAL_SCO_2', 'ALI_LEN_2',
'QSCORE_2', 'RMSD_2', 'SEQ_ID_2', 'N_ALIGN_2'],
[12, '9_10', 1, 'MAP_A_3', 'MAP_B_3', 'CON_SCO_3', 'GAP_SCO_3', 'TOTAL_SCO_3',
'ALI_LEN_3', 'QSCORE_3', 'RMSD_3', 'SEQ_ID_3', 'N_ALIGN_3']],
sorted(search.results, key=itemgetter(0)))
for result in search.results:
result[5] = result[2]
search._make_dataframe(search.results)
search.rank(consco_threshold=0)
self.assertListEqual([11, 8, 7, 6, 5, 4, 3, 3, 2, 2, 1, 1], search.ranked_searchmodels.consco.tolist())
search.rank(consco_threshold=0, combine_searchmodels=True)
self.assertListEqual([4.416666666666667], search.ranked_searchmodels.consco.tolist())
| 67.744373
| 332
| 0.512709
| 7,264
| 42,137
| 2.918227
| 0.226459
| 0.025899
| 0.012454
| 0.011888
| 0.300311
| 0.079347
| 0.067271
| 0.067271
| 0.067271
| 0.065336
| 0
| 0.488787
| 0.423238
| 42,137
| 621
| 333
| 67.853462
| 0.383451
| 0
| 0
| 0.035
| 0
| 0.308333
| 0.857702
| 0.028621
| 0
| 0
| 0
| 0
| 0.031667
| 1
| 0.003333
| false
| 0
| 0.011667
| 0
| 0.016667
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| 0
| 0
| 0
| 1
| 1
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
|
0
| 4
|
d70985722186dbfbe55c0d01494dd41a4805e511
| 969
|
py
|
Python
|
gui/serializers.py
|
narsi84/digilib
|
eec9632e7b7d3cb64a9832e313f47719621219c6
|
[
"MIT"
] | null | null | null |
gui/serializers.py
|
narsi84/digilib
|
eec9632e7b7d3cb64a9832e313f47719621219c6
|
[
"MIT"
] | null | null | null |
gui/serializers.py
|
narsi84/digilib
|
eec9632e7b7d3cb64a9832e313f47719621219c6
|
[
"MIT"
] | null | null | null |
from django.contrib.auth.models import User, Group
from rest_framework import serializers
from .models import *
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ('url', 'username', 'email', 'groups')
class GroupSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Group
fields = ('url', 'name')
class BookSerializer(serializers.ModelSerializer):
#class BookSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Book
fields = '__all__'
depth = 1
class TagSerializer(serializers.ModelSerializer):
#class TagSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Tag
fields = '__all__'
class CategorySerializer(serializers.ModelSerializer):
#class CategorySerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Category
fields = '__all__'
| 27.685714
| 66
| 0.717234
| 84
| 969
| 8.119048
| 0.392857
| 0.271261
| 0.307918
| 0.337243
| 0.3739
| 0
| 0
| 0
| 0
| 0
| 0
| 0.001285
| 0.19711
| 969
| 34
| 67
| 28.5
| 0.875321
| 0.19195
| 0
| 0.333333
| 0
| 0
| 0.064103
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0
| 0.125
| 0
| 0.541667
| 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
| 0
| 0
| 0
| 0
| null | 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
|
0
| 4
|
d714876ec4c41661abdfaec64c90677a20ebfeef
| 121
|
py
|
Python
|
mgba_gamedata/gb/__init__.py
|
mgba-emu/gamedata
|
d8a167e61f1fade77d08db2f705e08c264208a44
|
[
"BSD-2-Clause"
] | 2
|
2018-11-07T08:11:25.000Z
|
2021-07-15T12:31:20.000Z
|
mgba_gamedata/gb/__init__.py
|
mgba-emu/gamedata
|
d8a167e61f1fade77d08db2f705e08c264208a44
|
[
"BSD-2-Clause"
] | null | null | null |
mgba_gamedata/gb/__init__.py
|
mgba-emu/gamedata
|
d8a167e61f1fade77d08db2f705e08c264208a44
|
[
"BSD-2-Clause"
] | null | null | null |
from mgba_gamedata.registry import Platform, Game
class GB(Platform):
pass
class GBGame(Game):
platform = GB
| 12.1
| 49
| 0.719008
| 16
| 121
| 5.375
| 0.6875
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.206612
| 121
| 9
| 50
| 13.444444
| 0.895833
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0
| false
| 0.2
| 0.2
| 0
| 0.8
| 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
| 1
| 0
| 0
| 1
| 0
|
0
| 4
|
d761c4f51fd988692bea83fa884bc0447d1a062f
| 824
|
py
|
Python
|
drivers/driver.py
|
OttrOne/suivi
|
9e53a39b0f50054b89cb960eb9055fd0a28a5ebf
|
[
"MIT"
] | null | null | null |
drivers/driver.py
|
OttrOne/suivi
|
9e53a39b0f50054b89cb960eb9055fd0a28a5ebf
|
[
"MIT"
] | 2
|
2022-01-11T15:50:04.000Z
|
2022-01-13T01:53:53.000Z
|
drivers/driver.py
|
OttrOne/suivi
|
9e53a39b0f50054b89cb960eb9055fd0a28a5ebf
|
[
"MIT"
] | null | null | null |
class DriverMeta(type):
def __instancecheck__(cls, __instance) -> bool:
return cls.__subclasscheck__(type(__instance))
def __subclasscheck__(cls, __subclass: type) -> bool:
return (
hasattr(__subclass, 'create') and callable(__subclass.create)
) and (
hasattr(__subclass, 'logs') and callable(__subclass.logs)
) and (
hasattr(__subclass, 'stats') and callable(__subclass.stats)
) and (
hasattr(__subclass, 'stop') and callable(__subclass.stop)
) and (
hasattr(__subclass, 'cleanup') and callable(__subclass.cleanup)
) and (
hasattr(__subclass, 'wait') and callable(__subclass.wait)
)
class Driver(metaclass=DriverMeta):
pass
| 35.826087
| 79
| 0.582524
| 72
| 824
| 6.083333
| 0.319444
| 0.205479
| 0.260274
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0
| 0.31432
| 824
| 22
| 80
| 37.454545
| 0.775221
| 0
| 0
| 0.263158
| 0
| 0
| 0.036408
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| 0.105263
| false
| 0.052632
| 0
| 0.105263
| 0.315789
| 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
| 0
| 0
| 1
| 0
| 1
| 0
| 0
|
0
| 4
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.