merge
This commit is contained in:
commit
3b208904f8
15 changed files with 471 additions and 370 deletions
29
CHANGES.txt
29
CHANGES.txt
|
@ -1,4 +1,33 @@
|
|||
|
||||
0.1a6
|
||||
-----
|
||||
|
||||
- Fixed MANIFEST.in file.
|
||||
|
||||
0.1a5
|
||||
-----
|
||||
|
||||
- Added :mod:`edbob.csv` module.
|
||||
|
||||
- Tweaked logging configuration and initialization semantics.
|
||||
|
||||
0.1a4
|
||||
-----
|
||||
|
||||
- Fixed call to sleep() in filemon service.
|
||||
|
||||
0.1a3
|
||||
-----
|
||||
|
||||
- Various tweaks to Pyramid code.
|
||||
|
||||
0.1a2
|
||||
-----
|
||||
|
||||
- Add ``win32.send_data_to_printer()`` function.
|
||||
|
||||
- Various tweaks to Pyramid code.
|
||||
|
||||
0.1a1
|
||||
-----
|
||||
|
||||
|
|
18
MANIFEST.in
18
MANIFEST.in
|
@ -1,2 +1,18 @@
|
|||
include *.txt
|
||||
include COPYING.txt README.txt CHANGES.txt
|
||||
include ez_setup.py
|
||||
|
||||
include edbob/pyramid/static/favicon.ico
|
||||
include edbob/pyramid/static/robots.txt
|
||||
include edbob/pyramid/static/css/*.css
|
||||
include edbob/pyramid/static/js/*.js
|
||||
|
||||
include edbob/scaffolds/edbob/CHANGES.txt
|
||||
include edbob/scaffolds/edbob/+package+/pyramid/static/favicon.ico
|
||||
include edbob/scaffolds/edbob/+package+/pyramid/static/robots.txt
|
||||
|
||||
recursive-include edbob/pyramid/static/img *.jpg *.png
|
||||
recursive-include edbob/pyramid/templates *.mako
|
||||
|
||||
recursive-include edbob/scaffolds/edbob *.py
|
||||
recursive-include edbob/scaffolds/edbob *_tmpl
|
||||
recursive-include edbob/scaffolds/edbob/+package+/pyramid/templates *.mako
|
||||
|
|
|
@ -1 +1 @@
|
|||
__version__ = '0.1a3'
|
||||
__version__ = '0.1a7'
|
||||
|
|
|
@ -70,15 +70,17 @@ class AppConfigParser(ConfigParser.SafeConfigParser):
|
|||
file, and passes that to ``logging.config.fileConfig()``.
|
||||
"""
|
||||
|
||||
if self.getboolean(self.appname, 'basic_logging', default=False):
|
||||
edbob.basic_logging(self.appname)
|
||||
if self.getboolean('edbob', 'basic_logging', default=False):
|
||||
edbob.basic_logging()
|
||||
if self.getboolean('edbob', 'configure_logging', default=False):
|
||||
path = edbob.temp_path(suffix='.conf')
|
||||
self.save(path)
|
||||
try:
|
||||
logging.config.fileConfig(path)
|
||||
logging.config.fileConfig(path, disable_existing_loggers=False)
|
||||
except ConfigParser.NoSectionError:
|
||||
pass
|
||||
os.remove(path)
|
||||
log.debug("Configured logging")
|
||||
|
||||
def get(self, section, option, raw=False, vars=None, default=None):
|
||||
"""
|
||||
|
@ -243,7 +245,6 @@ class AppConfigParser(ConfigParser.SafeConfigParser):
|
|||
config.has_option('edbob', 'include_config')):
|
||||
include = config.get('edbob', 'include_config')
|
||||
if include:
|
||||
log.debug("Including config: %s" % include)
|
||||
for p in eval(include):
|
||||
self.read_path(os.path.abspath(p))
|
||||
ConfigParser.SafeConfigParser.read(self, path)
|
||||
|
|
|
@ -71,7 +71,9 @@ def basic_logging():
|
|||
handler = logging.StreamHandler()
|
||||
handler.setFormatter(logging.Formatter(
|
||||
'%(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s'))
|
||||
logging.getLogger().addHandler(handler)
|
||||
root = logging.getLogger()
|
||||
root.addHandler(handler)
|
||||
root.setLevel(logging.INFO)
|
||||
|
||||
|
||||
def get_uuid():
|
||||
|
|
71
edbob/csv.py
Normal file
71
edbob/csv.py
Normal file
|
@ -0,0 +1,71 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
################################################################################
|
||||
#
|
||||
# edbob -- Pythonic Software Framework
|
||||
# Copyright © 2010-2012 Lance Edgar
|
||||
#
|
||||
# This file is part of edbob.
|
||||
#
|
||||
# edbob is free software: you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# edbob is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
|
||||
# more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with edbob. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
"""
|
||||
``edbob.csv`` -- CSV File Utilities
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import codecs
|
||||
import csv
|
||||
|
||||
|
||||
class UTF8Recoder(object):
|
||||
"""
|
||||
Iterator that reads an encoded stream and reencodes the input to UTF-8.
|
||||
|
||||
.. note::
|
||||
This class was stolen from the Python 2.7 documentation.
|
||||
"""
|
||||
|
||||
def __init__(self, fileobj, encoding):
|
||||
self.reader = codecs.getreader(encoding)(fileobj)
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def next(self):
|
||||
return self.reader.next().encode('utf_8')
|
||||
|
||||
|
||||
class UnicodeReader(object):
|
||||
"""
|
||||
A CSV reader which will iterate over lines in a CSV file, which is encoded
|
||||
in the given encoding.
|
||||
|
||||
.. note::
|
||||
This class was stolen from the Python 2.7 documentation.
|
||||
"""
|
||||
|
||||
def __init__(self, fileobj, dialect=csv.excel, encoding='utf_8', **kwargs):
|
||||
fileobj = UTF8Recoder(fileobj, encoding)
|
||||
self.reader = csv.reader(fileobj, dialect=dialect, **kwargs)
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def next(self):
|
||||
row = self.reader.next()
|
||||
return [unicode(x, 'utf_8') for x in row]
|
|
@ -109,7 +109,7 @@ class FileMonitorService(win32serviceutil.ServiceFramework):
|
|||
while not file_is_free(path):
|
||||
# TODO: Add configurable timeout so long-open files can't hijack
|
||||
# our prcessing.
|
||||
time.sleep(0.25)
|
||||
win32api.SleepEx(250, True)
|
||||
for action in self.monitored[key].actions:
|
||||
if isinstance(action, tuple):
|
||||
func = action[0]
|
||||
|
|
|
@ -51,7 +51,6 @@ def main(global_config, **settings):
|
|||
|
||||
# Configure edbob. Note that this is done last, primarily to allow logging
|
||||
# to leverage edbob's config inheritance.
|
||||
edbob.basic_logging()
|
||||
edbob.init('{{package}}', os.path.abspath(settings['edbob.config']))
|
||||
|
||||
return config.make_wsgi_app()
|
||||
|
|
|
@ -27,10 +27,7 @@ whatever = you like
|
|||
use = egg:{{package}}
|
||||
|
||||
pyramid.reload_templates = true
|
||||
pyramid.debug_authorization = false
|
||||
pyramid.debug_notfound = false
|
||||
pyramid.debug_routematch = false
|
||||
pyramid.debug_templates = true
|
||||
pyramid.debug_all = true
|
||||
pyramid.default_locale_name = en
|
||||
pyramid.includes =
|
||||
pyramid_debugtoolbar
|
||||
|
@ -51,9 +48,6 @@ port = 6543
|
|||
[edbob]
|
||||
include_config = ['%(here)s/production.ini']
|
||||
|
||||
[edbob.db]
|
||||
sqlalchemy.url = sqlite:///{{package}}.sqlite
|
||||
|
||||
|
||||
####################
|
||||
# logging
|
||||
|
@ -62,8 +56,5 @@ sqlalchemy.url = sqlite:///{{package}}.sqlite
|
|||
[logger_root]
|
||||
level = INFO
|
||||
|
||||
[logger_edbob]
|
||||
level = INFO
|
||||
|
||||
[logger_{{package_logger}}]
|
||||
level = DEBUG
|
||||
|
|
|
@ -21,10 +21,7 @@ whatever = you like
|
|||
use = egg:{{package}}
|
||||
|
||||
pyramid.reload_templates = false
|
||||
pyramid.debug_authorization = false
|
||||
pyramid.debug_notfound = false
|
||||
pyramid.debug_routematch = false
|
||||
pyramid.debug_templates = false
|
||||
pyramid.debug_all = false
|
||||
pyramid.default_locale_name = en
|
||||
|
||||
# Hack so edbob can find this file from within WSGI app.
|
||||
|
@ -56,6 +53,8 @@ sqlalchemy.url = postgresql://user:pass@localhost/{{package}}
|
|||
|
||||
[edbob]
|
||||
init = edbob.time, edbob.db
|
||||
basic_logging = True
|
||||
configure_logging = True
|
||||
# shell.python = ipython
|
||||
|
||||
[edbob.db]
|
||||
|
@ -82,7 +81,7 @@ timezone = US/Central
|
|||
####################
|
||||
|
||||
[loggers]
|
||||
keys = root, edbob, {{package_logger}}
|
||||
keys = root, {{package_logger}}
|
||||
|
||||
[handlers]
|
||||
keys = file, console, email
|
||||
|
@ -95,15 +94,10 @@ keys = generic, console
|
|||
handlers = file, console
|
||||
level = WARNING
|
||||
|
||||
[logger_edbob]
|
||||
qualname = edbob
|
||||
handlers =
|
||||
# level = INFO
|
||||
|
||||
[logger_{{package_logger}}]
|
||||
qualname = {{package}}
|
||||
handlers =
|
||||
level = WARNING
|
||||
# level = NOTSET
|
||||
|
||||
[handler_file]
|
||||
class = FileHandler
|
||||
|
@ -114,12 +108,10 @@ formatter = generic
|
|||
class = StreamHandler
|
||||
args = (sys.stderr,)
|
||||
formatter = console
|
||||
# level = NOTSET
|
||||
|
||||
[handler_email]
|
||||
class = handlers.SMTPHandler
|
||||
args = ('mail.example.com', '{{package}}@example.com', ['support@example.com'], '[{{project}} error]',
|
||||
('user', 'pass'))
|
||||
args = ('mail.example.com', '{{package}}@example.com', ['support@example.com'], '[{{project}} error]', ('user', 'pass'))
|
||||
level = ERROR
|
||||
formatter = generic
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ def init(config):
|
|||
tz = config.get('edbob.time', 'timezone')
|
||||
if tz:
|
||||
set_timezone(tz)
|
||||
log.debug("Timezone set to '%s'" % tz)
|
||||
log.info("Timezone set to '%s'" % tz)
|
||||
else:
|
||||
log.warning("No timezone configured; falling back to US/Central")
|
||||
set_timezone('US/Central')
|
||||
|
|
2
setup.py
2
setup.py
|
@ -121,7 +121,7 @@ setup(
|
|||
#
|
||||
# package # low high
|
||||
|
||||
'alembic', # 0.2.1
|
||||
'alembic', # 0.3.4
|
||||
'py-bcrypt', # 0.2
|
||||
'SQLAlchemy', # 0.7.6
|
||||
'Tempita', # 0.5.1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue