Skip to content

Commit

Permalink
Merge pull request #288 from tmaeno/master
Browse files Browse the repository at this point in the history
fixed putEventPickingRequest
  • Loading branch information
tmaeno authored Jan 22, 2024
2 parents d7fc2e9 + e89fe13 commit c216e3c
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions pandaserver/taskbuffer/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ def putEventPickingRequest(

user_name = panda_request.subprocess_env["SSL_CLIENT_S_DN"]

tmp_log = LogWrapper(_logger, f"putEventPickingRequest {user_name}")
tmp_log.debug("start")
tmp_log = LogWrapper(_logger, f"putEventPickingRequest-{datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None).isoformat('/')}")
tmp_log.debug(f"start for {user_name}")

creation_time = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None).strftime("%Y-%m-%d %H:%M:%S")

Expand All @@ -251,7 +251,7 @@ def putEventPickingRequest(
tmp_log.error(f"{error_message}")
tmp_log.debug("end")
return "ERROR : " + error_message
_logger.debug(f"size {content_length}")
tmp_log.debug(f"size {content_length}")

if content_length > EVENT_PICKING_LIMIT:
error_message = f"Run/event list is too large. Exceeded size limit {content_length}>{EVENT_PICKING_LIMIT}."
Expand All @@ -267,7 +267,7 @@ def putEventPickingRequest(
try:
# generate the filename
file_name = f"{panda_config.cache_dir}/evp.{str(uuid.uuid4())}"
_logger.debug(f"putEventPickingRequest : {user_name} -> {file_name}")
tmp_log.debug(f"file: {file_name}")

# write the information to file
file_content = (
Expand All @@ -288,25 +288,22 @@ def putEventPickingRequest(

with open(file_name, "w") as file_object:
file_object.write(file_content)

run_event_guid_map = {}
for tmp_line in runEventList.split("\n"):
tmp_items = tmp_line.split()
if (len(tmp_items) != 2 and not giveGUID) or (len(tmp_items) != 3 and giveGUID):
continue
file_object.write("runEvent=%s,%s\n" % tuple(tmp_items[:2]))
if giveGUID:
run_event_guid_map[tuple(tmp_items[:2])] = [tmp_items[2]]
file_object.write(f"runEvtGuidMap={str(run_event_guid_map)}\n")
file_object.close()

except Exception:
error_type, error_value = sys.exc_info()[:2]
error_message = f"cannot put request due to {error_type} {error_value}"
_logger.error(f"putEventPickingRequest : {error_message} {user_name}")
run_event_guid_map = {}
for tmp_line in runEventList.split("\n"):
tmp_items = tmp_line.split()
if (len(tmp_items) != 2 and not giveGUID) or (len(tmp_items) != 3 and giveGUID):
continue
file_object.write("runEvent=%s,%s\n" % tuple(tmp_items[:2]))
if giveGUID:
run_event_guid_map[tuple(tmp_items[:2])] = [tmp_items[2]]
file_object.write(f"runEvtGuidMap={str(run_event_guid_map)}\n")

except Exception as e:
error_message = f"cannot put request due to {str(e)}"
tmp_log.error(error_message + traceback.format_exc())
return f"ERROR : {error_message}"

_logger.debug(f"putEventPickingRequest : {user_name} end")
tmp_log.debug("end")
return "True"


Expand Down

0 comments on commit c216e3c

Please sign in to comment.