text stringlengths 0 2.53M |
|---|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Provides ``mapping`` of url paths to request handlers.
"""
from bootstrap import Bootstrap
from fund import InstantPaymentNotificationHandler
from fund import ThankYouHandler
from view import *
mapping = [
(r"/", Index),
(r"/ipn", InstantPaymentNotificationHa... |
import msgpack
import gevent.pool
import gevent.queue
import gevent.event
import gevent.local
import gevent.lock
import logging
import sys
import gevent_zmq as zmq
from .exceptions import TimeoutExpired
from .context import Context
from .channel_base import ChannelBase
if (sys.version_info < (2, 7)):
def get_pyzmq... |
#!/usr/bin/env python
"""Django's command line utility."""
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
|
"""Installer for hippybot
"""
import os
cwd = os.path.dirname(__file__)
__version__ = open(os.path.join(cwd, "hippybot", "version.txt"), "r").read().strip()
try:
from setuptools import setup, find_packages
except ImportError:
from ez_setup import use_setuptools
use_setuptools()
from setuptools impor... |
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "twobuntu.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
|
# -*- coding: utf-8 -*-
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.CreateModel(
name="Category",
fields=[
(
"id",
models.AutoField(
... |
import twitter
from django.contrib import messages
from django.contrib.auth.decorators import user_passes_test
from django.db import transaction
from django.shortcuts import redirect, render
from twobuntu.news.forms import AddItemForm
@user_passes_test(lambda u: u.is_staff)
def add(request):
"""
Add news ite... |
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010-2015, 2degrees Limited.
# All Rights Reserved.
#
# This file is part of django-wsgi <https://github.com/2degrees/django-wsgi/>,
# which is subject to the provisions of the BSD at
# <http://dev.2... |
import boto
import boto.s3.connection
from django.conf import settings
import logging
log = logging.getLogger(__name__)
def get_s3_connection():
if settings.S3_ACCESS_KEY and settings.S3_SECRET_KEY and settings.S3_HOST:
log.debug(
"Connecting to {}, with secure connection is {}".format(
... |
from django.db import models
import datetime
from common.models import Project
class Stage(models.Model):
name = models.CharField(max_length=128)
project = models.ForeignKey(Project)
text = models.TextField(default="", blank=True)
link = models.URLField(default=None, blank=True, null=True)
state ... |
# -*- coding: utf-8 -*-
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
("testreport", "0026_testresult_launch_item_id"),
]
operations = [
migrations.AddField(
model_name="testplan",
name="filter",
fiel... |
import gevent
from gevent import monkey
()
import time
import smtplib
TEST_MAIL = '\nDate: Wed, 30 Jul 2014 03:29:50 +0800 (CST)\nFrom: =?utf-8?B?6IGU5oOz?= <client@gsmtpd.org>\nTo: test@gsmtpd.org\nMessage-ID: <766215193.1675381406662190229.JavaMail.root@USS-01>\nSubject: =?utf-8?B?6IGU5oOz56e75Yqo5LqS6IGU572R5pyN5Yqh... |
#!/usr/bin/env python
import sys
import json
if sys.version_info < (3,):
def b(x):
return x
def s(x):
return x
else:
def b(x):
return bytes(x, "utf-8")
def s(x):
return x.decode("utf-8")
def parse_payload(payload):
if not isinstance(payload, str):
pay... |
from flask_resty import Api, GenericModelView
from marshmallow import fields, Schema
import pytest
from sqlalchemy import Column, Integer, String
import helpers
@pytest.yield_fixture
def models(db):
class Widget(db.Model):
__tablename__ = 'widgets'
id_1 = (Integer)
id_2 = (Integer)
... |
from .dogpile import Dogpile
|
"""
RPi-Tron-Radio
Raspberry Pi Web-Radio with 2.8" TFT Touchscreen and Tron-styled graphical interface
GitHub: http://github.com/5volt-junkie/RPi-Tron-Radio
Blog: http://5volt-junkie.net
MIT License: see license.txt
"""
import pygame
from pygame.locals import *
import time
import datetime
import sys
import os
im... |
# coding:utf8
"""
Created on 2013-7-10
memcached client
@author: lan (www.9miao.com)
"""
import memcache
class MemConnError(Exception):
""" """
def __str__(self):
return "memcache connect error"
class MemClient:
"""memcached"""
def __init__(self, timeout=0):
""" """
self._h... |
""" Really basic gatttool (BlueZ) wrapper
Based on https://github.com/stratosinc/pygatt
Part of https://github.com/ALPSquid/thebutton-monitor
"""
import pexpect
class connect:
"""Use to initiate a connection to a GATT device
Example: bt_device = gatt.connect('AB:CD:EF:01:23:45')
"""
def __init__(se... |
# -*- coding: utf-8 -*-
from django.db import models, migrations
import wagtail.wagtailcore.fields
class Migration(migrations.Migration):
dependencies = [
("puput", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="blogpage",
name="description"... |
"""
==================================
Map two radars to a Cartesian grid
==================================
Map the reflectivity field of two nearby ARM XSARP radars from antenna
coordinates to a Cartesian grid.
"""
print(__doc__)
# Author: Jonathan J. Helmus (jhelmus@anl.gov)
# License: BSD 3 clause
import matplo... |
"""
pyart.exceptions
================
Custom Py-ART exceptions.
.. autosummary::
:toctree: generated/
MissingOptionalDependency
DeprecatedAttribute
DeprecatedFunctionName
_deprecated_alias
"""
import warnings
class MissingOptionalDependency(Exception):
"""Exception raised when a optional ... |
'\npyart.io.nexrad_archive\n=======================\n\nFunctions for reading NEXRAD Level II Archive files.\n\n.. autosummary::\n :toctree: generated/\n :template: dev_template.rst\n\n _NEXRADLevel2StagedField\n\n.. autosummary::\n :toctree: generated/\n\n read_nexrad_archive\n _find_range_params\n ... |
"""
pyart.io.uf
===========
Reading of Universal format (UF) files
.. autosummary::
:toctree: generated/
read_uf
_get_instrument_parameters
"""
import warnings
import numpy as np
from netCDF4 import date2num
from ..config import FileMetadata, get_fillvalue
from ..core.radar import Radar
from .common ... |
#! /usr/bin/env python
"""
Make a small netCDF CF/Radial file containing a single RHI scan.
Single field and scan is converted from sigmet file XSW110520113537.RAW7HHL
"""
import pyart
radar = pyart.io.read_rsl("XSW110520113537.RAW7HHL")
time_slice = slice(None, 713, 18)
range_slice = slice(None, None, 12)
sweep_sl... |
"""
pyart.util.radar_utils
======================
Functions for working radar instances.
.. autosummary::
:toctree: generated/
is_vpt
to_vpt
join_radar
"""
import copy
import numpy as np
from netCDF4 import num2date, date2num
from . import datetime_utils
def is_vpt(radar, offset=0.5):
"""
... |
"""
Default config for Workload Automation. DO NOT MODIFY this file. This file
gets copied to ~/.workload_automation/config.py on initial run of run_workloads.
Add your configuration to that file instead.
"""
# *** WARNING: ***
# Configuration listed in this file is NOT COMPLETE. This file sets the default
# configur... |
# Copyright 2014-2015 ARM Limited
#
# 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 agreed to in w... |
"""Louie version information."""
NAME = "Louie"
DESCRIPTION = "Signal dispatching mechanism"
VERSION = "1.1"
|
import os
import sqlite3
import json
import uuid
from datetime import datetime, timedelta
from contextlib import contextmanager
from wlauto import ResultProcessor, settings, Parameter
from wlauto.exceptions import ResultProcessorError
from wlauto.utils.types import boolean
SCHEMA_VERSION = '0.0.2'
SCHEMA = ['CREATE TAB... |
# Copyright 2012-2015 ARM Limited
#
# 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 agreed to in w... |
# Copyright 2013-2015 ARM Limited
#
# 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 agreed to in w... |
#!/usr/bin/env python
"""
mbed SDK
Copyright (c) 2011-2016 ARM Limited
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 ... |
#!/usr/bin/env python
"""
mbed SDK
Copyright (c) 2011-2015 ARM Limited
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 ... |
#!/usr/bin/python
#
import sys
input = open(sys.argv[1], "r")
output = open(sys.argv[2], "w")
for line in input:
if line[0] == ">":
print("@HTW-" + line[1:-1], file=output)
continue
else:
print(line[:-1], file=output)
print("+", file=output)
print("H" * len(line[:-1]), ... |
# Main entry point for the plugin.
# Author: Yuri van Geffen
import sublime, sublime_plugin
import os
import threading
import queue
import asyncore
import socket
from itertools import chain
import re
settings = sublime.load_settings("subdebug")
TCP_IP = "127.0.0.1"
TCP_PORT = 8172
BUFFER_SIZE = 1024
BASEDIR = sett... |
from django.contrib import sitemaps
from django.core.urlresolvers import reverse
class StaticViewSitemap(sitemaps.Sitemap):
priority = 0.5
changefreq = "monthly"
def items(self):
return [
"landpage",
"robots",
"humans",
"google_plus_verify",
... |
from django.conf.urls import patterns, include, url
from publisher.views import catalog
from publisher.views import my_publication
from publisher.views import publication
urlpatterns = patterns(
"",
# Publications(s)
url(r"^publish$", catalog.catalog_page),
url(r"^publication/(\d+)$", publication.publi... |
"""added goal properties
Revision ID: 5018059c5c8f
Revises: 16b4a243d41d
Create Date: 2015-09-23 11:56:01.897992
"""
# revision identifiers, used by Alembic.
revision = "5018059c5c8f"
down_revision = "16b4a243d41d"
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
def upgrade()... |
# Demonstration of `applib` features
import logging
from applib.base import Cmdln, Application
from applib.misc import require_option
from applib import textui, sh, _cmdln as cmdln
LOG = logging.getLogger(__name__)
application = Application("demo-app", "CompanyNameHere", "1.2")
@cmdln.option("", "--foo", action="... |
# Copyright (c) 2015-2016, Activision Publishing, Inc.
# 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 notice, this
# list of ... |
import sys
import math
import scipy
import pylab
import scipy.io.wavfile as wav
import wave
from scipy import signal
from itertools import product
import numpy
def readWav():
"""
Reads a sound wave from a standard input and finds its parameters.
"""
# Read the sound wave from the input.
sound_wav... |
__author__ = "Ahmed Hani Ibrahim"
class Action(object):
def GetActionName(self):
return self.__name
def SetActionName(self, name):
self.__name = name
def __init__(self, name):
self.__name = name
|
# auto-generated file
import _cffi_backend
ffi = _cffi_backend.FFI(
"_simple_example",
_version=0x2601,
_types=b"\x00\x00\x04\x0D\x00\x00\x03\x03\x00\x00\x01\x0F\x00\x00\x02\x01\x00\x00\x07\x01",
_globals=(
b"\x00\x00\x00\x23printf",
0,
),
)
|
#!/usr/bin/env python
from dnslib import *
packet = binascii.unhexlify(
b"d5ad818000010005000000000377777706676f6f676c6503636f6d0000010001c00c0005000100000005000803777777016cc010c02c0001000100000005000442f95b68c02c0001000100000005000442f95b63c02c0001000100000005000442f95b67c02c0001000100000005000442f95b93"
)
d = ... |
from app import app
if __name__ == "__main__":
app.run()
|
# coding: utf-8
from flask import render_template, Blueprint, redirect, request, url_for
from ..forms import SigninForm, SignupForm
from ..utils.account import signin_user, signout_user
from ..utils.permissions import VisitorPermission, UserPermission
from ..models import db, User
bp = Blueprint("account", __name__)
... |
from app import app, db
import unittest
import os
import tempfile
from flask import json
TEST_DB = "test.db"
class BasicTestCase(unittest.TestCase):
def test_index(self):
"""inital test. ensure flask was set up correctly"""
tester = app.test_client(self)
response = tester.get("/", content... |
#!/usr/bin/env python
# encoding: utf-8
import json
data = [{"a": "A", "b": (2, 4), "c": 3.0}]
print("DATA:", repr(data))
unsorted = json.dumps(data)
print("JSON:", json.dumps(data))
print("SORT:", json.dumps(data, sort_keys=True))
first = json.dumps(data, sort_keys=True)
second = json.dumps(data, sort_keys=True)
... |
#!/usr/bin/env python
# Exercise 30: Else and If
people = 30
cars = 40
trucks = 15
if cars > people:
print("We should take the cars.")
elif cars < people:
print("We should not take the cars.")
else:
print("We can't decide.")
if trucks > cars:
print("That's too many trucks.")
elif trucks < cars:
... |
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import _thread
import time
mylock = _thread.allocate_lock() # Allocate a lock
num = 0 # Shared resource
def add_num(name):
global num
while True:
mylock.acquire() # Get the lock
# Do something to the shared resource
print(("Thread %s... |
#!/usr/bin/env python
# encoding: utf-8
"""Expand shell variables in filenames.
"""
import os.path
import os
os.environ["MYVAR"] = "VALUE"
print(os.path.expandvars("/path/to/$MYVAR"))
|
#!/usr/bin/env python
import pyglet
from pyglet.window import key
from pyglet.window import mouse
window = pyglet.window.Window()
@window.event
def on_key_press(symbol, modifiers):
print("key %s was pressed" % symbol)
if symbol == key.A:
print('The "A" key was pressed.')
elif symbol == key.LEFT... |
number = 53
go = True
while go:
guess = int(raw_input('input a number please'))
if guess == number:
print 'correct'
go = False
elif guess < number:
print 'try a bigger one'
else:
print 'try a smaller one'
else:
print 'it\'s over'
|
import os
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, "README.txt")) as f:
README = f.read()
with open(os.path.join(here, "CHANGES.txt")) as f:
CHANGES = f.read()
requires = [
"pyramid",
"pyramid_chameleon",
"pyramid_d... |
from mako.template import Template
from mako.runtime import Context
from io import StringIO
mytemplate = ('hello, ${name}!')
buf = ()
ctx = (buf)
(ctx)
(()) |
#!/usr/bin/env python
"""Test for inequality
"""
import unittest
class InequalityTest(unittest.TestCase):
def testEqual(self):
self.assertNotEqual(1, 3 - 2)
def testNotEqual(self):
self.assertEqual(2, 3 - 2)
if __name__ == "__main__":
unittest.main()
|
from tests.common import parent_id, parent_name, child_id, child_parent_id, relation, child, parent
from eralchemy.main import _intermediary_to_markdown
import re
import pytest
column_re = ('(?P<key>\\*?)(?P<name>[^*].+) \\{label:"(?P<type>.+)"\\}')
def test_all_to_er():
tables = [child, parent]
relations = [r... |
from django.http import Http404
from django.shortcuts import render_to_response
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
###########
# CHOICES #
###########
def choice_list(request, app_label, module_name, field_name, models):
m, f = lookup_field(app_label, module_name, field_name... |
"""
This is testing project for KeyKeeper application.
"""
|
"""Dynamic REST (or DREST) is an extension of Django REST Framework.
DREST offers the following features on top of the standard DRF kit:
- Linked/embedded/sideloaded relationships
- Field inclusions/exlusions
- Field-based filtering/sorting
- Directory panel for the browsable API
- Optimizations
"""
|
# -*- coding: utf-8 -*-
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("contenttypes", "0001_initial"),
("tests", "0002_auto_20160310_1052"),
]
operations = [
migrations.AddField(
model_name="user",
name=... |
"""FamilySearch User submodule"""
# Python imports
# Magic
class User(object):
"""https://familysearch.org/developers/docs/api/resources#user"""
def __init__(self):
"""https://familysearch.org/developers/docs/api/examples#user"""
pass
def current_user(self):
"""https://familyse... |
"""
[Advanced] [In-development]
Export a program list to a single yaml file.
The export may contain machine specific paths.
and may need to be edited for portability
"""
from argparse import FileType
import logging
import sys
import yaml
from chalmers.utils.cli import add_selection_group, select_programs
log = ... |
"""
Linux services, this module checks the existence of linux command line
programs on import
* systemd_service
* upstart_service
* sysv_service
* cron_service
In that order
"""
import logging
import platform
import sys
from . import cron_service, sysv_service, upstart_service, systemd_service
from chalmers... |
import abc
import logging
import traceback
import servicemanager
import win32event, win32service, win32api
from win32serviceutil import ServiceFramework
log = logging.getLogger(__name__)
class WindowsService(object, ServiceFramework, metaclass=abc.ABCMeta):
"""
Base windows service class that provides all ... |
# Copyright (c) 2014 Johan Burke
# Distributed under the MIT software license. See http://www.opensource.org/licenses/mit-license.php.
from ..pyelliptic.ecc import *
from ..threads.threadutils import *
from ..constants import *
from .key import *
import hashlib
from struct import *
import sys
def encodeInt(val, alp... |
from anymesh import AnyMesh, AnyMeshDelegateProtocol
class LeftDelegate(AnyMeshDelegateProtocol):
def connected_to(self, device_info):
print(("left connected to " + device_info.name))
def disconnected_from(self, name):
pass
def received_msg(self, message):
print(("left received m... |
import unittest
import doctest
import urwid
def load_tests(loader, tests, ignore):
module_doctests = [
urwid.widget,
urwid.wimp,
urwid.decoration,
urwid.display_common,
urwid.main_loop,
urwid.monitored_list,
urwid.raw_display,
"urwid.split_repr", #... |
import logging
log = logging.getLogger(__name__)
EXCLUDED_LOG_VARS = [
"threadName",
"name",
"thread",
"created",
"process",
"processName",
"args",
"module",
"filename",
"levelno",
"exc_text",
"pathname",
"lineno",
"msg",
"exc_info",
"message",
"func... |
import uuid
import datetime
from appenlight_client.timing import get_local_storage
from appenlight_client.timing import default_timer
from appenlight_client.client import PY3
import logging
log = logging.getLogger(__name__)
class AppenlightWSGIWrapper(object):
__version__ = "0.3"
def __init__(self, app, app... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 10