-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathTest_GenerateAndExecutePilotWrapper.py
More file actions
57 lines (42 loc) · 1.32 KB
/
Copy pathTest_GenerateAndExecutePilotWrapper.py
File metadata and controls
57 lines (42 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
# This is a test that:
# - gets the (DIRAC-free) PilotWrapper.py (that should be in input)
# - use its functions to generate a pilot wrapper
# - starts it
#
# It should be executed for different versions of python, e.g.:
# - 3.6.x
# - 3.11.x
#
#
# Invoke this with:
#
# python Test_GenerateAndExecutePilotWrapper.py url://to_PilotWrapper.py
from __future__ import absolute_import, division, print_function
import os
import sys
import time
import subprocess
# 1) gets the (DIRAC-free) PilotWrapper.py
from urllib.request import urlopen # pylint: disable=import-error,no-name-in-module
import ssl # pylint: disable=import-error
context = ssl._create_unverified_context()
rf = urlopen(sys.argv[1], context=context)
locc = sys.argv[2]
with open("PilotWrapper.py", "wb") as pj:
pj.write(rf.read())
# 2) use its functions to generate a pilot wrapper
time.sleep(1)
# by now this will be in the local dir
from PilotWrapper import pilotWrapperScript # pylint: disable=import-error
res = pilotWrapperScript(
pilotOptions="--setup=CI -N ce.dirac.org -Q DIRACQUEUE -n DIRAC.CI.ORG --debug",
location=locc + "/,wrong.cern.ch",
)
with open("pilot-wrapper.sh", "wb") as pj:
pj.write(res.encode())
# 3) now start it
result = subprocess.call(["sh", "pilot-wrapper.sh"])
if result != 0:
sys.exit(1)
sys.exit(0)