function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def __init__(self, config_yaml):
self.Config = config_yaml | livingenvironmentslab/UniCAVE | [
89,
26,
89,
10,
1487359957
] |
def LaunchUniCAVEWindow(path, machine_name=None):
args = [path, "-popupWindow"]
if machine_name is not None:
args = args + ["overrideMachineName", machine_name]
return subprocess.Popen(args) | livingenvironmentslab/UniCAVE | [
89,
26,
89,
10,
1487359957
] |
def __init__(self, phi=B3Spline.dec_lo, level=None, boundary="symm",
data=None):
self.set_wavelet(phi=phi)
self.level = level
self.boundary = boundary
self.data = np.array(data) | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def load_data(self, data):
self.reset()
self.data = np.array(data) | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def calc_filters(self):
"""
Calculate the convolution filters of each scale.
Note: the zero-th scale filter (i.e., delta function) is the first
element, thus the array index is the same as the decomposition scale.
"""
self.filters = []
# scale 0: delta function
... | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def decompose(self, level, boundary="symm"):
"""
Perform IUWT decomposition in the plain loop way.
The filters of each scale/level are calculated first, then the
approximations of each scale/level are calculated by convolving the
raw/finest image with these filters.
retu... | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def __decompose(self, data, phi, level):
"""
2D IUWT decomposition (or stationary wavelet transform).
This is a convolution version, where kernel is zero-upsampled
explicitly. Not fast.
Parameters:
- level : level of decomposition
- phi : low-pass filter kernel
... | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def zupsample(data, order=1):
"""
Upsample data array by interleaving it with zero's.
h{up_order: n}[l] = (1) h[l], if l % 2^n == 0;
(2) 0, otherwise
"""
shape = data.shape
new_shape = [ (2**order * (n-1) + 1) for n in shape ]
output =... | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def get_detail(self, scale):
"""
Get the wavelet detail coefficients of given scale.
Note: 1 <= scale <= level
"""
if scale < 1 or scale > self.level:
raise ValueError("Invalid scale")
return self.decomposition[scale-1] | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def reset(self):
super(self.__class__, self).reset()
vst_coef = [] | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def soft_threshold(data, threshold):
if isinstance(data, np.ndarray):
data_th = data.copy()
data_th[np.abs(data) <= threshold] = 0.0
data_th[data > threshold] -= threshold
data_th[data < -threshold] += threshold
else:
data_th = data
... | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def filters_product(self, scale1, scale2):
"""
Calculate the scalar product of the filters of two scales,
considering only the overlapped part.
Helper function used in VST coefficients calculation.
"""
if scale1 > scale2:
filter_big = self.filters[scale1]
... | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def vst(self, data, scale, coupled=True):
"""
Perform variance stabling transform
XXX: parameter `coupled' why??
Credit: MSVST-V1.0/src/libmsvst/B3VSTAtrous.h
"""
self.vst_coupled = coupled
if self.vst_coef == []:
self.calc_vst_coef()
if coupl... | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def is_significant(self, scale, fdr=0.1, independent=False, verbose=False):
"""
Multiple hypothesis testing with false discovery rate (FDR) control.
`independent': whether the test statistics of all the null
hypotheses are independent.
If `independent=True': FDR <= (m0/m) * q
... | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def decompose(self, level=5, boundary="symm", verbose=False):
"""
2D IUWT decomposition with VST.
"""
self.boundary = boundary
if self.level != level or self.filters == []:
self.level = level
self.calc_filters()
self.calc_vst_coef()
sel... | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def reconstruct(self, denoised=True, niter=10, verbose=False):
"""
Reconstruct the original image using iterative method with
L1 regularization, because the denoising violates the exact inverse
procedure.
arguments:
* denoised: whether use the denoised coefficients
... | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def main():
# commandline arguments parser
parser = argparse.ArgumentParser(
description="Poisson Noise Removal with Multi-scale Variance " + \
"Stabling Transform and Wavelet Transform",
epilog="Version: %s (%s)" % (__version__, __date__))
parser.add_argument... | liweitianux/atoolbox | [
6,
4,
6,
1,
1464356672
] |
def getGeocodeLocation(inputString):
#Replace Spaces with '+' in URL
locationString = inputString.replace(" ", "+")
url = ('https://maps.googleapis.com/maps/api/geocode/json?address=%s&key=%s'% (locationString, google_api_key))
h = httplib2.Http()
result = json.loads(h.request(url,'GET')[1])
#pr... | tuanvu216/udacity-course | [
65,
99,
65,
2,
1443836127
] |
def findARestaurant(mealType, location):
latitude, longitude = getGeocodeLocation(location)
url = ('https://api.foursquare.com/v2/venues/search?client_id=%s&client_secret=%s&v=20130815&ll=%s,%s&query=%s' % (foursquare_client_id, foursquare_client_secret,latitude,longitude,mealType))
h = httplib2.Http()
... | tuanvu216/udacity-course | [
65,
99,
65,
2,
1443836127
] |
def __init__(
self, plotly_name="color", parent_name="icicle.outsidetextfont", **kwargs | plotly/plotly.py | [
13052,
2308,
13052,
1319,
1385013188
] |
def __init__(self, container, parent, value=None):
self._node = tree.Node(container, parent, value) | alviproject/alvi | [
12,
5,
12,
1,
1381172049
] |
def _container(self):
return self._node._container | alviproject/alvi | [
12,
5,
12,
1,
1381172049
] |
def id(self):
return self._node.id | alviproject/alvi | [
12,
5,
12,
1,
1381172049
] |
def value(self):
return self._node.value | alviproject/alvi | [
12,
5,
12,
1,
1381172049
] |
def value(self, value):
self._node.value = value | alviproject/alvi | [
12,
5,
12,
1,
1381172049
] |
def _create_child(self, index, value):
try:
children = self._children
except AttributeError:
children = self._create_children()
children[index].value = value
return children[index] | alviproject/alvi | [
12,
5,
12,
1,
1381172049
] |
def create_right_child(self, value):
return self._create_child(1, value) | alviproject/alvi | [
12,
5,
12,
1,
1381172049
] |
def left_child(self):
return self._child(0) | alviproject/alvi | [
12,
5,
12,
1,
1381172049
] |
def right_child(self):
return self._child(1) | alviproject/alvi | [
12,
5,
12,
1,
1381172049
] |
def __init__(self, *args, **kwargs):
self._tree = tree.Tree(*args, **kwargs) | alviproject/alvi | [
12,
5,
12,
1,
1381172049
] |
def root(self):
try:
return self._root
except AttributeError:
return None | alviproject/alvi | [
12,
5,
12,
1,
1381172049
] |
def _pipe(self):
return self._tree._pipe | alviproject/alvi | [
12,
5,
12,
1,
1381172049
] |
def get_raise(data, key, expect_type=None):
''' Helper function to retrieve an element from a JSON data structure.
The *key* must be a string and may contain periods to indicate nesting.
Parts of the key may be a string or integer used for indexing on lists.
If *expect_type* is not None and the retrieved value ... | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def basic_auth(message='Login required'):
''' Sends a 401 response that enables basic auth. '''
headers = {'WWW-Authenticate': 'Basic realm="{}"'.format(message)}
return Response('Please log in.', 401, headers, mimetype='text/plain') | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def wrapper(*args, **kwargs):
ip = request.remote_addr
token_string = session.get('flux_login_token')
token = models.LoginToken.select(lambda t: t.token == token_string).first()
if not token or token.ip != ip or token.expired():
if token and token.expired():
flash("Your login session has e... | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def with_io_response(kwarg='stream', stream_type='text', **response_kwargs):
''' Decorator for View functions that create a :class:`io.StringIO` or
:class:`io.BytesIO` (based on the *stream_type* parameter) and pass it
as *kwarg* to the wrapped function. The contents of the buffer are
sent back to the client. '... | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
if replace:
stream = kwargs.pop(stream_dest_kwarg)
else:
stream = kwargs[stream_dest_kwarg]
kwargs[kwarg] = logger = create_logger(stream)
try:
return func(*args, **kwargs)
except Base... | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def create_logger(stream, name=__name__, fmt=None):
''' Creates a new :class:`logging.Logger` object with the
specified *name* and *fmt* (defaults to a standard logging
formating including the current time, levelname and message).
The logger will also output to stderr. '''
fmt = fmt or '[%(asctime)-15s - %(... | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def generate():
with open(filename, 'rb') as fp:
yield from fp | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def flash(message=None):
if message is None:
return session.pop('flux_flash', None)
else:
session['flux_flash'] = message | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def hash_pw(pw):
return hashlib.md5(pw.encode('utf8')).hexdigest() | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def rmtree(path, remove_write_protection=False):
"""
A wrapper for #shutil.rmtree() that can try to remove write protection
if removing fails, if enabled.
"""
if remove_write_protection:
def on_rm_error(func, path, exc_info):
os.chmod(path, stat.S_IWRITE)
os.unlink(path)
else:
on_rm_err... | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def secure_filename(filename):
"""
Similar to #werkzeug.secure_filename(), but preserves leading dots in
the filename.
"""
while True:
filename = filename.lstrip('/').lstrip('\\')
if filename.startswith('..') and filename[2:3] in '/\\':
filename = filename[3:]
elif filename.startswith('.') ... | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def run(command, logger, cwd=None, env=None, shell=False, return_stdout=False,
inherit_env=True):
"""
Run a subprocess with the specified command. The command and output of is
logged to logger. The command will automatically be converted to a string
or list of command arguments based on the *shell* para... | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def strip_url_path(url):
''' Strips that path part of the specified *url*. '''
result = list(urllib.parse.urlparse(url))
result[2] = ''
return urllib.parse.urlunparse(result) | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def get_bitbucket_signature(secret, payload_data):
''' Generates the Bitbucket HMAC signature from the repository
*secret* and the *payload_data*. The Bitbucket signature is sent
with the ``X-Hub-Signature`` header. '''
return hmac.new(secret.encode('utf8'), payload_data, hashlib.sha256).hexdigest() | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def is_page_active(page, user):
path = request.path
if page == 'dashboard' and (not path or path == '/'):
return True
elif page == 'repositories' and (path.startswith('/repositories') or path.startswith('/repo') or path.startswith('/edit/repo') or path.startswith('/build') or path.startswith('/overrides')):
... | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def get_customs_path(repo):
return os.path.join(config.customs_dir, repo.name.replace('/', os.sep)) | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def get_override_build_script_path(repo):
return os.path.join(get_override_path(repo), config.build_scripts[0]) | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def write_override_build_script(repo, build_script):
build_script_path = get_override_build_script_path(repo)
if build_script.strip() == '':
if os.path.isfile(build_script_path):
os.remove(build_script_path)
else:
makedirs(os.path.dirname(build_script_path))
build_script_file = open(build_script... | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def generate_ssh_keypair(public_key_comment):
"""
Generates new RSA ssh keypair.
Return:
tuple(str, str): generated private and public keys
"""
key = rsa.generate_private_key(backend=default_backend(), public_exponent=65537, key_size=4096)
private_key = key.private_bytes(serialization.Encoding.PEM, seri... | NiklasRosenstein/flux | [
28,
8,
28,
9,
1455380498
] |
def __init__(self, text, menu=None, should_exit=False):
# Here so Sphinx doesn't copy extraneous info from the superclass's docstring
super(ExternalItem, self).__init__(text=text, menu=menu, should_exit=should_exit) | mholgatem/GPIOnext | [
95,
27,
95,
3,
1505762810
] |
def get_manager_config(cls):
ci = os.environ.get("CI", False)
if ci:
database = "orator_test"
user = "root"
password = ""
else:
database = "orator_test"
user = "orator"
password = "orator"
return {
"def... | sdispater/orator | [
1388,
164,
1388,
161,
1432491805
] |
def FindAll(haystack, needle):
r = []
if isinstance(haystack, str):
index = haystack.find(needle)
while True:
if ~index:
r += [index]
else:
return r
index = haystack.find(needle, index + 1)
else:
return [i for i, ite... | somebody1234/Charcoal | [
189,
8,
189,
1,
1475454499
] |
def dedup(iterable):
iterable = iterable[:]
items = []
i = 0
for item in iterable:
if item in items:
del iterable[i]
else:
i += 1
items += [item]
return iterable | somebody1234/Charcoal | [
189,
8,
189,
1,
1475454499
] |
def itersplit(iterable, number):
result = []
while len(iterable):
result += [iterable[:number]]
iterable = iterable[number:]
return result | somebody1234/Charcoal | [
189,
8,
189,
1,
1475454499
] |
def abs_str(string):
try:
return abs(float(string) if "." in string else int(string))
except:
return string # ??? | somebody1234/Charcoal | [
189,
8,
189,
1,
1475454499
] |
def product(item):
result = 1
for part in item:
result *= part
return result | somebody1234/Charcoal | [
189,
8,
189,
1,
1475454499
] |
def Abs(item):
if isinstance(item, int) or isinstance(item, float):
return abs(item)
if isinstance(item, str):
return abs_str(item)
if isinstance(item, Expression):
item = item.run()
if isinstance(item, String):
return String(abs_str(str(item)))
if hasattr(item, "__it... | somebody1234/Charcoal | [
189,
8,
189,
1,
1475454499
] |
def Product(item):
if isinstance(item, float):
item = int(item)
if isinstance(item, int):
result = 1
while item:
result *= item % 10
item //= 10
return result
if isinstance(item, Expression):
item = item.run()
if isinstance(item, String):
... | somebody1234/Charcoal | [
189,
8,
189,
1,
1475454499
] |
def vectorized(left, right, c):
if isinstance(left, String):
left = str(left)
if isinstance(right, String):
right = str(right)
if type(left) == Expression:
left = left.run()
if type(right) == Expression:
right = right.run()
left_typ... | somebody1234/Charcoal | [
189,
8,
189,
1,
1475454499
] |
def Incremented(item):
if isinstance(item, float) or isinstance(item, int):
return round(item + 1, 15)
if isinstance(item, Expression):
item = item.run()
if isinstance(item, String):
item = str(item)
if isinstance(item, str):
item = float(item) if "." in item else int(ite... | somebody1234/Charcoal | [
189,
8,
189,
1,
1475454499
] |
def Doubled(item):
if isinstance(item, float) or isinstance(item, int):
return round(item * 2, 15)
if isinstance(item, Expression):
item = item.run()
if isinstance(item, String):
item = str(item)
if isinstance(item, str):
item = float(item) if "." in item else int(item)
... | somebody1234/Charcoal | [
189,
8,
189,
1,
1475454499
] |
def Lower(item):
if isinstance(item, int) or isinstance(item, float):
return str(item)
if isinstance(item, str):
return item.lower()
if isinstance(item, Expression):
item = item.run()
if isinstance(item, String):
item = String(str(item).lower())
if isinstance(item, st... | somebody1234/Charcoal | [
189,
8,
189,
1,
1475454499
] |
def Max(item):
if isinstance(item, int) or isinstance(item, float):
return ceil(item)
if isinstance(item, str):
return chr(max(map(ord, item)))
if isinstance(item, Expression):
item = item.run()
if isinstance(item, String):
item = String(str(item).lower())
if isinstan... | somebody1234/Charcoal | [
189,
8,
189,
1,
1475454499
] |
def direction(dir):
if isinstance(dir, String):
dir = str(dir)
cls = type(dir)
if cls == Direction:
return dir
elif cls == int:
return [
Direction.right, Direction.up_right, Direction.up,
Direction.up_left, Direction.left, Direction.down_left,
... | somebody1234/Charcoal | [
189,
8,
189,
1,
1475454499
] |
def valid_module(m):
return m.endswith(".py") and not (m.startswith(u"_") or m in ["sem_module.py", "pipeline.py"]) | YoannDupont/SEM | [
24,
7,
24,
1,
1479070118
] |
def banter():
def username():
import os
return os.environ.get("USERNAME", os.environ.get("USER", os.path.split(os.path.expanduser(u"~"))[-1]))
import random
l = [
u"Do thou mockest me?",
u"Try again?",
u"I'm sorry {0}, I'm afraid I can'... | YoannDupont/SEM | [
24,
7,
24,
1,
1479070118
] |
def font(self):
"""
Sets this legend group's title font. | plotly/plotly.py | [
13052,
2308,
13052,
1319,
1385013188
] |
def font(self, val):
self["font"] = val | plotly/plotly.py | [
13052,
2308,
13052,
1319,
1385013188
] |
def text(self):
"""
Sets the title of the legend group. | plotly/plotly.py | [
13052,
2308,
13052,
1319,
1385013188
] |
def text(self, val):
self["text"] = val | plotly/plotly.py | [
13052,
2308,
13052,
1319,
1385013188
] |
def _prop_descriptions(self):
return """\
font
Sets this legend group's title font.
text
Sets the title of the legend group.
""" | plotly/plotly.py | [
13052,
2308,
13052,
1319,
1385013188
] |
def __init__(
self,
code: str,
short_desc: str,
context: str,
*parameters: Iterable[str], | GreenSteam/pep257 | [
1019,
188,
1019,
111,
1328030303
] |
def set_context(self, definition: Definition, explanation: str) -> None:
"""Set the source code context for this error."""
self.definition = definition
self.explanation = explanation | GreenSteam/pep257 | [
1019,
188,
1019,
111,
1328030303
] |
def message(self) -> str:
"""Return the message to print to the user."""
ret = f'{self.code}: {self.short_desc}'
if self.context is not None:
specific_error_msg = self.context.format(*self.parameters)
ret += f' ({specific_error_msg})'
return ret | GreenSteam/pep257 | [
1019,
188,
1019,
111,
1328030303
] |
def lines(self) -> str:
"""Return the source code lines for this error."""
if self.definition is None:
return ''
source = ''
lines = self.definition.source.splitlines(keepends=True)
offset = self.definition.start # type: ignore
lines_stripped = list(
... | GreenSteam/pep257 | [
1019,
188,
1019,
111,
1328030303
] |
def __repr__(self) -> str:
return str(self) | GreenSteam/pep257 | [
1019,
188,
1019,
111,
1328030303
] |
def __init__(self, prefix: str, name: str) -> None:
"""Initialize the object.
`Prefix` should be the common prefix for errors in this group,
e.g., "D1".
`name` is the name of the group (its subject).
"""
self.prefix = prefix
self.name... | GreenSteam/pep257 | [
1019,
188,
1019,
111,
1328030303
] |
def create_group(cls, prefix: str, name: str) -> ErrorGroup:
"""Create a new error group and return it."""
group = cls.ErrorGroup(prefix, name)
cls.groups.append(group)
return group | GreenSteam/pep257 | [
1019,
188,
1019,
111,
1328030303
] |
def get_error_codes(cls) -> Iterable[str]:
"""Yield all registered codes."""
for group in cls.groups:
for error in group.errors:
yield error.code | GreenSteam/pep257 | [
1019,
188,
1019,
111,
1328030303
] |
def to_rst(cls) -> str:
"""Output the registry as reStructuredText, for documentation."""
max_len = max(
len(error.short_desc)
for group in cls.groups
for error in group.errors
)
sep_line = '+' + 6 * '-' + '+' + '-' * (max_len + 2) + '+\n'
blan... | GreenSteam/pep257 | [
1019,
188,
1019,
111,
1328030303
] |
def __getattr__(self, item: str) -> Any:
return self[item] | GreenSteam/pep257 | [
1019,
188,
1019,
111,
1328030303
] |
def __init__(self, name, provider):
NamedEntity.__init__(self, name)
self.provider = provider | stlemme/python-dokuwiki-export | [
1,
1,
1,
1,
1378815092
] |
def _import(name):
"""Think call so we can mock it during testing"""
return __import__(name) | pytest-dev/pytest-qt | [
325,
67,
325,
29,
1361921626
] |
def __init__(self):
self._import_errors = {} | pytest-dev/pytest-qt | [
325,
67,
325,
29,
1361921626
] |
def _guess_qt_api(self): # pragma: no cover
def _can_import(name):
try:
_import(name)
return True
except ModuleNotFoundError as e:
self._import_errors[name] = str(e)
return False
# Note, not importing only the root... | pytest-dev/pytest-qt | [
325,
67,
325,
29,
1361921626
] |
def _import_module(module_name):
m = __import__(_root_module, globals(), locals(), [module_name], 0)
return getattr(m, module_name) | pytest-dev/pytest-qt | [
325,
67,
325,
29,
1361921626
] |
def _check_qt_api_version(self):
if not self.is_pyqt:
# We support all PySide versions
return
if self.QtCore.PYQT_VERSION == 0x060000: # 6.0.0
raise pytest.UsageError(
"PyQt 6.0 is not supported by pytest-qt, use 6.1+ instead."
)
... | pytest-dev/pytest-qt | [
325,
67,
325,
29,
1361921626
] |
def get_versions(self):
if self.pytest_qt_api == "pyside6":
import PySide6
version = PySide6.__version__
return VersionTuple(
"PySide6", version, self.QtCore.qVersion(), self.QtCore.__version__
)
elif self.pytest_qt_api == "pyside2":
... | pytest-dev/pytest-qt | [
325,
67,
325,
29,
1361921626
] |
def __repr__(self):
return format_repr(self, 'user_id', 'category_id', 'score', is_ignored=False) | indico/indico | [
1446,
358,
1446,
649,
1311774990
] |
def returnReplyToQuerier( error ="" ):
"""
@summary : Prints an empty reply so that the receiving web page will
not modify it's display. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def generateWebPage( images, lang ):
"""
@summary : Generates a web page that simply displays a
series of images one on top of the other. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getImagesLangFromForm():
"""
@summary : Parses form with whom this program was called. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def main():
"""
@summary : Generate an html page displaying all the image received in parameter.
Replies to the querier after generating web page so that querier
is informed the page was generated.
"""
images, lang = getImagesLangFromForm()
#print ima... | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def __init__(self,
cards,
atr=None,
type=types.TYPE_USIM,
mode=SIMTRACE_ONLINE):
self.loggingApdu = self.setupLogger()
if LOG_NONE_APDU_IN_FILE:
self.logging = self.loggingApdu
else:
self.logging = loggin... | kamwar/simLAB | [
74,
31,
74,
4,
1461177205
] |
def usbCtrlOut(self, req, buf):
if self.mode == SIMTRACE_OFFLINE:
return []
return self.dev.ctrl_transfer(0x40,
bRequest=req, # R-APDU
data_or_wLength=buf,
timeout=500) | kamwar/simLAB | [
74,
31,
74,
4,
1461177205
] |
def receiveData(self, cmd):
if self.mode == SIMTRACE_OFFLINE:
return []
try:
return self.usbCtrlIn(cmd)
except:
time.sleep(0.2)
return self.usbCtrlIn(cmd) | kamwar/simLAB | [
74,
31,
74,
4,
1461177205
] |
def resetCards(self, soft=True):
if soft:
resetThread = ResetThread(self)
resetThread.setDaemon(True)
# Start handling C-APDUs.
resetThread.start()
else:
for cardDict in self.cardsDict:
cardDict[MAIN_INTERFACE].reset() | kamwar/simLAB | [
74,
31,
74,
4,
1461177205
] |
def sendResponseApdu(self, msg):
self.sendData(msg) | kamwar/simLAB | [
74,
31,
74,
4,
1461177205
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.