Skip to main content

Miscellaneous functions used in the CogWorks lab.

Project description

pycogworks is a Python package with miscellaneous functions used in the CogWorks lab.

Installation

pycogworks can be installed using ‘pip’.

# pip install pycogworks

Dependencies

pycogworks has the following dependencies:

GUI Functions

pycogworks.getSubjectInfo

Creates a GUI dialog to collect subject information. The default dialog collects subjects first name, last name and RIN. Additional fields can be collected by passing an array of field names to getSubjectInfo. getSubjectInfo returns a dict of subject information where the keys are the field names converted to lower case and spaces replaced with underscores. The RIN field is automatically encrypted using pycogworks.rin2id and stored in the ‘encrypted_rin’ field.

>>> getSubjectInfo(["Age"])
{'rin': u'123456789', 'first_name': u'Foo', 'last_name': u'Bar', 'age': u'18'}
http://ompldr.org/vZm5ldw

Logging Functions

pycogworks.getDateTimeStamp

Returns the most accurate timestamp possible for the current OS.

>>> get_time()
1348684540.905437

pycogworks.getDateTimeStamp

Generates a date/time stamp usefull in logs and for log filenames.

>>> getDateTimeStamp()
'2012-9-26_13-33-6'

pycogworks.rin2id

Generates an encrypted id from a 9 digit RIN.

>>> rin2id(123456789)
'300fe9abdca99d4a32cb2c43f2a69c5c'
>>> rin2id('123456789')
'300fe9abdca99d4a32cb2c43f2a69c5c'

pycogworks.writeHistoryFile

Takes a dict of subject information and writes a history file. The subject information dict must contain a field called ‘rin’ with a value that contains a valid 9 digit RIN. If the subject information dict does not already contain an ‘encrypted_rin’ field, the RIN will be enrypted and added to the subject information dict under the field ‘encrypted_rin’. The subject information dict is then encoded as a JSON string and written to a file.

>>> writeHistoryFile("test.history",{"foo":"bar","rin":"123456789"})
# cat test.history
{
  "cipher": "AES/CBC (RIJNDAEL) - 16Byte Key",
  "encrypted_rin": "300fe9abdca99d4a32cb2c43f2a69c5c",
  "foo": "bar",
  "rin": "123456789"
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyCogWorks-0.3.1.tar.gz (11.7 kB view details)

Uploaded Source

File details

Details for the file PyCogWorks-0.3.1.tar.gz.

File metadata

  • Download URL: PyCogWorks-0.3.1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyCogWorks-0.3.1.tar.gz
Algorithm Hash digest
SHA256 f679aae8bcd9b279f4aef02e15b14df4c8d46370c75a272619e322b857817f32
MD5 ae06d57fd5924dc535a66589bf055b53
BLAKE2b-256 6f5320e5b6104e090e2e471b7861fde3878f80c2f02e19815e95cc1fb1959ad4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page