Skip to content

Commit

Permalink
the above all errors are modified such that code is working for pytho…
Browse files Browse the repository at this point in the history
…n3 as well as python2 #1
  • Loading branch information
Srishti-j18 committed Jun 19, 2023
1 parent 6d56027 commit 96b8903
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
11 changes: 10 additions & 1 deletion dist/client/adaptation/basic_dash.py
@@ -1,7 +1,16 @@
__author__ = 'pjuluri'


import config_dash
from adaptation.adaptation import calculate_rate_index
import sys

try:
# Try importing with Python 3 style import
from adaptation.adaptation import calculate_rate_index
except ImportError:
# Fallback to Python 2 style import
from adaptation import calculate_rate_index



def basic_dash(segment_number, bitrates, average_dwn_time,
Expand Down
12 changes: 10 additions & 2 deletions dist/client/dash_buffer.py
@@ -1,5 +1,13 @@
from __future__ import division
import queue
import sys

if sys.version_info[0] < 3:
# Python 2
import Queue as queue
else:
# Python 3
import queue

import threading
import time
import csv
Expand Down Expand Up @@ -43,7 +51,7 @@ def __init__(self, video_length, segment_duration):
self.beta = config_dash.BETA_BUFFER_COUNT
self.segment_limit = None
# Current video buffer that holds the segment data
self.buffer = Queue.Queue()
self.buffer = queue.Queue()
self.buffer_lock = threading.Lock()
self.current_segment = None
self.buffer_log_file = config_dash.BUFFER_LOG_FILENAME
Expand Down
21 changes: 15 additions & 6 deletions dist/client/dash_client.py
Expand Up @@ -14,9 +14,18 @@
"""
from __future__ import division
import read_mpd
from urllib.parse import urlparse
import urllib.request
import urllib.error
import future
import builtins
import past
import six


from future.standard_library import install_aliases
install_aliases()

from urllib.parse import urlparse, urlencode
from urllib.request import urlopen, Request
from urllib.error import HTTPError
import random
import os
import sys
Expand Down Expand Up @@ -70,8 +79,8 @@ def get_mpd(url):
""" Module to download the MPD from the URL and save it to file"""
print(url)
try:
connection = urllib.request.urlopen(url, timeout=10)
except urllib.error.HTTPError as error:
connection = urlopen(url, timeout=10)
except HTTPError as error:
config_dash.LOG.error("Unable to download MPD file HTTP Error: %s" % error.code)
return None
except urllib.error.URLError:
Expand Down Expand Up @@ -104,7 +113,7 @@ def get_domain_name(url):
""" Module to obtain the domain name from the URL
From : http://stackoverflow.com/questions/9626535/get-domain-name-from-url
"""
parsed_uri = urlparse.urlparse(url)
parsed_uri = urlparse(url)
domain = '{uri.scheme}://{uri.netloc}/'.format(uri=parsed_uri)
return domain

Expand Down

0 comments on commit 96b8903

Please sign in to comment.