@@ -33,48 +33,28 @@ def doWriteBack(source, destination):
3333
3434 # Get the scitoken content
3535 scitoken_file = None
36- if 'AUTHTOKEN' in os .environ :
37- # First, try to split the environment variable:
38- # Format: AUTHTOKEN=FILE:/var/lib/condor/execute/dir_24688/nobody.cc
39- if ':' in os .environ ['AUTHTOKEN' ]:
40- # Try splitting
41- scitoken_file = os .environ ['AUTHTOKEN' ].split (':' , 1 )[1 ]
42- if not os .path .exists (scitoken_file ):
43- logging .error ("Unable to find file %s" % scitoken_file )
44- scitoken_file = None
45- if scitoken_file == None :
46- # Splitting failed, now try just looking at the os.environ:
47- scitoken_file = os .environ ['AUTHTOKEN' ]
48- if not os .path .exists (scitoken_file ):
49- scitoken_file = None
50- logging .error ("Unable to find SciToken file, environment variable AUTHTOKEN=%s, but file not found" % (os .environ ['AUTHTOKEN' ]))
51- if scitoken_file == None :
52- try :
53- if os .path .exists ("%s.cc" % (os .getlogin ())):
54- scitokens_file = "%s.cc" % (os .getlogin ())
55- else :
56- logging .error ("Unable to find scitokens in the current directory" )
57- except OSError as ose :
58- logging .error ("OS error when trying to get login information, possibly running in stashcp. Moving on to globbing for *.cc file" )
59- if scitoken_file == None :
60- # Look for the cc file with glob
61- import glob
62- results = glob .glob ("*.cc" )
63- if len (results ) > 0 :
64- scitoken_file = results [0 ]
65- else :
66- logging .error ("Unable to find scitokens file with glob" )
67- return 1
68-
69- else :
70- logging .error ("Unable to find SciToken file, environment variable \" AUTHTOKEN\" not found." )
36+ if '_CONDOR_CREDS' in os .environ :
37+ # First, look for the scitokens.use file
38+ # Format: _CONDOR_CREDS=/var/lib/condor/execute/dir_908/.condor_creds
39+ scitoken_file = os .path .join (os .environ ['_CONDOR_CREDS' ], 'scitokens.use' )
40+ if not os .path .exists (scitoken_file ):
41+ scitoken_file = None
42+
43+ if not scitoken_file and os .path .exists (".condor_creds/scitokens.use" ):
44+ scitoken_file = ".condor_creds/scitokens.use"
45+
46+ if not scitoken_file :
47+ logging .error ("Unable to find scitokens.use file" )
7148 return 1
49+
7250
7351 with open (scitoken_file , 'r' ) as scitoken_obj :
7452 scitoken_contents = scitoken_obj .read ().strip ()
7553
7654 command = "curl -X PUT --fail --upload-file %s -H \" Authorization: Bearer %s\" %s%s" % (source , scitoken_contents , writeback_host , destination )
77- print command
55+
56+ if 'http_proxy' in os .environ :
57+ del os .environ ['http_proxy' ]
7858
7959 curl = subprocess .Popen ([command ],shell = True ,stdout = subprocess .PIPE ,stderr = subprocess .PIPE )
8060 (stdout , stderr ) = curl .communicate ()
@@ -83,6 +63,8 @@ def doWriteBack(source, destination):
8363 logging .error (stdout )
8464 logging .error (stderr )
8565
66+ sitename = os .environ .setdefault ("OSG_SITE_NAME" , "siteNotFound" )
67+ end1 = int (time .time ()* 1000 )
8668 # Send the payload
8769 payload = {
8870 'filename' : source ,
0 commit comments