Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Final v1.2.5
  • Loading branch information
iTaybb committed Jan 8, 2017
1 parent 23e42b2 commit 8386b0f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions ChangeLog.txt
Expand Up @@ -9,6 +9,7 @@ each version.
- NEW: Added support for Python 3.6.
- IMPROVE: Updated the user agents list.
- IMPROVE: Less memory-hungry hashing function.
- IMPROVE: Minor improvements.
- FIX: Bug fixes.

(Version 1.2.4 beta; 02/12/14)
Expand Down
4 changes: 3 additions & 1 deletion pySmartDL/pySmartDL.py
Expand Up @@ -80,7 +80,9 @@ def __init__(self, urls, dest=None, progress_bar=True, fix_urls=True, threads=5,
self.mirrors = [utils.url_fix(x) for x in self.mirrors]
self.url = self.mirrors.pop(0)

fn = urllib2.unquote(os.path.basename(urlparse(self.url).path)).decode('utf-8')
fn = urllib2.unquote(os.path.basename(urlparse(self.url).path))
if sys.version_info < (3, 0):
fn = fn.decode('utf-8') # required only on python 2
self.dest = dest or os.path.join(tempfile.gettempdir(), 'pySmartDL', fn)
if self.dest[-1] == os.sep:
if os.path.exists(self.dest[:-1]) and os.path.isfile(self.dest[:-1]):
Expand Down
2 changes: 1 addition & 1 deletion pySmartDL/utils.py
Expand Up @@ -128,7 +128,7 @@ def get_filesize(url, timeout=15):
return 0
try:
file_size = int(urlObj.headers["Content-Length"])
except (IndexError,KeyError):
except (IndexError, KeyError, TypeError):
return 0

return file_size
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -19,7 +19,7 @@
description='A Smart Download Manager for Python',
long_description=open('README.md').read(),
test_suite = "test.test_pySmartDL.test_suite",
classifiers=(
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Environment :: Console',
Expand All @@ -37,6 +37,6 @@
"Operating System :: POSIX",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries :: Python Modules",
),
],
**extra
)
10 changes: 8 additions & 2 deletions test/test_pySmartDL.py
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

import os
import sys
import random
Expand Down Expand Up @@ -84,7 +86,6 @@ def test_pause_unpause_stop(self):
obj.stop()
obj.wait()
self.assertFalse(obj.isSuccessful())
# self.assertTrue(isinstance(obj.get_errors()[-1], pySmartDL.CanceledException), msg=str(obj.get_errors()[-1]))

def test_basic_auth(self):
basic_auth_test_url = "http://httpbin.org/basic-auth/user/passwd"
Expand All @@ -94,6 +95,11 @@ def test_basic_auth(self):
data = obj.get_data()
self.assertTrue(json.loads(data)['authenticated'])

def test_unicode(self):
url = u"http://he.wikipedia.org/wiki/ג'חנון"
obj = pySmartDL.SmartDL(url, progress_bar=False)
obj.start()

def test_suite():
suite = unittest.makeSuite(TestSmartDL)
return suite
Expand All @@ -102,4 +108,4 @@ def test_suite():
if sys.version_info < (2,7):
unittest.main()
else:
unittest.main(verbosity=2)
unittest.main(verbosity=2)

0 comments on commit 8386b0f

Please sign in to comment.