Skip to content

Commit

Permalink
Merge branch 'dev128' into index128
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingface0 committed Aug 6, 2024
2 parents 50786a0 + b095f2a commit 1503567
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 22 deletions.
12 changes: 5 additions & 7 deletions bin/dqm-access
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def find_matching_samples(options):
sys.exit(1)

def req_done(c):
all_samples["result"] = json.loads(c.buffer.getvalue())
all_samples["result"] = json.loads(c.buffer.getvalue().decode())

reqman = RequestManager(
ssl_opts=ssl_opts,
Expand Down Expand Up @@ -158,14 +158,12 @@ def fetch_tstreamerinfo(options, dataset):

def req_error(c, url, errmsg, errno):
sys.stderr.write(
"%s: failed to retrieve TStreamerInfo: %s (%d)" % options.server,
errmsg,
errno,
f"{options.server}: failed to retrieve TStreamerInfo: {errmsg} ({errno})"
)
sys.exit(1)

def req_done(c):
topdir["contents"] = json.loads(c.buffer.getvalue())["contents"]
topdir["contents"] = json.loads(c.buffer.getvalue().decode())["contents"]

reqman = RequestManager(
ssl_opts=ssl_opts,
Expand Down Expand Up @@ -243,9 +241,9 @@ def process(c):
sys.stdout.write(".")
sys.stdout.flush()
if nreq % 750 == 0:
print
print()

reply = c.buffer.getvalue()
reply = c.buffer.getvalue().decode()
reply = re.sub(r'("value": ")"([A-Za-z0-9_]+")"', r"\1\2", reply)
reply = re.sub(r'("(?:mean|rms|min|max)":) nan,', r'\1 "NaN",', reply)
reply = re.sub(
Expand Down
6 changes: 3 additions & 3 deletions bin/dqm-grep
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def find_matching_samples(options):
sys.exit(1)

def req_done(c):
all_samples["result"] = json.loads(c.buffer.getvalue())
all_samples["result"] = json.loads(c.buffer.getvalue().decode())

reqman = RequestManager(
ssl_opts=ssl_opts,
Expand Down Expand Up @@ -301,9 +301,9 @@ def process(c):
sys.stdout.write(".")
sys.stdout.flush()
if nreq % 750 == 0:
print
print()

reply = c.buffer.getvalue()
reply = c.buffer.getvalue().decode()
reply = re.sub(r'("value": ")"([A-Za-z0-9_]+")"', r"\1\2", reply)
reply = re.sub(r'("(?:mean|rms|min|max)":) nan,', r'\1 "NaN",', reply)
reply = json.loads(reply)
Expand Down
8 changes: 4 additions & 4 deletions bin/dqm-ls
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import pycurl
from optparse import OptionParser
from time import time, strptime
from calendar import timegm
from urllib import parse
from urllib.parse import quote, urlparse

# Object types.
DIR = 0
Expand All @@ -48,7 +48,7 @@ found = []
def request_init(c, options, path):
"""`RequestManager` callback to initialise directory contents request."""
c.setopt(
pycurl.URL, options.server + parse.quote(path) + ((path != "/" and "/") or "")
pycurl.URL, options.server + quote(path) + ((path != "/" and "/") or "")
)


Expand All @@ -69,12 +69,12 @@ def parse_dir(c):
If verbosity has been requested, also shows simple progress bar on the
search progress, one dot for every ten directories retrieved."""
options, path = c.task
root_url = parse.urlparse(options.server).path.rstrip("/")
root_url = urlparse(options.server).path.rstrip("/")

items = re.findall(
r"<tr><td><a href='(.*?)'>(.*?)</a></td><td>(\d+|&nbsp;|-)</td>"
r"<td>(&nbsp;|\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d UTC)</td>",
c.buffer.getvalue(),
c.buffer.getvalue().decode(),
)

for path, name, size, date in items:
Expand Down
2 changes: 1 addition & 1 deletion bin/visDQMOnlineSyncDaemon
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def process_task(c):
items = re.findall(
r"<tr><td><a href='(.*?)'>(.*?)</a></td><td>(\d+|&nbsp;|-)</td>"
r"<td>(&nbsp;|\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d UTC)</td>",
c.buffer.getvalue(),
c.buffer.getvalue().decode(),
)

for path, name, size, date in items:
Expand Down
10 changes: 5 additions & 5 deletions bin/visDQMUploadLayout
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from Monitoring.Core.HTTP import RequestManager
from Monitoring.Core.X509 import SSLOptions
import sys, os, mimetypes
from io import StringIO
from stat import *
from io import BytesIO
# from stat import *

IDENT = "visDQMUploadLayout DQMGUI/%s python/%s" % (
os.getenv("DQMGUI_VERSION", "?"),
Expand Down Expand Up @@ -39,7 +39,7 @@ def encode(args, files):
body += ("Content-Type: %s" % filetype(filename)).encode() + crlf
with open(filename, "rb") as _f:
body += crlf + _f.read() + crlf
body += "--" + boundary + "--".encode() + crlf + crlf
body += "--".encode() + boundary + "--".encode() + crlf + crlf
return ("multipart/form-data; boundary=".encode() + boundary, body)


Expand All @@ -58,12 +58,12 @@ def req_init(c, url, files):
headers.append("Content-type: %s" % type)
headers.append("Content-length: %s" % str(len(body)))
c.setopt(c.HTTPHEADER, headers)
body_IO = StringIO(body)
body_IO = BytesIO(body)
c.setopt(c.READFUNCTION, body_IO.read)


def req_done(c):
print(c.buffer.getvalue())
print(c.buffer.getvalue().decode())


def req_error(c, task, errmsg, errno):
Expand Down
4 changes: 2 additions & 2 deletions src/python/Core/HTTP.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from io import StringIO
from io import BytesIO
from pycurl import (
CurlMulti,
Curl,
Expand Down Expand Up @@ -128,7 +128,7 @@ def process(self):
while self.queue and self.free:
c = self.free.pop()
c.task = self.queue.pop(0)
c.buffer = b = StringIO()
c.buffer = b = BytesIO()
c.setopt(WRITEFUNCTION, b.write)
self.request_init(c, *c.task)
self.cm.add_handle(c)
Expand Down

0 comments on commit 1503567

Please sign in to comment.