Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't input project's name #7

Closed
leeweizhe1993 opened this issue Feb 28, 2019 · 1 comment
Closed

Can't input project's name #7

leeweizhe1993 opened this issue Feb 28, 2019 · 1 comment
Assignees
Labels

Comments

@leeweizhe1993
Copy link

Glasses Firmware Version: 1.25.4-citronkola-0
Headunit version: 0.0.62
Python: Python 3.5.6 :: Anaconda, Inc.
IDE: Jupyter lab with Ipykernel 5.1.0

Copied from demo code:

import time
from tobiiglassesctrl.controller import TobiiGlassesController

if hasattr(__builtins__, 'raw_input'):
      input=raw_input


def main():

	tobiiglasses = TobiiGlassesController("192.168.71.50")
	print(tobiiglasses.get_battery_info())
	print(tobiiglasses.get_storage_info())

	if tobiiglasses.is_recording():
		rec_id = tobiiglasses.get_current_recording_id()
		tobiiglasses.stop_recording(rec_id)

	project_name = input("Please insert the project's name: ")
	project_id = tobiiglasses.create_project(project_name)

	participant_name = input("Please insert the participant's name: ")
	participant_id = tobiiglasses.create_participant(project_id, participant_name)

	calibration_id = tobiiglasses.create_calibration(project_id, participant_id)
	input("Put the calibration marker in front of the user, then press enter to calibrate")
	tobiiglasses.start_calibration(calibration_id)

	res = tobiiglasses.wait_until_calibration_is_done(calibration_id)

	if res is False:
		print("Calibration failed!")
		exit(1)

	recording_id = tobiiglasses.create_recording(participant_id)
	print("Important! The recording will be stored in the SD folder projects/%s/recordings/%s" % (project_id, recording_id))
	input("Press enter to start recording")
	tobiiglasses.start_recording(recording_id)
	tobiiglasses.send_custom_event("start_recording", "Start of the recording ")
	input("Press enter to stop recording")
	tobiiglasses.send_custom_event("stop_recording", "Stop of the recording " + str(recording_id))
	tobiiglasses.stop_recording(recording_id)


	if res is False:
		print("Recording failed!")
		exit(1)

if __name__ == '__main__':
    main()

Error:

[DEBUG]: Connecting to the Tobii Pro Glasses 2 ...
[DEBUG]: Tobii Pro Glasses 2 successful connected!
Battery info = [ Level: 86.00 % - Remaining Time: 5160.00 s ]
Storage info = [ Remaining Time: 5160.00 s ]
Please insert the project's name:  Li
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-19-4597c1eb8694> in <module>
     44 
     45 if __name__ == '__main__':
---> 46     main()

<ipython-input-19-4597c1eb8694> in main()
     14 
     15         project_name = input("Please insert the project's name: ")
---> 16         project_id = tobiiglasses.create_project(project_name)
     17 
     18         participant_name = input("Please insert the participant's name: ")

D:\Miniconda3\envs\python35\lib\site-packages\tobiiglassesctrl\controller.py in create_project(self, projectname)
    320                 if project_id is None:
    321 			data = {'pr_info' : {'CreationDate': self.__get_current_datetime__(),
--> 322                                                                  'EagleId':  str(uuid.uuid5(uuid.NAMESPACE_DNS, projectname.encode('utf-8'))),
    323 								 'Name': projectname},
    324 					'pr_created': self.__get_current_datetime__() }

D:\Miniconda3\envs\python35\lib\uuid.py in uuid5(namespace, name)
    606     """Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""
    607     from hashlib import sha1
--> 608     hash = sha1(namespace.bytes + bytes(name, "utf-8")).digest()
    609     return UUID(bytes=hash[:16], version=5)
    610 

TypeError: encoding without a string argument
@ddetommaso ddetommaso added the bug label Feb 28, 2019
@ddetommaso ddetommaso self-assigned this Feb 28, 2019
@ddetommaso
Copy link
Owner

Hi @leeweizhe1993,

thank you for reporting your issue.
I think this is due to different behaviors of encode methods between Python2 and 3.

Now should be fixed in latest master branch!
Best,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants