Remove progress stuff.
This commit is contained in:
parent
6d5b200c7b
commit
3d96adc3ff
3 changed files with 6 additions and 39 deletions
11
dosage
11
dosage
|
@ -23,7 +23,7 @@ import optparse
|
||||||
|
|
||||||
from dosagelib import events, scraper
|
from dosagelib import events, scraper
|
||||||
from dosagelib.output import out
|
from dosagelib.output import out
|
||||||
from dosagelib.util import is_tty, get_columns, internal_error
|
from dosagelib.util import get_columns, internal_error
|
||||||
from dosagelib.configuration import App, Freeware, Copyright
|
from dosagelib.configuration import App, Freeware, Copyright
|
||||||
|
|
||||||
def setupOptions():
|
def setupOptions():
|
||||||
|
@ -43,7 +43,6 @@ def setupOptions():
|
||||||
parser.add_option('-m', '--modulehelp', action='store_true', dest='modhelp', help='display help for comic modules')
|
parser.add_option('-m', '--modulehelp', action='store_true', dest='modhelp', help='display help for comic modules')
|
||||||
parser.add_option('-t', '--timestamps', action='store_true', dest='timestamps', default=False, help='print timestamps for all output at any info level')
|
parser.add_option('-t', '--timestamps', action='store_true', dest='timestamps', default=False, help='print timestamps for all output at any info level')
|
||||||
parser.add_option('-o', '--output', action='store', dest='output', choices=events.getHandlers(), help='output formatting for downloaded comics')
|
parser.add_option('-o', '--output', action='store', dest='output', choices=events.getHandlers(), help='output formatting for downloaded comics')
|
||||||
parser.add_option('-p', '--progress', action='store_true', dest='progress', default=False, help='display progress bar while downloading comics')
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,12 +61,12 @@ def setOutputInfo(options):
|
||||||
out.timestamps = options.timestamps
|
out.timestamps = options.timestamps
|
||||||
|
|
||||||
|
|
||||||
def saveComicStrip(strip, basepath, progress):
|
def saveComicStrip(strip, basepath):
|
||||||
"""Save a comic strip which can consist of multiple images."""
|
"""Save a comic strip which can consist of multiple images."""
|
||||||
errors = 0
|
errors = 0
|
||||||
for image in strip.getImages():
|
for image in strip.getImages():
|
||||||
try:
|
try:
|
||||||
image.save(basepath, progress)
|
image.save(basepath)
|
||||||
except IOError, msg:
|
except IOError, msg:
|
||||||
out.write('Error saving %s: %s' % (image.filename, msg))
|
out.write('Error saving %s: %s' % (image.filename, msg))
|
||||||
errors += 1
|
errors += 1
|
||||||
|
@ -95,7 +94,7 @@ def getComics(options, comics):
|
||||||
out.write('Retrieving the current strip...')
|
out.write('Retrieving the current strip...')
|
||||||
strips = [scraperobj.getCurrentStrip()]
|
strips = [scraperobj.getCurrentStrip()]
|
||||||
for strip in strips:
|
for strip in strips:
|
||||||
errors += saveComicStrip(strip, options.basepath, options.progress)
|
errors += saveComicStrip(strip, options.basepath)
|
||||||
events.handler.end()
|
events.handler.end()
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
|
@ -173,8 +172,6 @@ def main():
|
||||||
try:
|
try:
|
||||||
parser = setupOptions()
|
parser = setupOptions()
|
||||||
options, args = parser.parse_args()
|
options, args = parser.parse_args()
|
||||||
if not is_tty(sys.stdout) and options.progress:
|
|
||||||
options.progress = False
|
|
||||||
res = run(options, args)
|
res = run(options, args)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print "Aborted."
|
print "Aborted."
|
||||||
|
|
|
@ -14,27 +14,7 @@ is just a thin wrapper that invokes L{dosage.mainline}. Comic modules
|
||||||
for each webcomic are located in L{dosage.modules}; most of these make
|
for each webcomic are located in L{dosage.modules}; most of these make
|
||||||
use of the helper base classes and mixins in L{dosage.modules.helpers},
|
use of the helper base classes and mixins in L{dosage.modules.helpers},
|
||||||
thus making their individual implementations trivial.
|
thus making their individual implementations trivial.
|
||||||
|
|
||||||
@group Core modules: comic, events, output, progress, rss, util,
|
|
||||||
version
|
|
||||||
@group Interface modules: mainline
|
|
||||||
@group Comic modules: modules
|
|
||||||
|
|
||||||
@sort: modules.helpers
|
|
||||||
|
|
||||||
@author: U{Dosage development team <dosage@lists.slipgate.za.net>}
|
|
||||||
@requires: Python 2.3+
|
|
||||||
@see: U{The dosage webpage <http://slipgate.za.net/dosage>}
|
|
||||||
@see: U{The dosage Trac site <http://trac.slipgate.za.net/dosage>}
|
|
||||||
|
|
||||||
@newfield contributor: Contributor, Contributors (Alphabetical Order)
|
|
||||||
@contributor: U{Jonathan Jacobs <mailto:korpse@slipgate.za.net>}
|
|
||||||
@contributor: U{Tristan Seligmann <mailto:mithrandi@mithrandi.za.net>}
|
|
||||||
|
|
||||||
@var __license__: The license governing the use and distribution of
|
|
||||||
dosage.
|
|
||||||
"""
|
"""
|
||||||
__docformat__ = 'epytext en'
|
|
||||||
import sys
|
import sys
|
||||||
if not (hasattr(sys, 'version_info') or
|
if not (hasattr(sys, 'version_info') or
|
||||||
sys.version_info < (2, 5, 0, 'final', 0)):
|
sys.version_info < (2, 5, 0, 'final', 0)):
|
||||||
|
|
|
@ -8,7 +8,6 @@ import time
|
||||||
|
|
||||||
from .output import out
|
from .output import out
|
||||||
from .util import urlopen, saneDataSize, normaliseURL
|
from .util import urlopen, saneDataSize, normaliseURL
|
||||||
from .progress import progressBar, OperationComplete
|
|
||||||
from .events import handler
|
from .events import handler
|
||||||
|
|
||||||
class FetchComicError(IOError):
|
class FetchComicError(IOError):
|
||||||
|
@ -77,7 +76,7 @@ class ComicImage(object):
|
||||||
mtime = time.mktime(tt)
|
mtime = time.mktime(tt)
|
||||||
os.utime(filename, (mtime, mtime))
|
os.utime(filename, (mtime, mtime))
|
||||||
|
|
||||||
def save(self, basepath, showProgress=False):
|
def save(self, basepath):
|
||||||
"""Save comic URL to filename on disk."""
|
"""Save comic URL to filename on disk."""
|
||||||
self.connect()
|
self.connect()
|
||||||
filename = "%s%s" % (self.filename, self.ext)
|
filename = "%s%s" % (self.filename, self.ext)
|
||||||
|
@ -97,16 +96,7 @@ class ComicImage(object):
|
||||||
out.write('Writing comic to file %s...' % (fn,), 3)
|
out.write('Writing comic to file %s...' % (fn,), 3)
|
||||||
with open(fn, 'wb') as comicOut:
|
with open(fn, 'wb') as comicOut:
|
||||||
startTime = time.time()
|
startTime = time.time()
|
||||||
if showProgress:
|
comicOut.write(self.urlobj.read())
|
||||||
def pollData():
|
|
||||||
data = self.urlobj.read(8192)
|
|
||||||
if not data:
|
|
||||||
raise OperationComplete
|
|
||||||
comicOut.write(data)
|
|
||||||
return len(data), self.contentLength
|
|
||||||
progressBar(pollData)
|
|
||||||
else:
|
|
||||||
comicOut.write(self.urlobj.read())
|
|
||||||
endTime = time.time()
|
endTime = time.time()
|
||||||
self.touch(fn)
|
self.touch(fn)
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Reference in a new issue