File indexing completed on 2026-04-10 08:39:07
0001 import datetime
0002 import os
0003 import re
0004 import socket
0005 import sys
0006 import threading
0007 from http.client import HTTPSConnection
0008 from urllib.parse import parse_qs, urlencode
0009
0010 from pandacommon.pandautils.PandaUtils import naive_utcnow
0011
0012 from pandaserver.userinterface.Client import baseURLSSL
0013
0014 node = {}
0015 node["siteName"] = sys.argv[1]
0016 node["mem"] = 1000
0017 node["node"] = socket.getfqdn()
0018
0019 url = f"{baseURLSSL}/getJob"
0020
0021 match = re.search("[^:/]+://([^/]+)(/.+)", url)
0022 host = match.group(1)
0023 path = match.group(2)
0024
0025 if "X509_USER_PROXY" in os.environ:
0026 certKey = os.environ["X509_USER_PROXY"]
0027 else:
0028 certKey = f"/tmp/x509up_u{os.getuid()}"
0029
0030 rdata = urlencode(node)
0031
0032
0033 class Thr(threading.Thread):
0034 def __init__(self):
0035 threading.Thread.__init__(self)
0036
0037 def run(self):
0038 print(naive_utcnow().isoformat(" "))
0039 conn = HTTPSConnection(host, key_file=certKey, cert_file=certKey)
0040 conn.request("POST", path, rdata)
0041 resp = conn.getresponse()
0042 data = resp.read()
0043 print(naive_utcnow().isoformat(" "))
0044 print(parse_qs(data))
0045
0046
0047 nThr = 1
0048 thrs = []
0049 for i in range(nThr):
0050 thrs.append(Thr())
0051
0052 for thr in thrs:
0053 thr.start()