Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porgressbar -> Progressbar #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ampy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

import click
import dotenv
from progress_bar import PorgressBar
from progress_bar import PorgressBarBath
from progress_bar import ProgressBar
from progress_bar import ProgressBarBath

# Load AMPY_PORT et al from .ampy file
# Performed here because we need to beat click's decorators.
Expand Down Expand Up @@ -253,12 +253,12 @@ def put(local, remote):
# Otherwise it's a file and should simply be copied over.
if os.path.isdir(local):
# Create progress bar for each file
pb_bath = PorgressBarBath('Overall progress')
pb_bath = ProgressBarBath('Overall progress')
for parent, child_dirs, child_files in os.walk(local, followlinks=True):
for filename in child_files:
path = os.path.join(parent, filename)
size = os.stat(path).st_size
pb_bath.add_subjob(PorgressBar(name=path,total=size ))
pb_bath.add_subjob(ProgressBar(name=path,total=size ))

# Directory copy, create the directory and walk all children to copy
# over the files.
Expand Down Expand Up @@ -289,7 +289,7 @@ def put(local, remote):
# Put the file on the board.
with open(local, "rb") as infile:
data = infile.read()
progress = PorgressBar(name=local, total=len(data))
progress = ProgressBar(name=local, total=len(data))
board_files = files.Files(_board)
board_files.put(remote, data, progress.on_progress_done)
print('')
Expand Down
18 changes: 9 additions & 9 deletions ampy/progress_bar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import math
import time

class PorgressBar(object):
class ProgressBar(object):
def __init__(self, name='', total=100, bar_width = 22, autorender=True):
self.total = total
self.progress = 0
Expand Down Expand Up @@ -42,19 +42,19 @@ def print( self ):
else:
print(self.render)

class PorgressBarBath(object):
class ProgressBarBath(object):
def __init__(self, name, bar_width = 40):
self.jobs = []
self.name = name
self.progress = PorgressBar(name, 0, bar_width=bar_width, autorender=False )
self.progress = ProgressBar(name, 0, bar_width=bar_width, autorender=False )
self.last_render_lines = 0
self.bar_width = bar_width

def get_subjob(self, name):
return next( (x for x in self.jobs if x.name == name), None)

def add_subjob(self, job):
if isinstance(job, PorgressBar):
if isinstance(job, ProgressBar):
job.parent_bath_job = self
job.autorender = False
job.bar_width = self.bar_width
Expand Down Expand Up @@ -93,12 +93,12 @@ def print( self ):


if __name__ == '__main__':
pb = PorgressBar('reading stuff', 200, 60, True)
pb_1 = PorgressBar('writing', 100, 22, True)
pb_2 = PorgressBar('sleeping', 20, 22, True)
pb_3 = PorgressBar('reading again', 200, 60, True)
pb = ProgressBar('reading stuff', 200, 60, True)
pb_1 = ProgressBar('writing', 100, 22, True)
pb_2 = ProgressBar('sleeping', 20, 22, True)
pb_3 = ProgressBar('reading again', 200, 60, True)

bath = PorgressBarBath('Overall')
bath = ProgressBarBath('Overall')
bath.add_subjob(pb)
bath.add_subjob(pb_1)
bath.add_subjob(pb_2)
Expand Down