text
stringlengths
17
737k
import requests # Hack (make this somethign we can pass around?) BASE_URL = "https://www.secondguard.com/" # BASE_URL = "http://localhost:1323/" HEX_CHARS = set('0123456789abcdef') # For testing only # Limited to 1 INSECURE pubkey, rate-limiting shared across all users TESTING_API_TOKEN = 'SG-XXXX' with open('inse...
import re import os import time import boto import boto.ec2 import boto.vpc from boto.ec2.networkinterface import NetworkInterfaceSpecification from boto.ec2.networkinterface import NetworkInterfaceCollection from buildbot import interfaces from buildbot.buildslave.ec2 import EC2LatentBuildSlave, SHUTTINGDOWN, TERMINAT...
#!/usr/bin/python # # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
# -*- coding: utf-8 -*- # # Wyrm documentation build configuration file, created by # sphinx-quickstart on Fri Jun 28 11:37:55 2013. # # 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 co...
"""Plot sound fields etc.""" from __future__ import division import matplotlib.pyplot as plt from matplotlib.patches import PathPatch from matplotlib.path import Path from matplotlib.collections import PatchCollection from mpl_toolkits import axes_grid1 from mpl_toolkits.mplot3d import Axes3D import numpy as np from . ...
# -*- coding: utf-8 -*- # # joblib documentation build configuration file, created by # sphinx-quickstart on Thu Oct 23 16:36:51 2008. # # This file is execfile()d with the current directory set to its containing dir. # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleab...
#!/usr/bin/env python3 # # Copyright (c) 2021, The OpenThread Authors. # 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 # ...
from decimal import Decimal import datetime import unittest import locale from kiwi.datatypes import currency, converter, ValidationError, ValueUnset import utils def set_locale(category, name): # set the date format to the spanish one try: locale.setlocale(category, name) except locale.Error: ...
#!/usr/bin/env python # Copyright 2009-2012 Jasper Poppe <jgpoppe@gmail.com> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
2623b342-2e74-11e5-9284-b827eb9e62be
# -*- coding: utf-8 -*- # # desisim documentation build configuration file, created by # sphinx-quickstart on Tue Dec 9 10:43:33 2014. # # 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. # # A...
"""Import tasks for Pan-STARRS. """ import csv import json import os import urllib import warnings from glob import glob import requests from astrocats.catalog.photometry import PHOTOMETRY from astrocats.catalog.utils import is_number, make_date_string, pbar, uniq_cdl from astropy.time import Time as astrotime from bs...
import os import sys import errno import importlib import contextlib from maya import cmds, OpenMaya from pyblish import api as pyblish from . import lib, compat from ..lib import logger from .. import api, io, schema from ..vendor import six from ..vendor.Qt import QtCore, QtWidgets self = sys.modules[__name__] sel...
import unittest import numpy as np import assertions import floq.evolution as ev import floq.helpers as h import floq.dtos as dtos def rabi_hf(g,e1,e2): hf = np.zeros([3,2,2]) hf[0] = np.array([[0,0],[g,0]]) hf[1] = np.array([[e1,0],[0,e2]]) hf[2] = np.array([[0,g],[0,0]]) return hf def rabi_u(g,e...
# -*- coding: utf-8 -*- # # elita documentation build configuration file, created by # sphinx-quickstart on Tue Nov 26 17:11:52 2013. # # 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...
# -*- coding: utf-8 -*- """An extension of the objectfilter to provide plaso specific options.""" from __future__ import unicode_literals import calendar import datetime import logging import re from plaso.formatters import manager as formatters_manager from plaso.formatters import mediator as formatters_mediator f...
import os import sys import random from StringIO import StringIO from nose.tools import eq_, nottest from setlx2py.setlx_util import run FIXTURES = os.path.abspath('tests/fixtures') REFERENCE = os.path.join(FIXTURES, 'reference') SOURCE_EXAMPLES = os.path.join(FIXTURES, 'examples') SOURCE_LOGIC = os.path.join(FIXT...
""" The attributes module provides a simple yet flexible attribute framework for python classes, built on top of the built-in python properties. >>> ############################### >>> # Attribute Basics >>> ############################### >>> >>> #------ typed attributes ------ >>> >>> class PhotoIdentification (obje...
### $Id$ ### $URL$ from sfa.trust.certificate import Keypair, convert_public_key from sfa.trust.gid import * from sfa.util.faults import * from sfa.util.misc import * from sfa.util.method import Method from sfa.util.parameter import Parameter, Mixed from sfa.util.record import GeniRecord from sfa.util.debug import lo...
#!/usr/bin/env python3 ''' Description: Fetches a list of all the Steam ID's and checks the current pricing of each game ''' import time import requests import json import datetime from sqlalchemy import create_engine, ForeignKey from sqlalchemy import Column, Date, DateTime, Integer, String from sqlalchemy.ext.declar...
""" The attributes module provides a simple yet flexible attribute framework for python classes, built on top of the built-in python properties. >>> ############################### >>> # Attribute Basics >>> ############################### >>> >>> #------ typed attributes ------ >>> >>> class PhotoIdentification (obje...
#---------------------------------------------------------------------- # Copyright (c) 2008 Board of Trustees, Princeton University # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and/or hardware specification (the "Work") to # deal in the Work without restriction, i...
""" This file is part of the PyMeasure package. Copyright (c) 2013-2015 Colin Jermain, Graham Rowlands Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limi...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # nanodbc documentation build configuration file, created by # sphinx-quickstart on Tue Nov 1 22:27:39 2016. # # 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 # au...
""" Linearization of higher order solutions for the purposes of visualization. """ import numpy as nm from sfepy.linalg import dot_sequences from sfepy.fem.refine import refine_reference def get_eval_dofs(dofs, dof_conn, ps, ori=None): """ Get default function for evaluating field DOFs given a list of element...
""" PDBProp ======= """ import gzip import json import logging import os.path as op import mmtf import os from cobra.core import DictList import pandas as pd import requests import deprecation from Bio.PDB import PDBList from lxml import etree from six.moves.urllib_error import URLError from six.moves.urllib.request i...
#!/usr/bin/env python3 import math def float_eq(a, b): """Check if two floats are equal within a certain accuracy.""" epsilon = 2**(-30) if abs(a - b) < epsilon: return True else: return False def line_intersects_segment(line, line_segment): """Returns the intersection the Line an...
import os.path as op import sfepy from sfepy.base.base import * import sfepy.base.ioutils as io from sfepy.base.conf import ProblemConf, get_standard_keywords, transform_variables from functions import Functions from mesh import Mesh from domain import Domain from fields import fields_from_conf from variables import ...
from lib.system import System import time system = System() print "has printer?", system.has_printer() if system.has_printer(): printer = system.printer() print "using printer", printer print "sending job to printer..." job = printer.send_to_printer("/tmp/image.jpg") while True: print system.pr...
import numbers import os from sig_utils import overload_scalar, get_cpp_type, arg_types class CppStatement: """Base class for all statements. Implements some default checks. Should not be used directly""" def __init__(self): raise Exception("CppStatement should never be instantiated directly") ...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Tests for `fibonacci` module. """ import pytest from fibonacci import fibonacci TEST_DATA = ( pytest.mark.xfail(raises=ValueError)((-1, 0)), pytest.mark.xfail(raises=ValueError)((1.4, 2)), (0, 0), (1, 1), (2, 1), (3, 2), (8, 21), (24,...
""" ******************************************************************************** * Name: tethys_gizmos.py * Author: Nathan Swain * Created On: 2014 * Copyright: (c) Brigham Young University 2014 * License: BSD 2-Clause ******************************************************************************** """ import os im...
# -*- coding: utf-8 -*- # # django-payments documentation build configuration file, created by # sphinx-quickstart on Thu Sep 30 16:25:38 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....
#!/usr/bin/env python # -*- coding: UTF-8 -*- import time import os import select import Queue import subprocess from Tkinter import * from chk_wiki import Wiki from responses import Response from chat_socket import ChatSocket class Client(object): def __init__(self, **kwargs): se...
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright 2015 clowwindy # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required b...
60845b4a-2e74-11e5-9284-b827eb9e62be
# # # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # ...
# Shortcuts to MIB instrumentation items used internally in SNMP applications import string from pysnmp.smi.error import SmiError, NoSuchObjectError from pysnmp.smi.exval import noSuchInstance from pysnmp.entity import config def getVersionSpecifics(snmpVersion): pass def getTargetAddr(snmpEngine, snmpTargetAddrName)...
# -*- coding: utf-8 -*- import pytest @pytest.yield_fixture def ogr(): import gdaltools ogr = gdaltools.ogr2ogr() yield ogr @pytest.yield_fixture def tmpdir(): import tempfile tmp_path = tempfile.mkdtemp() yield tmp_path import shutil shutil.rmtree(tmp_path) @pytest.fixture def tmp...
from rest_framework.permissions import BasePermission, SAFE_METHODS class IsOwnerOrReadOnly(BasePermission): message = 'You must be the owner of the object.' #my_safe_method = ['GET', 'PUT'] #def has_permission(self, request, view): #if request.method in self.my_safe_method: #return True #return False de...
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright 2015 clowwindy # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required b...
import sys import os from goatools.obo_parser import GODag ROOT = os.path.dirname(os.path.abspath(__file__)) + "/data/" def prt_paths(paths, PRT=sys.stdout): for path in paths: PRT.write('\n') for GO in path: PRT.write('{}\n'.format(GO)) def chk_results(actual_paths, expected_paths)...
try: import time, random, re, pycurl, hmac, urllib, simplejson, sys, calendar from hashlib import sha256 try: from io import BytesIO except ImportError: from StringIO import StringIO as BytesIO POPULAR = 1 LIKE = 2 LIKE_FOLLOW = 3 UNFOLLOW = 4 # # 1: Swap out <C...
# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
# See LICENSE file for copyright and license details. """ amprolla configuration file """ # from hashlib import md5, sha1, sha256 from hashlib import sha256 cpunm = 2 # number of cpus you want to use for multiprocessing logdir = '/home/amprolla/amprolla/log' spooldir = '/home/amprolla/amprolla/spool' gpgdir = '/hom...
start = 0 try: import time import random import re import pycurl import hmac import urllib import urllib2 import simplejson import sys import calendar import options from hashlib import sha256 try: from io import BytesIO except ImportError: from St...
import numpy as np import multiprocessing import sys from .explainer import Explainer have_cext = False try: from .. import _cext have_cext = True except ImportError: pass except: print("the C extension is installed...but failed to load!") pass try: import xgboost except ImportError: pass ...
class FileHandler(object): def __init__(self, path): self.path = path def escape_str(self, string): return string.replace(r'"', r'\"') def save(self, data, num): with open(self.path, 'w') as fd: fd.write('var data = [') for k1 in data: for k2 in data: if k2 in data[k1].keys(): perc = fl...
"""Tests for the _pyjava module. This package contains tests for the internal components of PyJava, implemented in C as the _pyjava package. Even if it is not used directly but rather through the pyjava Python interface, the package is covered by tests. """ import math import _pyjava from base import PyjavaTestCas...
# -*- coding: utf-8 -*- from __future__ import print_function import os import shutil import sys import requests import zipfile import time DEFAULT_REPO = "ywangd" DEFAULT_BRANCH = "master" TMPDIR = os.environ.get('TMPDIR', os.environ.get('TMP')) URL_TEMPLATE = 'https://github.com/{}/stash/archive/{}.zip' TEMP_ZIPFIL...
import unittest from collections import namedtuple from functional.chain import seq, FunctionalSequence, _wrap, _is_iterable class TestChain(unittest.TestCase): def assert_type(self, s): self.assertTrue(isinstance(s, FunctionalSequence)) def assert_not_type(self, s): self.assertFalse(isinsta...
""" Created on 8th October 2018 :author: Adam Neaves """ import logging from tornado.escape import json_decode from odin_data.ipc_tornado_channel import IpcTornadoChannel import numpy as np import cv2 import re from collections import OrderedDict from odin.adapters.adapter import ApiAdapter, ApiAdapterResponse, res...
# -*- coding: utf-8 -*- # tmccli / connection.py # ====================== # # Handles connections to the TMC server and checking for errors. # # Copyright 2014 Juhani Imberg import requests import os import sys from vlog import VLog as v import zipfile from course import Course from exercise import Exercise import ...
import unittest import itertools import re import platform from pymel.all import * from pymel.tools.pymelControlPanel import getClassHierarchy from pymel.core.factories import ApiEnumsToPyComponents import pymel.mayahook as mayahook from testingutils import TestCaseExtended, setCompare VERBOSE = True def getFundame...
f3abbde8-2e72-11e5-9284-b827eb9e62be
# -*- Mode: Python; py-indent-offset: 4 -*- # vim: tabstop=4 shiftwidth=4 expandtab import unittest import sys import os sys.path.insert(0, "../") from compathelper import _long, _unicode from gi.repository import GLib from gi.repository import GObject from gi.repository import Gdk from gi.repository import Gtk fro...
import copy import datetime import fedmsg.meta import fedmsg.consumers import statscache.utils import logging log = logging.getLogger("fedmsg") class StatsConsumer(fedmsg.consumers.FedmsgConsumer): """ This consumer class propagates copies of incoming messages to the producers to cache for later processi...
# Object models for SDK import six from functools import partial from collections import namedtuple from .client import get_client from .utils import to_api, from_api, enum, get_location_id, file_exists from .errors import AppPlatformError from.generics import AudioMixin class BaseResource(object): client = None ...
#!/usr/bin/env python """ $Id$ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ import re from xml.etree import ElementTree as ET from lib.core.common import getCompiledRegex from lib.core.common import getInjectionCase from lib.core.c...
# -*- coding: utf-8 -*- import unittest import bst class TestDelete(unittest.TestCase): """Tests deletion of nodes from BST.""" def test_empty_tree(self): tree = bst.BinarySearchTree() self.assertFalse(tree.delete(1)) self.assertEqual(tree.size, 0) def test_nonempty_tree_key_not_found(self): ...
import requests, json import urllib3 urllib3.disable_warnings() import config as config class Glower(object): sid = None token = None params = {} config = config def __init__(self, _sid, _token, **kwargs): setattr(self, 'sid', _sid) setattr(self, 'token', _token) for key, val in ...
9f6d2578-2e72-11e5-9284-b827eb9e62be
class Lexer: def __init__(self): self.__current_delim = None # This is bad. The lexer itself should not be stateful. def tokenize(self, characters): return [token for token in self.__split_into_tokens(characters)] def __split_into_tokens(self, characters): current_word = '' ...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Tests methods of the TEC class. """ __author__ = "Joshua Ryan Smith (joshua.r.smith@gmail.com)" __version__ = "" __date__ = "" __copyright__ = "Copyright (c) 2012 Joshua Ryan Smith" __license__ = "" from tec import TEC import unittest import pickle class MethodsSpec...
## # Copyright 2016 Sagnik Ghosh, licensed under the Apache 2.0 License. # # GooPyCharts: an interface between Python and Google Charts API. Written to serve as a simple substitute # for matplotlib. Syntax is similar to MATLAB figures. ## # Python3 compatibility import sys python_version = sys.version_info[0] if pytho...
""" User-related remote objects. """ import urllib from ..core.api import RemoteObject, ListObject, fields from ..core.models import Company from ..static.fields import StaticData class User(RemoteObject): company = fields.Locator(Company) email = fields.Field() firstName = fields.Field() lastName ...
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function import base64 import hashlib import time import functools import json import io import os import re import xml.dom.minidom import xml.etree.ElementTree as ET import threading import shutil from datetime import datetim...
b58acf76-2e73-11e5-9284-b827eb9e62be
from nullroute.core import Core import uuid from .entry_util import * from .string import * class FilterSyntaxError(Exception): pass class Filter(): def __call__(self, entry): return bool(self.test(entry)) @staticmethod def parse(text): token = "" tokens = [] depth = ...
""" :mod:`disco.util` --- Helper functions ====================================== This module provides utility functions that are mostly used by Disco internally. The :func:`external` function below comes in handy if you use the Disco external interface. """ import os, sys import cPickle, marshal, time, gzip import c...
53f3fbf2-2e73-11e5-9284-b827eb9e62be
"""Send data to Graphite metrics server (synchronously or on a background thread). For example usage, see README.rst. This code is licensed under a permissive MIT license -- see LICENSE.txt. The graphyte project lives on GitHub here: https://github.com/Jetsetter/graphyte """ import atexit import logging try: im...
bcedd4f8-2e72-11e5-9284-b827eb9e62be
#!/usr/bin/python import json import re import subprocess from ansible.module_utils.basic import * def _escape_single_quotes(string): return re.sub("'", r"'\''", string) def _split_key(full_key): key_array = full_key.split('.') schema = '.'.join(key_array[0:-1]) single_key = key_array[-1] return...
e9bdf7c4-2e72-11e5-9284-b827eb9e62be
b3d6b4d8-2e73-11e5-9284-b827eb9e62be
a9552460-2e71-11e5-9284-b827eb9e62be
#!/usr/bin/env python3 """ DCSO TIE2MISP Parser Copyright (c) 2017, DCSO GmbH """ import click from datetime import datetime, timedelta from model import Config from loader import Loader @click.command() @click.argument('type') @click.option('--delay', default=0, help='Specify a delay from which data should be analy...
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
9ed447aa-2e71-11e5-9284-b827eb9e62be
import unittest from whoosh import fields, index, searching, scoring, store, writing from whoosh.query import * class TestReading(unittest.TestCase): def setUp(self): s = fields.Schema(key = fields.ID(stored = True), name = fields.TEXT, value = fields.TE...
import os import time import re import numpy as np import simulation.model.constants import util.batch.universal.system import util.io.fs import util.petsc.universal import util.logging class Metos3D_Job(util.batch.universal.system.Job): IGNORE_ERROR_KEYWORDS = tuple(error_message.lower() for error_message i...
import os, subprocess, re, shutil, logging, datetime, json from ftplib import FTP from timeit import timeit def logger(message): if(os.path.isdir("Logs") == False): os.mkdir("Logs") LOG_FILENAME = "Logs/" + datetime.datetime.now().strftime("%Y-%m-%d") + ".log" logging.basicConfig(filename=LOG_FIL...
#!/usr/bin/python # -*- coding: utf-8 -*- import unittest from rmgpy.molecule import * from rmgpy.group import Group from rmgpy.element import getElement, elementList ################################################################################ class TestAtom(unittest.TestCase): """ Contains unit tests o...
f441d3e2-2e71-11e5-9284-b827eb9e62be
from unittest import TestCase from dbt.adapters.cache import RelationsCache from dbt.adapters.default.relation import DefaultRelation from multiprocessing.dummy import Pool as ThreadPool import dbt.exceptions import random import time def make_relation(schema, identifier): return DefaultRelation.create(schema=sc...
import socket UDP_IP = "0.0.0.0" UDP_PORT = 9050 sock = socket.socket(socket.AF_INET, # Internet protocol socket.SOCK_DGRAM) # User Datagram (UDP) sock.bind((UDP_IP, UDP_PORT)) while True: data, addr = sock.recvfrom(1280) # Max recieve size is 1280 bytes print "received message:", data
661d823a-2e73-11e5-9284-b827eb9e62be
"""Sublime Text Color Scheme Editor.""" from __future__ import unicode_literals import argparse import os import sys from .lib import __meta__ from .lib.gui import custom_app from .lib.gui import subclrschm_app from .lib import util def parse_arguments(script): """Parse the command arguments.""" parser = arg...
613ae252-2e74-11e5-9284-b827eb9e62be
__metaclass__ = type from argparse import Namespace from collections import OrderedDict from contextlib import contextmanager import os from tempfile import ( mkdtemp, NamedTemporaryFile, ) from textwrap import dedent from unittest import TestCase from boto.ec2.securitygroup import SecurityGroup from mock...
import time from random import uniform from typing import Callable, Optional class Retry: def __init__( self, total: int = 3, backoff_factor: float = 0.2, jitter: float = 0.2, quiet: bool = False ) -> None: self.total = total self.__backoff_factor = backoff_factor self.__jitter...
import numpy as np import scipy.integrate import scipy.optimize DEG2RAD = np.pi/180 def _toArray(x): """Convert x to array if needed Returns: array(x), boolean if x was an array before """ if isinstance(x, np.ndarray): return x, True if hasattr(x, '__iter__'): return np.ar...
ae5d54c6-2e73-11e5-9284-b827eb9e62be
from six.moves import xrange import tensorflow as tf from .var_layer import VarLayer from ..tf import sparse_identity, sparse_tensor_diag_matmul def conv(features, adj, weights): n = adj.dense_shape[0] degree = tf.sparse_reduce_sum(adj, axis=1) + 1 degree = tf.cast(degree, tf.float32) degree = tf.p...
27ac65de-2e73-11e5-9284-b827eb9e62be
91fe5ec4-2e73-11e5-9284-b827eb9e62be
#!/usr/bin/env python """X12.parse defines classes to build an X12 message parser. An :class:`X12.parse.Parser` object participates in several use cases. 1. It is used to unmarshall X12 message text and create a message instance, :class:`X12.message.X12Message` structures, from that text. 2. It can...
#!/usr/bin/env python2.7 # Copyright (c) 2017-2018 Metempsy Technology Consulting # 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 ...
#=================# # Clear Tile Statistics def clearStats(list_stats, host='localhost', port='27017', dbname='tilejet', GEVENT_MONKEY_PATCH=False): # Import Gevent and monkey patch if GEVENT_MONKEY_PATCH: from gevent import monkey monkey.patch_all() # Update MongoDB from pymongo import...