Removed unused imports, file -> fileURI [ keyword ]
This commit is contained in:
@@ -3,14 +3,12 @@
|
|||||||
# avoiding multiple invocations of the same instance
|
# avoiding multiple invocations of the same instance
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import string
|
|
||||||
import bsddb.dbshelve as shelve
|
import bsddb.dbshelve as shelve
|
||||||
import os
|
|
||||||
|
|
||||||
d = shelve.open( sys.argv[1] )
|
d = shelve.open( sys.argv[1] )
|
||||||
|
|
||||||
#print 'list serial time, db size ', len(d)
|
#print 'list serial time, db size ', len(d)
|
||||||
for (k,data) in d.iteritems():
|
for (k, data) in d.iteritems():
|
||||||
print k, data
|
print k, data
|
||||||
|
|
||||||
d.close()
|
d.close()
|
||||||
|
|||||||
+11
-15
@@ -11,7 +11,6 @@ import os
|
|||||||
|
|
||||||
# pisi modules
|
# pisi modules
|
||||||
import util
|
import util
|
||||||
from config import config
|
|
||||||
from purl import PUrl
|
from purl import PUrl
|
||||||
from ui import ui
|
from ui import ui
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ class Fetcher:
|
|||||||
|
|
||||||
return os.path.join(self.filedest, self.url.filename())
|
return os.path.join(self.filedest, self.url.filename())
|
||||||
|
|
||||||
def doGrab(self, file, dest, totalsize):
|
def doGrab(self, fileURI, dest, totalsize):
|
||||||
symbols = [' B/s', 'KB/s', 'MB/s', 'GB/s']
|
symbols = [' B/s', 'KB/s', 'MB/s', 'GB/s']
|
||||||
from time import time
|
from time import time
|
||||||
tt, oldsize = int(time()), 0
|
tt, oldsize = int(time()), 0
|
||||||
@@ -72,12 +71,12 @@ class Fetcher:
|
|||||||
bs, size = 1024, 0
|
bs, size = 1024, 0
|
||||||
symbol, depth = "B/s", 0
|
symbol, depth = "B/s", 0
|
||||||
st = time()
|
st = time()
|
||||||
chunk = file.read(bs)
|
chunk = fileURI.read(bs)
|
||||||
size = size + len(chunk)
|
size = size + len(chunk)
|
||||||
self.percent = p.update(size)
|
self.percent = p.update(size)
|
||||||
while chunk:
|
while chunk:
|
||||||
dest.write(chunk)
|
dest.write(chunk)
|
||||||
chunk = file.read(bs)
|
chunk = fileURI.read(bs)
|
||||||
size = size + len(chunk)
|
size = size + len(chunk)
|
||||||
ct = time()
|
ct = time()
|
||||||
if int(tt) != int(ct):
|
if int(tt) != int(ct):
|
||||||
@@ -98,9 +97,7 @@ class Fetcher:
|
|||||||
|
|
||||||
dest.close()
|
dest.close()
|
||||||
|
|
||||||
|
|
||||||
def fetchLocalFile (self):
|
def fetchLocalFile (self):
|
||||||
from shutil import copyfile
|
|
||||||
url = self.url
|
url = self.url
|
||||||
|
|
||||||
if os.access(url.path(), os.F_OK) == False:
|
if os.access(url.path(), os.F_OK) == False:
|
||||||
@@ -108,16 +105,15 @@ class Fetcher:
|
|||||||
|
|
||||||
dest = open(os.path.join(self.filedest, url.filename()) , "w")
|
dest = open(os.path.join(self.filedest, url.filename()) , "w")
|
||||||
totalsize = os.path.getsize(url.path())
|
totalsize = os.path.getsize(url.path())
|
||||||
file = open(url.path())
|
fileURI = open(url.path())
|
||||||
self.doGrab(file, dest, totalsize)
|
self.doGrab(fileURI, dest, totalsize)
|
||||||
|
|
||||||
|
|
||||||
def fetchRemoteFile (self):
|
def fetchRemoteFile (self):
|
||||||
from httplib import HTTPException
|
from httplib import HTTPException
|
||||||
|
|
||||||
try:
|
try:
|
||||||
file = urllib2.urlopen(self.url.uri)
|
fileURI = urllib2.urlopen(self.url.uri)
|
||||||
headers = file.info()
|
headers = fileURI.info()
|
||||||
|
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
self.err('%s' % (e, ))
|
self.err('%s' % (e, ))
|
||||||
@@ -133,7 +129,7 @@ class Fetcher:
|
|||||||
else: totalsize = int(headers['Content-Length'])
|
else: totalsize = int(headers['Content-Length'])
|
||||||
|
|
||||||
dest = open(os.path.join(self.filedest, self.url.filename()) , "w")
|
dest = open(os.path.join(self.filedest, self.url.filename()) , "w")
|
||||||
self.doGrab(file, dest, totalsize)
|
self.doGrab(fileURI, dest, totalsize)
|
||||||
|
|
||||||
|
|
||||||
def err (self, error):
|
def err (self, error):
|
||||||
@@ -150,7 +146,7 @@ class Progress:
|
|||||||
|
|
||||||
percent = (size * 100) / self.totalsize
|
percent = (size * 100) / self.totalsize
|
||||||
if percent and self.percent is not percent:
|
if percent and self.percent is not percent:
|
||||||
self.percent = percent
|
self.percent = percent
|
||||||
return percent
|
return percent
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user