Commits

John Paulett  committed 68efc89

Convert loading test to use file.get_dir.

  • Participants
  • Parent commits e935ae6

Comments (0)

Files changed (8)

File docs/conf.py

 
 # Example configuration for intersphinx: refer to the Python standard library.
 intersphinx_mapping = {'http://docs.python.org/dev': None,
-                       'http://networkx.lanl.gov/': None}
+                       'http://networkx.lanl.gov/': None,
+                       'http://www.sqlalchemy.org/docs/05/': None}
 
 autodoc_member_order = 'groupwise'
 

File docs/configuration.rst

 Executing HORNET
 ================
 
-:file:`run_hornet.py`
-
 .. code-block:: bash
 
-    Usage: run_hornet.py [options]
+    $ hornet
+    Usage: hornet [options]
     
     Options:
       --version             show program's version number and exit

File docs/ref/db.rst

 
 .. automodule:: hornet.db
 
-        
+.. function:: hornet.db.create_engine
+    
+    Create an instance of the database, from which you can obtain
+    connections.  Takes in a database connection string 
+    (e.g. ``dialect://user:password@host/dbname[?key=value..]``). 
+    See :func:`sqlalchemy.create_engine` for more details.
     package_dir = {'': SRC_DIR},
     classifiers = [
       'License :: OSI Approved :: Apache Software License',
+    ],
+    entry_points = {
+      'console_scripts': [
+        'hornet = hornet.command.main',
       ],
+    },
+
     #test_suite = 'nose.collector',
     #install_requires = ['matplotlib', 'numpy', 'processing', 'decorator',
     #                    'networkx', 'wxPython', 'sqlalchemy'], #'configobj', 

File run_hornet.py

-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2008 John Paulett (john -at- vanderbilt.edu)
-# All rights reserved.
-#
-# This software is licensed as described in the file COPYING, which
-# you should have received as part of this distribution.
-
-#import pyximport; pyximport.install(pyimport = True)
-import logging
-import logging.config
-import os, sys
-
-from optparse import OptionParser
-
-sys.path.append(os.path.abspath('src'))
-
-from hornet.application import PluginRunner, Config
-from hornet.loading import load_class
-
-
-limit = sys.getrecursionlimit()
-sys.setrecursionlimit(limit*20)
-logging.config.fileConfig('logging.conf')
-logger = logging.getLogger(__name__)
-
-def main(config_file):
-    """Run HORNET."""
-    config = load_class(config_file, Config)
-    PluginRunner(config).run()
-    
-def profile():
-    """Profile the main application."""
-    import hotshot
-    
-    log = 'hotshot_network.log'
-
-    prof = hotshot.Profile(log)
-    prof.runcall(main)
-    prof.close()
-    
-    logger.debug('Analyzing profile log: %s' % log)
-    stats = hotshot.stats.load(log)
-    stats.sort_stats('time').print_stats(30)
-    
-def _optparse():
-    parser = OptionParser(version='%prog __version__') #TODO fix the version
-    parser.add_option('-a', '--action', dest='action', default='run',
-                      help='Perform the ACTION (one of run, profile)', 
-                      metavar='ACTION')
-    parser.add_option('-c', '--config', dest='config', default='config_hornet.py',
-                      help="""Use the configuration in CONFIG_FILE (defaults 
-                      to './config_hornet.py')""", 
-                      metavar='CONFIG_FILE')
-    parser.add_option('-p', '--psyco', action='store_true', dest='enable_psyco', 
-                      default=False, help='Turn on psyco compilation')
-
-    (options, args) = parser.parse_args()
-    return options, args
-    
-if __name__ == '__main__':
-    options, args = _optparse()
-    
-    if options.enable_psyco:
-        import psyco
-        psyco.full()
-
-    action = options.action
-    if action == 'run':
-        main(options.config)
-    elif action == 'profile':
-        profile()
-      

File src/hornet/command.py

+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2008 John Paulett (john -at- vanderbilt.edu)
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution.
+
+#import pyximport; pyximport.install(pyimport = True)
+
+from hornet.application import PluginRunner, Config
+from hornet.loading import load_class
+from hornet.release import version
+from optparse import OptionParser
+import logging
+import os
+
+#import sys
+#limit = sys.getrecursionlimit()
+#sys.setrecursionlimit(limit*20)
+
+def run(config_file):
+    """Run HORNET."""
+    config = load_class(config_file, Config)
+    PluginRunner(config).run()
+    
+def profile():
+    """Profile the main application."""
+    import hotshot
+    
+    log = 'hotshot_network.log'
+
+    prof = hotshot.Profile(log)
+    prof.runcall(run)
+    prof.close()
+    
+    logger.debug('Analyzing profile log: %s' % log)
+    stats = hotshot.stats.load(log)
+    stats.sort_stats('time').print_stats(30)
+    
+def _optparse():
+    parser = OptionParser(version='%prog ' + version) #TODO fix the version
+    parser.add_option('-a', '--action', dest='action', default='run',
+                      help='Perform the ACTION (one of run, profile)', 
+                      metavar='ACTION')
+    parser.add_option('-c', '--config', dest='config', default='config_hornet.py',
+                      help="""Use the configuration in CONFIG_FILE (defaults 
+                      to './config_hornet.py')""", 
+                      metavar='CONFIG_FILE')
+    parser.add_option('-p', '--psyco', action='store_true', dest='enable_psyco', 
+                      default=False, help='Turn on psyco compilation')
+
+    (options, args) = parser.parse_args()
+    return options, args
+
+def main():
+    logging.config.fileConfig('logging.conf')
+    logger = logging.getLogger(__name__)
+    
+    options, args = _optparse()
+    if options.enable_psyco:
+        import psyco
+        psyco.full()
+
+    action = options.action
+    if action == 'run':
+        main(options.config)
+    elif action == 'profile':
+        profile()
+      
+if __name__ == '__main__':
+    main()

File src/hornet/db.py

 
 :mod:`hornet.db` is a simple wrapper for `SQLAlchemy <http://www.sqlalchemy.org>`_.
 
-Create an in-memory database:
+Create an in-memory database, using :func:`hornet.db.create_engine`:
 
 >>> db = create_engine('sqlite://')
 

File tests/test_loading.py

 # See the License for the specific language governing permissions and 
 # limitations under the License. 
 
+from hornet.file import get_dir, join
 from hornet.loading import *
 from nose import with_setup
 from nose.tools import assert_raises
                   ExampleCls2)
     
 def relative(filename):
-    return path.join(path.dirname(path.abspath(__file__)), filename)
+    return join(get_dir(__file__), filename)