From 63277546b0f17feb90b769648dd018493d776b40 Mon Sep 17 00:00:00 2001 From: Brandon Shelley Date: Sun, 7 Jul 2019 10:26:22 -0700 Subject: [PATCH] Fix Plex not updating on completion and formatting issues --- CHANGELOG | 5 +++++ README.md | 2 +- fylm/__init__.py | 2 +- fylm/fylmlib/console.py | 7 ++++--- fylm/fylmlib/notify.py | 4 ++-- fylm/fylmlib/progress.py | 8 ++++---- fylm/tests/test_notify.py | 2 +- setup.py | 2 +- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3631b6e..afcd71a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,11 @@ # All notable changes to this project will be documented in this file. # This project adheres to [Semantic Versioning](http://semver.org/). +## [0.2.7-beta] 2019-07-07 +- Fix Plex not updating on completion +- Fix progress bar not formatting correctly +- Hide progress bar updating in plaintext mode + ## [0.2.6-beta] 2019-07-05 - Add support for Python 3.5 and 3.7 (3.6 already supported) - Clean up and future-proofing for later versions of dependencies diff --git a/README.md b/README.md index 18f15a9..810e1ca 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-0.2.6--beta-green.svg) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/8fcfaf45a6494aedb4b0340461c2b79b)](https://www.codacy.com/app/brandonscript/fylm) [![Build Status](https://travis-ci.org/brandonscript/fylm.svg?branch=master)](https://travis-ci.org/brandonscript/fylm) +![version](https://img.shields.io/badge/version-0.2.7--beta-green.svg) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/8fcfaf45a6494aedb4b0340461c2b79b)](https://www.codacy.com/app/brandonscript/fylm) [![Build Status](https://travis-ci.org/brandonscript/fylm.svg?branch=master)](https://travis-ci.org/brandonscript/fylm) diff --git a/fylm/__init__.py b/fylm/__init__.py index 80b201c..b740952 100644 --- a/fylm/__init__.py +++ b/fylm/__init__.py @@ -35,7 +35,7 @@ import fylmlib.notify as notify import fylmlib.counter as counter -__version__ = '0.2.6-beta' +__version__ = '0.2.7-beta' def main(): """Main program.""" diff --git a/fylm/fylmlib/console.py b/fylm/fylmlib/console.py index 23adccd..7312334 100644 --- a/fylm/fylmlib/console.py +++ b/fylm/fylmlib/console.py @@ -189,7 +189,7 @@ def print_search_result(self, film): if film.tmdb_id is not None: c = console().indent() c.green(f'✓ {film.title} ({film.year})') - c.dark_gray(f' [{film.tmdb_id}] {formatter.percent(film.title_similarity)} match') + c.dark_gray(f' [{film.tmdb_id}] {formatter.percent(film.title_similarity)}% match') c.print() else: console().red().indent(f'× {film.title} ({film.year})').print() @@ -294,8 +294,9 @@ def print_move_or_copy(self, src, dst_path, dst): def print_copy_progress_bar(self, copied, total): """Print progress bar to terminal. """ - print(' ' + progress.progress_bar(100 * copied / total), end='\r') - sys.stdout.flush() + if not config.plaintext: + print(' ' + progress.progress_bar(100 * copied / total), end='\r') + sys.stdout.flush() @classmethod def get_input(cls, prompt): diff --git a/fylm/fylmlib/notify.py b/fylm/fylmlib/notify.py index 041144d..5ee51a3 100644 --- a/fylm/fylmlib/notify.py +++ b/fylm/fylmlib/notify.py @@ -75,9 +75,9 @@ def plex(): # in live mode. No need to notify in test mode since there won't be any changes. if not config.test: for section in (plex.library.section(section) for section in config.plex.sections): - section.update() + section.refresh() - console().green(' Done ✓').print() + console().green(' Done ✓\n').print() # Re-enable logging when done. log.enable() diff --git a/fylm/fylmlib/progress.py b/fylm/fylmlib/progress.py index d9c78cf..f5cba2b 100644 --- a/fylm/fylmlib/progress.py +++ b/fylm/fylmlib/progress.py @@ -39,8 +39,8 @@ def progress_bar(percentage, width=50): """ if config.plaintext: - FULL_BLOCK = color('X', fg=ansi.pink) - INCOMPLETE_BLOCK_GRAD = [color('-', fg=ansi.dark_gray), color('-', fg=ansi.dark_gray), color('=', fg=ansi.dark_gray)] + FULL_BLOCK = "X" + INCOMPLETE_BLOCK_GRAD = ["-", "-", "="] else: FULL_BLOCK = color('█', fg=ansi.pink) INCOMPLETE_BLOCK_GRAD = [color('░', fg=ansi.dark_gray), color('▒', fg=ansi.dark_gray), color('▓', fg=ansi.dark_gray)] @@ -78,10 +78,10 @@ def progress_bar(percentage, width=50): blocks_widget[full_blocks] = INCOMPLETE_BLOCK_GRAD[grad_index] # Build percentage widget - str_perc = f'{percentage}.0f' + str_perc = f'{percentage:.1f}' # Subtract 1 because the percentage sign is not included. - perc_widget = f'{str_perc.ljust(len(max_perc_widget) - 3)}%%' + perc_widget = f'{str_perc.ljust(len(max_perc_widget) - 3)}%' # Generate progress bar progress_bar = f"{''.join(blocks_widget)}{separator}{perc_widget}" diff --git a/fylm/tests/test_notify.py b/fylm/tests/test_notify.py index 9c2e193..5f72bbe 100644 --- a/fylm/tests/test_notify.py +++ b/fylm/tests/test_notify.py @@ -48,7 +48,7 @@ def test_plex(self): plex = PlexServer(baseurl=config.plex.baseurl, token=config.plex.token, timeout=10) for section in (plex.library.section(section) for section in config.plex.sections): - section.update() + section.refresh() @pytest.mark.xfail(raises=(OSError, IOError)) def test_plex_fail(self): diff --git a/setup.py b/setup.py index 0978aa0..d9fcea5 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ setup( name='Fylm', - version='0.2.6-beta', + version='0.2.7-beta', description='A automated command line app for organizing your film media.', long_description=long_description,