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

jonmon at ci.uchicago.edu jonmon at ci.uchicago.edu
Fri Jul 15 14:16:06 CDT 2011


Author: jonmon
Date: 2011-07-15 14:16:06 -0500 (Fri, 15 Jul 2011)
New Revision: 4822

Modified:
   SwiftApps/GOSwift/pykoa/tools/koa_goswift.py
Log:
o Fixed how the next run directory is computed. Now there is not a limit of 10 directories before I have to go manually purge.
o Added comments
o Changed a lot of ' to "


Modified: SwiftApps/GOSwift/pykoa/tools/koa_goswift.py
===================================================================
--- SwiftApps/GOSwift/pykoa/tools/koa_goswift.py	2011-07-15 16:16:20 UTC (rev 4821)
+++ SwiftApps/GOSwift/pykoa/tools/koa_goswift.py	2011-07-15 19:16:06 UTC (rev 4822)
@@ -174,25 +174,31 @@
 
     # check to see is the swift directory has been created
     home = os.getenv( "HOME" )
-    swift_dir = home + '/swift'
+    swift_dir = home + "/Swift"
     if not os.access( swift_dir, os.F_OK ):
         os.mkdir( swift_dir )
 
     # default is run.0, if there are other directories then adjust the run directory count
-    run_directory = 'run.0'
+    run_directory = "run.0"
     directories = os.listdir( swift_dir )
 
     # This might cause a performance problem(to even begin to start Swift)
     # Need to figure out how maybe purge these run directories
     # For now I can manually purge
-    directories.sort()
-    directories.reverse()
+    runs = []
+    for direc in directories:
+        ( name, sep, run_num ) = direc.partition( "." )
+        try:
+            runs.append( int( run_num) )
+        except ValueError:
+            pykoa.debug( "Directory "+direc+" is not a run directory" )
+            
+    runs.sort()
 
-    # if the directories list is not empty.
-    if directories:
-        last_directory = directories[ 0 ]
-        ( run, sep, run_num ) = last_directory.partition( '.' )
-        run_directory = run + '.' + str( int ( run_num ) + 1 )
+    # if the directories list is not empty, create the name of the run directory
+    if runs:
+        last_run = runs[ len(runs)-1 ] + 1
+        run_directory = "run."+str(last_run)
 
     # get a space seperated String of the sites to execute on
     execution_sites=" ".join( map ( str, args ) )
@@ -210,21 +216,24 @@
         return 0
 
     # Set up for the acutal execution
-    os.mkdir( swift_dir+'/'+run_directory )
+    os.mkdir( swift_dir+"/"+run_directory )
 
-    with open( swift_dir+'/'+run_directory+'/tc', 'w' ) as tc_file:
+    with open( swift_dir+"/"+run_directory+"/tc", "w" ) as tc_file:
         tc_file.write( tc )
 
-    with open( swift_dir+'/'+run_directory+'/sites.xml', 'w' ) as sites_file:
+    with open( swift_dir+"/"+run_directory+"/sites.xml", "w" ) as sites_file:
         sites_file.write( sites )
 
-    with open( swift_dir+'/'+run_directory+'/cf', 'w' ) as config_file:
+    with open( swift_dir+"/"+run_directory+"/cf", "w" ) as config_file:
         config_file.write( config )
 
-    with open( swift_dir+'/'+run_directory+'/script.swift', 'w' ) as script_file:
+    with open( swift_dir+"/"+run_directory+"/script.swift", "w" ) as script_file:
         script_file.write( script )
 
     # A logical endpoint (no dots) can be a scp like path, if it has a :
+    # This for loop is wrong.  If I am understanding this correctly, this should only parsethe last site I pass the script.
+    # A current issue is that the site must also be accompanied by a path, which is not necessary for Swift execution.
+    # Unless I leave it and use the path given as the work directory on the site in the sites.xml file?
     for arg in args:
         if re.match("^[^.]+:", arg):
             url = url_parse.SCPUrl(arg, allow_empty_path=True)
@@ -266,8 +275,8 @@
 
     if not src_url:
         # Not a logical endpoint
-	if '.' not in url.name:
-	    raise ToolsException('EEXIST_ENDPOINT', url.name)
+	if "." not in url.name:
+	    raise ToolsException("EEXIST_ENDPOINT", url.name)
         if not url.scheme:
             url.scheme = "gsiftp"
         if not url.port:
@@ -299,7 +308,7 @@
             src_cred = open(cred_file).read()
             if ep:
                 # Save to the database
-                ep_cache = {'foo': ep.id}
+                ep_cache = {"foo": ep.id}
                 koa_transfer.do_activate(conn, cred_file, ep_cache, user_id,
                                          quiet=True)
         finally:
@@ -315,20 +324,21 @@
 def execute_swift(user_id, options, src_url, src_cred, src_subject, swift_dir, run_directory, home):
 
     if src_subject:
-        os.environ['GLOBUS_FTP_CLIENT_TEST_SUBJECT'] = src_subject
+        os.environ["GLOBUS_FTP_CLIENT_TEST_SUBJECT"] = src_subject
     if src_cred:
         proxyfile = guc_util.sec_text_to_proxy_file(user_id, src_cred)
         os.environ["X509_USER_CERT"] = proxyfile
         os.environ["X509_USER_KEY"] = proxyfile
         os.environ["X509_USER_PROXY"] = proxyfile
 
+    # Need to figure out how to get the values. Not sure how.
     os.environ["GLOBUS_HOSTNAME"] = "50.16.138.64"
     os.environ["GLOBUS_TCP_PORT_RANGE"] = "50000,51000"
     os.environ["GLOBUS_SOURCE_PORT_RANGE"] = "50000,51000"
 
     # Execute the script
-    os.chdir( swift_dir+'/'+run_directory )
-    ( status, output ) = commands.getstatusoutput( home+'/swift-0.92/bin/swift -sites.file sites.xml -tc.file tc -config cf script.swift' )
+    os.chdir( swift_dir+"/"+run_directory )
+    ( status, output ) = commands.getstatusoutput( home+"/swift-0.92/bin/swift -sites.file sites.xml -tc.file tc -config cf script.swift" )
     sys.stdout.write( "\nSwift output: " + output + "\n" )
     sys.stdout.write( "Swift exit status: " + str(status) + "\n" )
 




More information about the Swift-commit mailing list