Author: tack
Date: Tue Apr 25 18:26:18 2006
New Revision: 1494
Modified:
trunk/beacon/bin/beacon
trunk/beacon/src/__init__.py
trunk/beacon/src/db.py
Log:
Add a --info switch to get stats on the db.
Modified: trunk/beacon/bin/beacon
==============================================================================
--- trunk/beacon/bin/beacon (original)
+++ trunk/beacon/bin/beacon Tue Apr 25 18:26:18 2006
@@ -32,6 +32,7 @@
print '--help | -h this message'
print
print 'Client options:'
+ print '--info displays info about the database'
print '--search args search mode'
print '--monitor do not exit after search and monitor for changes'
print
@@ -47,7 +48,7 @@
try:
# read arguments
opts = [ 'start', 'stop', 'db=', 'daemon', 'autoshutdown', 'logfile=',
- 'verbose=', 'help', 'search', 'monitor' ]
+ 'verbose=', 'help', 'search', 'monitor', 'info' ]
opts, args = getopt.getopt(sys.argv[1:], 'h', opts)
except getopt.GetoptError:
usage(1)
@@ -60,28 +61,28 @@
database = os.path.expanduser("~/.beacon")
for o, a in opts:
- if o in ('--start', '--stop', '--search'):
+ if o in ('--start', '--stop', '--search', "--info"):
if mode:
usage(1)
mode = o[2:]
- if o == '--db':
+ elif o == '--db':
database = a
- if o == '--daemon':
+ elif o == '--daemon':
detach = True
- if o == '--autoshutdown':
+ elif o == '--autoshutdown':
shutdown = True
- if o == '--logfile':
+ elif o == '--logfile':
logfile = a
- if o == '--verbose':
+ elif o == '--verbose':
a = a.lower()
if a == 'all':
logging.getLogger('beacon').setLevel(logging.INFO)
else:
for m in a.split(','):
logging.getLogger('beacon.' + m).setLevel(logging.INFO)
- if o == '--monitor':
+ elif o == '--monitor':
monitor = True
- if o in ('--help', '-h'):
+ elif o in ('--help', '-h'):
usage(0)
if not mode:
@@ -101,12 +102,32 @@
print 'server not running'
sys.exit(0)
-if mode == 'search':
- # client search mode
+if mode in ("search", "info"):
+ # client info/search mode
import kaa.notifier
import kaa.beacon
+ try:
+ kaa.beacon.connect()
+ except:
+ print 'beacon server not running'
+ sys.exit(1)
+
+if mode == "info":
+ info = kaa.beacon.get_db_info()
+ print 'Beacon database information:'
+ print
+ print 'Total objects:'.rjust(20), info['total']
+ print 'Indexed keywords:'.rjust(20), info['wordcount']
+ print
+ print 'Object breakdown by type:'
+ for key in info['count']:
+ print (key + ':').rjust(15), info['count'][key]
+ sys.exit(0)
+
+elif mode == 'search':
+
def progress(cur, total, item):
n = 0
if total > 0:
@@ -138,12 +159,6 @@
else:
query[key] = value
- try:
- kaa.beacon.connect()
- except:
- print 'beacon server not running'
- sys.exit(1)
-
if 'dirname' in query:
t1 = time.time()
result = kaa.beacon.get(query['dirname']).listdir()
@@ -168,6 +183,7 @@
kaa.notifier.loop()
sys.exit(0)
+
# When we reach this point we need to start a new beacon server. If run
# in daemon mode we fork and detach from the parent. After that a logger
Modified: trunk/beacon/src/__init__.py
==============================================================================
--- trunk/beacon/src/__init__.py (original)
+++ trunk/beacon/src/__init__.py Tue Apr 25 18:26:18 2006
@@ -84,4 +84,11 @@
if not _client:
connect()
return _client.add_mountpoint(type, device, directory)
-
+
+def get_db_info():
+ """
+ Gets statistics about the database
+ """
+ if not _client:
+ connect()
+ return _client.database.get_db_info()
Modified: trunk/beacon/src/db.py
==============================================================================
--- trunk/beacon/src/db.py (original)
+++ trunk/beacon/src/db.py Tue Apr 25 18:26:18 2006
@@ -642,3 +642,13 @@
kwargs['mtime'] = (int, ATTR_SIMPLE)
indices = [("name", "parent_type", "parent_id")]
return self._db.register_object_type_attrs(type, indices, *args,
**kwargs)
+
+
+ def get_db_info(self):
+ """
+ Returns information about the database. Look at
+ kaa.db.Database.get_db_info() for more details.
+ """
+ info = self._db.get_db_info()
+ # Anything else we want to add?
+ return info
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog