Skip to content

Commit

Permalink
Merge pull request #71 from mdsol/develop
Browse files Browse the repository at this point in the history
Merge release 1.1.5 for pushing to pypi
  • Loading branch information
anewbigging authored Aug 30, 2016
2 parents 73609f7 + 09c2d0e commit 5aab93c
Show file tree
Hide file tree
Showing 36 changed files with 2,126 additions and 198 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
#Distribution folder
dist/
rwslib.egg-info/
build

# sphinx build folder
docs/build

# coverage
htmlcov

# tox
.tox
.eggs

# coverage
.coverage
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: python
python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "pypy"
# command to install dependencies
install: "python setup.py install"
# command to run tests
script: "python setup.py test"
2 changes: 1 addition & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Authors
- Geoff Low <glow@mdsol.com>
- Andrew Newbigging <anewbigging@mdsol.com>
- Oli Quinet <https://github.com/Oli76>

- Daniel Smoczyk <https://github.com/dPeS>
1 change: 1 addition & 0 deletions docs/source/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Class Reference
.. autoclass:: StudyDatasetRequest
.. autoclass:: SubjectDatasetRequest
.. autoclass:: VersionDatasetRequest
.. autoclass:: ConfigurableDatasetRequest

.. module:: rwslib.rwsobjects

Expand Down
8 changes: 4 additions & 4 deletions docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RWSConnection ``send_request`` method::
>>> rws = RWSConnection('innovate')
>>> from rwslib.rws_requests import VersionRequest
>>> rws.send_request(VersionRequest())
1.8.0
u'1.8.0'

The result you get back from send_request will depend on the request type since Request objects have the chance to
process the text values returned from Rave. ``VersionRequest()`` returns a string value but other request types may
Expand Down Expand Up @@ -174,15 +174,15 @@ were sent, what URL was called etc.
>>> rws = RWSConnection('innovate')
>>> #Get the rave version from rws
>>> rws.send_request(VersionRequest())
1.8.0
u'1.8.0'
>>> rws.last_result.url
https://innovate.mdsol.com/RaveWebServices/version
>>> rws.last_result.status_code
200
>>> rws.last_result.headers['content-type']
text/plain; charset=utf-8
>>> rws.last_result.text
1.8.0
u'1.8.0'

``last_result`` is a `Requests <http://docs.python-requests.org/>`_ object. Please see that library for more
information on all the properties that can be returned there.
Expand All @@ -202,7 +202,7 @@ in it's ``request_time`` attribute.
>>> rws = RWSConnection('innovate')
>>> #Get the rave version from rws
>>> rws.send_request(VersionRequest())
1.8.0
u'1.8.0'
>>> #Get the elapsed time in seconds to process the previous request
>>> rws.request_time
0.760736942291
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Contents:
using_builders
biostats_gateway
odm_adapter
rwscmd
classes


Indices and tables
==================

Expand Down
84 changes: 80 additions & 4 deletions docs/source/rws_requests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Example::
>>> from rwslib.rws_requests import VersionRequest
>>> r = RWSConnection('innovate', 'username', 'password') #Authorization optional
>>> r.send_request(VersionRequest())
1.8.0
u'1.15.0'


.. _buildversion_request:
Expand All @@ -57,10 +57,31 @@ Example::
>>> from rwslib.rws_requests import BuildVersionRequest
>>> r = RWSConnection('innovate', 'username', 'password') #Authorization optional
>>> r.send_request(BuildVersionRequest())
5.6.5.12
u'5.6.5.213'



.. _codename_request:
.. index:: CodeNameRequest

CodeNameRequest()
-----------------

Returns the text result of calling::

https://{ host }/RaveWebServices/version/codename

Returns a 200 response code and the internal code name of the RWS version.

Example::

>>> from rwslib import RWSConnection
>>> from rwslib.rws_requests import CodeNameRequest
>>> r = RWSConnection('innovate') #Authorization optional
>>> r.send_request(CodeNameRequest())
u'Uakari'


.. _diagnostics_request:
.. index:: DiagnosticsRequest

Expand All @@ -69,7 +90,7 @@ DiagnosticsRequest()

Returns the text result of calling::

https://{ host }/RaveWebServices/version/build
https://{ host }/RaveWebServices/diagnostics

Returns a 200 response code and the text *OK* if RWS self-checks pass.

Expand All @@ -79,8 +100,29 @@ Example::
>>> from rwslib.rws_requests import DiagnosticsRequest
>>> r = RWSConnection('innovate', 'username', 'password') #Authorization optional
>>> r.send_request(DiagnosticsRequest())
OK
u'OK'


.. _twohundred_request:
.. index:: TwoHundredRequest

TowHundredRequest()
-------------------

Returns the html result of calling::

https://{ host }/RaveWebServices/twohundred

Returns a 200 response code and a html document that contains information about the MAuth configuration of Rave
Web Services on this url.

Example::

>>> from rwslib import RWSConnection
>>> from rwslib.rws_requests import TwoHundredRequest
>>> r = RWSConnection('innovate') #Authorization optional
>>> r.send_request(TwoHundredRequest())
u'<!DOCTYPE html>\r\n<html>\r\n<head><script.....


.. _cacheflush_request:
Expand Down Expand Up @@ -114,3 +156,37 @@ Example::
>>> response.istransactionsucessful
True


