Permalink
Browse files

somewhat more docs, better error message

  • Loading branch information...
1 parent 11fbe84 commit d829dc4e0717800d1420505c8f657f71dc364786 @piranha committed Jun 8, 2013
Showing with 40 additions and 6 deletions.
  1. +19 −0 README.rst
  2. +14 −2 nomad/__init__.py
  3. +2 −2 nomad/repo.py
  4. +3 −0 nomad/utils.py
  5. +2 −2 setup.py
View
@@ -35,6 +35,25 @@ It looks like this::
2-up.sql
3-post.py
+And a `nomad.ini` could look like this::
+
+ [nomad]
+ engine = sqla
+ url = pgsql://user:password@host:port/db
+
+Possible options for `engine`:
+
+ - `sqla` - use SQLAlchemy as an adapter, supports everything SQLAlchemy supports
+ - `dbapi` - use regular DB API, supports `sqlite`, `mysql` and `pgsql`
+
+`url` can be defined in a few various ways:
+
+ - `url = <YOUR-URL-TO-DB>` - just a static connection url
+ - `url-file = <PATH-TO-FILE>` - a path to file containing connection url
+ - `url-python = <python.mod.variable>` - a Python path to a module, containing
+ a variable with connection url
+ - `url-command = <cmd-to-execute>` - command line to execute to get connection url
+
Main properties
---------------
View
@@ -1,26 +1,38 @@
#!/usr/bin/env python
-import os, os.path as op
+import os, os.path as op, sys
from opster import Dispatcher
from termcolor import cprint, colored
from nomad.repo import Repository
from nomad.engine import DBError
-from nomad.utils import abort, NomadError
+from nomad.utils import abort, NomadError, NomadIniNotFound
GLOBAL = [
('c', 'config', 'nomad.ini', 'path to config file'),
('D', 'define', {}, 'override config values'),
]
+
+EXAMPLE_INI = '''
+ [nomad]
+ engine = dbapi
+ url = sqlite://data.db
+'''
+
+
def getconfig(func):
if func.__name__.startswith('help'):
return func
def inner(*args, **kwargs):
try:
repo = Repository(kwargs['config'], kwargs['define'])
+ except NomadIniNotFound, e:
+ sys.stderr.write('Create %r to use nomad, example:\n%s\n' %
+ (e.message, EXAMPLE_INI))
+ abort('config file not found')
except (IOError, NomadError), e:
abort(e)
View
@@ -4,7 +4,7 @@
from subprocess import call
from functools import wraps
-from nomad.utils import cachedproperty, geturl, NomadError
+from nomad.utils import cachedproperty, geturl, NomadError, NomadIniNotFound
def tx(getrepo):
@@ -36,7 +36,7 @@ def __init__(self, confpath, overrides=None):
})
self.conf.read_dict(self.DEFAULTS)
if not self.conf.read([confpath]):
- raise IOError('configuration file %r not found' % confpath)
+ raise NomadIniNotFound(confpath)
for k, v in (overrides or {}).iteritems():
section, key = k.split('.')
View
@@ -14,6 +14,9 @@
class NomadError(Exception):
pass
+class NomadIniNotFound(Exception):
+ pass
+
def cachedproperty(f):
"""Returns a cached property that is calculated by function f
View
@@ -11,7 +11,7 @@ def read(fname):
description = 'simple sql migration tool to save you from becoming mad',
long_description = read('README.rst'),
license = 'BSD',
- version = '0.1.3',
+ version = '0.2',
author = 'Alexander Solovyov',
author_email = 'alexander@solovyov.net',
url = 'http://github.com/piranha/nomad/',
@@ -26,7 +26,7 @@ def read(fname):
'Topic :: Database'
],
- install_requires = ['opster>=3.2.1', 'configparser', 'termcolor'],
+ install_requires = ['opster>=4.0', 'configparser', 'termcolor'],
packages = find_packages(),
entry_points = {'console_scripts': ['nomad=nomad:app.dispatch']},
platforms='any',

0 comments on commit d829dc4

Please sign in to comment.