Skip to content

Commit

Permalink
Merge a9f5220 into 0a17f39
Browse files Browse the repository at this point in the history
  • Loading branch information
scaramallion committed Feb 10, 2018
2 parents 0a17f39 + a9f5220 commit 42e7c7d
Show file tree
Hide file tree
Showing 55 changed files with 7,223 additions and 4,356 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ before_script:
- wget https://github.com/pydicom/pydicom/archive/master.tar.gz -O /tmp/pydicom.tar.gz
- tar xzf /tmp/pydicom.tar.gz
- pip install $PWD/pydicom-master
- pip install pytest pytest-cov

install:
- pip install coverage
- pip install coveralls
- pip install pytest pytest-cov
- python setup.py install

# Command to run tests
script:
- coverage run --source=pynetdicom3 -m test.run_all_tests -v
- pytest --cov=pynetdicom3

after_success:
- coveralls
Expand Down
16 changes: 13 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,19 @@ Examples
if assoc.is_established:
# Send a DIMSE C-ECHO request to the peer
assoc.send_c_echo()
# `status` is a pydicom Dataset object with (at a minimum) a
# (0000,0900) Status element
status = assoc.send_c_echo()
# Output the response from the peer
if status:
print('C-ECHO Response: 0x{0:04x}'.format(status.Status))
# Release the association
assoc.release()
- Create a DICOM C-ECHO listen SCP on port 11112:
- Create a DICOM C-ECHO listen SCP on port 11112 (you may optionally implement
the `AE.on_c_echo callback` if you want to return a non Success status):

.. code-block:: python
Expand Down Expand Up @@ -146,6 +153,9 @@ Examples
assoc = ae.associate(addr, port)
if assoc.is_established:
dataset = read_file('file-in.dcm')
assoc.send_c_store(dataset)
# `status` is the response from the peer to the store request
# but may be an empty pydicom Dataset if the peer timed out or
# sent an invalid dataset.
status = assoc.send_c_store(dataset)
assoc.release()
13 changes: 12 additions & 1 deletion docs/echoscp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,18 @@ Miscellaneous DICOM
``-td --dimse-timeout [s]econdsr (int)``
timeout for DIMSE messages (default: unlimited)
``-pdu --max-pdu [n]umber of bytes (int)``
set maximum receive PDU bytes to n bytes (default: 16384)
set maximum receive PDU bytes to n bytes (default: 16384)

Preferred Transfer Syntaxes
---------------------------
``-x= --prefer-uncompr``
prefer explicit VR local byte order (default)
``-xe --prefer-little``
prefer explicit VR little endian transfer syntax
``-xb --prefer-big``
prefer explicit VR big endian transfer syntax
``-xi --implicit``
accept implicit VR little endian transfer syntax only

