@@ -36,29 +36,27 @@ def __init__(self, app_client_id, app_client_secret, **kwargs):
36
36
def start (self ):
37
37
"""
38
38
To open websocket and process authorizing step.
39
- After get authorize_done The program will query_records
39
+ After get authorize_done The program will query records
40
40
Returns
41
41
-------
42
42
None
43
43
"""
44
44
self .c .open ()
45
45
46
- def query_records (self ):
46
+ def query_records (self , license_id , application_id ):
47
47
"""
48
48
To query records
49
49
Parameters
50
50
----------
51
51
orderBy : array of object, required : Specify how to sort the records.
52
52
query: object, required: An object to filter the records.
53
53
If you set an empty object, it will return all records created by your application
54
- If you want get records created by other applications , you need set licenseId as parameter of query object
54
+ If you want get records created by other application , you need set licenseId and applicationId as parameter of query object
55
55
More detail at https://emotiv.gitbook.io/cortex-api/records/queryrecords
56
56
Returns
57
57
-------
58
58
"""
59
59
60
- license_id = '' #Set this parameter to filter the records by their license.
61
- application_id = "" , # filter by applicationId but must set licenseId as well. for example: com.emotiv.emotivpro
62
60
query_obj = {}
63
61
if license_id != '' :
64
62
query_obj ["licenseId" ] = license_id
@@ -85,14 +83,15 @@ def request_download_records(self, record_ids):
85
83
"""
86
84
self .c .request_download_records (record_ids )
87
85
88
- def export_record (self , record_ids ):
86
+ def export_record (self , record_ids , license_ids ):
89
87
"""
90
88
To export records
91
89
By default, you can only export the records that were created by your application.
92
90
If you want to export a record that was created by another applications
93
- then you must provide the license id of those applications in the parameter licenseIds.
91
+ then you must provide the license ids of those applications in the parameter licenseIds.
94
92
Parameters
95
93
record_ids: list, required: list of wanted export record ids
94
+ license_ids: list, no required: list of license id of other applications
96
95
----------
97
96
More detail at https://emotiv.gitbook.io/cortex-api/records/exportrecord
98
97
Returns
@@ -101,21 +100,16 @@ def export_record(self, record_ids):
101
100
"""
102
101
folder = '' # your place to export, you should have write permission, for example: 'C:\\Users\\NTT\\Desktop'
103
102
stream_types = ['EEG' , 'MOTION' , 'PM' , 'BP' ]
104
- export_format = 'CSV'
103
+ export_format = 'CSV' # support 'CSV' or 'EDF'
105
104
version = 'V2'
106
-
107
- # license_ids: If set empty list, which means that you can only export the records created by your application.
108
- # You can provide the license ID of other applications in order to export the records created by these applications.
109
- license_ids = []
110
-
111
105
self .c .export_record (folder , stream_types , export_format , record_ids , version , licenseIds = license_ids )
112
106
113
107
114
108
# callbacks functions
115
109
def on_authorize_done (self , * args , ** kwargs ):
116
110
print ('on_authorize_done' )
117
111
# query records
118
- self .query_records ()
112
+ self .query_records (self . license_id , self . application_id )
119
113
120
114
# callbacks functions
121
115
def on_query_records_done (self , * args , ** kwargs ):
@@ -125,21 +119,27 @@ def on_query_records_done(self, *args, **kwargs):
125
119
# print(data)
126
120
not_downloaded_record_Ids = []
127
121
export_record_Ids = []
122
+ license_ids = []
128
123
for item in data :
129
124
uuid = item ['uuid' ]
130
125
sync_status = item ["syncStatus" ]["status" ]
131
126
application_id = item ["applicationId" ]
127
+ license_id = item ["licenseId" ]
132
128
print ("recordId {0}, applicationId {1}, sync status {2}" .format (uuid , application_id , sync_status ))
133
129
if (sync_status == "notDownloaded" ) :
134
130
not_downloaded_record_Ids .append (uuid )
135
131
elif (sync_status == "neverUploaded" ) or (sync_status == "downloaded" ):
136
132
export_record_Ids .append (uuid )
133
+ if license_id not in license_ids :
134
+ license_ids .append (license_id )
137
135
138
136
# download records has not downloaded to local machine
139
137
if len (not_downloaded_record_Ids ) > 0 :
140
138
self .request_download_records (not_downloaded_record_Ids )
141
- elif len (export_record_Ids ) > 0 : # or export records are in local machine
142
- self .export_record (export_record_Ids )
139
+
140
+ # Open comment below to export records
141
+ # if len(export_record_Ids) > 0: # or export records are in local machine
142
+ # self.export_record(export_record_Ids, license_ids)
143
143
144
144
def on_export_record_done (self , * args , ** kwargs ):
145
145
print ('on_export_record_done: the successful record exporting as below:' )
@@ -186,6 +186,14 @@ def main():
186
186
187
187
# Don't need to create session in this case
188
188
r = Records (your_app_client_id , your_app_client_secret , auto_create_session = False )
189
+
190
+ # As default, the Program will query records of your application.
191
+ # In the case, you want to query records created from other application (such as EmotivPRO).
192
+ # You need set license_id and application_id of the application
193
+ # If set license_id without application_id. It will return records created from all applications use the license_id
194
+ # If set both license_id and application_id. It will return records from the application has the application_id
195
+ r .license_id = ''
196
+ r .application_id = ''
189
197
190
198
r .start ()
191
199
0 commit comments