Skip to content

Commit fa2b849

Browse files
committed
Added method for sending custom variables
1 parent ddb40a8 commit fa2b849

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tobiiglassesctrl/tobiiglassesctrl.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# You should have received a copy of the GNU General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>
1717

18-
import urllib2
18+
import urllib
1919
import json
2020
import time
2121
import datetime
@@ -341,7 +341,7 @@ def wait_for_status(self, api_action, key, values):
341341
if json_data[key] in values:
342342
running = False
343343
time.sleep(1)
344-
except urllib2.URLError, e:
344+
except urllib2.URLError as e:
345345
log.error(e)
346346
return -1
347347
return json_data[key]
@@ -457,7 +457,10 @@ def wait_for_recording_status(self, recording_id, status_array = ['init', 'start
457457

458458
def start_recording(self, recording_id):
459459
self.__post_request__('/api/recordings/' + recording_id + '/start')
460-
return self.wait_for_recording_status(recording_id, ['recording']) == "recording"
460+
if self.wait_for_recording_status(recording_id, ['recording']) == "recording":
461+
self.send_recording_info()
462+
return True
463+
return False
461464

462465
def stop_recording(self, recording_id):
463466
self.__post_request__('/api/recordings/' + recording_id + '/stop')
@@ -473,6 +476,17 @@ def send_event(self, event_type, event_tag = '', wait_until_status_is_ok = False
473476
if wait_until_status_is_ok:
474477
return self.wait_until_status_is_ok()
475478

479+
def send_variable(self, variable, tag):
480+
self.send_event('#%s#' % variable, tag)
481+
482+
def send_recording_info(self):
483+
config_tags = ''
484+
config_tags += 'recording_id=%s,' % self.recording_name
485+
config_tags += 'project_name=%s,' % self.project_name
486+
config_tags += 'participant_name=%s,' % self.participant_name
487+
config_tags += 'sd_path=projects/%s/recordings/%s,' % (self.project_id, self.recording_id)
488+
self.send_variable('recording_config', config_tags)
489+
476490
def get_data(self):
477491
return self.data
478492

0 commit comments

Comments
 (0)