.. _configurabledatasetrequest_request:
.. index:: ConfigurableDatasetRequest

ConfigurableDatasetRequest()
----------------------------

Authorization is required for this method call.

Returns the text result of calling::

https://{ host }/RaveWebServices/datasets/{dataset_name}(.{dataset_format})?{params}


Sends a Configurable Dataset request to RWS. The `dataset_format` argument is optional and is only required if the
corresponding configurable dataset requires it. The primary use case of this is as an abstract class that the user
can subclass for their particular Configurable Dataset; the implemented class could such as validation of the
requested `dataset_format` against the list of formats accepted by the configurable dataset or by overloading the
`result` method to parse the raw response content (e.g. return a pre-parsed JSON response or a `csv.reader`).
Returns a :class:`rwsobjects.RWSResponse` object:

Example::

>>> from rwslib import RWSConnection
>>> from rwslib.rws_requests import ConfigurableDatasetRequest
>>> r = RWSConnection('innovate', 'username', 'password') #Authorization REQUIRED
>>> response = r.send_request(ConfigurableDatasetRequest('SomeRequest', dataset_format='csv', params=dict(start='2012-02-01')))
>>> response.text
DataPageID,DataPointID,LastUpdated
1234,4321,2012-12-01T12:33:00
4334,1234,2012-12-02T12:33:00
...


56 changes: 56 additions & 0 deletions docs/source/rwscmd.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.. _rwscmd:

rwscmd
******

rwscmd is a command-line tool providing convenient access to Rave WebServices, via rwslib.

Usage
-----

.. code-block:: shell
rwscmd [OPTIONS] URL COMMAND [ARGS]
Options:
-u, --username TEXT Rave login
-p, --password TEXT Rave password
--virtual_dir TEXT RWS virtual directory, defaults to RaveWebServices
--raw / --list Display raw xml response from RWS or human-readable list, defaults to list
-v, --verbose / -s, --silent
-o, --output FILENAME Write output to file
--help Show this message and exit.
Commands:
autofill Request enterable data for a subject,...
data List EDC data for [STUDY] [ENV] [SUBJECT]
direct Make direct call to RWS, bypassing rwslib
metadata List metadata for [PROJECT] [VERSION]
post Post ODM clinical data
version Display RWS version
Examples
--------

.. code-block:: shell
$ rwscmd innovate version
Username: anewbigging
Password:
1.15.0
$ export RWSCMD_USERNAME=anewbigging
$ export RWSCMD_PASSWORD=*********
$ rwscmd innovate version
1.15.0
$ rwscmd innovate data
ATN01(Prod)
Medidata(Prod)
Mediflex(Prod)
Mediflex(Dev)
$ rwscmd innovate data Mediflex Prod
0004-bbc-003
001 aaa
001 ADS
3 changes: 2 additions & 1 deletion docs/source/using_builders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ following example creates the same document as above::
The builder creates a number of ODM properties including CreationDateTime, FileOID (a random identifier), FileType and
all namespace declarations.

## Metadata Builders
Metadata Builders
-----------------

Builders also exist for creating Metadata ODM files::

Expand Down
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
lxml>=3.4.4
lxml
requests
httpretty
tox
six
enum34
mock
mock
click
fake-factory
2 changes: 1 addition & 1 deletion rwslib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__title__ = 'rwslib'
__author__ = 'Ian Sparks (isparks@mdsol.com)'
__version__ = '1.1.4'
__version__ = '1.1.5'
__license__ = 'MIT'
__copyright__ = 'Copyright 2016 Medidata Solutions Inc'

Expand Down
16 changes: 15 additions & 1 deletion rwslib/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ def add(self, *args):
self << child
return self

def __str__(self):
"""Return string representation"""
builder = ET.TreeBuilder()
self.build(builder)
return ET.tostring(builder.close(),encoding='utf-8').decode('utf-8')

def set_single_attribute(self, other, trigger_klass, property_name):
"""Used to set guard the setting of an attribute which is singular and can't be set twice"""

Expand Down Expand Up @@ -1365,7 +1371,8 @@ class ItemDef(ODMElement):
VALID_DATATYPES = [DataType.Text, DataType.Integer, DataType.Float, DataType.Date,
DataType.DateTime, DataType.Time]

def __init__(self, oid, name, datatype, length,
def __init__(self, oid, name, datatype,
length=None,
significant_digits=None,
sas_field_name=None,
sds_var_name=None,
Expand Down Expand Up @@ -1404,6 +1411,13 @@ def __init__(self, oid, name, datatype, length,
if not isinstance(control_type, ControlType):
raise AttributeError("{0} is not a valid Control Type".format(control_type))

if length is None:
if datatype in [DataType.DateTime, DataType.Time, DataType.Date]:
# Default this
length = len(date_time_format)
else:
raise AttributeError('length must be set for all datatypes except Date/Time types')

self.datatype = datatype
self.length = length
self.significant_digits = significant_digits
Expand Down
5 changes: 4 additions & 1 deletion rwslib/extras/audit_event/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,18 @@ The _context_ object passed contains all the data pulled from the audit record.
transaction_type
instance_name
instance_overdue
instance_id
form
oid
repeat_key
transaction_type
datapage_name
datapage_id
itemgroup
oid
repeat_key
transaction_type
transaction_type
record_id
item
oid
value
Expand Down
Loading

0 comments on commit 5aab93c

Please sign in to comment.