Skip to content

Commit

Permalink
fix: compatibility with py2 and py3
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Jan 9, 2025
1 parent fbd4a59 commit db63b85
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/DIRAC/Resources/Computing/PilotBundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,28 @@ def bundleProxy(executableFile, proxy):
try:
workingDirectory = tempfile.mkdtemp(suffix='_wrapper', prefix='TORQUE_')
os.chdir(workingDirectory)
open('proxy', "w").write(bz2.decompress(base64.b64decode("{compressedAndEncodedProxy}")))
open('{executable}', "w").write(bz2.decompress(base64.b64decode("{compressedAndEncodedExecutable}")))
# Decode and decompress the proxy
with open('proxy', "wb") as proxy_file:
proxy_file.write(bz2.decompress(base64.b64decode("{compressedAndEncodedProxy}")))
# Decode and decompress the executable
with open('{executable}', "wb") as executable_file:
executable_file.write(bz2.decompress(base64.b64decode("{compressedAndEncodedExecutable}")))
os.chmod('proxy', stat.S_IRUSR | stat.S_IWUSR)
os.chmod('{executable}', stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
os.environ["X509_USER_PROXY"] = os.path.join(workingDirectory, 'proxy')
except Exception as x:
print >> sys.stderr, x
print("Error:", x, file=sys.stderr)
sys.exit(-1)
cmd = "./{executable}"
print 'Executing: ', cmd
print('Executing:', cmd)
sys.stdout.flush()
os.system(cmd)
shutil.rmtree(workingDirectory)
""".format(
compressedAndEncodedProxy=compressedAndEncodedProxy,
compressedAndEncodedExecutable=compressedAndEncodedExecutable,
Expand Down

0 comments on commit db63b85

Please sign in to comment.