-
Notifications
You must be signed in to change notification settings - Fork 1
/
opensesame-questionnaire-processor
executable file
·73 lines (59 loc) · 2.84 KB
/
opensesame-questionnaire-processor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This file is part of OpenSesame Toolbox
OpenSesame Toolbox is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenSesame Experiment Manager is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Refer to <http://www.gnu.org/licenses/> for a copy of the GNU General Public License.
@author Bob Rosbag
"""
import sys
import os
from PyQt5 import QtWidgets
from configobj import ConfigObj
from libopensesametoolbox.questionnaireprocessor import QuestionnaireProcessor
from libopensesametoolbox.questionnaireprocessor_ui import QuestionnaireProcessorUI
from libopensesametoolbox.io_tools import getResourceLoc
config = ConfigObj(getResourceLoc('opensesame-toolbox.conf'))
def main():
if len(sys.argv) == 1:
app = QtWidgets.QApplication(sys.argv)
win = QuestionnaireProcessorUI()
win.show()
sys.exit(app.exec_())
elif len(sys.argv) == 2:
errorMessage = "Not enough arguments, without a GUI at the input directory and output directory have to be given."
print(errorMessage, file=sys.stderr)
elif len(sys.argv) == 3:
if not os.path.isdir(sys.argv[1]):
errorMessage = "Error: The specified input folder is not a valid directory"
print(errorMessage, file=sys.stderr)
elif not os.path.isdir(sys.argv[2]):
errorMessage = "Error: The specified output folder is not a valid directory"
print(errorMessage, file=sys.stderr)
else:
conf_default_input = config['default_input']
idKey = conf_default_input['idKey']
responseKey = conf_default_input['responseKey']
categoryKey = conf_default_input['categoryKey']
answerKey = conf_default_input['answerKey']
scoreKey = conf_default_input['scoreKey']
idList = None
categoryList = None
answerString = None
scoreList = None
custom = False
QuestionnaireProcessor(sys.argv[1], sys.argv[2], responseKey, idKey, categoryKey, answerKey, scoreKey,
idList, categoryList, answerString, scoreList, custom, ui=None)
else:
errorMessage = ("Too many arguments given. No parameters given starts the GUI and two parameters given, "
"a source directory name and a destination directory name starts the automated processing.")
print(errorMessage, file=sys.stderr)
if __name__ == "__main__":
main()