Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
from django.db import connection
from django.db.models.base import ModelBase
from django.core.management.color import no_style
from django_sphinxsearch.managers import SearchManager
# Create a dummy model which extends the mixin
import pudb; pudb.set_trace()
self.model = ModelBase('__TestModel__{}'.format(self.mixin.__name__), (self.mixin, ),
{ '__module__': self.mixin.__module__ })
# Create the schema for our test model
self._style = no_style()
sql, _ = connection.creation.sql_create_model(self.model, self._style)
self._cursor = connection.cursor()
for statement in sql:
self._cursor.execute(statement)
self.model.search = SearchManager(index="test_index", fields={'data': 100}, limit=10)
self.model.search.contribute_to_class(model=self.model, name="search")
source_data = (
"Python is a programming language that lets you work more quickly and integrate your systems more effectively.",
"You can learn to use Python and see almost immediate gains in productivity and lower maintenance costs.",
"Python runs on Windows, Linux/Unix, Mac OS X, and has been ported to the Java and .NET virtual machines.",
# Run telnet server and get the new fds
(pid, stdout, stdin) = run_telnet_server(addr, port)
sys.stdout = stdout
sys.stdin = stdin
# Kill children on exit.
def cleanup():
print('Killing server...')
os.kill(pid, signal.SIGKILL)
atexit.register(cleanup)
def signal_handler(signal, frame):
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
# Finally, run pudb
pudb.set_trace()
def _wrapper(*args, **kwargs):
import pudb
sys.stdout = sys.__stdout__
pudb.set_trace()
return func(*args, **kwargs)
return _wrapper
def Use_debugger(_args):
pdb.set_trace()
logger.error("response: '{}'".format(repr(body)))
expected_rc.append(rc)
elif rc == 404 and rc not in expected_rc:
logger.error("No longer available or access denied: {}".format(url))
# TODO: Figure out what to do here. Maybe it's just that message, but
# maybe need to delete from DB before next run
body = []
# don't throw on this one
expected_rc.append(rc)
logger.debug("{} for {}".format(rc, url))
if rc not in expected_rc:
if DEBUG:
import pudb
pudb.set_trace() # noqa: E702
else:
logger.error("{} for {}".format(rc, url))
raise AG_Exception
return body
def check_if_need_relogin(self, resp, passed=False, need_raise=True):
if passed or "缓存已经过期" in resp.text:
"""
登录超时重新登录
"""
debug("cache timeout!")
if self.first_fetch():
self.login()
elif "您必须注册并登录才能浏览这个版面" in resp.text or "无效的用户名" in resp.text:
import pudb
pudb.set_trace()
"""
账户遭到封锁重新注册
"""
# if self.need_re_register:
# self.register()
# else:
# self.login()
pass
else:
return True
if need_raise:
raise ValueError
import pudb
pudb.set_trace()
def mklist(*args):
result = None
for element in reversed(args):
result = (element, result)
return result
print mklist(1,2,3,4,5,6)
def bin_to_times(self):
self.d_times = np.zeros(len(self.y))
for i in range(len(self.y)):
if self.y[i] == 0:
self.d_times[i] = 300.0
elif self.y[i] == 1:
self.d_times[i] = 8.0
else:
pudb.set_trace()
self.d_times *= 0.001
self.O.d_times = self.d_times
cout = spike_count(ia, o)
tau1, tau2 = info.O.tau1, info.O.tau2
delta = info.y - np.clip(cout, 0, 1)
dt, v = info.O.dt, info.O.v
lam = 100
dt = info.O.dt
vo = info.O.v
### m input neurons, n hidden neurons, o output neurons, p subconnections
### w_ih[n_p*i + p*j + k] acceses the kth synapse from input i to hidden j
### w_ho[o_p*i + p*j + k] acceses the kth synapse from hidden i to output j
if stop==True:
pudb.set_trace()
# loop over hidden neurons
for h in range(n):
# loop over input spikes
for I in range(len(ii)):
i = ii[I]
index_ih = n_p*i+p*h
delay = delay_ih[index_ih:index_ih+p]*0.001
# loop over output spikes
for j in range(o):
if delta[j] != 0:
index_ho = o_p*h+p*j
j_max = np.argmax(v[j])
t_max = j_max * dt
#indices = np.argwhere(ia - j).ravel()
#for k in indices:
t_ih = ti[I] + delay