changeset 452:f19d3ee89335

updated whoosh indexer to take path as second argument
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 03 Sep 2010 13:15:16 +0200
parents d726f62f886e
children 2a95d54b19e6
files pylons_app/lib/indexers/daemon.py
diffstat 1 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/pylons_app/lib/indexers/daemon.py	Fri Sep 03 13:07:07 2010 +0200
+++ b/pylons_app/lib/indexers/daemon.py	Fri Sep 03 13:15:16 2010 +0200
@@ -185,10 +185,12 @@
         
 if __name__ == "__main__":
     arg = sys.argv[1:]
-    if not arg:
-        sys.stdout.write('Please specify indexing type [full|incremental]' 
-                         ' as script arg \n')
+    if len(arg) != 2:
+        sys.stderr.write('Please specify indexing type [full|incremental]' 
+                         'and path to repositories as script args \n')
         sys.exit()
+    
+    
     if arg[0] == 'full':
         full_index = True
     elif arg[0] == 'incremental':
@@ -196,11 +198,17 @@
         full_index = False
     else:
         sys.stdout.write('Please use [full|incremental]' 
-                         ' as script arg \n')
+                         ' as script first arg \n')
         sys.exit()
     
-    
-    repo_location = '/home/hg_repos/*'
+    if not os.path.isdir(arg[1]):
+        sys.stderr.write('%s is not a valid path \n' % arg[1])
+        sys.exit()
+    else:
+        if arg[1].endswith('/'):
+            repo_location = arg[1] + '*'
+        else:
+            repo_location = arg[1] + '/*'
     
     try:
         l = DaemonLock()