forked from seba/servefile
too much whitespace
This commit is contained in:
parent
e7215bd9cb
commit
096be09372
20
servefile
20
servefile
|
@ -71,7 +71,7 @@ class FileHandler(FileBaseHandler):
|
||||||
if self.checkAndDoRedirect():
|
if self.checkAndDoRedirect():
|
||||||
return
|
return
|
||||||
myfile = open(self.filePath, 'rb')
|
myfile = open(self.filePath, 'rb')
|
||||||
|
|
||||||
# find out if this is a continuing download
|
# find out if this is a continuing download
|
||||||
fromto = None
|
fromto = None
|
||||||
if "Range" in self.headers:
|
if "Range" in self.headers:
|
||||||
|
@ -91,7 +91,7 @@ class FileHandler(FileBaseHandler):
|
||||||
return
|
return
|
||||||
# now we can wind the file *brrrrrr*
|
# now we can wind the file *brrrrrr*
|
||||||
myfile.seek(fromto[0])
|
myfile.seek(fromto[0])
|
||||||
|
|
||||||
if fromto != None:
|
if fromto != None:
|
||||||
self.send_response(216)
|
self.send_response(216)
|
||||||
self.send_header('Content-Range', 'bytes %s-%s/%s' % (fromto[0], fromto[1], self.fileLength))
|
self.send_header('Content-Range', 'bytes %s-%s/%s' % (fromto[0], fromto[1], self.fileLength))
|
||||||
|
@ -114,7 +114,7 @@ class FileHandler(FileBaseHandler):
|
||||||
myfile.close()
|
myfile.close()
|
||||||
print "%s finished downloading" % (self.client_address[0])
|
print "%s finished downloading" % (self.client_address[0])
|
||||||
return
|
return
|
||||||
|
|
||||||
def getChunk(self, myfile, fromto):
|
def getChunk(self, myfile, fromto):
|
||||||
if fromto and myfile.tell()+self.blockSize >= fromto[1]:
|
if fromto and myfile.tell()+self.blockSize >= fromto[1]:
|
||||||
readsize = fromto[1]-myfile.tell()+1
|
readsize = fromto[1]-myfile.tell()+1
|
||||||
|
@ -249,7 +249,7 @@ class FilePutter(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||||
self.sendResponse(400, "Filename was empty or invalid")
|
self.sendResponse(400, "Filename was empty or invalid")
|
||||||
return
|
return
|
||||||
|
|
||||||
# write file down to disk, send an
|
# write file down to disk, send an
|
||||||
target = open(destFileName, "w")
|
target = open(destFileName, "w")
|
||||||
target.write(fstorage["file"].file.read(length))
|
target.write(fstorage["file"].file.read(length))
|
||||||
target.close()
|
target.close()
|
||||||
|
@ -316,7 +316,7 @@ class FilePutter(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||||
""" Generate a clean and secure filename.
|
""" Generate a clean and secure filename.
|
||||||
|
|
||||||
This function takes a filename and strips all the slashes out of it.
|
This function takes a filename and strips all the slashes out of it.
|
||||||
If the file already exists in the target directory, a (NUM) will be
|
If the file already exists in the target directory, a (NUM) will be
|
||||||
appended, so no file will be overwritten.
|
appended, so no file will be overwritten.
|
||||||
"""
|
"""
|
||||||
cleanFileName = fname.replace("/", "")
|
cleanFileName = fname.replace("/", "")
|
||||||
|
@ -489,13 +489,13 @@ class ServeFile():
|
||||||
print "done."
|
print "done."
|
||||||
print "SHA1 fingerprint:", cert.digest("sha1")
|
print "SHA1 fingerprint:", cert.digest("sha1")
|
||||||
print "MD5 fingerprint:", cert.digest("md5")
|
print "MD5 fingerprint:", cert.digest("md5")
|
||||||
|
|
||||||
def _getCert(self):
|
def _getCert(self):
|
||||||
return self.cert
|
return self.cert
|
||||||
|
|
||||||
def _getKey(self):
|
def _getKey(self):
|
||||||
return self.key
|
return self.key
|
||||||
|
|
||||||
def setAuth(self, user, password):
|
def setAuth(self, user, password):
|
||||||
if len(user) == "" or len(password) == "":
|
if len(user) == "" or len(password) == "":
|
||||||
raise ServeFileException("User and password both need to be at least one character long")
|
raise ServeFileException("User and password both need to be at least one character long")
|
||||||
|
@ -580,7 +580,7 @@ class ServeFile():
|
||||||
except OSError:
|
except OSError:
|
||||||
raise ServeFileException("Error: Could not change directory to '%s'" % self.target)
|
raise ServeFileException("Error: Could not change directory to '%s'" % self.target)
|
||||||
handler = SimpleHTTPServer.SimpleHTTPRequestHandler
|
handler = SimpleHTTPServer.SimpleHTTPRequestHandler
|
||||||
|
|
||||||
|
|
||||||
if self.auth:
|
if self.auth:
|
||||||
# do authentication
|
# do authentication
|
||||||
|
@ -654,7 +654,7 @@ def main():
|
||||||
parser.add_argument('-c', '--compression', type=str, metavar='method', \
|
parser.add_argument('-c', '--compression', type=str, metavar='method', \
|
||||||
default="none", \
|
default="none", \
|
||||||
help="Set compression method, only in combination with --tar. Can be one of %s." % ", ".join(TarFileHandler.compressionMethods))
|
help="Set compression method, only in combination with --tar. Can be one of %s." % ", ".join(TarFileHandler.compressionMethods))
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
maxUploadSize = 0
|
maxUploadSize = 0
|
||||||
|
|
||||||
|
@ -742,7 +742,7 @@ def main():
|
||||||
print e
|
print e
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
print "Good bye.."
|
print "Good bye.."
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue