rendered paste body#version=1.0
############################################################
# ______ _ _ #
# | ___ \ | | | | #
# | |_/ / __ _ ___| | ____ _ _ __ ___ _ _ _ __ __| | #
# | ___ \/ _` |/ __| |/ / _` | '__/ _ \| | | | '_ \ / _` | #
# | |_/ / (_| | (__| < (_| | | | (_) | |_| | | | | (_| | #
# \____/ \__,_|\___|_|\_\__, |_| \___/ \__,_|_| |_|\__,_| #
# __/ | #
# |___/ #
# _ _ _ #
# | | | | | | #
# | | | | ___ _ __| | _____ _ __ #
# | |/\| |/ _ \| '__| |/ / _ \ '__| #
# \ /\ / (_) | | | < __/ | #
# \/ \/ \___/|_| |_|\_\___|_| #
# #
# https://sourceforge.net/projects/bworkstation #
# thesound[at]hotmail.fr #
# #
# WGET Download file from url #
# Created by THE|R0OT #
# #
############################################################
import urllib2
try:
import psyco
psyco.full()
except ImportError:
pass
class wget():
def __init__(self):
self.prefix = '[ wget ]'
self.help='Usage: wget url\nExample: wget http://website.com/file.tar'
self.desc=self.__class__.__name__+" > Download file from url"
def help(self):
return self.help
def loaded(self):
return self.desc
def main(self, value):
i=1
args=[]
for x in value:
args.insert(i, x)
i=i+1
try:
url=args[0]
file_name=url.split('/')[-1]
u=urllib2.urlopen(url)
f=open(file_name, 'wb')
meta=u.info()
file_size=int(meta.getheaders("Content-Length")[0])
megabytes = file_size / 1048576
size = '%.2fM' % megabytes
print self.prefix, "Downloading: %s : %s" % (file_name, size)
file_size_dl=0
block_sz=8192
while True:
buffer=u.read(block_sz)
if not buffer:
break
file_size_dl+=len(buffer)
f.write(buffer)
status=r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)
status=status + chr(8)*(len(status)+1)
print status,
f.close()
except IndexError:
print self.help