repo_name
stringlengths
7
65
path
stringlengths
5
186
copies
stringclasses
581 values
size
stringlengths
4
7
content
stringlengths
805
1.02M
license
stringclasses
14 values
mozilla/normandy
normandy/recipes/tests/api/v3/test_shield_identicon.py
1
1396
import pytest from normandy.recipes.api.v3.shield_identicon import Genome @pytest.fixture def genome(): seed = 123 return Genome(seed) class TestGenome(object): """ Tests the Genome module by setting the seed to a known value and making sure that the random choices remain consistent, ie. they d...
mpl-2.0
mozilla/normandy
normandy/recipes/tests/api/v3/test_api.py
1
84448
from datetime import timedelta, datetime from django.conf import settings from django.db import connection from django.test.utils import CaptureQueriesContext import pytest from rest_framework import serializers from rest_framework.reverse import reverse from pathlib import Path from normandy.base.api.permissions im...
mpl-2.0
mozilla/normandy
normandy/recipes/tests/test_checks.py
1
4881
from datetime import timedelta from django.core.exceptions import ImproperlyConfigured from django.db.utils import ProgrammingError import pytest import requests.exceptions from normandy.recipes import checks, signing from normandy.recipes.tests import ActionFactory, RecipeFactory, SignatureFactory, UserFactory @p...
mpl-2.0
mozilla/normandy
normandy/recipes/api/filters.py
1
4813
import django_filters from rest_framework import serializers from normandy.recipes.models import Recipe class EnabledStateFilter(django_filters.Filter): """A special case filter for filtering recipes by their enabled state""" def filter(self, qs, value): if value is not None: lc_value = ...
mpl-2.0
mozilla/normandy
normandy/recipes/migrations/0008_auto_20180510_2252.py
1
1967
# Generated by Django 2.0.5 on 2018-05-10 22:52 # flake8: noqa from django.conf import settings from django.db import migrations, models import django.db.models.deletion import django.utils.timezone class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USE...
mpl-2.0
mozilla/normandy
normandy/recipes/exports.py
1
8717
import logging import kinto_http from django.conf import settings from django.core.exceptions import ImproperlyConfigured from normandy.base.utils import ScopedSettings APPROVE_CHANGES_FLAG = {"status": "to-sign"} ROLLBACK_CHANGES_FLAG = {"status": "to-rollback"} logger = logging.getLogger(__name__) rs_settings = Sc...
mpl-2.0
mozilla/normandy
normandy/recipes/tests/test_filters.py
1
25613
from datetime import datetime import factory.fuzzy import pytest import re from collections import defaultdict from rest_framework import serializers from normandy.base.jexl import get_normandy_jexl from normandy.recipes import filters from normandy.recipes.tests import ( ChannelFactory, CountryFactory, L...
mpl-2.0
mozilla/normandy
normandy/recipes/migrations/0009_auto_20180510_2328.py
1
1037
# Generated by Django 2.0.5 on 2018-05-10 23:28 from django.db import migrations def enabled_to_enabled_state(apps, schema_editor): Recipe = apps.get_model("recipes", "Recipe") EnabledState = apps.get_model("recipes", "EnabledState") for recipe in Recipe.objects.filter(enabled=True): if recipe.a...
mpl-2.0
mozilla/normandy
normandy/studies/tests/__init__.py
1
4038
import factory import json import tempfile import zipfile from factory.django import DjangoModelFactory from faker import Faker from normandy.base.tests import FuzzyUnicode from normandy.studies.models import Extension INSTALL_RDF_TEMPLATE = """<?xml version="1.0" encoding="utf-8"?> <RDF xmlns="http://w3.org/1999/02...
mpl-2.0
mozilla/normandy
normandy/recipes/management/commands/initial_data.py
1
1928
from django.core.management.base import BaseCommand from django_countries import countries from normandy.recipes.models import Channel, Country, WindowsVersion class Command(BaseCommand): """ Adds some helpful initial data to the site's database. If matching data already exists, it should _not_ be overwr...
mpl-2.0
mozilla/normandy
normandy/base/tests/test_storage.py
1
1594
from itertools import chain import pytest from django.core.files.base import ContentFile from normandy.base.storage import PermissiveFilenameStorageMixin class TestPermissiveFilenameStorageMixin(object): @pytest.fixture def storage(self): return PermissiveFilenameStorageMixin() class TestGetVa...
mpl-2.0
mozilla/normandy
contract-tests/v1_api/test_performance.py
1
3083
from urllib.parse import urljoin import html5lib import pytest """These are paths hit by self repair that need to be very fast""" HOT_PATHS = [ "/en-US/repair", "/en-US/repair/", "/api/v1/recipe/?enabled=1", "/api/v1/recipe/signed/?enabled=1", "/api/v1/action/", ] @pytest.mark.parametrize("path...
mpl-2.0
mozilla/normandy
normandy/recipes/api/v1/views.py
1
6564
from django.conf import settings from django.db import transaction from django.db.models import Q from django.views.decorators.cache import never_cache import django_filters from rest_framework import generics, permissions, views, viewsets from rest_framework.decorators import action from rest_framework.exceptions imp...
mpl-2.0
mozilla/normandy
normandy/recipes/migrations/0004_auto_20180502_2340.py
1
5164
# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-05-02 23:40 # flake8: noqa from __future__ import unicode_literals import hashlib from django.db import migrations def create_tmp_from_revision(apps, revision, parent=None): ApprovalRequest = apps.get_model("recipes", "ApprovalRequest") TmpRecipe...
mpl-2.0
mozilla/normandy
contract-tests/v3_api/test_approval_request_reject.py
1
1850
from support.assertions import assert_valid_schema from support.helpers import new_recipe from urllib.parse import urljoin def test_approval_request_reject(conf, requests_session, headers): # Get an action we can work with action_response = requests_session.get( urljoin(conf.getoption("server"), "/api...
mpl-2.0
mozilla/normandy
normandy/recipes/api/v3/serializers.py
1
11345
from rest_framework import serializers from factory.fuzzy import FuzzyText from normandy.base.api.v3.serializers import UserSerializer from normandy.base.jexl import get_normandy_jexl from normandy.recipes import filters from normandy.recipes.api.fields import ( ActionImplementationHyperlinkField, FilterObject...
mpl-2.0
mozilla/normandy
contract-tests/v3_api/test_group_delete.py
1
1231
import uuid from support.assertions import assert_valid_schema from urllib.parse import urljoin def test_group_delete(conf, requests_session, headers): # Create a new group data = {"name": str(uuid.uuid4())} response = requests_session.post( urljoin(conf.getoption("server"), "/api/v3/group/"), he...
mpl-2.0
developmentseed/landsat-util
docs/conf.py
9
9890
# -*- coding: utf-8 -*- # # Landsat-util documentation build configuration file, created by # sphinx-quickstart on Thu May 28 17:52:10 2015. # # 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. ...
cc0-1.0
rmmh/skybot
plugins/lastfm.py
3
2391
""" The Last.fm API key is retrieved from the bot config file. """ from util import hook, http api_url = "http://ws.audioscrobbler.com/2.0/?format=json" @hook.api_key("lastfm") @hook.command(autohelp=False) def lastfm(inp, chan="", nick="", reply=None, api_key=None, db=None): ".lastfm <username> [dontsave] | @...
unlicense
rmmh/skybot
plugins/google.py
2
1308
from __future__ import unicode_literals import random from util import hook, http def api_get(query, key, is_image=None, num=1): url = ( "https://www.googleapis.com/customsearch/v1?cx=007629729846476161907:ud5nlxktgcw" "&fields=items(title,link,snippet)&safe=off&nfpr=1" + ("&searchType=i...
unlicense
rmmh/skybot
plugins/util/timesince.py
3
4139
# Copyright (c) Django Software Foundation and individual contributors. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notic...
unlicense
rmmh/skybot
plugins/mtg.py
3
2470
from __future__ import print_function from builtins import range from util import hook, http import random def card_search(name): matching_cards = http.get_json( "https://api.magicthegathering.io/v1/cards", name=name ) for card in matching_cards["cards"]: if card["name"].lower() == name.lo...
unlicense
pytube/pytube
tests/test_captions.py
1
5759
import os import pytest from unittest import mock from unittest.mock import MagicMock, mock_open, patch from pytube import Caption, CaptionQuery, captions def test_float_to_srt_time_format(): caption1 = Caption( {"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en", "vssId": ".en"} ) ...
unlicense
pytube/pytube
pytube/cipher.py
1
22529
""" This module contains all logic necessary to decipher the signature. YouTube's strategy to restrict downloading videos is to send a ciphered version of the signature to the client, along with the decryption algorithm obfuscated in JavaScript. For the clients to play the videos, JavaScript must take the ciphered ver...
unlicense
pytube/pytube
tests/contrib/test_channel.py
1
3122
from unittest import mock from pytube import Channel @mock.patch('pytube.request.get') def test_init_with_url(request_get, channel_videos_html): request_get.return_value = channel_videos_html c = Channel('https://www.youtube.com/c/ProgrammingKnowledge/videos') assert c.channel_url == 'https://www.youtube...
unlicense
pytube/pytube
pytube/request.py
1
8512
"""Implements a simple wrapper around urlopen.""" import http.client import json import logging import re import socket from functools import lru_cache from urllib import parse from urllib.error import URLError from urllib.request import Request, urlopen from pytube.exceptions import RegexMatchError, MaxRetriesExceede...
unlicense
mozilla-iam/cis
python-modules/cis_identity_vault/cis_identity_vault/vault.py
1
15533
"""Create, destroy, and configure the appropriate vault for the environment.""" import boto3 import time from botocore.exceptions import ClientError from botocore.stub import Stubber from cis_identity_vault import autoscale from cis_identity_vault.common import get_config from cis_identity_vault.models import rds from ...
mpl-2.0
mozilla-iam/cis
python-modules/cis_notifications/tests/test_notifier.py
1
1570
import cis_notifications import json import mock class TestNotifier(object): @mock.patch("cis_notifications.event.Event._notify_via_post") @mock.patch("cis_notifications.secret.Manager.secret") @mock.patch("cis_notifications.secret.Manager.secretmgr") @mock.patch("cis_notifications.secret.Manager.secr...
mpl-2.0
mozilla-iam/cis
python-modules/cis_identity_vault/integration_tests/test_scan_speed.py
1
2425
"""Designed to run against the testing environment.""" import boto3 import logging import os from cis_identity_vault.models import user logger = logging.getLogger(__name__) logging.basicConfig(level=logging.DEBUG) logging.getLogger('boto3').setLevel(logging.CRITICAL) logging.getLogger('botocore').setLevel(logging.CR...
mpl-2.0
mozilla-iam/cis
python-modules/cis_crypto/cis_crypto/operation.py
1
5491
import json import logging import os import yaml from jose import jwk from jose import jws from jose.exceptions import JWSError from cis_crypto import secret from cis_crypto import common logger = logging.getLogger(__name__) # Note: # These attrs on sign/verify could be refactored to use object inheritance. Leaving a...
mpl-2.0
mozilla-iam/cis
python-modules/cis_identity_vault/tests/test_rds.py
1
5959
import os from moto import mock_ssm from cis_profile import FakeUser @mock_ssm class TestRDS(object): def setup(self, *args): os.environ["CIS_ENVIRONMENT"] = "testing" os.environ["CIS_REGION_NAME"] = "us-east-1" os.environ["DEFAULT_AWS_REGION"] = "us-east-1" # Mock a user profile ...
mpl-2.0
mozilla-iam/cis
python-modules/cis_logger/cis_logger/__init__.py
1
1579
import logging.handlers from pythonjsonlogger import jsonlogger import datetime class JsonFormatter(jsonlogger.JsonFormatter, object): def __init__( self, fmt="%(asctime) %(name) %(processName) %(filename) \ %(funcName) %(levelname) %(lineno) %(module) %(threadName) %(message)", da...
mpl-2.0
ibm-watson-iot/iot-python
test/test_device_command.py
2
1862
# ***************************************************************************** # Copyright (c) 2019 IBM Corporation and other Contributors. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution,...
epl-1.0
ibm-watson-iot/iot-python
src/wiotp/sdk/api/registry/devices.py
2
15894
# ***************************************************************************** # Copyright (c) 2018 IBM Corporation and other Contributors. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution,...
epl-1.0
ibm-watson-iot/iot-python
src/wiotp/sdk/device/config.py
2
10296
# ***************************************************************************** # Copyright (c) 2014, 2019 IBM Corporation and other Contributors. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distrib...
epl-1.0
ibm-watson-iot/iot-python
test/test_api_state_schemas.py
2
7315
# ***************************************************************************** # Copyright (c) 2019 IBM Corporation and other Contributors. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution,...
epl-1.0
ibm-watson-iot/iot-python
src/wiotp/sdk/api/dsc/destinations.py
2
4384
# ***************************************************************************** # Copyright (c) 2019 IBM Corporation and other Contributors. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution,...
epl-1.0
ibm-watson-iot/iot-python
src/wiotp/sdk/api/state/state.py
2
2752
# ***************************************************************************** # Copyright (c) 2019 IBM Corporation and other Contributors. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution,...
epl-1.0
ibm-watson-iot/iot-python
samples/simpleApp/simpleApp.py
2
5201
# ***************************************************************************** # Copyright (c) 2014, 2019 IBM Corporation and other Contributors. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distrib...
epl-1.0
ibm-watson-iot/iot-python
src/wiotp/sdk/api/usage/__init__.py
2
2241
# ***************************************************************************** # Copyright (c) 2018 IBM Corporation and other Contributors. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution,...
epl-1.0
ibm-watson-iot/iot-python
test/test_device_mgd.py
2
11230
# ***************************************************************************** # Copyright (c) 2016,2018 IBM Corporation and other Contributors. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribu...
epl-1.0
mbj4668/pyang
pyang/repository.py
1
5853
"""A repository for searching and holding loaded pyang modules""" import os import sys import io from . import util from . import syntax class Repository(object): """Abstract base class that represents a module repository""" def get_modules_and_revisions(self, ctx): """Return a list of all modules a...
isc
mbj4668/pyang
test/test_issues/test_i225/test_prefix_deviation.py
1
3107
#!/usr/bin/env python # -*- coding: utf-8 -*- # pylint: disable=redefined-outer-name """ tests for PYANG data files """ import os import sys # hack to handle pip 10 internals try: import pip.locations as locations except ImportError: import pip._internal.locations as locations from pyang.context import Contex...
isc
mbj4668/pyang
pyang/plugins/omni.py
1
11901
import optparse from pyang import plugin paths_in_module = [] leafrefs = [] key = '' class_keywords = ["container", "list", "case", "choice", "augment"] servicepoints = ["servicepoint", "productpoint"] classnamecolor = " {0.113725, 0.352941, 0.670588}" mandatoryconfig = " {0.600000, 0.152941, 0.152941}" optionalconf...
isc
mbj4668/pyang
pyang/yacc.py
1
137902
# ----------------------------------------------------------------------------- # ply: yacc.py # # Copyright (C) 2001-2019 # David M. Beazley (Dabeaz LLC) # All rights reserved. # # Latest version: https://github.com/dabeaz/ply # # Redistribution and use in source and binary forms, with or without # modification, are p...
isc
rdegges/django-twilio
django_twilio/models.py
1
1827
# -*- coding: utf-8 -*- from django.db import models from django.conf import settings from phonenumber_field.modelfields import PhoneNumberField AUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User') class Caller(models.Model): """ A caller is defined uniquely by their phone number. :par...
unlicense
rdegges/django-twilio
test_project/test_app/models.py
1
1869
# -*- coding: utf-8 -*- from types import MethodType from django.test import TestCase from django.contrib.auth.models import User from django_dynamic_fixture import G from django_twilio.models import Caller, Credential class CallerTestCase(TestCase): """ Run tests against the :class:`django_twilio.models....
unlicense
mozilla-services/buildhub
jobs/buildhub/s3_inventory_to_kinto.py
1
12262
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, you can obtain one at http://mozilla.org/MPL/2.0/. import re import asyncio import datetime import glob import json import logging import os import pkgutil import tempfile...
mpl-2.0
pikepdf/pikepdf
src/pikepdf/_cpphelpers.py
1
2965
# SPDX-FileCopyrightText: 2022 James R. Barlow # SPDX-License-Identifier: MPL-2.0 """Support functions called by the C++ library binding layer. Not intended to be called from Python, and subject to change at any time. """ from __future__ import annotations from typing import Callable from warnings import warn from...
mpl-2.0
pikepdf/pikepdf
tests/test_image_access.py
1
35498
# SPDX-FileCopyrightText: 2022 James R. Barlow # SPDX-License-Identifier: CC0-1.0 from __future__ import annotations import subprocess import zlib from contextlib import contextmanager from io import BytesIO from math import ceil from os import fspath from pathlib import Path from subprocess import run from typing im...
mpl-2.0
pikepdf/pikepdf
tests/test_parsers.py
1
9538
# SPDX-FileCopyrightText: 2022 James R. Barlow # SPDX-License-Identifier: CC0-1.0 from __future__ import annotations import shutil import sys from subprocess import PIPE, run import pytest import pikepdf from pikepdf import ( ContentStreamInlineImage, ContentStreamInstruction, Dictionary, Name, ...
mpl-2.0
pikepdf/pikepdf
tests/test_matrix.py
1
1141
# SPDX-FileCopyrightText: 2022 James R. Barlow # SPDX-License-Identifier: CC0-1.0 from __future__ import annotations from math import isclose import pytest import pikepdf from pikepdf.models import PdfMatrix def test_init_6(): m = PdfMatrix(1, 0, 0, 1, 0, 0) m2 = m.scaled(2, 2) m2t = m2.translated(2, ...
mpl-2.0
pikepdf/pikepdf
tests/test_decimal.py
1
1961
# SPDX-FileCopyrightText: 2022 James R. Barlow # SPDX-License-Identifier: CC0-1.0 from __future__ import annotations from decimal import Decimal, getcontext import pytest import pikepdf from pikepdf.settings import get_decimal_precision, set_decimal_precision encode = pikepdf._qpdf._encode # pylint: disable=redef...
mpl-2.0
pikepdf/pikepdf
src/pikepdf/models/_transcoding.py
1
8054
# SPDX-FileCopyrightText: 2022 James R. Barlow # SPDX-License-Identifier: MPL-2.0 from __future__ import annotations import struct from typing import Any, Callable, NamedTuple, Union from PIL import Image from PIL.TiffTags import TAGS_V2 as TIFF_TAGS BytesLike = Union[bytes, memoryview] MutableBytesLike = Union[byt...
mpl-2.0
marl/jams
tests/test_sonify.py
1
4469
#!/usr/bin/env python # CREATED:2016-02-11 12:07:58 by Brian McFee <brian.mcfee@nyu.edu> """Sonification tests""" import numpy as np import pytest from test_eval import create_hierarchy import jams @pytest.mark.xfail(raises=jams.NamespaceError) def test_no_sonify(): ann = jams.Annotation(namespace='vector') ...
isc
marl/jams
jams/sonify.py
1
6973
#!/usr/bin/env python # CREATED:2015-12-12 18:20:37 by Brian McFee <brian.mcfee@nyu.edu> r''' Sonification ------------ .. autosummary:: :toctree: generated/ sonify ''' from itertools import product from collections import OrderedDict, defaultdict import six import numpy as np import mir_eval.sonify from mir...
isc
marl/jams
docs/examples/example_beat.py
1
1897
#!/usr/bin/env python import librosa import jams def beat_track(infile, outfile): # Load the audio file y, sr = librosa.load(infile) # Compute the track duration track_duration = librosa.get_duration(y=y, sr=sr) # Extract tempo and beat estimates tempo, beat_frames = librosa.beat.beat_trac...
isc
mail-in-a-box/mailinabox
tests/fail2ban.py
1
6372
# Test that a box's fail2ban setting are working # correctly by attempting a bunch of failed logins. # # Specify a SSH login command (which we use to reset # fail2ban after each test) and the hostname to # try to log in to. ###################################################################### import sys, os, time, fu...
cc0-1.0
mail-in-a-box/mailinabox
management/auth.py
1
6049
import base64, os, os.path, hmac, json, secrets from datetime import timedelta from expiringdict import ExpiringDict import utils from mailconfig import get_mail_password, get_mail_user_privileges from mfa import get_hash_mfa_state, validate_auth_mfa DEFAULT_KEY_PATH = '/var/lib/mailinabox/api.key' DEFAULT_AUTH_RE...
cc0-1.0
mcedit/pymclevel
minecraft_server.py
3
20215
import atexit import itertools import logging import os from os.path import dirname, join, basename import random import re import shutil import subprocess import sys import tempfile import time import urllib import infiniteworld from mclevelbase import appSupportDir, exhaust, ChunkNotPresent log = logging.getLogger(...
isc
mcedit/pymclevel
block_fill.py
3
3454
import logging import materials log = logging.getLogger(__name__) import numpy from mclevelbase import exhaust import blockrotation from entity import TileEntity def blockReplaceTable(blocksToReplace): blocktable = numpy.zeros((materials.id_limit, 16), dtype='bool') for b in blocksToReplace: if b.ha...
isc
mcedit/mcedit
filters/CreateSpawners.py
1
1386
# Feel free to modify and use this filter however you wish. If you do, # please give credit to SethBling. # http://youtube.com/SethBling from pymclevel import TAG_Compound from pymclevel import TAG_Int from pymclevel import TAG_Short from pymclevel import TAG_Byte from pymclevel import TAG_String from pymclevel import...
isc
mcedit/mcedit
filters/surfacerepair.py
1
2001
from numpy import zeros, array import itertools #naturally occuring materials from pymclevel.level import extractHeights blocktypes = [1, 2, 3, 7, 12, 13, 14, 15, 16, 56, 73, 74, 87, 88, 89] blockmask = zeros((256,), dtype='bool') #compute a truth table that we can index to find out whether a block # is naturally o...
isc
josephmisiti/awesome-machine-learning
scripts/pull_R_packages.py
1
1150
#!/usr/bin/python """ This script will scrape the r-project.org machine learning selection and format the packages in github markdown style for this awesome-machine-learning repo. """ from pyquery import PyQuery as pq import urllib import codecs import random text_file = codecs.open("Packages.txt", encod...
cc0-1.0
mozilla-services/tecken
docs/exts/adr_log.py
1
5841
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at https://mozilla.org/MPL/2.0/. """Directive for generating an ADR log from a directory of ADRs. Usage:: .. adrlog:: PATH .. adrlog:: PATH ...
mpl-2.0
mozilla-services/tecken
tecken/useradmin/management/commands/is-blocked-in-auth0.py
1
1430
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at https://mozilla.org/MPL/2.0/. from urllib.parse import urlparse from django.conf import settings from django.core.management.base import BaseCommand...
mpl-2.0
mozilla-services/tecken
eliot-service/eliot/health_resource.py
1
1629
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at https://mozilla.org/MPL/2.0/. """ Application-health related Falcon resources. """ import json from dockerflow.version import get_version import fa...
mpl-2.0
mozilla-services/tecken
systemtests/bin/make-stacks.py
1
4833
#!/usr/bin/env python # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at https://mozilla.org/MPL/2.0/. # Fetches processed crash data for given crash ids and generates # stacks for use with the Symbo...
mpl-2.0
mozilla-services/tecken
tecken/tests/test_libboto.py
1
1241
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at https://mozilla.org/MPL/2.0/. import pickle from tecken.libboto import ( OwnEndpointConnectionError, OwnClientError, ) def test_pickle_Own...
mpl-2.0
mozilla-services/tecken
tecken/upload/forms.py
1
4406
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at https://mozilla.org/MPL/2.0/. import os from urllib.parse import urlparse from requests.exceptions import ConnectionError, RetryError from django i...
mpl-2.0
pimutils/todoman
tests/test_ui.py
1
4822
from datetime import datetime from unittest import mock import pytest import pytz from freezegun import freeze_time from urwid import ExitMainLoop from todoman.interactive import TodoEditor def test_todo_editor_priority(default_database, todo_factory, default_formatter): todo = todo_factory(priority=1) list...
isc
pimutils/todoman
docs/source/conf.py
1
2282
#!/usr/bin/env python3 import todoman from todoman.configuration import CONFIG_SPEC from todoman.configuration import NO_DEFAULT # -- Generate confspec.rst ---------------------------------------------- def confspec_rst(): """Generator that returns lines for the confspec doc page.""" for name, type_, defau...
isc
mozilla-services/autopush
autopush/main.py
1
10560
"""autopush/autoendpoint daemon scripts""" import os from argparse import Namespace # noqa from twisted.application.internet import ( TCPServer, TimerService, SSLServer, StreamServerEndpointService, ) from twisted.application.service import MultiService from twisted.internet import reactor from twiste...
mpl-2.0
mozilla-services/autopush
autopush/tests/test_web_validation.py
1
40559
import time import uuid import base64 from hashlib import sha256 import ecdsa from cryptography.fernet import InvalidToken from cryptography.exceptions import InvalidSignature from jose import jws, jwk from marshmallow import Schema, fields from mock import Mock, patch import pytest from twisted.internet.defer import...
mpl-2.0
mozilla-services/autopush
autopush/tests/test_ssl.py
1
1186
import socket import ssl from twisted.trial import unittest from autopush.ssl import ( monkey_patch_ssl_wrap_socket, ssl_wrap_socket_cached, undo_monkey_patch_ssl_wrap_socket ) class SSLContextCacheTestCase(unittest.TestCase): def setUp(self): # XXX: test_main doesn't cleanup after itself ...
mpl-2.0
mozilla-services/autopush
autopush/tests/test_protocol.py
1
1356
from mock import Mock from nose.tools import eq_ from twisted.trial import unittest from twisted.web.client import Response from autopush.protocol import IgnoreBody class ProtocolTestCase(unittest.TestCase): def test_ignore(self): mock_reason = Mock() mock_reason.check.return_value = True ...
mpl-2.0
mozilla-services/autopush
autopush/base.py
1
3544
import sys import uuid from typing import TYPE_CHECKING import cyclone.web from twisted.logger import Logger from twisted.python import failure if TYPE_CHECKING: # pragma: nocover from autopush.config import AutopushConfig # noqa from autopush.db import DatabaseManager # noqa from autopush.metrics impo...
mpl-2.0
mozilla-services/autopush
autopush/tests/test_db.py
1
27490
import os import unittest import uuid from datetime import datetime, timedelta from autopush.websocket import ms_time from botocore.exceptions import ClientError from mock import Mock, patch import pytest from autopush.config import DDBTableConfig from autopush.db import ( get_rotating_message_tablename, crea...
mpl-2.0
mozilla-services/autopush
autopush/router/webpush.py
1
10390
"""WebPush Style Autopush Router This router handles notifications that should be dispatched to an Autopush node, or stores each individual message, along with its data, in a Message table for retrieval by the client. """ import json import time from StringIO import StringIO from typing import Any # noqa from botoc...
mpl-2.0
mozilla-services/autopush
autopush/web/message.py
1
1772
from cryptography.fernet import InvalidToken from marshmallow import Schema, fields, pre_load from twisted.internet.threads import deferToThread from twisted.internet.defer import Deferred # noqa from autopush.exceptions import InvalidRequest, InvalidTokenException from autopush.utils import WebPushNotification from ...
mpl-2.0
mozilla-services/autopush
autopush/gcdump.py
1
3447
#! /usr/bin/env python """ Prints a human-readable total out of a dumpfile produced by gc.dump_rpy_heap(), and optionally a typeids.txt. Syntax: dump.py <dumpfile> [<typeids.txt>] By default, typeids.txt is loaded from the same dir as dumpfile. """ import array import os import struct import sys class Stat(objec...
mpl-2.0
mozilla-services/autopush
autopush/tests/test_logging.py
1
7541
import json import os import Queue import sys import StringIO import cyclone.web import twisted.internet import twisted.trial.unittest from mock import Mock, patch from twisted.internet import reactor from twisted.internet.defer import Deferred from twisted.logger import Logger from twisted.python import failure fro...
mpl-2.0
dbr/tvnamer
tvnamer/_titlecase.py
1
3442
#!/usr/bin/env python # -*- coding: utf-8 -*- # fmt: off """ Original Perl version by: John Gruber http://daringfireball.net/ 10 May 2008 Python version by Stuart Colville http://muffinresearch.co.uk License: http://www.opensource.org/licenses/mit-license.php """ import re __all__ = ['titlecase'] __version__ = '0.5...
unlicense
dbr/tvnamer
tvnamer/main.py
1
17600
#!/usr/bin/env python """Main tvnamer utility functionality """ import os import sys import logging import warnings try: import readline except ImportError: pass import json import tvdb_api from typing import List, Union, Optional from tvnamer import cliarg_parser, __version__ from tvnamer.config_defaults...
unlicense
fedspendingtransparency/data-act-broker-backend
tests/unit/dataactcore/factories/fsrs.py
1
10488
from datetime import date, datetime, timezone import factory from factory import fuzzy from dataactcore.models import fsrs class _FSRSAttributes(factory.Factory): duns = fuzzy.FuzzyText() uei_number = fuzzy.FuzzyText() dba_name = fuzzy.FuzzyText() principle_place_city = fuzzy.FuzzyText() princip...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
tests/unit/dataactvalidator/test_fabs47.py
1
1670
from tests.unit.dataactcore.factories.staging import FABSFactory from tests.unit.dataactvalidator.utils import number_of_errors, query_columns _FILE = 'fabs47' def test_column_headers(database): expected_subset = {'row_number', 'funding_opportunity_number', 'assistance_type', 'uniqueid_Ass...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
dataactcore/aws/s3Handler.py
1
4256
import boto3 import logging from botocore.exceptions import ClientError from dataactcore.config import CONFIG_BROKER logger = logging.getLogger(__name__) class S3Handler: """ This class acts a wrapper for S3 URL Signing Attributes: bucketRoute: The name of the bucket to be used Co...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
dataactcore/migrations/versions/4d8408c33fee_add_frec_to_user_model.py
1
2519
"""add FREC to user model Revision ID: 4d8408c33fee Revises: da2e50d423ff Create Date: 2017-07-06 13:19:01.155328 """ # revision identifiers, used by Alembic. revision = '4d8408c33fee' down_revision = 'da2e50d423ff' branch_labels = None depends_on = None from alembic import op import sqlalchemy as sa def upgrade(...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
dataactcore/migrations/versions/812387580a0b_rename_user_permissions_column.py
1
1298
"""rename user permissions column Revision ID: 812387580a0b Revises: a97dabbd44f4 Create Date: 2016-11-09 11:40:11.657516 """ # revision identifiers, used by Alembic. revision = '812387580a0b' down_revision = 'a97dabbd44f4' branch_labels = None depends_on = None from alembic import op import sqlalchemy as sa def ...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
tests/unit/dataactvalidator/test_fabs37_3.py
1
1435
from tests.unit.dataactcore.factories.staging import FABSFactory from dataactcore.models.domainModels import CFDAProgram from tests.unit.dataactvalidator.utils import number_of_errors, query_columns _FILE = 'fabs37_3' def test_column_headers(database): expected_subset = {'row_number', 'cfda_number', 'uniqueid_As...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
tests/unit/dataactvalidator/test_fabs6.py
1
1333
from tests.unit.dataactcore.factories.staging import FABSFactory from tests.unit.dataactvalidator.utils import number_of_errors, query_columns _FILE = 'fabs6' def test_column_headers(database): expected_subset = {'row_number', 'record_type', 'uniqueid_AssistanceTransactionUniqueKey'} actual = set(query_colum...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
tests/unit/dataactvalidator/test_fabsreq9.py
1
1607
from tests.unit.dataactcore.factories.staging import FABSFactory from tests.unit.dataactvalidator.utils import number_of_errors, query_columns _FILE = 'fabsreq9' def test_column_headers(database): expected_subset = {'row_number', 'awardee_or_recipient_legal', 'correction_delete_indicatr', ...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
dataactcore/migrations/versions/11338a6b7e77_adding_business_categories_derivation_.py
1
4287
"""Adding business categories derivation function Revision ID: 11338a6b7e77 Revises: e26d14b0d235 Create Date: 2021-12-09 09:42:10.715687 """ # revision identifiers, used by Alembic. revision = '11338a6b7e77' down_revision = 'e26d14b0d235' branch_labels = None depends_on = None from alembic import op import sqlalch...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
tests/unit/dataactvalidator/test_b5_object_class_program_activity_2.py
1
1853
from tests.unit.dataactcore.factories.staging import ObjectClassProgramActivityFactory from tests.unit.dataactvalidator.utils import number_of_errors, query_columns _FILE = 'b5_object_class_program_activity_2' def test_column_headers(database): expected_subset = {'row_number', 'gross_outlay_amount_by_pro_cpe', '...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
dataactcore/migrations/versions/d45dde2ba15b_alter_detached_regular_award_procurement.py
1
4837
"""Alter and add many columns in DetachedAwardProcurement and AwardProcurement Revision ID: d45dde2ba15b Revises: 001758a1ab82 Create Date: 2018-03-09 14:08:13.058669 """ # revision identifiers, used by Alembic. revision = 'd45dde2ba15b' down_revision = '001758a1ab82' branch_labels = None depends_on = None from ale...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
dataactcore/migrations/versions/df2f541291a5_create_gtas_submission_window_table.py
1
1146
"""Create gtas_submission_window table Revision ID: df2f541291a5 Revises: 427320dea2ab Create Date: 2017-07-06 12:06:53.946926 """ # revision identifiers, used by Alembic. revision = 'df2f541291a5' down_revision = '427320dea2ab' branch_labels = None depends_on = None from alembic import op import sqlalchemy as sa ...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
dataactcore/migrations/versions/4d66a8d6e11b_create_filerequest_table_for_d_file_.py
1
2841
"""create FileRequest table for D file generation Revision ID: 4d66a8d6e11b Revises: bcdf1134f0df Create Date: 2017-10-19 14:28:03.788883 """ # revision identifiers, used by Alembic. revision = '4d66a8d6e11b' down_revision = 'bcdf1134f0df' branch_labels = None depends_on = None from alembic import op import sqlalch...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
dataactcore/migrations/versions/7597deb348fb_fabs_created_at_and_fpds_updated_at_.py
1
1251
"""FABS created_at and FPDS updated_at indexes Revision ID: 7597deb348fb Revises: b168f0cdc5a8 Create Date: 2018-02-06 16:08:20.985202 """ # revision identifiers, used by Alembic. revision = '7597deb348fb' down_revision = 'b168f0cdc5a8' branch_labels = None depends_on = None from alembic import op import sqlalchemy...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
dataactcore/scripts/load_duns_exec_comp.py
1
14861
import argparse import datetime import logging import os import re import json import tempfile import boto3 import requests from dataactcore.config import CONFIG_BROKER from dataactcore.interfaces.db import GlobalDB from dataactcore.interfaces.function_bag import update_external_data_load_date from dataactcore.broker_...
cc0-1.0
fedspendingtransparency/data-act-broker-backend
tests/unit/dataactvalidator/test_fabs33_1.py
1
1700
from tests.unit.dataactcore.factories.staging import FABSFactory from tests.unit.dataactvalidator.utils import number_of_errors, query_columns _FILE = 'fabs33_1' def test_column_headers(database): expected_subset = {'row_number', 'period_of_performance_curr', 'uniqueid_AssistanceTransactionUniqueKey'} actual...
cc0-1.0