@@ -27,7 +27,7 @@ def doWriteBack(source, destination):
2727 Do a write back to Stash using SciTokens
2828
2929 :param str source: The location of the local file
30- :param str destination: The location of the remote file
30+ :param str destination: The location of the remote file, in stash:// format
3131 """
3232 start1 = int (time .time ()* 1000 )
3333
@@ -50,6 +50,9 @@ def doWriteBack(source, destination):
5050
5151 with open (scitoken_file , 'r' ) as scitoken_obj :
5252 scitoken_contents = scitoken_obj .read ().strip ()
53+
54+ # Remove the stash:// at the beginning, don't need it
55+ destination = destination .replace ("stash://" )
5356
5457 command = "curl -X PUT --fail --upload-file %s -H \" Authorization: Bearer %s\" %s%s" % (source , scitoken_contents , writeback_host , destination )
5558
@@ -103,8 +106,8 @@ def doStashCpSingle(sourceFile, destination, cache, debug=False):
103106 payload ['sitename' ] = sitename
104107 payload .update (parse_job_ad ())
105108
106- # Check if this is a source
107- if os . path . exists ( sourceFile ):
109+ # Check if the desitnation is a protocol like stash:///user/blah
110+ if destination . startswith ( "stash://" ):
108111 # Source file exists, must be a writeback
109112 return doWriteBack (sourceFile , destination )
110113
@@ -143,7 +146,7 @@ def doStashCpSingle(sourceFile, destination, cache, debug=False):
143146
144147 return 0
145148
146- except IOError , e :
149+ except IOError as e :
147150 logging .error ("Unable to copy with CVMFS, even though file exists: %s" , str (e ))
148151
149152 else :
0 commit comments