DICOM Conformance
=================
Expand Down
4 changes: 2 additions & 2 deletions docs/echoscu.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Logging
debug mode, prints debugging information
``-ll --log-level [l]evel (str)``
One of ['critical', 'error', 'warning', 'info', 'debug'], prints
logging messages with corresponding level l or higher
logging messages with corresponding level or higher
``-lc --log-config [f]ilename (str)``
use python logging config [#]_ file f for the logger

Expand All @@ -75,7 +75,7 @@ Miscellaneous DICOM
timeout for DIMSE messages (default: unlimited)
``-pdu --max-pdu [n]umber of bytes (int)``
set maximum receive PDU bytes to n bytes (default: 16384)
``--repeat [n]umber (int)``
``--repeat [n]umber (int)``
repeat echo n times
``--abort``
abort association instead of releasing it
Expand Down
8 changes: 7 additions & 1 deletion docs/scu_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ Application Entity (AE) is to send a DICOM C-ECHO, which utilises the
if assoc.is_established:
print('Association accepted by the peer')
# Send a DIMSE C-ECHO request to the peer
assoc.send_c_echo()
# status is a pydicom Dataset object with (at a minimum) a
# (0000, 0900) Status element
status = assoc.send_c_echo()
# Output the response from the peer
if status:
print('C-ECHO Response: 0x{0:04x}'.format(status.Status))
# Release the association
assoc.release()
Expand Down
2 changes: 1 addition & 1 deletion pynetdicom3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Set module shortcuts and globals
"""
version = ['0', '1', '0']
version = ['0', '9', '0']
pynetdicom_version = 'PYNETDICOM3_' + ''.join(version)

# UID prefix provided by https://www.medicalconnections.co.uk/Free_UID
Expand Down
32 changes: 17 additions & 15 deletions pynetdicom3/acse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
ACSE service provider
"""
import logging
import time
import socket

from pydicom.uid import UID

from pynetdicom3 import pynetdicom_uid_prefix
from pynetdicom3 import pynetdicom_version
from pynetdicom3.pdu_primitives import MaximumLengthNegotiation, \
ImplementationClassUIDNotification, \
ImplementationVersionNameNotification
from pynetdicom3.pdu_primitives import A_ASSOCIATE, A_RELEASE, A_ABORT, \
A_P_ABORT
from pynetdicom3.pdu_primitives import (MaximumLengthNegotiation,
ImplementationClassUIDNotification,
ImplementationVersionNameNotification)
from pynetdicom3.pdu_primitives import (A_ASSOCIATE, A_RELEASE, A_ABORT,
A_P_ABORT)
from pynetdicom3.utils import PresentationContextManager
from pynetdicom3.utils import wrap_list
from pynetdicom3.utils import pretty_bytes

LOGGER = logging.getLogger('pynetdicom3.acse')

Expand Down Expand Up @@ -378,8 +378,8 @@ def CheckRelease(self):
self.dul.send_pdu(release_rsp)

return True
else:
return False

return False

def CheckAbort(self):
"""Checks for abort indication from the remote AE. """
Expand All @@ -389,8 +389,8 @@ def CheckAbort(self):
if primitive.__class__ in (A_ABORT, A_P_ABORT):
self.dul.receive_pdu(wait=False)
return True
else:
return False

return False

def Status(self):
"""Return the current state of the DUL's state machine"""
Expand Down Expand Up @@ -482,7 +482,7 @@ def debug_send_associate_rq(a_associate_rq):
#s.append(' Application Information, length: %d bytes'
# %len(item.app_info))

app_info = wrap_list(item.app_info)
app_info = pretty_bytes(item.app_info)
app_info[0] = '[' + app_info[0][1:]
app_info[-1] = app_info[-1] + ' ]'
for line in app_info:
Expand Down Expand Up @@ -581,6 +581,9 @@ def debug_send_associate_ac(a_associate_ac):
'{0!s}'.format(user_info.maximum_length))
s.append('Presentation Contexts:')

if not pres_contexts:
s.append(' (no valid presentation contexts)')

for item in pres_contexts:
s.append(' Context ID: {0!s} ({1!s})'
.format(item.ID, item.result_str))
Expand Down Expand Up @@ -677,8 +680,7 @@ def debug_send_abort(a_abort_rq):
a_abort : pynetdicom3.pdu.A_ABORT_RQ
The A-ABORT PDU instance
"""
pass

LOGGER.info('Aborting Association')

# Local AE receiving PDU from peer AE
@staticmethod
Expand Down Expand Up @@ -751,7 +753,7 @@ def debug_receive_associate_rq(a_associate_rq):
#s.append(' Application Information, length: %d bytes'
# %len(item.app_info))

app_info = wrap_list(item.app_info)
app_info = pretty_bytes(item.app_info)
app_info[0] = '[' + app_info[0][1:]
app_info[-1] = app_info[-1] + ' ]'
for line in app_info:
Expand Down
Loading

0 comments on commit 42e7c7d

Please sign in to comment.