text
stringlengths
0
1.05M
meta
dict
import os from functools import partial import pytest from elasticapm.conf import constants from elasticapm.utils import ( get_name_from_func, get_url_dict, read_pem_file, sanitize_url, starmatch_to_regex, url_to_destination, ) from elasticapm.utils.deprecation import deprecated try: fro...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/utils/tests.py", "copies": "1", "size": "7557", "license": "bsd-3-clause", "hash": 8212375835859125000, "line_mean": 30.356846473, "line_max": 110, "alpha_frac": 0.5785364563, "autogenerated": false, "ratio": 3.5346117867165576, "config...
import os import re CGROUP_PATH = "/proc/self/cgroup" SYSTEMD_SCOPE_SUFFIX = ".scope" kubepods_regexp = re.compile( r"(?:^/kubepods[\S]*/pod([^/]+)$)|(?:^/kubepods\.slice/(kubepods-[^/]+\.slice/)?kubepods[^/]*-pod([^/]+)\.slice$)" ) container_id_regexp = re.compile( "^(?:[0-9a-f]{64}|[0-9a-f]{8}-[0-9a-f]{4...
{ "repo_name": "beniwohli/apm-agent-python", "path": "elasticapm/utils/cgroup.py", "copies": "1", "size": "4432", "license": "bsd-3-clause", "hash": 2810033636795195000, "line_mean": 40.4205607477, "line_max": 123, "alpha_frac": 0.6617779783, "autogenerated": false, "ratio": 3.5342902711323765, ...
import os import mock import pytest import elasticapm from elasticapm.conf.constants import ERROR, KEYWORD_MAX_LENGTH from elasticapm.utils import compat, encoding from tests.utils.stacks import get_me_more_test_frames def test_explicit_message_on_exception_event(elasticapm_client): try: raise ValueErr...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/client/exception_tests.py", "copies": "1", "size": "15734", "license": "bsd-3-clause", "hash": -163819178885008000, "line_mean": 39.6563307494, "line_max": 115, "alpha_frac": 0.6809457226, "autogenerated": false, "ratio": 3.67016561698157...
import os import pytest from elasticapm.conf.constants import TRANSACTION from elasticapm.instrumentation.packages.pymssql import get_host_port from elasticapm.utils import default_ports pymssql = pytest.importorskip("pymssql") pytestmark = [pytest.mark.pymssql] if "MSSQL_HOST" not in os.environ: pytestmark....
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/instrumentation/pymssql_tests.py", "copies": "1", "size": "5395", "license": "bsd-3-clause", "hash": 4334765124516448000, "line_mean": 38.962962963, "line_max": 104, "alpha_frac": 0.6637627433, "autogenerated": false, "ratio": 3.870157819...
import os import pytest from elasticapm.conf.constants import TRANSACTION from elasticapm.traces import capture_span pylibmc = pytest.importorskip("pylibmc") pytestmark = [pytest.mark.pylibmc] if "MEMCACHED_HOST" not in os.environ: pytestmark.append(pytest.mark.skip("Skipping pylibmc tests, no MEMCACHED_HOST ...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/instrumentation/pylibmc_tests.py", "copies": "1", "size": "3690", "license": "bsd-3-clause", "hash": 7886026676889988000, "line_mean": 40, "line_max": 109, "alpha_frac": 0.6956639566, "autogenerated": false, "ratio": 3.731041456016178, ...
import pytest # isort:skip aiohttp = pytest.importorskip("aiohttp") # isort:skip import mock from multidict import MultiDict import elasticapm from elasticapm import async_capture_span from elasticapm.conf import constants from elasticapm.contrib.aiohttp import ElasticAPM from elasticapm.contrib.aiohttp.middlewar...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/contrib/asyncio/aiohttp_web_tests.py", "copies": "1", "size": "8113", "license": "bsd-3-clause", "hash": -7722702032495204000, "line_mean": 39.9747474747, "line_max": 113, "alpha_frac": 0.7104646863, "autogenerated": false, "ratio": 3.643...
import pytest # isort:skip flask = pytest.importorskip("flask") # isort:skip celery = pytest.importorskip("celery") # isort:skip import mock from elasticapm.conf.constants import ERROR, TRANSACTION pytestmark = [pytest.mark.celery, pytest.mark.flask] def test_task_failure(flask_celery): apm_client = flask...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/contrib/celery/flask_tests.py", "copies": "1", "size": "3202", "license": "bsd-3-clause", "hash": -3086964921144654300, "line_mean": 39.025, "line_max": 84, "alpha_frac": 0.7292317302, "autogenerated": false, "ratio": 4.0025, "config_te...
import pytest # isort:skip opentracing = pytest.importorskip("opentracing") # isort:skip import sys import mock from opentracing import Format import elasticapm from elasticapm.conf import constants from elasticapm.contrib.opentracing import Tracer from elasticapm.contrib.opentracing.span import OTSpanContext fr...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/contrib/opentracing/tests.py", "copies": "1", "size": "12355", "license": "bsd-3-clause", "hash": -4322840258052077000, "line_mean": 38.5993589744, "line_max": 115, "alpha_frac": 0.6794010522, "autogenerated": false, "ratio": 3.4224376731...
import pytest # isort:skip pytest.importorskip("cassandra") # isort:skip import os import socket from cassandra.cluster import Cluster from cassandra.query import SimpleStatement from elasticapm.conf.constants import TRANSACTION from elasticapm.instrumentation.packages.dbapi2 import extract_signature pytestmark...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/instrumentation/cassandra_tests.py", "copies": "1", "size": "6423", "license": "bsd-3-clause", "hash": 8677407193698500000, "line_mean": 38.1646341463, "line_max": 121, "alpha_frac": 0.7059006695, "autogenerated": false, "ratio": 3.911693...
import pytest # isort:skip pytest.importorskip("elasticsearch") # isort:skip import json import os from elasticsearch import VERSION as ES_VERSION from elasticsearch import Elasticsearch from elasticsearch.serializer import JSONSerializer from elasticapm.conf.constants import TRANSACTION from elasticapm.utils im...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/instrumentation/elasticsearch_tests.py", "copies": "1", "size": "22468", "license": "bsd-3-clause", "hash": -5278299923598440000, "line_mean": 41.3924528302, "line_max": 120, "alpha_frac": 0.6584920776, "autogenerated": false, "ratio": 3....
import pytest # isort:skip pytest.importorskip("flask") # isort:skip import logging import os import mock from elasticapm.conf import constants from elasticapm.conf.constants import ERROR, TRANSACTION from elasticapm.contrib.flask import ElasticAPM from elasticapm.utils import compat from elasticapm.utils.disttr...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/contrib/flask/flask_tests.py", "copies": "1", "size": "19038", "license": "bsd-3-clause", "hash": -6255384880563079000, "line_mean": 39.6794871795, "line_max": 118, "alpha_frac": 0.6715516336, "autogenerated": false, "ratio": 3.4944933920...
import pytest # isort:skip pytest.importorskip("httpx") # isort:skip import httpx from httpx import InvalidURL from elasticapm.conf import constants from elasticapm.conf.constants import TRANSACTION from elasticapm.traces import capture_span from elasticapm.utils import compat from elasticapm.utils.disttracing im...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/instrumentation/httpx_tests.py", "copies": "1", "size": "7315", "license": "bsd-3-clause", "hash": -4874697416994192000, "line_mean": 42.5416666667, "line_max": 111, "alpha_frac": 0.7197539303, "autogenerated": false, "ratio": 3.770618556...
import pytest # isort:skip pytest.importorskip("twisted") # isort:skip from twisted.python.failure import Failure from elasticapm.conf.constants import ERROR from elasticapm.contrib.twisted import LogObserver pytestmark = pytest.mark.twisted def test_twisted_log_observer(elasticapm_client): observer = LogO...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/contrib/twisted/tests.py", "copies": "1", "size": "2274", "license": "bsd-3-clause", "hash": -3970581154759454000, "line_mean": 40.3454545455, "line_max": 81, "alpha_frac": 0.7576956904, "autogenerated": false, "ratio": 4.274436090225564,...
import sqlite3 from elasticapm.conf.constants import TRANSACTION def test_connect(instrument, elasticapm_client): elasticapm_client.begin_transaction("transaction.test") sqlite3.connect(":memory:") elasticapm_client.end_transaction("MyView") transactions = elasticapm_client.events[TRANSACTION] ...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/instrumentation/sqlite_tests.py", "copies": "1", "size": "5786", "license": "bsd-3-clause", "hash": -2460819182310716000, "line_mean": 39.1805555556, "line_max": 94, "alpha_frac": 0.6851019703, "autogenerated": false, "ratio": 3.685350318...
import sys from elasticapm.utils.module_import import import_string _cls_register = { "elasticapm.instrumentation.packages.botocore.BotocoreInstrumentation", "elasticapm.instrumentation.packages.httpx.HttpxClientInstrumentation", "elasticapm.instrumentation.packages.jinja2.Jinja2Instrumentation", "el...
{ "repo_name": "beniwohli/apm-agent-python", "path": "elasticapm/instrumentation/register.py", "copies": "1", "size": "5469", "license": "bsd-3-clause", "hash": -279583116311008260, "line_mean": 54.2424242424, "line_max": 103, "alpha_frac": 0.7915523862, "autogenerated": false, "ratio": 4.15893536...
from elasticapm.conf import constants from elasticapm.instrumentation.packages.base import AbstractInstrumentedModule from elasticapm.traces import DroppedSpan, capture_span, execution_context from elasticapm.utils import compat, default_ports, sanitize_url, url_to_destination from elasticapm.utils.disttracing import...
{ "repo_name": "beniwohli/apm-agent-python", "path": "elasticapm/instrumentation/packages/urllib.py", "copies": "1", "size": "5436", "license": "bsd-3-clause", "hash": 6757879864624958000, "line_mean": 43.1951219512, "line_max": 103, "alpha_frac": 0.6865342163, "autogenerated": false, "ratio": 4.1...
from elasticapm.instrumentation.packages.dbapi2 import ( ConnectionProxy, CursorProxy, DbApi2Instrumentation, extract_signature, ) from elasticapm.utils import default_ports class MySQLCursorProxy(CursorProxy): provider_name = "mysql" def extract_signature(self, sql): return extract...
{ "repo_name": "beniwohli/apm-agent-python", "path": "elasticapm/instrumentation/packages/mysql_connector.py", "copies": "1", "size": "2569", "license": "bsd-3-clause", "hash": 7399017138885704000, "line_mean": 39.7777777778, "line_max": 96, "alpha_frac": 0.737251849, "autogenerated": false, "rati...
from __future__ import absolute_import import contextvars from elasticapm.context.base import BaseContext class ContextVarsContext(BaseContext): elasticapm_transaction_var = contextvars.ContextVar("elasticapm_transaction_var") elasticapm_span_var = contextvars.ContextVar("elasticapm_span_var") def ge...
{ "repo_name": "beniwohli/apm-agent-python", "path": "elasticapm/context/contextvars.py", "copies": "1", "size": "2529", "license": "bsd-3-clause", "hash": 2737223315485008400, "line_mean": 37.9076923077, "line_max": 85, "alpha_frac": 0.7330960854, "autogenerated": false, "ratio": 4.35283993115318...
from twisted.logger import ILogObserver from zope.interface import implementer from elasticapm.base import Client @implementer(ILogObserver) class LogObserver(object): """ A twisted log observer for Elastic APM. Eg.: from elasticapm.base import Client from twisted.logger import Logger cli...
{ "repo_name": "beniwohli/apm-agent-python", "path": "elasticapm/contrib/twisted/__init__.py", "copies": "1", "size": "2462", "license": "bsd-3-clause", "hash": -2551512516198542000, "line_mean": 36.8769230769, "line_max": 112, "alpha_frac": 0.7250203087, "autogenerated": false, "ratio": 4.3730017...
from werkzeug.exceptions import ClientDisconnected from elasticapm.conf import constants from elasticapm.utils import compat, get_url_dict from elasticapm.utils.wsgi import get_environ, get_headers def get_data_from_request(request, config, event_type): result = { "env": dict(get_environ(request.enviro...
{ "repo_name": "beniwohli/apm-agent-python", "path": "elasticapm/contrib/flask/utils.py", "copies": "1", "size": "3683", "license": "bsd-3-clause", "hash": -2447981097690520600, "line_mean": 42.8452380952, "line_max": 105, "alpha_frac": 0.6749932121, "autogenerated": false, "ratio": 4.282558139534...
import logging from django.template.base import Node from elasticapm.utils.stacks import get_frame_info try: from django.template.base import Template except ImportError: class Template(object): pass def iterate_with_template_sources( frames, with_locals=True, library_frame_context_l...
{ "repo_name": "beniwohli/apm-agent-python", "path": "elasticapm/contrib/django/utils.py", "copies": "1", "size": "3925", "license": "bsd-3-clause", "hash": 43453454699107096, "line_mean": 41.2043010753, "line_max": 111, "alpha_frac": 0.6489171975, "autogenerated": false, "ratio": 4.49599083619702...
import os import mock import pytest import urllib3.poolmanager from urllib3.exceptions import MaxRetryError, TimeoutError from elasticapm.conf import constants from elasticapm.transport.exceptions import TransportException from elasticapm.transport.http import Transport from elasticapm.utils import compat try: ...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/transports/test_urllib3.py", "copies": "1", "size": "14584", "license": "bsd-3-clause", "hash": -1026546961873067000, "line_mean": 40.908045977, "line_max": 116, "alpha_frac": 0.6876714207, "autogenerated": false, "ratio": 3.6940222897669...
import pytest from elasticapm.conf.constants import TRANSACTION from elasticapm.traces import capture_span graphene = pytest.importorskip("graphene") graphql = pytest.importorskip("graphql") pytestmark = pytest.mark.graphene class Success(graphene.ObjectType): yeah = graphene.String(required=True) class Er...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/instrumentation/graphql_tests.py", "copies": "1", "size": "4896", "license": "bsd-3-clause", "hash": 6470997379109999000, "line_mean": 33.7234042553, "line_max": 118, "alpha_frac": 0.7087418301, "autogenerated": false, "ratio": 3.85208497...
import sys import elasticapm.context from elasticapm.context.threadlocal import ThreadLocalContext def test_execution_context_backing(): execution_context = elasticapm.context.init_execution_context() if sys.version_info[0] == 3 and sys.version_info[1] >= 7: from elasticapm.context.contextvars imp...
{ "repo_name": "beniwohli/apm-agent-python", "path": "tests/context/test_context.py", "copies": "1", "size": "2468", "license": "bsd-3-clause", "hash": -3873893397538811400, "line_mean": 43.8727272727, "line_max": 85, "alpha_frac": 0.7690437601, "autogenerated": false, "ratio": 4.391459074733096, ...
import threading from elasticapm.context.base import BaseContext class ThreadLocalContext(BaseContext): thread_local = threading.local() thread_local.transaction = None thread_local.span = None def get_transaction(self, clear=False): """ Get the transaction registered for the curre...
{ "repo_name": "beniwohli/apm-agent-python", "path": "elasticapm/context/threadlocal.py", "copies": "1", "size": "2434", "license": "bsd-3-clause", "hash": 3186549276487586300, "line_mean": 37.03125, "line_max": 81, "alpha_frac": 0.7337715694, "autogenerated": false, "ratio": 4.46605504587156, "...
""" This module implements WSGI related helpers adapted from ``werkzeug.wsgi`` :copyright: (c) 2010 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ from elasticapm.utils import compat try: from urllib import quote except ImportError: from urllib.parse impo...
{ "repo_name": "beniwohli/apm-agent-python", "path": "elasticapm/utils/wsgi.py", "copies": "1", "size": "5031", "license": "bsd-3-clause", "hash": 3097882667887082000, "line_mean": 38.3046875, "line_max": 105, "alpha_frac": 0.6676605049, "autogenerated": false, "ratio": 3.958300550747443, "confi...
"""Provides classes to instrument dbapi2 providers https://www.python.org/dev/peps/pep-0249/ """ import re from elasticapm.instrumentation.packages.base import AbstractInstrumentedModule from elasticapm.traces import capture_span from elasticapm.utils import compat, wrapt from elasticapm.utils.encoding import force...
{ "repo_name": "beniwohli/apm-agent-python", "path": "elasticapm/instrumentation/packages/dbapi2.py", "copies": "1", "size": "9948", "license": "bsd-3-clause", "hash": 5266316686702867000, "line_mean": 35.0434782609, "line_max": 119, "alpha_frac": 0.6056493768, "autogenerated": false, "ratio": 4.1...
"""Code for ResNet. Adapted from https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py """ import math import torch.nn as nn import torch.utils.model_zoo as model_zoo from torchvision.models.resnet import BasicBlock from torchvision.models.vgg import cfg, model_urls, VGG class ResNet(nn.Module...
{ "repo_name": "google/graph_distillation", "path": "third_party/pytorch/get_cnn.py", "copies": "1", "size": "3968", "license": "apache-2.0", "hash": -4396732771664096000, "line_mean": 30.4920634921, "line_max": 79, "alpha_frac": 0.6605342742, "autogenerated": false, "ratio": 3.220779220779221, ...
import lasagne import quantization as q import quantized_net as qn def genCnv(input, num_outputs, learning_parameters): # A function to generate the cnv network topology which matches the overlay for the Pynq board. # WARNING: If you change this file, it's likely the resultant weights will not fit on the Pynq...
{ "repo_name": "Xilinx/BNN-PYNQ", "path": "bnn/src/training/cnv.py", "copies": "1", "size": "8127", "license": "bsd-3-clause", "hash": -2773586619946016000, "line_mean": 33.0041841004, "line_max": 107, "alpha_frac": 0.5765965301, "autogenerated": false, "ratio": 4.11493670886076, "config_test": ...
import lasagne import quantization as q import quantized_net as qn def genLfc(input, num_outputs, learning_parameters): # A function to generate the lfc network topology which matches the overlay for the Pynq board. # WARNING: If you change this file, it's likely the resultant weights will not fit on the Pynq...
{ "repo_name": "Xilinx/BNN-PYNQ", "path": "bnn/src/training/lfc.py", "copies": "1", "size": "4117", "license": "bsd-3-clause", "hash": -4570189370777603000, "line_mean": 38.5865384615, "line_max": 107, "alpha_frac": 0.6631042021, "autogenerated": false, "ratio": 4.192464358452138, "config_test":...
from __future__ import print_function import sys import os import time from argparse import ArgumentParser import numpy as np np.random.seed(1234) # for reproducibility # specifying the gpu to use # import theano.sandbox.cuda # theano.sandbox.cuda.use('gpu1') import theano import theano.tensor as T import lasagn...
{ "repo_name": "Xilinx/BNN-PYNQ", "path": "bnn/src/training/mnist.py", "copies": "1", "size": "7721", "license": "bsd-3-clause", "hash": -5452925896018380000, "line_mean": 37.605, "line_max": 126, "alpha_frac": 0.677632431, "autogenerated": false, "ratio": 3.4936651583710407, "config_test": true...
import numpy as np import scipy.ndimage as ndimg def linear_rotations(X, Y, angles, original=True): Xo = np.copy(X) Yo = np.copy(Y) i = 0 for angle in angles: Xtmp = ndimg.rotate(Xo, angle, prefilter=False, mode='nearest', axes=(2,3), reshape=False) Ytmp = np.copy(Yo) if not or...
{ "repo_name": "Xilinx/BNN-PYNQ", "path": "bnn/src/training/augmentors.py", "copies": "1", "size": "3607", "license": "bsd-3-clause", "hash": 7348121904898430000, "line_mean": 37.3723404255, "line_max": 136, "alpha_frac": 0.6307180482, "autogenerated": false, "ratio": 3.3836772983114445, "config...
import theano import theano.tensor as T import numpy as np from functools import partial from theano.scalar.basic import UnaryScalarOp, same_out_nocomplex from theano.tensor.elemwise import Elemwise # Our own rounding function, that does not set the gradient to 0 like Theano's class Round3(UnaryScalarOp): d...
{ "repo_name": "Xilinx/BNN-PYNQ", "path": "bnn/src/training/quantization.py", "copies": "1", "size": "5758", "license": "bsd-3-clause", "hash": 1279140318710156300, "line_mean": 36.6339869281, "line_max": 135, "alpha_frac": 0.6877387982, "autogenerated": false, "ratio": 3.569745815251085, "confi...
import time from collections import OrderedDict import numpy as np # specifying the gpu to use # import theano.sandbox.cuda # theano.sandbox.cuda.use('gpu1') import theano import theano.tensor as T import lasagne from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams import augmentors # a class ...
{ "repo_name": "Xilinx/BNN-PYNQ", "path": "bnn/src/training/quantized_net.py", "copies": "1", "size": "11235", "license": "bsd-3-clause", "hash": -1735805022909202400, "line_mean": 34.3301886792, "line_max": 158, "alpha_frac": 0.5893190921, "autogenerated": false, "ratio": 3.6811926605504586, "c...
# Copyright (c) 2020, Xilinx # All rights reserved. # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the followin...
{ "repo_name": "Xilinx/BNN-PYNQ", "path": "bnn/src/training/mnist-gen-weights-W1A2.py", "copies": "1", "size": "2559", "license": "bsd-3-clause", "hash": 9147194519432233000, "line_mean": 40.9508196721, "line_max": 99, "alpha_frac": 0.7268464244, "autogenerated": false, "ratio": 3.7577092511013217...
import tkinter as tk import tkinter.ttk as ttk from tkinter import PhotoImage import os import glob colors = { #~ "frame": "#9ee874", # a green color for testing etc #~ "disabledfg": "#9ee874", #~ "selectbg": "#9ee874", #~ "selectfg": "#9ee874" "frame": "#efefef", "disabledfg": "#aaaaaa", "selectbg": "#657a9e...
{ "repo_name": "timeyyy/tttt", "path": "tttt/button_styling.py", "copies": "1", "size": "3449", "license": "bsd-3-clause", "hash": 1470057812523053800, "line_mean": 35.6914893617, "line_max": 96, "alpha_frac": 0.6729486808, "autogenerated": false, "ratio": 3.505081300813008, "config_test": false...
from engine.modem import Modem import time # # this modem lets us do unit testing # class CompletedException(Exception): pass class MockModem(Modem): def __init__(self, prog): self.org = time.time() self.prog = prog def poll(self): # play back programmed modem commands now = t...
{ "repo_name": "benjaveri/phonescreen", "path": "v2/test/mock_modem.py", "copies": "1", "size": "1242", "license": "bsd-3-clause", "hash": -5932192162618214000, "line_mean": 27.2272727273, "line_max": 72, "alpha_frac": 0.5458937198, "autogenerated": false, "ratio": 3.9056603773584904, "config_te...
from test.mock_modem import MockModem, CompletedException from engine.database import Database from engine.sm import StateMachine # # set up test environment # # modem program REDIAL_WINDOW = 1 prog = [ # blacklist test { "at": 1.0, "from":"408--black", "expect":"block" }, # whitelist test { "at": 1.5...
{ "repo_name": "benjaveri/phonescreen", "path": "v2/test.py", "copies": "1", "size": "2193", "license": "bsd-3-clause", "hash": 8529163217910860000, "line_mean": 27.4805194805, "line_max": 76, "alpha_frac": 0.5950752394, "autogenerated": false, "ratio": 3.0714285714285716, "config_test": true, ...
from v1.interfaces import * from v1.core import * DBPATH = ":memory:" REDIAL_TIMEOUT = 3 #s class CompletedException(Exception): pass class FakeModem(Modem): def __init__(self): self.buf = [] self.org = time.time() self.pgm = [ # blacklist test { "at": 1.0,...
{ "repo_name": "benjaveri/phonescreen", "path": "v1/unit_test.py", "copies": "1", "size": "3075", "license": "bsd-3-clause", "hash": 1237649419970552600, "line_mean": 31.3684210526, "line_max": 76, "alpha_frac": 0.5313821138, "autogenerated": false, "ratio": 3.626179245283019, "config_test": fal...
import serial,sys,os.path # pip install pyserial from v1.interfaces import * from v1.core import * if len(sys.argv) != 3: print "main.py <path for database> <serial port>" sys.exit(1) ECHO = False PATH = sys.argv[1] PORT = sys.argv[2] DBPATH = os.path.join(PATH,"numbers.sqlite") REDIAL_TIMEOUT = 60 #...
{ "repo_name": "benjaveri/phonescreen", "path": "v1/main.py", "copies": "1", "size": "1354", "license": "bsd-3-clause", "hash": -9027892066148085000, "line_mean": 24.0740740741, "line_max": 64, "alpha_frac": 0.576070901, "autogenerated": false, "ratio": 3.2161520190023754, "config_test": false, ...
import sqlite3, time # log states LS_IDLE = "idle" LS_BLOCK = "blacklist" LS_PMODE = "pmode" LS_HALT = "halt" # # database abstraction # class Database: def __init__(self,filename): self.filename = filename self.conn = sqlite3.connect(filename) def __enter__(self): self.crsr = self....
{ "repo_name": "benjaveri/phonescreen", "path": "v2/engine/database.py", "copies": "1", "size": "2567", "license": "bsd-3-clause", "hash": 6399832961646292000, "line_mean": 33.2266666667, "line_max": 127, "alpha_frac": 0.5816127776, "autogenerated": false, "ratio": 3.9922239502332815, "config_te...
import sys, re from engine.database import Database # blacklist.py [del|delete|remove] [number] def clean(s): return re.sub(' +', ' ', s.strip()) try: PRIMARY = "blacklist" SECONDARY = "whitelist" REMOVE = (len(sys.argv) > 2) and sys.argv[1] in ["del","delete","remove"] NUMBER = (sys.argv[2] if R...
{ "repo_name": "benjaveri/phonescreen", "path": "v2/blacklist.py", "copies": "1", "size": "1336", "license": "bsd-3-clause", "hash": 8589221947601320000, "line_mean": 32.4, "line_max": 97, "alpha_frac": 0.6167664671, "autogenerated": false, "ratio": 3.399491094147583, "config_test": false, "ha...
import sys, re from engine.database import Database # whitelist.py [del|delete|remove] [number] def clean(s): return re.sub(' +', ' ', s.strip()) try: PRIMARY = "whitelist" SECONDARY = "blacklist" REMOVE = (len(sys.argv) > 2) and sys.argv[1] in ["del","delete","remove"] NUMBER = (sys.argv[2] if R...
{ "repo_name": "benjaveri/phonescreen", "path": "v2/whitelist.py", "copies": "1", "size": "1336", "license": "bsd-3-clause", "hash": 7993572665742935000, "line_mean": 32.4, "line_max": 97, "alpha_frac": 0.6167664671, "autogenerated": false, "ratio": 3.399491094147583, "config_test": false, "ha...
import time class Core: def __init__(self,db,modem,redial_timeout): self.db = db self.modem = modem self.redial_timeout = redial_timeout with self.db as conn: conn.execute("CREATE TABLE IF NOT EXISTS props (id INTEGER PRIMARY KEY ASC,key TEXT UNIQUE,value TEXT)") ...
{ "repo_name": "benjaveri/phonescreen", "path": "v1/core.py", "copies": "1", "size": "4257", "license": "bsd-3-clause", "hash": -5073933172183871000, "line_mean": 42.8865979381, "line_max": 127, "alpha_frac": 0.4998825464, "autogenerated": false, "ratio": 4.78314606741573, "config_test": false, ...
import time, serial # pip install pyserial NEWLINE = "\r\n" HEALTH_CHECK_PERIOD = 60*60 # how often to check that modem is still alive class Modem: def poll(self): raise NotImplementedError def ring_through(self): raise NotImplementedError def answer_as_fax(self, sleep): raise NotImplementedError def ...
{ "repo_name": "benjaveri/phonescreen", "path": "v2/engine/modem.py", "copies": "1", "size": "2614", "license": "bsd-3-clause", "hash": 7281809342244389000, "line_mean": 25.9484536082, "line_max": 74, "alpha_frac": 0.5535577659, "autogenerated": false, "ratio": 3.6973125884016973, "config_test":...
"""BSDDB BTree-based Shelve OID Storage""" import bsddb, shelve, traceback, sys from twistedsnmp import oidstore, errors, pysnmpproto import struct, weakref OID = pysnmpproto.oid.OID if pysnmpproto.USE_STRING_OIDS: def oidToSortable( oid ): """Convert a dotted-format OID to a sortable string""" return "".join([ ...
{ "repo_name": "mmattice/TwistedSNMP", "path": "bsdoidstore.py", "copies": "1", "size": "4498", "license": "bsd-3-clause", "hash": -61109660027558160, "line_mean": 27.4683544304, "line_max": 71, "alpha_frac": 0.6809693197, "autogenerated": false, "ratio": 3.1698379140239608, "config_test": false...
from setuptools import setup, find_packages import sys, os import os.path as op HERE = op.dirname(__file__) README = open(op.join(HERE, 'README')).READ() setup(name='drslib', version=version, description="A library for extracting analytics from the ESGF system", long_description=README, , cla...
{ "repo_name": "stephenpascoe/esgf-analytics", "path": "setup.py", "copies": "1", "size": "1073", "license": "bsd-3-clause", "hash": -6266431222985474000, "line_mean": 28, "line_max": 95, "alpha_frac": 0.6411929171, "autogenerated": false, "ratio": 3.6621160409556315, "config_test": false, "ha...
from setuptools import setup, find_packages import sys, os __version__ = '0.1.4a2' __description__ = """ Metaconfig ========== Metaconfig is a library for centralising your Python's ConfigParser files. It is inspired by the logging module where it is increadibly easy to start writing code that depends on logging w...
{ "repo_name": "cedadev/metaconfig", "path": "setup.py", "copies": "1", "size": "1774", "license": "bsd-3-clause", "hash": -1571121698683913000, "line_mean": 28.5666666667, "line_max": 77, "alpha_frac": 0.6662908681, "autogenerated": false, "ratio": 4.004514672686231, "config_test": true, "has...
from setuptools import setup, find_packages import sys, os version = '0.3.1p3' drs_version = '0.28' setup(name='drslib', version=version, description="A library for processing the CMIP5 Data Reference Syntax", long_description="""\ This library supports the generation of paths and filenames corres...
{ "repo_name": "ESGF/esgf-drslib", "path": "setup.py", "copies": "1", "size": "1574", "license": "bsd-3-clause", "hash": -5517075854405684000, "line_mean": 31.7916666667, "line_max": 95, "alpha_frac": 0.6391359593, "autogenerated": false, "ratio": 3.3704496788008567, "config_test": false, "has...
""" A framework for translating DRS objects to and from filenames and paths. This module is very object-heavy and over engineered. However, it does the job. """ #!TODO: CORDEX. Completely reimplement translation in a more flexible manner # Maybe use the Python logic programming library used by IRIS. We sho...
{ "repo_name": "ESGF/esgf-drslib", "path": "drslib/translate.py", "copies": "1", "size": "19365", "license": "bsd-3-clause", "hash": -2792944269373414400, "line_mean": 29.2106084243, "line_max": 112, "alpha_frac": 0.5990188484, "autogenerated": false, "ratio": 3.7161773172135866, "config_test": ...
""" A translator specific to CMIP3 The CMIP3 translation code is less complete than CMIP5. It focuses on translating paths to DRS instances. 1. CMIP3 files or paths cannot be generated from DRS instances 2. the code doesn't use MIP tables to validate and deduce components """ import re import logging log = l...
{ "repo_name": "ESGF/esgf-drslib", "path": "drslib/cmip3.py", "copies": "1", "size": "9592", "license": "bsd-3-clause", "hash": -7830867715433713000, "line_mean": 29.5477707006, "line_max": 105, "alpha_frac": 0.5793369475, "autogenerated": false, "ratio": 3.3421602787456446, "config_test": false...
""" """ #!TODO: tidy this up and review what needs documenting. import os import sys import metaconfig config = metaconfig.get_config('drslib') ############################################################################## # Configure the location of MIP tables. # # This can be configured with the MIP_TABLE_P...
{ "repo_name": "ESGF/esgf-drslib", "path": "drslib/config.py", "copies": "1", "size": "6597", "license": "bsd-3-clause", "hash": 2861525471115010600, "line_mean": 23.8943396226, "line_max": 101, "alpha_frac": 0.6143701683, "autogenerated": false, "ratio": 3.5315845824411136, "config_test": true,...
''' The drs module contains a minimal model class for DRS information and some utility functions for converting filesystem paths to and from DRS objects. More sophisticated conversions can be done with the :mod:`drslib.translate` and :mod:`drslib.cmip5` modules. ''' import os import itertools import re from abc im...
{ "repo_name": "ESGF/esgf-drslib", "path": "drslib/drs.py", "copies": "1", "size": "16959", "license": "bsd-3-clause", "hash": 5992350760387457000, "line_mean": 29.947080292, "line_max": 113, "alpha_frac": 0.5755056312, "autogenerated": false, "ratio": 4.094398841139546, "config_test": false, ...
""" Simple parser for MIP tables. My interpretation of the format from reading the CMIP5 tables. """ import re from glob import glob import csv import logging log = logging.getLogger(__name__) entry_ids = ['axis_entry', 'variable_entry'] line_rexp = re.compile(r'(\w+):\s*(.*)') dquote = '"(?:""|[^"])*"' squote =...
{ "repo_name": "ESGF/esgf-drslib", "path": "drslib/mip_table.py", "copies": "1", "size": "8060", "license": "bsd-3-clause", "hash": -6118902066071691000, "line_mean": 25.4262295082, "line_max": 107, "alpha_frac": 0.559057072, "autogenerated": false, "ratio": 3.8601532567049808, "config_test": fa...
# -*- coding: utf-8 -*- # # drslib documentation build configuration file, created by # sphinx-quickstart on Thu Jul 8 11:22:21 2010. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All...
{ "repo_name": "ESGF/esgf-drslib", "path": "doc/conf.py", "copies": "1", "size": "7396", "license": "bsd-3-clause", "hash": 7857934502530055000, "line_mean": 31.4385964912, "line_max": 80, "alpha_frac": 0.7049756625, "autogenerated": false, "ratio": 3.71098845960863, "config_test": false, "has...
""" Bulk Generate DRS objects for testing. """ import random from copy import copy from datetime import datetime import os, sys import os.path as op from drslib.drs import CmipDRS from drslib import cmip5, config from itertools import izip # Python 2.5 compatibility try: from itertools import product except ...
{ "repo_name": "ESGF/esgf-drslib", "path": "test/gen_drs.py", "copies": "1", "size": "7015", "license": "bsd-3-clause", "hash": -7822207505014605000, "line_mean": 26.40234375, "line_max": 80, "alpha_frac": 0.5962936565, "autogenerated": false, "ratio": 3.3774675012036592, "config_test": false, ...
""" Generate mapfiles from streams of DRS objects """ #!TODO: check againsts similar code in datanode_admin and merge CHECKSUM_BLOCKSIZE = 2**20 import stat, os def write_mapfile(stream, fh, checksum_func=None): """ Write an esgpublish mapfile from a stream of tuples (filepath, drs). :param checksum...
{ "repo_name": "ESGF/esgf-drslib", "path": "drslib/mapfile.py", "copies": "1", "size": "1669", "license": "bsd-3-clause", "hash": 7074971919737047000, "line_mean": 23.9104477612, "line_max": 107, "alpha_frac": 0.6237267825, "autogenerated": false, "ratio": 3.5662393162393164, "config_test": fals...
""" Manage DRS directory structure versioning. This module provides an API for manipulating a DRS directory structure to facilitate keeping multiple versions of datasets on disk simultaniously. The class :class:`DRSTree` provides a top-level interface to the DRS directory structure and a container for :class:`Publis...
{ "repo_name": "ESGF/esgf-drslib", "path": "drslib/drs_tree.py", "copies": "1", "size": "12016", "license": "bsd-3-clause", "hash": -3840925594459336700, "line_mean": 33.6282420749, "line_max": 108, "alpha_frac": 0.5873002663, "autogenerated": false, "ratio": 3.9960093116062523, "config_test": f...
""" Statistics on dap requests """ import numpy import sys import re from dapbench.dap_request import DapRequest class DapStats(object): """ Container for OPeNDAP request statistics. """ def __init__(self): self.datasets = {} def get_cursor(self, dataset=None): if dataset is No...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/dap_stats.py", "copies": "1", "size": "5754", "license": "bsd-3-clause", "hash": -6630446582895862000, "line_mean": 29.6063829787, "line_max": 82, "alpha_frac": 0.5785540494, "autogenerated": false, "ratio": 4.227773695811903, "config_test": f...
""" Process a curl verbose log to capture OpenDAP requests. """ import re class DapRequest(object): def __init__(self, dataset, response, projection, subset): self.response = response self.dataset = dataset self.projection = projection self.subset = subset def __str__(self): ...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/dap_request.py", "copies": "1", "size": "1885", "license": "bsd-3-clause", "hash": -7810588819997025000, "line_mean": 29.9016393443, "line_max": 86, "alpha_frac": 0.5299734748, "autogenerated": false, "ratio": 4.027777777777778, "config_test":...
class ResponseCode(object): """ We only allow Response codes to be instances of ResponseCode The calling code must set them e.g. with status = Response.failure and can expect at a minimum that status.__nonzero__() will return True for success or False for failure. The implementation ...
{ "repo_name": "cedadev/mistamover", "path": "lib/Response.py", "copies": "1", "size": "4523", "license": "bsd-3-clause", "hash": -1729287051742294300, "line_mean": 27.9935897436, "line_max": 91, "alpha_frac": 0.6062347999, "autogenerated": false, "ratio": 4.168663594470046, "config_test": false...
from AbstractControlFile import * class ControlFile(AbstractControlFile): """ Simple class to read/write control file. Note read() and create() are in base class; encode() and decode() are helpers for them. Lines of control file are: magic1 data_file_name expected_size...
{ "repo_name": "cedadev/mistamover", "path": "lib/ControlFile.py", "copies": "1", "size": "1681", "license": "bsd-3-clause", "hash": -5026727638796916000, "line_mean": 24.8615384615, "line_max": 71, "alpha_frac": 0.6162998215, "autogenerated": false, "ratio": 3.40973630831643, "config_test": fal...
from AbstractControlFile import * class ThankyouFile(AbstractControlFile): """ Simple class to read/write thank you file. It contains the name of the receipt file that is being acknowledged. Lines of Thankyou file are: magic1 basename_for_receipt_file magic2 Note read()...
{ "repo_name": "cedadev/mistamover", "path": "lib/ThankyouFile.py", "copies": "1", "size": "1161", "license": "bsd-3-clause", "hash": 2778457417958082600, "line_mean": 22.22, "line_max": 72, "alpha_frac": 0.6296296296, "autogenerated": false, "ratio": 3.4864864864864864, "config_test": false, ...
from AbstractControlFile import * SUCCESS = 0 BAD_SIZE = 1 BAD_CKSUM = 2 IO_ERROR = 3 NO_SUCH_FILE = 4 status_description = { 0: "success", 1: "data file has bad size", 2: "data file has bad checksum", 3: "I/O error reading data file", ...
{ "repo_name": "cedadev/mistamover", "path": "lib/ReceiptFile.py", "copies": "1", "size": "2782", "license": "bsd-3-clause", "hash": -424600853882407200, "line_mean": 26.82, "line_max": 72, "alpha_frac": 0.6067577283, "autogenerated": false, "ratio": 3.7093333333333334, "config_test": false, "...
from BaseConfig import BaseConfig class GlobalConfig(BaseConfig): """ A configuration-file object based on BaseConfig with the added feature of some compulsory variables which are relevant to stager global configuration """ def reread(self): BaseConfig.readDefaults(self) BaseConf...
{ "repo_name": "cedadev/mistamover", "path": "lib/Config/GlobalConfig.py", "copies": "1", "size": "1033", "license": "bsd-3-clause", "hash": -7535833031696333000, "line_mean": 28.5142857143, "line_max": 79, "alpha_frac": 0.6534365924, "autogenerated": false, "ratio": 3.637323943661972, "config_t...
from setuptools import setup, find_packages import sys, os import ceda_cc from ceda_cc.versionConfig import version, versionComment # Load long_description from README.txt here = os.path.dirname(__file__) readme_txt = os.path.join(here, 'README.txt') long_description = '\n\n' + open(readme_txt).read() setup(name='ce...
{ "repo_name": "martinjuckes/ceda_cc", "path": "setup.py", "copies": "1", "size": "1435", "license": "bsd-3-clause", "hash": -4624950229652956000, "line_mean": 32.3720930233, "line_max": 84, "alpha_frac": 0.6543554007, "autogenerated": false, "ratio": 3.5607940446650126, "config_test": false, ...
from setuptools import setup, find_packages import sys, os # Import version from the top-level package sys.path[:0] = os.path.dirname(__file__) from pyesgf import __version__ from pyesgf import __doc__ as long_description setup(name='esgf-pyclient', version=__version__, description="A library interactin...
{ "repo_name": "sterlingbaldwin/esgf-pyclient", "path": "setup.py", "copies": "2", "size": "1419", "license": "bsd-3-clause", "hash": -7130470813378001000, "line_mean": 32, "line_max": 84, "alpha_frac": 0.6497533474, "autogenerated": false, "ratio": 3.7440633245382586, "config_test": false, "h...
from TransferBase import TransferBase from TransferUtils import * import os import tempfile import sys this_dir = os.path.dirname(__file__) top_dir = os.path.abspath(os.path.dirname(this_dir + "../")) lib_dir = os.path.join(top_dir, "lib") sys.path.append(lib_dir) from Response import Response, ResponseCode from Con...
{ "repo_name": "cedadev/mistamover", "path": "lib/TransferModules/GridFTPTransferMyProxy.py", "copies": "1", "size": "10703", "license": "bsd-3-clause", "hash": -3847077731988030500, "line_mean": 41.983935743, "line_max": 97, "alpha_frac": 0.5831075399, "autogenerated": false, "ratio": 3.697063903...
from TransferBase import TransferBase from TransferUtils import TransferUtils import os import tempfile import time import sys this_dir = os.path.dirname(__file__) top_dir = os.path.abspath(os.path.dirname(this_dir + "../")) lib_dir = os.path.join(top_dir, "lib") sys.path.append(lib_dir) from Response import Respons...
{ "repo_name": "cedadev/mistamover", "path": "lib/TransferModules/FtpTransfer.py", "copies": "1", "size": "10797", "license": "bsd-3-clause", "hash": -5655465468520843000, "line_mean": 38.2618181818, "line_max": 105, "alpha_frac": 0.5648791331, "autogenerated": false, "ratio": 3.5692561983471074, ...
import os import stat import time import hashlib import Response import MyZipFile class _SizeAdder(object): """ Helper for FileUtils.getDirSize() Provides add() that we can call from FileUtils.recurseDir() """ def __init__(self, futils): self.total = 0 self.futils = futils d...
{ "repo_name": "cedadev/mistamover", "path": "lib/FileUtils.py", "copies": "1", "size": "13035", "license": "bsd-3-clause", "hash": -5691437855925812000, "line_mean": 30.9485294118, "line_max": 110, "alpha_frac": 0.5436133487, "autogenerated": false, "ratio": 4.516632016632016, "config_test": fa...
import os import time import hashlib import sys this_dir = os.path.dirname(__file__) top_dir = os.path.abspath(os.path.dirname(this_dir + "../")) lib_dir = os.path.join(top_dir, "lib") sys.path.append(lib_dir) from FileUtils import futils class TransferUtils: """ Utilities class for TransferBase """ ...
{ "repo_name": "cedadev/mistamover", "path": "lib/TransferModules/TransferUtils.py", "copies": "1", "size": "4272", "license": "bsd-3-clause", "hash": -3072189851701545000, "line_mean": 29.9565217391, "line_max": 81, "alpha_frac": 0.5735018727, "autogenerated": false, "ratio": 4.084130019120459, ...
import os import time from AbstractDatasetController import AbstractDatasetController import ReceiptFile import ControlFile import ThankyouFile from StatusFlag import status from FileUtils import futils class DatasetArrivalMonitor(AbstractDatasetController): """ Sub-process that monitors arrivals, runs c...
{ "repo_name": "cedadev/mistamover", "path": "lib/DatasetArrivalMonitor.py", "copies": "1", "size": "10509", "license": "bsd-3-clause", "hash": -9083575762572536000, "line_mean": 38.6566037736, "line_max": 99, "alpha_frac": 0.5997716243, "autogenerated": false, "ratio": 4.181854357341822, "confi...
import os class Invalid(Exception): pass class FileExists(Exception): pass class AbstractControlFile(object): """ Simple class to read/write control file. Note that this base class contains read() and create() that the calling code will actually call, but they rely on the subclass to p...
{ "repo_name": "cedadev/mistamover", "path": "lib/AbstractControlFile.py", "copies": "1", "size": "2674", "license": "bsd-3-clause", "hash": -6385862685858649000, "line_mean": 28.3846153846, "line_max": 78, "alpha_frac": 0.5774121167, "autogenerated": false, "ratio": 3.985096870342772, "config_t...
import os from BaseConfig import BaseConfig import GlobalConfig from StatusFlag import status class DatasetConfig(BaseConfig): """ A configuration which bases the filename on the global configuration, and inherits from the global configuration any variables which it does not provide locally. It ...
{ "repo_name": "cedadev/mistamover", "path": "lib/Config/DatasetConfig.py", "copies": "1", "size": "3565", "license": "bsd-3-clause", "hash": -4217314218610752000, "line_mean": 32.6320754717, "line_max": 123, "alpha_frac": 0.6, "autogenerated": false, "ratio": 4.135730858468677, "config_test": t...
import sys import os import time this_dir = os.path.dirname(__file__) if os.path.basename(this_dir) != "test": raise Exception("Must be run from 'test' directory to work.") top_dir = os.path.abspath(os.path.dirname(this_dir)) lib_dir = os.path.join(top_dir, "lib") sys.path.append(lib_dir) import MiStaMoverCont...
{ "repo_name": "cedadev/mistamover", "path": "test/emailtest.py", "copies": "1", "size": "1436", "license": "bsd-3-clause", "hash": 5072894762170762000, "line_mean": 30.9111111111, "line_max": 92, "alpha_frac": 0.6072423398, "autogenerated": false, "ratio": 3.563275434243176, "config_test": true...
import sys, os this_dir = os.path.dirname(__file__) if os.path.basename(this_dir) != "unittests": raise Exception("Must be run from 'test' directory to work.") top_dir = os.path.abspath(os.path.dirname(this_dir)) lib_dir = os.path.join(top_dir, "../lib") sys.path.append(lib_dir) import FileUtils if __name__ ==...
{ "repo_name": "cedadev/mistamover", "path": "test/unittests/test_FileUtils.py", "copies": "1", "size": "3660", "license": "bsd-3-clause", "hash": -5465318404708663000, "line_mean": 35.9696969697, "line_max": 84, "alpha_frac": 0.4486338798, "autogenerated": false, "ratio": 3.995633187772926, "co...
import time import os import signal from AbstractDatasetController import AbstractDatasetController from FileUtils import futils from StatusFlag import status from TransferModules.TransferBaseController import TransferBaseController class DatasetTransferController(AbstractDatasetController): """ A sub-proc...
{ "repo_name": "cedadev/mistamover", "path": "lib/DatasetTransferController.py", "copies": "1", "size": "8445", "license": "bsd-3-clause", "hash": -817427044657998100, "line_mean": 39.4066985646, "line_max": 175, "alpha_frac": 0.5824748372, "autogenerated": false, "ratio": 4.5722793719545205, "c...
import time import os import LoggerClient import Daemon from FileUtils import futils from StatusFlag import status class AbstractDatasetController(object): """ Base class for DatasetTransferController, TransferUnitController, and DatasetArrivalMonitor. """ def __init__(self, dataset_config, de...
{ "repo_name": "cedadev/mistamover", "path": "lib/AbstractDatasetController.py", "copies": "1", "size": "3753", "license": "bsd-3-clause", "hash": -3638803610192425000, "line_mean": 29.2661290323, "line_max": 79, "alpha_frac": 0.622968292, "autogenerated": false, "ratio": 4.156146179401993, "con...
import time import re import smtplib import commands #from email.MIMEText import MIMEText import Daemon #import tempfile import os class AlertEmailer(object): """ An emailer that provides the sendEmail() method to send email, whose only argument is the message and everything else is taken from the ...
{ "repo_name": "cedadev/mistamover", "path": "lib/AlertEmailer.py", "copies": "1", "size": "4127", "license": "bsd-3-clause", "hash": -3173003667567231000, "line_mean": 27.8601398601, "line_max": 128, "alpha_frac": 0.5757208626, "autogenerated": false, "ratio": 3.9644572526416906, "config_test":...
""" add call to set the process name - if we have ctypes available """ try: import ctypes as C def setProcName(name): """ Set the name of the process to be the specified string when we do a "ps". To avoid big complications, the string will be truncated if it exceeds ...
{ "repo_name": "cedadev/mistamover", "path": "lib/ProcName.py", "copies": "1", "size": "1527", "license": "bsd-3-clause", "hash": 9207959762459870000, "line_mean": 27.2777777778, "line_max": 78, "alpha_frac": 0.5920104781, "autogenerated": false, "ratio": 3.8756345177664975, "config_test": false...
""" A simple subclass of zipfile.ZipFile that lets you remove leading path element from the zipfile name. Use exactly as for ZipFile except that on instantiaion you have the argument remove_prefix which is the prefix you want removed from all paths in the zip file, and method writeWithoutPrefix() which will be like ...
{ "repo_name": "cedadev/mistamover", "path": "lib/MyZipFile.py", "copies": "1", "size": "1161", "license": "bsd-3-clause", "hash": 6950089951063947000, "line_mean": 32.1714285714, "line_max": 71, "alpha_frac": 0.6916451335, "autogenerated": false, "ratio": 3.9760273972602738, "config_test": fals...
""" A wrapper around the NetCDF4 Java API @note: currently read-only """ from ucar.nc2.dataset import NetcdfDataset from UserDict import DictMixin class AttributeDict(DictMixin): def __init__(self, ref, is_global=True): self._ref = ref self._is_global = is_global def __getitem__(self, key)...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/jython/netcdf.py", "copies": "1", "size": "2687", "license": "bsd-3-clause", "hash": 7506108957389403000, "line_mean": 24.8365384615, "line_max": 74, "alpha_frac": 0.5880163751, "autogenerated": false, "ratio": 3.7633053221288515, "config_test...
''' Checker configuration class. Created on 29 Sep 2011 @author: rwilkinson ''' class Configuration(object): """Checker configuration. """ def __init__(self, key_file, cert_file, debug, recurse=False, listonly=False, quiet=False, services_to_test="", service_extensions=None, public_servi...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/thredds/lib/configuration.py", "copies": "1", "size": "3240", "license": "bsd-3-clause", "hash": 7818355912386013000, "line_mean": 45.2857142857, "line_max": 98, "alpha_frac": 0.6447530864, "autogenerated": false, "ratio": 4.343163538873995, "...
''' Checker results class Created on 29 Sep 2011 @author: rwilkinson ''' import bisect class Results(object): def __init__(self, access_allowed_count=0, access_denied_count=0, inconsistent_count=0, untested_count=0): self.access_allowed_count = access_allowed_count self.access_d...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/thredds/lib/results.py", "copies": "1", "size": "1942", "license": "bsd-3-clause", "hash": 8832174049061482000, "line_mean": 34.3090909091, "line_max": 93, "alpha_frac": 0.6431513903, "autogenerated": false, "ratio": 3.749034749034749, "config...
''' Configuration data for services. Created on 26 Sep 2011 @author: rwilkinson ''' class Service(object): # Extensions to be appended to URLs for particular services to access different types of data. _default_extensions = { 'OPENDAP': [".html", ".dds", ".das", ".asc", ".ascii", ".dods"], 'H...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/thredds/lib/service_config.py", "copies": "1", "size": "2486", "license": "bsd-3-clause", "hash": -8391336329318144000, "line_mean": 37.84375, "line_max": 100, "alpha_frac": 0.5997586484, "autogenerated": false, "ratio": 4.431372549019608, "co...
''' Created on 27 Sep 2011 @author: rwilkinson ''' from optparse import OptionParser import os import sys import dapbench.thredds.lib.catalog_access as catalog_access from dapbench.thredds.lib.configuration import Configuration def main(): '''Utility to report on the ability of the user to access datasets in a T...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/thredds/scripts/check_catalog.py", "copies": "1", "size": "4999", "license": "bsd-3-clause", "hash": -6508310851603781000, "line_mean": 50.5360824742, "line_max": 120, "alpha_frac": 0.601120224, "autogenerated": false, "ratio": 4.328138528138528...
''' Created on 28 Oct 2011 @author: rwilkinson ''' from optparse import OptionParser import os import sys import dapbench.thredds.lib.metadata_finder as metadata_finder from dapbench.thredds.lib.configuration import Configuration def main(): '''Utility to report on the presence of expected dataset properties in ...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/thredds/scripts/check_metadata.py", "copies": "1", "size": "3690", "license": "bsd-3-clause", "hash": -6158101762403453000, "line_mean": 45.7088607595, "line_max": 114, "alpha_frac": 0.6178861789, "autogenerated": false, "ratio": 4.4138755980861...
''' Created on 28 Sep 2011 @author: rwilkinson ''' from dapbench.thredds.lib.configuration import Configuration import dapbench.thredds.lib.httpget as httpget from optparse import OptionParser import os def main(): '''Utility to check access to a URL by the current user and optionally to return the data retr...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/thredds/scripts/check_url.py", "copies": "1", "size": "2077", "license": "bsd-3-clause", "hash": 2772055386901351000, "line_mean": 40.54, "line_max": 114, "alpha_frac": 0.6340876264, "autogenerated": false, "ratio": 3.9262759924385633, "config...
''' Created on 30 Sep 2011 @author: rwilkinson ''' import os import unittest import dapbench.thredds.lib.catalog_access as catalog_access from dapbench.thredds.lib.configuration import Configuration from dapbench.thredds.lib.results import Results class Test(unittest.TestCase): """Example test of access to catal...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/thredds/test/test_access.py", "copies": "1", "size": "2849", "license": "bsd-3-clause", "hash": -465164199351333600, "line_mean": 38.5694444444, "line_max": 99, "alpha_frac": 0.5931905932, "autogenerated": false, "ratio": 3.9790502793296088, "...
''' Created on 5 Oct 2011 @author: rwilkinson ''' from dapbench.thredds.lib.configuration import Configuration import dapbench.thredds.lib.file_access as file_access from optparse import OptionParser import os import sys def main(): '''Utility to check access to a URL by the current user and optionally to return...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/thredds/scripts/check_files.py", "copies": "1", "size": "3159", "license": "bsd-3-clause", "hash": -262376935109955140, "line_mean": 40.5657894737, "line_max": 114, "alpha_frac": 0.6131687243, "autogenerated": false, "ratio": 4.065637065637065, ...
""" Daemon.py - daemon module ========================= Module holds a couple of classes related to launching code in a daemon process. The key usage concept is that the parent process should instantiate ``DaemonCtl``, passing the method for the daemon to run, and the arguments to pass to that method. This will l...
{ "repo_name": "cedadev/mistamover", "path": "lib/Daemon.py", "copies": "1", "size": "12512", "license": "bsd-3-clause", "hash": 1529224571978357000, "line_mean": 25.9655172414, "line_max": 84, "alpha_frac": 0.535326087, "autogenerated": false, "ratio": 4.368715083798882, "config_test": true, ...
''' Dataset and enclosed access entities. Created on 26 Sep 2011 @author: rwilkinson ''' class Dataset(object): '''Dataset entity as read from a THREDDS catalog. ''' def __init__(self, name, url_path, service_name): """ @param name - name attribute @param url_path - urlPath attrib...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/thredds/lib/dataset_config.py", "copies": "1", "size": "2057", "license": "bsd-3-clause", "hash": 214044124941114700, "line_mean": 28.8260869565, "line_max": 125, "alpha_frac": 0.5882352941, "autogenerated": false, "ratio": 3.74, "config_test"...
''' Functions for manipulating URLs. Created on 27 Sep 2011 @author: rwilkinson ''' import urlparse def get_base_url(url): """Returns the base part of a URL, i.e., excluding any characters after the last /. @param url - URL to process @return base URL """ parts = url.rpartition('/') return p...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/thredds/lib/url_util.py", "copies": "1", "size": "2448", "license": "bsd-3-clause", "hash": -8481098691664598000, "line_mean": 34.4782608696, "line_max": 99, "alpha_frac": 0.6687091503, "autogenerated": false, "ratio": 3.8795562599049127, "con...
""" Main dispatcher script for the 4 subscripts: 1. check_url.py 2. check_files.py 3. check_catalog.py 4. check_metadata.py Execute with the first argument as 'url', 'files', 'catalog' or 'metadata' to execute the required script. """ import sys import os.path as op from check_url import main as url_main f...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/thredds/scripts/dispatch.py", "copies": "1", "size": "1370", "license": "bsd-3-clause", "hash": -5351894322243310000, "line_mean": 21.0967741935, "line_max": 89, "alpha_frac": 0.6313868613, "autogenerated": false, "ratio": 3.374384236453202, "...
''' Parses required details from a THREDDS catalog. Created on 26 Sep 2011 @author: rwilkinson ''' import xml.dom.minidom as minidom from dapbench.thredds.lib.dataset_config import Dataset, Access, CatalogRef from dapbench.thredds.lib.service_config import Service import dapbench.thredds.lib.url_util as url_util imp...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/thredds/lib/catalog_parser.py", "copies": "1", "size": "7909", "license": "bsd-3-clause", "hash": -6128188120085722000, "line_mean": 48.7421383648, "line_max": 129, "alpha_frac": 0.6410418511, "autogenerated": false, "ratio": 4.63056206088993, ...
""" Provides BaseConfig - a class that makes a config file act like a dictionary myconf = BaseConfig("myfile.ini") val = myconf["mysection"]["mykey"] for each value you read, it tries to return int, failing this float, failing this returns bool for special string values 'true' / 'false' (case insensitive tes...
{ "repo_name": "cedadev/mistamover", "path": "lib/Config/BaseConfig.py", "copies": "1", "size": "13298", "license": "bsd-3-clause", "hash": 2607763747651723000, "line_mean": 31.3552311436, "line_max": 109, "alpha_frac": 0.5542938788, "autogenerated": false, "ratio": 4.2042364843503, "config_test...
""" This is adapted from the example from the python docs. http://docs.python.org/library/logging.html """ import cPickle import logging import logging.handlers import SocketServer import struct class LogRecordStreamHandler(SocketServer.StreamRequestHandler): """Handler for a streaming logging request. Th...
{ "repo_name": "cedadev/mistamover", "path": "lib/LogReceiver.py", "copies": "1", "size": "3147", "license": "bsd-3-clause", "hash": 3912277632126398000, "line_mean": 29.2596153846, "line_max": 77, "alpha_frac": 0.60883381, "autogenerated": false, "ratio": 4.419943820224719, "config_test": false...
""" Tools for creating test data. """ import netCDF4 def anonymise(ncpath): """ Remove metadata from the netetcdf file ncpath. @warning: This function is destructive and isn't written to be generic for any CF-NetCDF file. """ exclude_attrs = set(['standard_name', 'missing_value', '_Fil...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/mkdata.py", "copies": "1", "size": "1981", "license": "bsd-3-clause", "hash": 1277114890091880700, "line_mean": 24.0759493671, "line_max": 74, "alpha_frac": 0.5608278647, "autogenerated": false, "ratio": 3.5693693693693693, "config_test": fals...
""" Utilities for creating and processing XML, @author: rwilkinson """ def appendElement(document, parentEl, elementType, elementText): """Adds a text element to a specified parent. """ el = document.createElement(elementType) textEl = document.createTextNode(elementText) el.appendChild(textEl) ...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/thredds/lib/xml_util.py", "copies": "1", "size": "3564", "license": "bsd-3-clause", "hash": 4053282820967030000, "line_mean": 30.8214285714, "line_max": 115, "alpha_frac": 0.6596520763, "autogenerated": false, "ratio": 4.040816326530612, "conf...
""" Utilities for processing nmon output. """ import csv import pandas import datetime as DT import matplotlib.pyplot as plt DATETIME_FORMAT = '%H:%M:%S %d-%b-%Y' TIMESTEP_STREAM = 'ZZZZ' INCLUDE_STREAMS = [ 'DISKXFER', 'DISKREAD', 'MEM', #'CPU02', #'CPU01', 'VM', 'DISKBUSY', 'DISK...
{ "repo_name": "cedadev/dapbench", "path": "dapbench/nmon.py", "copies": "1", "size": "3579", "license": "bsd-3-clause", "hash": -2095657179159871200, "line_mean": 27.4047619048, "line_max": 93, "alpha_frac": 0.556021235, "autogenerated": false, "ratio": 3.6483180428134556, "config_test": false,...