Permalink
Browse files

Getting the order right in the time_diff function. Could possibly do …

…better
  • Loading branch information...
1 parent 36323c2 commit f3b3adbdb45b8d708684142d804229ff4a625166 @yamatt committed Mar 26, 2012
Showing with 6 additions and 5 deletions.
  1. +6 −5 downloader.py
View
@@ -16,7 +16,7 @@
"""
from urllib2 import urlopen as download_file
-from time import time as time_now
+from time import time as now
from urlparse import urlparse
import os
from os import path
@@ -56,11 +56,12 @@ def __calculate_metrics(self, downloaded_length):
self.kbps = round(kbytes_ps,3)
def __get_time_diff(self):
- now = time_now()
- last_time = self.last_time
- self.last_time = now
+ now = now()
+ time_diff = 0
if self.last_time:
- return now - last_time
+ time_diff = now - last_time
+ self.last_time = now
+ return time_diff
class DownloadToPath(BaseDownload):
def __init__(self, url, output_path):

1 comment on commit f3b3adb

Owner

yamatt commented on f3b3adb Mar 26, 2012

If someone knows a more elegant way of writing the get_time_diff function please let me know or send a patch

Please sign in to comment.