[Swift-commit] r4712 - SwiftApps/GOSwift/pykoa/tools

jonmon at ci.uchicago.edu jonmon at ci.uchicago.edu
Wed Jun 29 14:52:35 CDT 2011


Author: jonmon
Date: 2011-06-29 14:52:35 -0500 (Wed, 29 Jun 2011)
New Revision: 4712

Modified:
   SwiftApps/GOSwift/pykoa/tools/koa_goswift.py
Log:
o added so the command can now be run from GlobusOnline and does something.


Modified: SwiftApps/GOSwift/pykoa/tools/koa_goswift.py
===================================================================
--- SwiftApps/GOSwift/pykoa/tools/koa_goswift.py	2011-06-29 18:20:06 UTC (rev 4711)
+++ SwiftApps/GOSwift/pykoa/tools/koa_goswift.py	2011-06-29 19:52:35 UTC (rev 4712)
@@ -27,15 +27,56 @@
 from pykoa.data import preflight_dao
 
 
+def setup_opts(argv):
+    # Set up help message
+    help_screen = """ \
+goswift [options] <sites> < \"goswift.package\"
+
+Executes Swift under Globus Online. The <sites> must be logical sites. This will not work for physical sites.
+Add site using enpoint-add and configure site using endpoint-modify.
+
+Note: localhost runs on the VM.\
+"""
+
+    # parse out options
+    parser = pykoa.tools.get_option_parser(help_screen)
+    parser.add_option("--dry-run", dest="do_not_execute",
+                      default=False, action="store_true",
+                      help="Output the Swift command line that will execute the workflow")
+
+
+    (options, args) = pykoa.tools.parse_args(parser, argv)
+
+    return (parser, options, args)
+
+# Do not know what this syntax is 
 @cli_exception_handler
 def main( argv=sys.argv[1:] ):
+    (parser, options, args) = setup_opts(argv)
+
+    # Not sure what these lines do yet, just copied from koa-ly.py
     guc_util.init_guc_env()
 
     conn     = pykoa.connect()
     user_row = pykoa.tools.cli_get_user( conn )
     user_id  = user_row.id
 
-    sys.stdout.write( "Executing Swift on: " + argv[0] + "\n" )
+    # If I did not specify at least one site, print help message
+    if len(args) < 1:
+        parser.print_help()
+        return 1
+
+    # get a space seperated list of the sites to execute on
+    sites=" ".join( map ( str, args ) )
+    sys.stdout.write( "\nExecuting Swift on: " + sites + "\n" )
+
+    # If I do not execute the script, just print out all pertatent information
+    if options.do_not_execute:
+        sys.stdout.write( "swift -sites.file sites.xml -tc.file tc -config cf -cdm.file cdm script.swift\n\n" )
+        return 0
+
+    # Execute the script
+
     return 0
 
 if __name__ == "__main__":




More information about the Swift-commit mailing list