archive tam olarak indirilmediği sürece ad dosya_adi.part olsun..
pisitools içerisindeki gereksiz fonksiyonu cikart..
This commit is contained in:
@@ -168,10 +168,6 @@ def rename(sourceFile, destinationFile):
|
|||||||
except OSError:
|
except OSError:
|
||||||
ctx.ui.error(_('\n!!! ActionsAPI [rename]: No such file or directory: %s') % (sourceFile))
|
ctx.ui.error(_('\n!!! ActionsAPI [rename]: No such file or directory: %s') % (sourceFile))
|
||||||
|
|
||||||
def dopython():
|
|
||||||
'''FIXME: What the hell is this?'''
|
|
||||||
pass
|
|
||||||
|
|
||||||
def dosed(sourceFile, findPattern, replacePattern = ''):
|
def dosed(sourceFile, findPattern, replacePattern = ''):
|
||||||
'''replaces patterns in sourceFile'''
|
'''replaces patterns in sourceFile'''
|
||||||
|
|
||||||
|
|||||||
+13
-9
@@ -19,6 +19,7 @@
|
|||||||
import urllib2
|
import urllib2
|
||||||
import os
|
import os
|
||||||
from base64 import encodestring
|
from base64 import encodestring
|
||||||
|
from shutil import move
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
__trans = gettext.translation('pisi', fallback=True)
|
__trans = gettext.translation('pisi', fallback=True)
|
||||||
@@ -68,12 +69,15 @@ class Fetcher:
|
|||||||
if not os.access(self.filedest, os.W_OK):
|
if not os.access(self.filedest, os.W_OK):
|
||||||
self.err(_("Access denied to write to dest dir"))
|
self.err(_("Access denied to write to dest dir"))
|
||||||
|
|
||||||
if self.url.is_local_file():
|
archiveFile = os.path.join(self.filedest, self.url.filename())
|
||||||
self.fetchLocalFile()
|
|
||||||
else:
|
|
||||||
self.fetchRemoteFile()
|
|
||||||
|
|
||||||
return os.path.join(self.filedest, self.url.filename())
|
if self.url.is_local_file():
|
||||||
|
self.fetchLocalFile(archiveFile + ".part")
|
||||||
|
else:
|
||||||
|
self.fetchRemoteFile(archiveFile + ".part")
|
||||||
|
|
||||||
|
move(archiveFile + ".part", archiveFile)
|
||||||
|
return archiveFile
|
||||||
|
|
||||||
def _do_grab(self, fileURI, dest, totalsize):
|
def _do_grab(self, fileURI, dest, totalsize):
|
||||||
symbols = [' B/s', 'KB/s', 'MB/s', 'GB/s']
|
symbols = [' B/s', 'KB/s', 'MB/s', 'GB/s']
|
||||||
@@ -110,18 +114,18 @@ class Fetcher:
|
|||||||
|
|
||||||
dest.close()
|
dest.close()
|
||||||
|
|
||||||
def fetchLocalFile (self):
|
def fetchLocalFile (self, archiveFile):
|
||||||
url = self.url
|
url = self.url
|
||||||
|
|
||||||
if not os.access(url.path(), os.F_OK):
|
if not os.access(url.path(), os.F_OK):
|
||||||
self.err(_("No such file or no permission to read"))
|
self.err(_("No such file or no permission to read"))
|
||||||
|
|
||||||
dest = open(os.path.join(self.filedest, url.filename()) , "w")
|
dest = open(archiveFile, "w")
|
||||||
totalsize = os.path.getsize(url.path())
|
totalsize = os.path.getsize(url.path())
|
||||||
fileObj = open(url.path())
|
fileObj = open(url.path())
|
||||||
self._do_grab(fileObj, dest, totalsize)
|
self._do_grab(fileObj, dest, totalsize)
|
||||||
|
|
||||||
def fetchRemoteFile (self):
|
def fetchRemoteFile (self, archiveFile):
|
||||||
from httplib import HTTPException
|
from httplib import HTTPException
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -143,7 +147,7 @@ class Fetcher:
|
|||||||
except:
|
except:
|
||||||
totalsize = 0
|
totalsize = 0
|
||||||
|
|
||||||
dest = open(os.path.join(self.filedest, self.url.filename()) , "w")
|
dest = open(archiveFile, "w")
|
||||||
self._do_grab(fileObj, dest, totalsize)
|
self._do_grab(fileObj, dest, totalsize)
|
||||||
|
|
||||||
def formatRequest(self, request):
|
def formatRequest(self, request):
|
||||||
|
|||||||
Reference in New Issue
Block a user