Skip to content

Commit

Permalink
update pysettings
Browse files Browse the repository at this point in the history
  • Loading branch information
UmSenhorQualquer committed Feb 21, 2018
1 parent 1ea1ae8 commit df0b285
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Enhances trial building
Adds new example for testing states that occur several times

## v1.0.0
Use pyforms to manage this library settings
Use pysettings to manage this library settings
Simplifies bpod protocol by processing trial events when running state machine
Allows timeout to be defined for serial connections
Changes some logger calls
Expand Down
28 changes: 16 additions & 12 deletions pybpodapi/session.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# !/usr/bin/python3
# -*- coding: utf-8 -*-

import logging, csv, uuid
import logging, uuid
from pyforms import conf
from datetime import datetime

Expand All @@ -13,6 +13,9 @@
from pybpodapi.com.messaging.softcode_occurrence import SoftcodeOccurrence
from pybpodapi.com.messaging.session_info import SessionInfo

from sca.formats import csv


logger = logging.getLogger(__name__)

class Session(object):
Expand Down Expand Up @@ -41,26 +44,27 @@ def __init__(self, path=None):

self.log_function = conf.PYBPOD_API_PUBLISH_DATA_FUNC

self.csvwriter = None
self._path = path

if path:
with open(path, 'w') as csvfile:
csvwriter = csv.writer(path)
json.dump(data2save, jsonfile)
self.csv = CSVWriter(
path,
self.csvfile = open(path, 'w')
self.csvwriter = csv.writer(
self.csvfile,
columns_headers=['TYPE', 'PC-TIME', 'BPOD-INITIAL-TIME', 'BPOD-FINAL-TIME', 'MSG', '+INFO'],
software='PyBpod API v'+str(pybpodapi.__version__),
def_url='http://pybpod-api.readthedocs.org',
def_text='This file contains data recorded during a session from the PyBpod system'
)
self.csvwriter.open()
else:
self.csvwriter = None


def __del__(self):
if self.csvwriter:
if self.csvwriter:
self.csvwriter.writerow( SessionInfo( self.INFO_SESSION_ENDED, datetime.now() ).tolist() )
self.csvwriter.close()
self.csvfile.close()







Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ numpy
python-dateutil

# swp dependencies
git+https://github.com/UmSenhorQualquer/pyforms.git
git+https://github.com/UmSenhorQualquer/pysettings.git
git+https://UmSenhorQualquer@bitbucket.org/fchampalimaud/logging-bootstrap.git
git+https://UmSenhorQualquer@bitbucket.org/fchampalimaud/pybpod-rotary-encoder-module.git
2 changes: 1 addition & 1 deletion requirements-rtd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ recommonmark
python-dateutil

# swp dependencies
git+https://github.com/UmSenhorQualquer/pyforms.git
git+https://github.com/UmSenhorQualquer/pysettings.git
git+https://UmSenhorQualquer@bitbucket.org/fchampalimaud/logging-bootstrap.git
git+https://UmSenhorQualquer@bitbucket.org/fchampalimaud/pybpod-rotary-encoder-module.git

0 comments on commit df0b285

Please sign in to comment.