[Collab-qa-commits] r1120 - udd/src

neronus-guest at alioth.debian.org neronus-guest at alioth.debian.org
Tue Aug 19 09:42:10 UTC 2008


Author: neronus-guest
Date: 2008-08-19 09:42:09 +0000 (Tue, 19 Aug 2008)
New Revision: 1120

Added:
   udd/src/udd.py
Removed:
   udd/src/udd-dispatch.py
Log:
Renamed udd-dispatch.py to udd.py


Deleted: udd/src/udd-dispatch.py
===================================================================
--- udd/src/udd-dispatch.py	2008-08-19 09:41:49 UTC (rev 1119)
+++ udd/src/udd-dispatch.py	2008-08-19 09:42:09 UTC (rev 1120)
@@ -1,70 +0,0 @@
-#!/usr/bin/env python
-# Last-Modified: <Tue Aug 19 09:38:06 2008>
-
-"""Dispatch udd gatherers
-
-This script is used to dispatch the source gatherers of the UDD project."""
-
-import sys
-from os import system
-from time import asctime
-import udd.aux
-import os.path
-
-def print_help():
-  print "Usage: " + sys.argv[0] + " <configuration> <command> <source1> [source2 source3 ...]"
-
-if __name__ == '__main__':
-  if len(sys.argv) < 4:
-    print_help()
-    sys.exit(1)
-
-  command = sys.argv[2]
-  if command not in ('run', 'setup', 'drop', 'tables', 'update'):
-    sys.stderr.write("command has to be one of 'run', 'setup', 'drop', 'update' and 'tables'\n")
-    sys.exit(1)
-
-  config = udd.aux.load_config(open(sys.argv[1]).read())
-
-  types = config['general']['types']
-
-  connection = udd.aux.open_connection(config)
-
-  # Process the sources
-  for src in sys.argv[3:]:
-    src_config = config[src]
-    type = src_config['type']
-    udd.aux.lock(config, src)
-    try:
-      # If the command is update, we need a special case. Otherwise we can just use the gatherer's methods
-      if command == 'update':
-	if "update-command" in src_config:
-	  result = system(src_config['update-command']) 
-	  if result != 0:
-	    sys.exit(result)
-	  if 'timestamp-folder' in config['general']:
-	    f = open(os.path.join(config['general']['timestamp-folder'], src+".update"), "w")
-	    f.write(asctime())
-	    f.close()
-      else:
-	(src_command,rest) = types[type].split(None, 1)
-	if src_command == "exec":
-	  system(rest + " " + sys.argv[1] + " " + sys.argv[2] + " " + src)
-	elif src_command == "module":
-	  exec("import " + rest)
-	  exec "gatherer = " + rest + ".get_gatherer(connection, config, src)"
-	  if command == 'tables':
-	    exec "tables = gatherer.%s()" % command
-	    print "\n".join(tables)
-	  else:
-	    exec "gatherer.%s()" % command
-	if 'timestamp-folder' in config['general']:
-	  f = open(os.path.join(config['general']['timestamp-folder'], src+".dispatch"), "w")
-	  f.write(asctime())
-	  f.close()
-    except:
-      udd.aux.unlock(config, src)
-      raise
-    udd.aux.unlock(config, src)
-  connection.commit()
-

Copied: udd/src/udd.py (from rev 1119, udd/src/udd-dispatch.py)
===================================================================
--- udd/src/udd.py	                        (rev 0)
+++ udd/src/udd.py	2008-08-19 09:42:09 UTC (rev 1120)
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+# Last-Modified: <Tue Aug 19 09:38:06 2008>
+
+"""Dispatch udd gatherers
+
+This script is used to dispatch the source gatherers of the UDD project."""
+
+import sys
+from os import system
+from time import asctime
+import udd.aux
+import os.path
+
+def print_help():
+  print "Usage: " + sys.argv[0] + " <configuration> <command> <source1> [source2 source3 ...]"
+
+if __name__ == '__main__':
+  if len(sys.argv) < 4:
+    print_help()
+    sys.exit(1)
+
+  command = sys.argv[2]
+  if command not in ('run', 'setup', 'drop', 'tables', 'update'):
+    sys.stderr.write("command has to be one of 'run', 'setup', 'drop', 'update' and 'tables'\n")
+    sys.exit(1)
+
+  config = udd.aux.load_config(open(sys.argv[1]).read())
+
+  types = config['general']['types']
+
+  connection = udd.aux.open_connection(config)
+
+  # Process the sources
+  for src in sys.argv[3:]:
+    src_config = config[src]
+    type = src_config['type']
+    udd.aux.lock(config, src)
+    try:
+      # If the command is update, we need a special case. Otherwise we can just use the gatherer's methods
+      if command == 'update':
+	if "update-command" in src_config:
+	  result = system(src_config['update-command']) 
+	  if result != 0:
+	    sys.exit(result)
+	  if 'timestamp-folder' in config['general']:
+	    f = open(os.path.join(config['general']['timestamp-folder'], src+".update"), "w")
+	    f.write(asctime())
+	    f.close()
+      else:
+	(src_command,rest) = types[type].split(None, 1)
+	if src_command == "exec":
+	  system(rest + " " + sys.argv[1] + " " + sys.argv[2] + " " + src)
+	elif src_command == "module":
+	  exec("import " + rest)
+	  exec "gatherer = " + rest + ".get_gatherer(connection, config, src)"
+	  if command == 'tables':
+	    exec "tables = gatherer.%s()" % command
+	    print "\n".join(tables)
+	  else:
+	    exec "gatherer.%s()" % command
+	if 'timestamp-folder' in config['general']:
+	  f = open(os.path.join(config['general']['timestamp-folder'], src+".dispatch"), "w")
+	  f.write(asctime())
+	  f.close()
+    except:
+      udd.aux.unlock(config, src)
+      raise
+    udd.aux.unlock(config, src)
+  connection.commit()
+




More information about the Collab-qa-commits mailing list