New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add constants for status values #454
Comments
Would that support having multiple values for the same status category? For example, Different service classes can also have different meanings for the same status value, although the category remains the same). Not sure if that matters though, presumably you could lookup the meaning via the service class (or |
I alluded to that in the "alternatives" section above, but I don't think it's necessary. Users can use the existing I would just like to avoid having to use magic values in my SCP code. Here's what I'm currently doing: from enum import IntEnum
class Status(IntEnum):
CANCEL = 0xFE00
PENDING = 0xFF00
PENDING_WITH_WARNING = 0xFF01
# -----------------------------------------------------------------------------
MODALITY = "US"
def handle_find(event):
"""Handle a C-FIND request event."""
app.logger.info("received C-FIND request for worklist id=%s", worklist.id)
items = event.assoc._worklist.items
for item in items:
# Check if C-CANCEL has been received
if event.is_cancelled:
yield (Status.CANCEL, None)
return
identifier = to_identifier(item)
# Pending
yield (Status.PENDING, identifier) |
I think this is a good idea, but including all the status codes is impractical so I decided that defaulting to a small set of statuses and allowing the user to add extra constants is the way to go. from pynetdicom.status import Status
# Customise the class
Status.add('UNABLE_TO_PROCESS', 0xC000)
def handle_store(event):
try:
event.dataset.save_as('temp.dcm')
except:
return Status.UNABLE_TO_PROCESS
return Status.SUCCESS |
Great! Thanks for implementing this |
Is your feature request related to a problem? Please describe.
It would be convenient to have constants for the various status values.
Describe the solution you'd like
Ideally, there would be an
IntEnum
with the valid service statuses. I imagine it'd look similar to thehttp.HTTPStatus
from the stdlib.Describe alternatives you've considered
You could also use an enum of tuples or sets, so you could have e.g.
But this isn't clearly better and is less flexible.
Additional context
Might want to add this after Python 2 is dropped so you don't have to conditionally install an
enum
backport.The text was updated successfully, but these errors were encountered: