Skip to content

Commit

Permalink
Merge pull request #32 from kthy/master
Browse files Browse the repository at this point in the history
Add --no-download-progress install flag. Closes #7
  • Loading branch information
matham authored May 13, 2019
2 parents 6f23d91 + 09beb09 commit 3c6a937
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bin/garden
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class GardenTool(object):
help='Use the kivy garden directory (kivy/garden)')
p.add_argument('--upgrade', action='store_true',
help='Force the installation')
p.add_argument('--no-download-progress', action='store_false', dest='animate',
help='Disable download progress indicator')
p.add_argument('package', nargs=1,
help='Name of the package to install')
p.set_defaults(func=self.cmd_install)
Expand Down Expand Up @@ -138,7 +140,7 @@ class GardenTool(object):
print('Use --upgrade to upgrade.')
sys.exit(0)

fd = self.download(src_package)
fd = self.download(src_package, opts.animate)
tempdir = tempfile.mkdtemp(prefix='garden-')
try:
self.extract(fd, tempdir)
Expand Down Expand Up @@ -185,7 +187,7 @@ class GardenTool(object):
return 'garden.' + package
return package

def download(self, package):
def download(self, package, animate):
url = 'https://github.com/kivy-garden/{}/archive/master.zip'.format(
package)

Expand All @@ -204,8 +206,9 @@ class GardenTool(object):
index += 1
data += buf
count += len(buf)
print('Progression', count, animation[index % len(animation)], '\r')
sys.stdout.flush()
if animate:
print('Progression', count, animation[index % len(animation)], '\r')
sys.stdout.flush()
print('Download done ({} downloaded)'.format(count))

return BytesIO(data)
Expand Down

0 comments on commit 3c6a937

Please sign in to comment.