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

Port to Python 3 #1

Closed
ffund opened this issue Jun 1, 2023 · 16 comments
Closed

Port to Python 3 #1

ffund opened this issue Jun 1, 2023 · 16 comments

Comments

@ffund
Copy link
Collaborator

ffund commented Jun 1, 2023

This implementation runs on Python 2, which is way past end of life, so we should get it running on Python 3.

@ffund
Copy link
Collaborator Author

ffund commented Jun 1, 2023

Our general approach will be:

  1. Run code in Python 2 and make sure it works
  2. Run code in Python 3 and see what the next error message is. Copy+paste the error message and post it as a comment here on this issue.
  3. Edit code (locally) to resolve the error message. Run code in Python 2 and make sure it still works (we prefer to be backwards compatible too).
  4. Commit changes, reference issue Port to Python 3 #1
  5. Push changes to the python3 branch.

Repeat until there are no errors when running in Python 3!

Make sure to test with all of the available adaptation policies.

@Srishti-j18
Copy link
Owner

File "/home/ubuntu/AStream/dist/client/dash_client.py", line 73
except urllib2.HTTPError, error:
^
SyntaxError: invalid syntax

@Srishti-j18
Copy link
Owner

File "/home/ubuntu/AStream/dist/client/dash_client.py", line 17, in
import urlparse
ModuleNotFoundError: No module named 'urlparse'

Srishti-j18 added a commit that referenced this issue Jun 10, 2023
@Srishti-j18
Copy link
Owner

File "/home/ubuntu/AStream/dist/client/dash_client.py", line 30, in
from adaptation import basic_dash, basic_dash2, weighted_dash, netflix_dash
File "/home/ubuntu/AStream/dist/client/adaptation/basic_dash.py", line 4, in
from adaptation import calculate_rate_index
ImportError: cannot import name 'calculate_rate_index' from 'adaptation' (/home/ubuntu/AStream/dist/client/adaptation/init.py)

@Srishti-j18
Copy link
Owner

File "/home/ubuntu/AStream/dist/client/dash_client.py", line 539, in
sys.exit(main())
File "/home/ubuntu/AStream/dist/client/dash_client.py", line 510, in main
domain = get_domain_name(MPD)
File "/home/ubuntu/AStream/dist/client/dash_client.py", line 107, in get_domain_name
parsed_uri = urlparse.urlparse(url)
AttributeError: 'function' object has no attribute 'urlparse'

Srishti-j18 added a commit that referenced this issue Jun 19, 2023
@Srishti-j18
Copy link
Owner

Srishti-j18 commented Jun 19, 2023

From here, we are going to switch to the new branch python3compat from commit 1da674c because, till this commit, the code has been working fine for python2 ..Our goal is to port the implementation to Python3 such that it can work for Python 2 as well as in every time of our general approach ..We are making this because, after each change, we can test it and make sure we have not introduced some problem that changes the way it works.

@Srishti-j18
Copy link
Owner

And from now we will push all the changes to the python3compat branch.

@Srishti-j18
Copy link
Owner

File "/home/ubuntu/AStream/dist/client/dash_client.py", line 17, in
import urlparse
ModuleNotFoundError: No module named 'urlparse'

@Srishti-j18
Copy link
Owner

File "/home/ubuntu/AStream/dist/client/dash_client.py", line 40, in
import httplib
ModuleNotFoundError: No module named 'httplib'

Srishti-j18 added a commit that referenced this issue Jul 18, 2023
@Srishti-j18
Copy link
Owner

File "/home/ubuntu/AStream/dist/client/dash_client.py", line 53, in
from adaptation import basic_dash, basic_dash2, weighted_dash, netflix_dash
File "/home/ubuntu/AStream/dist/client/adaptation/basic_dash.py", line 4, in
from adaptation import calculate_rate_index
ImportError: cannot import name 'calculate_rate_index' from 'adaptation' (/home/ubuntu/AStream/dist/client/adaptation/init.py)

@Srishti-j18
Copy link
Owner

File "/home/ubuntu/AStream/dist/client/dash_client.py", line 56, in
import dash_buffer
File "/home/ubuntu/AStream/dist/client/dash_buffer.py", line 2, in
import Queue
ModuleNotFoundError: No module named 'Queue'

Srishti-j18 added a commit that referenced this issue Jul 18, 2023
@Srishti-j18
Copy link
Owner

File "/home/ubuntu/AStream/dist/client/dash_client.py", line 61, in
WindowsError
NameError: name 'WindowsError' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ubuntu/AStream/dist/client/dash_client.py", line 63, in
from shutil import WindowsError
ImportError: cannot import name 'WindowsError' from 'shutil' (/usr/lib/python3.8/shutil.py)

@Srishti-j18
Copy link
Owner

File "/home/ubuntu/AStream/dist/client/dash_client.py", line 569, in
sys.exit(main())
File "/home/ubuntu/AStream/dist/client/dash_client.py", line 539, in main
mpd_file = get_mpd(MPD)
File "/home/ubuntu/AStream/dist/client/dash_client.py", line 121, in get_mpd
mpd_file_handle.write(mpd_data)
TypeError: write() argument must be str, not bytes

Srishti-j18 added a commit that referenced this issue Jul 18, 2023
@Srishti-j18
Copy link
Owner

File "/home/ubuntu/AStream/dist/client/dash_client.py", line 578, in
sys.exit(main())
File "/home/ubuntu/AStream/dist/client/dash_client.py", line 566, in main
start_playback_smart(dp_object, domain, "BASIC", DOWNLOAD, video_segment_duration)
File "/home/ubuntu/AStream/dist/client/dash_client.py", line 239, in start_playback_smart
dash_player.start()
File "/home/ubuntu/AStream/dist/client/dash_buffer.py", line 228, in start
self.log_entry("Starting")
File "/home/ubuntu/AStream/dist/client/dash_buffer.py", line 261, in log_entry
result_writer.writerow(header_row)
TypeError: a bytes-like object is required, not 'str'

@Srishti-j18
Copy link
Owner

File "/home/ubuntu/AStream/dist/client/dash_client.py", line 578, in
sys.exit(main())
File "/home/ubuntu/AStream/dist/client/dash_client.py", line 566, in main
start_playback_smart(dp_object, domain, "BASIC", DOWNLOAD, video_segment_duration)
File "/home/ubuntu/AStream/dist/client/dash_client.py", line 262, in start_playback_smart
bitrates.sort()
AttributeError: 'dict_keys' object has no attribute 'sort'

@Srishti-j18
Copy link
Owner

The issue with porting the code to Python 3 #1 has been resolved, and the code is now running successfully in both Python 2 and Python 3 versions.

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

No branches or pull requests

2 participants