[Swift-commit] r4818 - SwiftApps/GOSwift/pykoa/tools
jonmon at ci.uchicago.edu
jonmon at ci.uchicago.edu
Tue Jul 12 12:00:08 CDT 2011
Author: jonmon
Date: 2011-07-12 12:00:08 -0500 (Tue, 12 Jul 2011)
New Revision: 4818
Modified:
SwiftApps/GOSwift/pykoa/tools/koa_goswift.py
Log:
changed the way files are written. added information to contact the proxy servers correctly.
Modified: SwiftApps/GOSwift/pykoa/tools/koa_goswift.py
===================================================================
--- SwiftApps/GOSwift/pykoa/tools/koa_goswift.py 2011-07-12 00:10:40 UTC (rev 4817)
+++ SwiftApps/GOSwift/pykoa/tools/koa_goswift.py 2011-07-12 17:00:08 UTC (rev 4818)
@@ -19,7 +19,6 @@
from pykoa.tools.koa_ep_activate import check_explicit_activate
from pykoa.consumers import guc_util
from pykoa.constants import get_scheme
-from pykoa.lib.mlsd import MLSDEntry
from pykoa.data import endpoint_dao
from pykoa.data import creds_dao
from pykoa.koaexception import ToolsException, cli_exception_handler
@@ -52,8 +51,12 @@
default=False, action="store_true",
help="Use gsi-ssh delegated credential")
+ myproxy.add_myproxy_options(parser)
(options, args) = pykoa.tools.parse_args(parser, argv)
+ if options.gsi_activation and not os.getenv("X509_USER_PROXY"):
+ raise ToolsException("ENO_GSI_SSH")
+
return (parser, options, args)
def parse_stdin():
@@ -70,8 +73,7 @@
sites_file = extract_sites( lines )
config = extract_config( lines )
script = extract_script( lines )
-
-
+
return ( tc, sites_file, config, script )
def extract_tc( lines ):
@@ -206,33 +208,30 @@
# Set up for the acutal execution
os.mkdir( swift_dir+'/'+run_directory )
- tc_file = open( swift_dir+'/'+run_directory+'/tc', 'w' )
- sites_file = open( swift_dir+'/'+run_directory+'/sites.xml', 'w' )
- config_file = open( swift_dir+'/'+run_directory+'/cf', 'w' )
- script_file = open( swift_dir+'/'+run_directory+'/script.swift', 'w' )
+ with open( swift_dir+'/'+run_directory+'/tc', 'w' ) as tc_file:
+ tc_file.write( tc )
- tc_file.write( tc )
- sites_file.write( sites )
- config_file.write( config )
- script_file.write( script )
+ with open( swift_dir+'/'+run_directory+'/sites.xml', 'w' ) as sites_file:
+ sites_file.write( sites )
- tc_file.close()
- sites_file.close()
- config_file.close()
- script_file.close()
+ with open( swift_dir+'/'+run_directory+'/cf', 'w' ) as config_file:
+ config_file.write( config )
- # A logical endpoint (no dots) can be a scp like path, if it has a :
- if re.match("^[^.]+:", args[0]):
- url = url_parse.SCPUrl(args[0], allow_empty_path=True)
- url.update_relative_path()
- else:
- url = url_parse.TransferURL(args[0])
+ 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 :
+ for arg in args:
+ if re.match("^[^.]+:", arg):
+ url = url_parse.SCPUrl(arg, allow_empty_path=True)
+ url.update_relative_path()
+ else:
+ url = url_parse.TransferURL(arg)
+
src_url = None
src_cred = None
default_myproxy = None
ep = None
- myproxy_host = None
if not url.scheme:
# See if it's a logical endpoint
@@ -280,13 +279,13 @@
cred_file = os.environ["X509_USER_PROXY"]
src_cred = open(cred_file).read()
- elif myproxy_host or ((not src_cred) and default_myproxy):
- if not myproxy_host:
- myproxy_host = default_myproxy
+ elif options.myproxy_host or ((not src_cred) and default_myproxy):
+ if not options.myproxy_host:
+ options.myproxy_host = default_myproxy
if ep:
- check_explicit_activate([ep], myproxy_host)
+ check_explicit_activate([ep], options.myproxy_host)
- cred_file = myproxy.contact_myproxy_server(myproxy_host,
+ cred_file = myproxy.contact_myproxy_server(options.myproxy_host,
options.myproxy_user, options.myproxy_dn,
lifetime=options.myproxy_lifetime)
@@ -295,12 +294,12 @@
try:
src_cred = open(cred_file).read()
if ep:
- # Save cred to DB, re-entering passphrases is annoying
+ # Save to the database
ep_cache = {'foo': ep.id}
koa_transfer.do_activate(conn, cred_file, ep_cache, user_id,
- quiet=True)
+ quiet=True)
finally:
- os.unlink(cred_file)
+ os.remove(cred_file)
if not src_cred:
raise ToolsException("A credential is needed. Try -g or -m.")
More information about the Swift-commit
mailing list