From c126f738bd5be581d5321521eedc9b14a8165a0e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 May 2015 18:11:25 +0200 Subject: Use 'import' instead 'from' (2) --- pyload/network/Bucket.py | 6 ++++-- pyload/network/HTTPDownload.py | 17 +++++++++-------- pyload/network/RequestFactory.py | 6 +++--- 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'pyload/network') diff --git a/pyload/network/Bucket.py b/pyload/network/Bucket.py index 2f957fcad..b7f33f993 100644 --- a/pyload/network/Bucket.py +++ b/pyload/network/Bucket.py @@ -1,8 +1,10 @@ # -*- coding: utf-8 -*- # @author: RaNaN +import threading + from time import time -from threading import Lock + MIN_RATE = 10240 #: 10kb minimum rate @@ -13,7 +15,7 @@ class Bucket(object): self.rate = 0 #: bytes per second, maximum targeted throughput self.tokens = 0 self.timestamp = time() - self.lock = Lock() + self.lock = threading.Lock() def __nonzero__(self): diff --git a/pyload/network/HTTPDownload.py b/pyload/network/HTTPDownload.py index 1e74d4476..2276af609 100644 --- a/pyload/network/HTTPDownload.py +++ b/pyload/network/HTTPDownload.py @@ -3,12 +3,13 @@ from __future__ import with_statement +import shutil + import pycurl from os import remove, fsync from os.path import dirname from time import sleep, time -from shutil import move from logging import getLogger from pyload.network.HTTPChunk import ChunkInfo, HTTPChunk @@ -94,16 +95,16 @@ class HTTPDownload(object): break fo.write(data) if fo.tell() < self.info.getChunkRange(i)[1]: - remove(init) - self.info.remove() #: there are probably invalid chunks + reshutil.move(init) + self.info.reshutil.move() #: there are probably invalid chunks raise Exception("Downloaded content was smaller than expected. Try to reduce download connections.") - remove(fname) #: remove chunk + reshutil.move(fname) #: remove chunk if self.nameDisposition and self.disposition: self.filename = fs_join(dirname(self.filename), self.nameDisposition) - move(init, fs_encode(self.filename)) - self.info.remove() #: remove info file + shutil.move(init, fs_encode(self.filename)) + self.info.reshutil.move() #: remove info file def download(self, chunks=1, resume=False): @@ -238,8 +239,8 @@ class HTTPDownload(object): to_clean = filter(lambda x: x is not init, self.chunks) for chunk in to_clean: self.closeChunk(chunk) - self.chunks.remove(chunk) - remove(fs_encode(self.info.getChunkName(chunk.id))) + self.chunks.reshutil.move(chunk) + reshutil.move(fs_encode(self.info.getChunkName(chunk.id))) # let first chunk load the rest and update the info file init.resetRange() diff --git a/pyload/network/RequestFactory.py b/pyload/network/RequestFactory.py index 5e2c15f4b..d10c35cf0 100644 --- a/pyload/network/RequestFactory.py +++ b/pyload/network/RequestFactory.py @@ -1,19 +1,19 @@ # -*- coding: utf-8 -*- # @author: RaNaN, mkaay -from threading import Lock +import threading from pyload.network.Browser import Browser from pyload.network.Bucket import Bucket -from pyload.network.HTTPRequest import HTTPRequest from pyload.network.CookieJar import CookieJar +from pyload.network.HTTPRequest import HTTPRequest from pyload.network.XDCCRequest import XDCCRequest class RequestFactory(object): def __init__(self, core): - self.lock = Lock() + self.lock = threading.Lock() self.core = core self.bucket = Bucket() self.updateBucket() -- cgit v1.2.3