code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
#!/usr/bin/python
import cgi, re, os, posixpath, mimetypes
from mako.lookup import TemplateLookup
from mako import exceptions
root = './'
port = 8000
error_style = 'html' # select 'text' for plaintext error reporting
lookup = TemplateLookup(directories=[root + 'templates', root + 'htdocs'], filesystem_checks=True, m... | Python |
#!/usr/bin/env python
def render(data):
from mako.template import Template
from mako.lookup import TemplateLookup
lookup = TemplateLookup(["."])
return Template(data, lookup=lookup).render()
def main(argv=None):
from os.path import isfile
from sys import stdin
if argv is None:
im... | Python |
from setuptools import setup, find_packages
import os
import re
import sys
extra = {}
if sys.version_info >= (3, 0):
extra.update(
use_2to3=True,
)
v = open(os.path.join(os.path.dirname(__file__), 'mako', '__init__.py'))
VERSION = re.compile(r".*__version__ = '(.*?)'", re.S).match(v.read()).group(1)
v... | Python |
"""
gae-pytz
========
pytz has a severe performance problem that impedes its usage on Google App
Engine. This is caused because pytz.__init__ builds a list of available
zoneinfos checking the entire zoneinfo database (which means: it tries to open
hundreds of files). This is done in the module globals, so it is not eas... | Python |
'''
Reference tzinfo implementations from the Python docs.
Used for testing against as they are only correct for the years
1987 to 2006. Do not use these for real code.
'''
from datetime import tzinfo, timedelta, datetime
from pytz import utc, UTC, HOUR, ZERO
# A class building tzinfo objects for fixed-offset time zo... | Python |
"""
A pytz version that runs smoothly on Google App Engine.
Based on http://appengine-cookbook.appspot.com/recipe/caching-pytz-helper/
To use, add pytz to your path normally, but import it from the gae module:
from pytz.gae import pytz
Applied patches:
- The zoneinfo dir is removed fr... | Python |
'''
datetime.tzinfo timezone definitions generated from the
Olson timezone database:
ftp://elsie.nci.nih.gov/pub/tz*.tar.gz
See the datetime section of the Python Library Reference for information
on how to use these modules.
'''
# The Olson database is updated several times a year.
OLSON_VERSION = '2010h'
VERSI... | Python |
'''Base classes and helpers for building zone specific tzinfo classes'''
from datetime import datetime, timedelta, tzinfo
from bisect import bisect_right
try:
set
except NameError:
from sets import Set as set
import pytz
__all__ = []
_timedelta_cache = {}
def memorized_timedelta(seconds):
'''Create only... | Python |
#!/usr/bin/env python
'''
$Id: tzfile.py,v 1.8 2004/06/03 00:15:24 zenzen Exp $
'''
from cStringIO import StringIO
from datetime import datetime, timedelta
from struct import unpack, calcsize
from pytz.tzinfo import StaticTzInfo, DstTzInfo, memorized_ttinfo
from pytz.tzinfo import memorized_datetime, memorized_timede... | Python |
# A reaction to: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/552751
from webob import Request, Response
from webob import exc
from simplejson import loads, dumps
import traceback
import sys
class JsonRpcApp(object):
"""
Serve the given object via json-rpc (http://json-rpc.org/)
"""
def __i... | Python |
import os
import urllib
import time
import re
from cPickle import load, dump
from webob import Request, Response, html_escape
from webob import exc
class Commenter(object):
def __init__(self, app, storage_dir):
self.app = app
self.storage_dir = storage_dir
if not os.path.exists(storage_dir... | Python |
import os
import re
from webob import Request, Response
from webob import exc
from tempita import HTMLTemplate
VIEW_TEMPLATE = HTMLTemplate("""\
<html>
<head>
<title>{{page.title}}</title>
</head>
<body>
<h1>{{page.title}}</h1>
{{if message}}
<div style="background-color: #99f">{{message}}</div>
{{endif}}
<div>{... | Python |
import unittest
import doctest
def test_suite():
flags = doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE
return unittest.TestSuite((
doctest.DocFileSuite('test_request.txt', optionflags=flags),
doctest.DocFileSuite('test_response.txt', optionflags=flags),
doctest.DocFileSuite('test_dec.tx... | Python |
# -*- coding: utf-8 -*-
from webob import __version__
extensions = ['sphinx.ext.autodoc']
source_suffix = '.txt' # The suffix of source filenames.
master_doc = 'index' # The master toctree document.
project = 'WebOb'
copyright = '2011, Ian Bicking and contributors'
version = release = __version__
exclude_patterns =... | Python |
from setuptools import setup
version = '1.2.2'
testing_extras = ['nose']
docs_extras = ['Sphinx']
setup(
name='WebOb',
version=version,
description="WSGI request and response object",
long_description="""\
WebOb provides wrappers around the WSGI request environment, and an
object to help create WSGI... | Python |
#!/usr/bin/env python
from webob.response import Response
def make_middleware(app):
from repoze.profile.profiler import AccumulatingProfileMiddleware
return AccumulatingProfileMiddleware(
app,
log_filename='/tmp/profile.log',
discard_first_request=True,
flush_at_shutdown=True,
... | Python |
#
| Python |
import os, sys
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
import pkg_resources
pkg_resources.require('WebOb')
| Python |
"""
Parses a variety of ``Accept-*`` headers.
These headers generally take the form of::
value1; q=0.5, value2; q=0
Where the ``q`` parameter is optional. In theory other parameters
exists, but this ignores them.
"""
import re
from webob.headers import _trans_name as header_to_key
from webob.util import (
... | Python |
from collections import MutableMapping
from webob.compat import (
iteritems_,
string_types,
)
from webob.multidict import MultiDict
__all__ = ['ResponseHeaders', 'EnvironHeaders']
class ResponseHeaders(MultiDict):
"""
Dictionary view on the response headerlist.
Keys are normalized for ... | Python |
import calendar
from datetime import (
date,
datetime,
timedelta,
tzinfo,
)
from email.utils import (
formatdate,
mktime_tz,
parsedate_tz,
)
import time
from webob.compat import (
integer_types,
long,
native_,
text_type,
)
__all__ = [
'UTC', 'timedelta_to... | Python |
import collections
from datetime import (
date,
datetime,
timedelta,
)
import re
import string
import time
from webob.compat import (
PY3,
text_type,
bytes_,
text_,
native_,
string_types,
)
__all__ = ['Cookie']
_marker = object()
class RequestCookies(collections.MutableM... | Python |
import mimetypes
import os
from webob import exc
from webob.dec import wsgify
from webob.response import Response
__all__ = [
'FileApp', 'DirectoryApp',
]
mimetypes._winreg = None # do not load mimetypes from windows registry
mimetypes.add_type('text/javascript', '.js') # stdlib default is application/x-javascri... | Python |
import binascii
import cgi
import io
import os
import re
import sys
import tempfile
import mimetypes
try:
import simplejson as json
except ImportError:
import json
import warnings
from webob.acceptparse import (
AcceptLanguage,
AcceptCharset,
MIMEAccept,
MIMENilAccept,
NoAccept,
accept_... | Python |
from datetime import (
date,
datetime,
)
import re
from webob.byterange import (
ContentRange,
Range,
)
from webob.compat import (
PY3,
text_type,
)
from webob.datetime_utils import (
parse_date,
serialize_date,
)
from webob.util import (
header_docstring,
wa... | Python |
"""
Decorators to wrap functions to make them WSGI applications.
The main decorator :class:`wsgify` turns a function into a WSGI
application (while also allowing normal calling of the method with an
instantiated request).
"""
from webob.compat import (
bytes_,
text_type,
)
from webob.request import Reque... | Python |
"""
HTTP Exception
--------------
This module processes Python exceptions that relate to HTTP exceptions
by defining a set of exceptions, all subclasses of HTTPException.
Each exception, in addition to being a Python exception that can be
raised and caught, is also a WSGI application and ``webob.Response``
object.
Thi... | Python |
import warnings
from webob.compat import (
escape,
string_types,
text_,
text_type,
)
from webob.headers import _trans_key
def html_escape(s):
"""HTML-escape a string or object
This converts any non-string objects passed into it to strings
(actually, using ``unicode()``). All values ... | Python |
import re
__all__ = ['Range', 'ContentRange']
_rx_range = re.compile('bytes *= *(\d*) *- *(\d*)', flags=re.I)
_rx_content_range = re.compile(r'bytes (?:(\d+)-(\d+)|[*])/(?:(\d+)|[*])')
class Range(object):
"""
Represents the Range header.
"""
def __init__(self, start, end):
assert end is... | Python |
import errno
import sys
import re
try:
import httplib
except ImportError: # pragma: no cover
import http.client as httplib
from webob.compat import url_quote
import socket
from webob import exc
from webob.compat import PY3
__all__ = ['send_request_app', 'SendRequest']
class SendRequest:
"""
Sends the... | Python |
from webob.datetime_utils import *
from webob.request import *
from webob.response import *
from webob.util import html_escape
__all__ = [
'Request', 'LegacyRequest', 'Response', 'UTC', 'day', 'week', 'hour',
'minute', 'second', 'month', 'year', 'html_escape'
]
BaseRequest.ResponseClass = Response
__version_... | Python |
from base64 import b64encode
from datetime import (
datetime,
timedelta,
)
from hashlib import md5
import re
import struct
import zlib
try:
import simplejson as json
except ImportError:
import json
from webob.byterange import ContentRange
from webob.cachecontrol import (
CacheControl,
seri... | Python |
"""
Represents the Cache-Control header
"""
import re
class UpdateDict(dict):
"""
Dict that has a callback on all updates
"""
# these are declared as class attributes so that
# we don't need to override constructor just to
# set some defaults
updated = None
updated_args = None
def ... | Python |
# code stolen from "six"
import sys
import types
# True if we are running on Python 3.
PY3 = sys.version_info[0] == 3
if PY3: # pragma: no cover
string_types = str,
integer_types = int,
class_types = type,
text_type = str
long = int
else:
string_types = basestring,
integer_types = (int, l... | Python |
# (c) 2005 Ian Bicking and contributors; written for Paste
# (http://pythonpaste.org) Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license.php
"""
Gives a multi-value dictionary object (MultiDict) plus several wrappers
"""
from collections import MutableMapping
import warnings
from webob.c... | Python |
"""
Does parsing of ETag-related headers: If-None-Matches, If-Matches
Also If-Range parsing
"""
from webob.datetime_utils import (
parse_date,
serialize_date,
)
from webob.descriptors import _rx_etag
from webob.util import (
header_docstring,
warn_deprecation,
)
__all__ = ['AnyETag', 'NoETag... | Python |
# A reaction to: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/552751
from webob import Request, Response
from webob import exc
from simplejson import loads, dumps
import traceback
import sys
class JsonRpcApp(object):
"""
Serve the given object via json-rpc (http://json-rpc.org/)
"""
def __i... | Python |
import os
import urllib
import time
import re
from cPickle import load, dump
from webob import Request, Response, html_escape
from webob import exc
class Commenter(object):
def __init__(self, app, storage_dir):
self.app = app
self.storage_dir = storage_dir
if not os.path.exists(storage... | Python |
import os
import re
from webob import Request, Response
from webob import exc
from tempita import HTMLTemplate
VIEW_TEMPLATE = HTMLTemplate("""\
<html>
<head>
<title>{{page.title}}</title>
</head>
<body>
<h1>{{page.title}}</h1>
{{if message}}
<div style="background-color: #99f">{{message}}</div>
{{endif}}
<div>{... | Python |
import unittest
import doctest
def test_suite():
flags = doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE
return unittest.TestSuite((
doctest.DocFileSuite('test_request.txt', optionflags=flags),
doctest.DocFileSuite('test_response.txt', optionflags=flags),
doctest.DocFileSuite('test_dec.tx... | Python |
# -*- coding: utf-8 -*-
#
# Paste documentation build configuration file, created by
# sphinx-quickstart on Tue Apr 22 22:08:49 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 pickleabl... | Python |
from setuptools import setup
version = '1.0.8'
setup(
name='WebOb',
version=version,
description="WSGI request and response object",
long_description="""\
WebOb provides wrappers around the WSGI request environment, and an
object to help create WSGI responses.
The objects map much of the specified be... | Python |
#!/usr/bin/env python
import webob
def make_middleware(app):
from repoze.profile.profiler import AccumulatingProfileMiddleware
return AccumulatingProfileMiddleware(
app,
log_filename='/tmp/profile.log',
discard_first_request=True,
flush_at_shutdown=True,
path='/__profile... | Python |
#
| Python |
import os, sys
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
import pkg_resources
pkg_resources.require('WebOb')
| Python |
"""
Parses a variety of ``Accept-*`` headers.
These headers generally take the form of::
value1; q=0.5, value2; q=0
Where the ``q`` parameter is optional. In theory other parameters
exists, but this ignores them.
"""
import re
from webob.util import rfc_reference
from webob.headers import _trans_name as header... | Python |
from webob.multidict import MultiDict
from UserDict import DictMixin
__all__ = ['ResponseHeaders', 'EnvironHeaders']
class ResponseHeaders(MultiDict):
"""
Dictionary view on the response headerlist.
Keys are normalized for case and whitespace.
"""
def __getitem__(self, key):
key = ... | Python |
import time
import calendar
from datetime import datetime, date, timedelta, tzinfo
from rfc822 import parsedate_tz, mktime_tz, formatdate
__all__ = [
'UTC', 'timedelta_to_seconds',
'year', 'month', 'week', 'day', 'hour', 'minute', 'second',
'parse_date', 'serialize_date',
'parse_date_delta', 'serialize... | Python |
import re, time, string
from datetime import datetime, date, timedelta
__all__ = ['Cookie']
class Cookie(dict):
def __init__(self, input=None):
if input:
self.load(input)
def load(self, data):
ckey = None
for key, val in _rx_cookie.findall(data):
if key.lower()... | Python |
import sys, tempfile, warnings
import urllib, urlparse, cgi
if sys.version >= '2.7':
from io import BytesIO as StringIO # pragma nocover
else:
from cStringIO import StringIO # pragma nocover
from webob.headers import EnvironHeaders
from webob.acceptparse import accept_property, Accept, MIMEAccept, NilAccept, M... | Python |
import warnings
import re
from datetime import datetime, date
from webob.byterange import Range, ContentRange
from webob.etag import IfRange, NoIfRange
from webob.datetime_utils import parse_date, serialize_date
from webob.util import rfc_reference
CHARSET_RE = re.compile(r';\s*charset=([^;]*)', re.I)
QUOTES_RE = re... | Python |
"""
Decorators to wrap functions to make them WSGI applications.
The main decorator :class:`wsgify` turns a function into a WSGI
application (while also allowing normal calling of the method with an
instantiated request).
"""
import webob
import webob.exc
from types import ClassType
__all__ = ['wsgify']
class wsgif... | Python |
"""
HTTP Exception
--------------
This module processes Python exceptions that relate to HTTP exceptions
by defining a set of exceptions, all subclasses of HTTPException.
Each exception, in addition to being a Python exception that can be
raised and caught, is also a WSGI application and ``webob.Response``
object.
Thi... | Python |
def rfc_reference(header, section):
if not section:
return ''
major_section = section.split('.')[0]
link = 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec%s.html#sec%s' % (major_section, section)
if header.startswith('HTTP_'):
header = header[5:].title().replace('_', '-')
return " F... | Python |
class Range(object):
"""
Represents the Range header.
This only represents ``bytes`` ranges, which are the only kind
specified in HTTP. This can represent multiple sets of ranges,
but no place else is this multi-range facility supported.
"""
def __init__(self, ranges): # e... | Python |
import cgi
from webob.datetime_utils import *
from webob.request import *
from webob.response import *
# Pylons has imported UnicodeMultiDict directly from this location; so
# we're putting it here just to help them out (though it has also been
# fixed in Pylons tip on 17 Dec 2009)
from webob.multidict import UnicodeMu... | Python |
import re, urlparse, zlib, struct
from datetime import datetime, date, timedelta
from webob.headers import ResponseHeaders
from webob.cachecontrol import CacheControl, serialize_cache_control
from webob.descriptors import *
from webob.datetime_utils import *
from webob.cookies import Cookie, Morsel
from webob.util im... | Python |
"""
Represents the Cache-Control header
"""
import re
class UpdateDict(dict):
"""
Dict that has a callback on all updates
"""
# these are declared as class attributes so that
# we don't need to override constructor just to
# set some defaults
updated = None
updated_args = None
def ... | Python |
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
"""
Gives a multi-value dictionary object (MultiDict) plus several wrappers
"""
import cgi, copy, sys, warnings, urllib
from UserDict import DictMixin
... | Python |
"""
Does parsing of ETag-related headers: If-None-Matches, If-Matches
Also If-Range parsing
"""
from webob.datetime_utils import *
from webob.util import rfc_reference
__all__ = ['AnyETag', 'NoETag', 'ETagMatcher', 'IfRange', 'NoIfRange', 'etag_property']
def etag_property(key, default, rfc_section):
doc = "Ge... | Python |
"""To test specific webapp issues."""
import os
import StringIO
import sys
import urllib
import unittest
gae_path = '/usr/local/google_appengine'
sys.path[0:0] = [
gae_path,
os.path.join(gae_path, 'lib', 'django_0_96'),
os.path.join(gae_path, 'lib', 'webob'),
os.path.join(gae_path, 'lib', 'yaml', 'lib... | Python |
'''
Created on May 11, 2013
@author: group 2 - team pflegp, prutsm, steinb, winste
'''
import os
from libthermalraspi.sensors.lm73device import LM73Device
from libthermalraspi.sensors.ad7414 import AD7414Thermometer
from libthermalraspi.sensors.tc74 import TC74Thermometer
from libthermalraspi.sensors.hyt221 import Hyt... | Python |
class DataStoreStdOut(object):
def get_sample(self, fromDatetime, toDatetime, maxResultCount = None, sensorIDs = None):
assert False, 'cannot get samples from stdout'
def add_sample(self, timestamp, sensorname, temperatur, status):
print timestamp, sensorname, temperatur, status
... | Python |
# -*- coding: utf-8 -*-
import abc
"""Abstract base class for SampleCollector for gathering
sensor measurment data"""
class SampleCollector(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __init__(self, store, sensorList = {}):
"""Collector mit Datenspeicher und Dictionary der ab... | Python |
'''
Created on 29.04.2013
@author: Patrick Groeller
'''
from xml.dom import minidom
from libthermalraspi.database.Measurement import Measurement
class XmlMeasurementService:
def __init__(self, listOfMeasurements):
self.__listOfMeasurements = listOfMeasurements
def toXml(self):
... | Python |
# coding: utf-8
from libthermalraspi.services.sampleCollector import SampleCollector
import datetime
import os
class ParallelSampleCollector(SampleCollector):
def __init__(self, store, sensorList):
self.__store = store
if type(sensorList) is dict:
self.__sensorList ... | Python |
import struct
from i2c_device import I2CDevice
class BlinkM(I2CDevice):
GO_TO_RGB = '\x6e'
FADE_TO_RGB = '\x63'
FADE_TO_HSB = '\x68'
FADE_TO_RANDOM_RGB = '\x43'
FADE_TO_RANDOM_HSB = '\x48'
PLAY_LIGHT_SCRIPT = '\x70'
STOP_SCRIPT = '\x6f'
SET_FADE_SPEED = '\x66'
SET_TIME_ADJUST = '\x... | Python |
import time
import sys
import signal
class ProgramLooper:
def __init__(self, interval_seconds):
self.__interval = interval_seconds
self.__counter = 0
# to be set from signal handler
self.__stop = False
signal.signal(signal.SIGINT, self.signal_handler)
... | Python |
'''
Created on 04.05.2013
@author: Helmut Kopf
'''
import socket
import threading
import logging
import os
import sys
import datetime
import platform
from xml.dom.minidom import parseString
from libthermalraspi.services.xml_measurement_service import XmlMeasurementService
from libthermalraspi.database ... | Python |
import os
import smbus
class SMBusDevice(object):
def __init__(self, busno, addr):
self.__bus = smbus.SMBus(busno)
self.__addr = addr
# todo: implement some read/write functions... | Python |
import os
import platform
# Done by HeKo, since i run the first tests for
# LM73 under windows it's necessary to load
# LM73Device successfully!
if platform.system() != "Windows":
import fcntl
class I2CDevice(object):
I2C_SLAVE = 0x0703 # from <linux/i2c-dev.h>
def __init__(self, busno, addr, testCase = ... | Python |
#!/usr/bin/python
from thermometer import Thermometer
from libthermalraspi.i2c_device import I2CDevice
import struct
class TC74Thermometer (I2CDevice, Thermometer):
def get_temperature(self):
# "temperature register" according to datasheet (DS)
#response of TC74 is only one byte, no bits must be shifted.
self.w... | Python |
from thermometer import Thermometer
import socket
class ThermoProxy_ItmG2(Thermometer):
def __init__(self):
self.__host = '127.0.0.1'
self.__port = 7000
def get_temperature(self):
self.__s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.__s.connect((self.__host, self.... | Python |
from libthermalraspi.i2c_device import I2CDevice
import time
import struct
import sys
class Stds75(I2CDevice):
def __init__(self, bus, addr):
I2CDevice.__init__(self, bus, addr)
def get_temperature(self):
# set register for next operation to 1 (CONF)
self.write('\1')
... | Python |
""" Author: Christopher Barilich - ITM11 """
import struct
from libthermalraspi.i2c_device import I2CDevice
from libthermalraspi.sensors.thermometer import Thermometer
class Stds75(I2CDevice, Thermometer):
'''
Thermal Senser STDS75
default resolution for thermometer is 9 bit (.5)
'''
... | Python |
import abc
class HumiditySensor(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def get_humidity(self):
return
| Python |
from thermometer import Thermometer
import os
# SWD11 - G2 - 2 - Pflegpeter, Prutsch, Steinbauer, Winkler
class CompositeSensor(Thermometer):
__sensors = []
def __init__(self, sensors=[]):
self.add_sensors(sensors)
def add_sensors(self, sensors):
self.__sensors.extend(s... | Python |
# StoreMock sammelt die Messungen, die der ParallelSampleCollector
# auf SensorStub durchfuehrt.
class StoreMock(object):
def __init__(self):
self.__samples = []
def add_sample(self, timestamp, sensorname, temperatur, status):
self.__samples.append((timestamp, sensorname, temp... | Python |
from thermometer import Thermometer
import os
class CompositeSensor(Thermometer):
__sensors = []
def __init__(self, sensors=[]):
self.add_sensors(sensors)
def add_sensors(self, sensors):
self.__sensors.extend(sensors)
def get_temperature(self):
imTheFather = True... | Python |
import abc
# Abstract base class for Thermometer objects
# get_temperature abstract interface
class Thermometer(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def get_temperature(self):
return
pass
| Python |
#SensorStub simuliert die Temperaturmessungen und erhaelt einfach eine Liste
#mit Messwerten, die als Testeingangswerte dienen.
from libthermalraspi.sensors.thermometer import Thermometer
# SensorStub erhaelt eine Liste an Messwerten, die
# in get_temperature zurueck geliefert werden.
# Dieser Test-Stub wird ... | Python |
from thermometer import Thermometer
import itertools
class CyclicThermometer(Thermometer):
def __init__(self, temperatures):
self.__temperatures = itertools.cycle(temperatures)
pass
def get_temperature(self):
return self.__temperatures.next()
pass
| Python |
from libthermalraspi.i2c_device import I2CDevice
from libthermalraspi.sensors.thermometer import Thermometer
from libthermalraspi.sensors.humiditysensor import HumiditySensor
import time
import struct
class Hyt221(I2CDevice, Thermometer, HumiditySensor):
def _perform_measurement(self):
# init -... | Python |
from thermometer import Thermometer
from libthermalraspi.i2c_device import I2CDevice
import struct
class HypotheticalThermometer(I2CDevice, Thermometer):
def get_temperature(self):
# select register ("temperature register", according to
# hypothetical datasheet) for next operation
self.wr... | Python |
import os
from thermometer import Thermometer
class CompositeSensor(Thermometer):
__listSensors = []
def __init__(self, sensors = []):
self.__listSensors = sensors
def append_sensor(self, sensor):
self.__listSensors.append(sensor)
def get_temp... | Python |
from thermometer import Thermometer
from libthermalraspi.i2c_device import I2CDevice
import struct
class DS1631SThermometer(I2CDevice, Thermometer):
def get_temperature(self):
self.write('\x4F')
msb_lsb = self.read(2)
msb, lsb = struct.unpack('BB', msb_lsb)
return s... | Python |
#!/usr/bin/python
import socket
from libthermalraspi.sensors.thermometer import Thermometer
class ThermoProxy(Thermometer):
"""Connects with a server"""
def __init__(self, host="127.0.0.1", port=1024):
self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:... | Python |
from thermometer import Thermometer
from libthermalraspi.i2c_device import I2CDevice
import struct
class AD7414Thermometer(I2CDevice, Thermometer):
def get_temperature(self):
# "temperature register" according to datasheet (DS)
self.write('\x00')
# Read 2-byte temperature ... | Python |
#!/usr/bin/python
from thermometer import Thermometer
from libthermalraspi.i2c_device import I2CDevice
import struct
class TC74Thermometer (I2CDevice, Thermometer):
def get_temperature(self):
# "temperature register" according to datasheet (DS)
#response of TC74 is only one byte, no bits must be shifted.
self.w... | Python |
#!/usr/bin/python
import socket
from libthermalraspi.sensors.thermometer import Thermometer
class ThermoProxy(Thermometer):
"""Connects with a server"""
def __init__(self, host="127.0.0.1", port=1024):
self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:... | Python |
# -*- coding: utf-8 -*-
import struct
from libthermalraspi.i2c_device import I2CDevice
from libthermalraspi.sensors.thermometer import Thermometer
# Not yet tested on raspberry
# all methods successfully tested against
# datasheet specs.
class LM73Device(Thermometer, I2CDevice):
"""
Author: HeKo,... | Python |
from libthermalraspi.smbus_device import SMBusDevice
from libthermalraspi.sensors.thermometer import Thermometer
from libthermalraspi.sensors.humiditysensor import HumiditySensor
import time
class Hyt221SMBus(SMBusDevice, Thermometer, HumiditySensor):
def __init__(self, bus, addr):
SMBusDevice.__i... | Python |
import hwtest_lm73device
import unittest
suite = unittest.TestSuite()
suite.addTest(hwtest_lm73device.suite)
if __name__ == '__main__':
unittest.TextTestRunner().run(suite)
pass
| Python |
#!/usr/bin/python
from libthermalraspi.database.Measurement import Measurement
from libthermalraspi.database.DataStoreInMemory import DataStoreInMemory
from libthermalraspi.database.DataStoreSQL import DataStoreSQL
import datetime
import unittest
import sqlite3
import os
class Datastoretest(unittest.TestCase):
de... | Python |
#!/usr/bin/python
from libthermalraspi.database.SensorDAO import SensorDAO
from libthermalraspi.database.MeasurementDAO import MeasurementDAO
from libthermalraspi.database.Measurement import Measurement
from libthermalraspi.database.DataStoreSQL import DataStoreSQL
import datetime
import unittest
import sqlite3
import ... | Python |
#!/usr/bin/python
from libthermalraspi.sensors.simulation import CyclicThermometer
from libthermalraspi.sensors.thermometer import Thermometer
import os
import sys
_listSensors = []
_listSensors.append(CyclicThermometer([5]))
_listSensors.append(CyclicThermometer([10]))
_listSensors.append(CyclicThermometer([45]))
_... | Python |
#!usr/bin/python
from libthermalraspi.sensors.stds75 import Stds75
t = Stds75(1, 0x4e)
print t.get_temperature()
| Python |
import test_simulation
import test_lm73device
import test_xmlMeasurementService
import test_compositeSensor_g2_3
import test_compositeThermometer_SWD11G2_2
#import test_SensorConfigReader
import unittest
suite = unittest.TestSuite()
suite.addTest(test_simulation.suite)
suite.addTest(test_lm73device.suite)
suite.addTe... | Python |
'''
Created on 22.04.2013
@author: Helmut
'''
from libthermalraspi.sensors.lm73device import LM73Device
import unittest
class LM73DeviceHWTest(unittest.TestCase):
def test__resolution(self):
dev = LM73Device(1, 0x48)
res = dev.get_resolution()
# todo...
#dev.set_re... | Python |
import datetime
from libthermalraspi.database.DataStore import DataStore
from libthermalraspi.database.Measurement import Measurement
class DataStoreInMemory(DataStore):
def __init__(self):
self._measures = []
def get_samples(self,fromTimestamp=None,toTimestamp=None):
return sorted( \
sor... | Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.