diff --git a/Changelog b/Changelog index 58ca4aa0..7f9ef874 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,8 @@ +2024-02-24 s-n-g + * version 0.9.2.25 + * droping python 2 - PyRadio will only run on python 3 + * fixing #228 + 2024-01-12 s-n-g * version 0.9.2.24 (BUG FIX) * fixing mpv title parsing (once again) diff --git a/README.md b/README.md index 2300042a..c79f001b 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ If you face this situation, please refer to [this page](docs/pip-error.md) to re and much more... ## Requirements -* python 2.7/3.5+ +* python 3.7+ - setuptools - wheel - requests diff --git a/devel/build_install_pyradio b/devel/build_install_pyradio index 54c4e5d8..99a2fdeb 100755 --- a/devel/build_install_pyradio +++ b/devel/build_install_pyradio @@ -1,9 +1,8 @@ #!/usr/bin/env bash function help(){ -echo "Usage: $0 [2/-R]" +echo "Usage: $0 [-R/-t]" echo " Available options: - 2 build using python v. 2.7 (linux only) -R remove (uninstall) pyradio -t Use this terminal for Desktop file (linux only) @@ -44,10 +43,8 @@ exit 1 function find_paths(){ local APATH python devel/site.py 2>/dev/null -python2 devel/site.py 2>/dev/null python3 devel/site.py 2>/dev/null APATH=$(python -m site --user-site 2>/dev/null) && echo "$APATH" -APATH=$(python2 -m site --user-site 2>/dev/null) && echo "$APATH" APATH=$(python3 -m site --user-site 2>/dev/null) && echo "$APATH" } @@ -249,6 +246,7 @@ function check_root(){ check_root rm -rf build pyradio.egg-info 2>/dev/null TO_PYTHON=3 +[[ $(python --version 2>/dev/null) == *" 3."* ]] && TO_PYTHON='' TO_PYTHON_FROM_X='' NO_DEV='' while [[ $# -gt 0 ]] @@ -289,15 +287,11 @@ do exit ;; 2) - [ -z "${TO_PYTHON_FROM_X}" ] && TO_PYTHON=2 - if [ $(uname -s) = "Darwin" ] || [ $(uname -s) = "darwin" ] - then - echo - echo - echo "Error: PyRadio does not support python 2 any more." - echo "Please install python 3 and try again." - exit 1 - fi + echo + echo + echo "Error: PyRadio does not support python 2 any more." + echo "Please install python 3 and try again." + exit 1 shift ;; -x) diff --git a/docs/build.html b/docs/build.html index a1152d2c..4b38d036 100644 --- a/docs/build.html +++ b/docs/build.html @@ -50,7 +50,6 @@
PEP 668 – Marking Python base environments as “externally managed”
If you are still using Python 2 in a linux system, plase make sure “pip” is installed. Execute the following command to verify its existance:
-python[2] -m pip list-
If you get a response, you are good to go. Otherwise, use your distro package manager to install it.
-If your distro does not provide it (some do not anymore), use the following commands to get it:
-curl https://bootstrap.pypa.io/pip/2.7/get-pip.py \ - --output get-pip.py - sudo python[2] get-pip.py-
or
-wget https://bootstrap.pypa.io/pip/2.7/get-pip.py - sudo python[2] get-pip.py-
When you are done, proceed to “pip installation (the old way)”, adapting the commands to python2.
If you are on any of the BSDs, please do install bash beforehand and try to follow the pip installation guide.
Please be aware that PyRadio is provided as a port on FreeBSB.
diff --git a/docs/build.md b/docs/build.md index c3ae8ea9..9d2e3de9 100644 --- a/docs/build.md +++ b/docs/build.md @@ -7,7 +7,6 @@ * [What does it all mean and why should you care](#what-does-it-all-mean-and-why-should-you-care) * [When do I need to install pipx?](#when-do-i-need-to-install-pipx?) * [More info](#more-info) - * [Notice for Python 2 users](#notice-for-python-2-users) * [Installation on the BSDs](#installation-on-the-bsds) * [Rasberry Pi installation](#rasberry-pi-installation) * [Installation guides](#installation-guides) @@ -85,33 +84,6 @@ If you get that message, or a similar one, it is time to install `pipx`. - [PEP 668 – Marking Python base environments as “externally managed”](https://peps.python.org/pep-0668/) -### Notice for Python 2 users - -If you are still using **Python 2** in a linux system, plase make sure "**pip**" is installed. Execute the following command to verify its existance: - -``` -python[2] -m pip list -``` - -If you get a response, you are good to go. Otherwise, use your distro package manager to install it. - -If your distro does not provide it (some do not anymore), use the following commands to get it: - -``` - curl https://bootstrap.pypa.io/pip/2.7/get-pip.py \ - --output get-pip.py - sudo python[2] get-pip.py -``` - -or - -``` - wget https://bootstrap.pypa.io/pip/2.7/get-pip.py - sudo python[2] get-pip.py -``` - -When you are done, proceed to "[pip installation](linux.md) (the old way)", adapting the commands to python2. - ### Installation on the BSDs If you are on any of the BSDs, please do install **bash** beforehand and try to follow the [pip installation guide](linux.md). diff --git a/docs/index.html b/docs/index.html index 7c58e7b9..f3730a5b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -158,7 +158,7 @@+2024-02-24 s-n-g + * version 0.9.2.25 + * droping python 2 - PyRadio will only run on python 3 + * fixing #228 + 2024-01-12 s-n-g * version 0.9.2.24 (BUG FIX) * fixing mpv title parsing (once again) diff --git a/docs/index.md b/docs/index.md index 5324e2a8..8780f9e5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -95,7 +95,7 @@ If you face this situation, please refer to [this page](pip-error.md) to resolve and much more... ## Requirements -* python 2.7/3.5+ +* python 3.7+ - setuptools - wheel - requests diff --git a/docs/pyradio.1 b/docs/pyradio.1 index d968cb68..c347e29d 100644 --- a/docs/pyradio.1 +++ b/docs/pyradio.1 @@ -2,7 +2,7 @@ .\" Copyright (C) 2018-2024 Spiros Georgaras.\" This manual is freely distributable under the terms of the GPL. .\" -.TH pyradio 1 "January 2024" pyradio +.TH pyradio 1 "February 2024" pyradio .SH Name .PP @@ -603,7 +603,7 @@ A playlist that does not reside within the program’s configuration directory i When this happens, \fBpyradio\fR will offer you the choise to copy the playlist in its configuration directory, thus making it available for manipulation within the program. -If a playlist of the same name already exists in the configuration directory, the "\fIforeign\fR" playlist will be time-stamped. For example, if a "\fIforeign\fR" playlist is named "\fIstations.csv\fR", it will be named "\fI2019-01-11_13-35-47_stations.csv\fR" (provided that the action was taked on January 11, 2019 at 13:35:47). +If a playlist of the same name already exists in the configuration directory, the "\fIforeign\fR" playlist will be time-stamped. For example, if a "\fIforeign\fR" playlist is named "\fIstations.csv\fR", it will be named "\fI2019-01-11_13-35-47_stations.csv\fR" (provided that the action was taked on February 11, 2019 at 13:35:47). .PP diff --git a/docs/pyradio_rb.1 b/docs/pyradio_rb.1 index 6ff524ac..0dfc9c2f 100644 --- a/docs/pyradio_rb.1 +++ b/docs/pyradio_rb.1 @@ -1,7 +1,7 @@ .\" Copyright (C) 2018-2024 Spiros Georgaras .\" This manual is freely distributable under the terms of the GPL. .\" -.TH pyradio_rb 1 "January 2024" pyradio +.TH pyradio_rb 1 "February 2024" pyradio .SH Name .PP diff --git a/docs/pyradio_rec.1 b/docs/pyradio_rec.1 index 3f79b26b..9e9ffb4e 100644 --- a/docs/pyradio_rec.1 +++ b/docs/pyradio_rec.1 @@ -1,4 +1,4 @@ -.TH pyradio_rec 1 "January 2024" pyradio +.TH pyradio_rec 1 "February 2024" pyradio .SH Name .PP diff --git a/docs/pyradio_server.1 b/docs/pyradio_server.1 index 60a99563..da4f2bb1 100644 --- a/docs/pyradio_server.1 +++ b/docs/pyradio_server.1 @@ -1,7 +1,7 @@ .\" Copyright (C) 2018-2024 Spiros Georgaras .\" This manual is freely distributable under the terms of the GPL. .\" -.TH pyradio_server 1 "January 2024" pyradio +.TH pyradio_server 1 "February 2024" pyradio .SH Name .PP diff --git a/pyproject.toml b/pyproject.toml index 7ea17eb9..9d564191 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pyradio" -version = "0.9.2.24" +version = "0.9.2.25" authors = [ { name="Ben Dowling", email="ben.m.dowling@gmail.com" }, { name="Spiros Georgaras", email="sng@hellug.gr" }, diff --git a/pyradio/__init__.py b/pyradio/__init__.py index 46184058..5b270e50 100644 --- a/pyradio/__init__.py +++ b/pyradio/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- " pyradio -- Console radio player. " -version_info = (0, 9, 2, 24) +version_info = (0, 9, 2, 25) # Set it to True if new stations have been # added to the package's stations.csv diff --git a/pyradio/install.py b/pyradio/install.py index 58699ce4..f158ca08 100644 --- a/pyradio/install.py +++ b/pyradio/install.py @@ -15,7 +15,7 @@ ''' This is PyRadio version this install.py was released for ''' -PyRadioInstallPyReleaseVersion = '0.9.2.24' +PyRadioInstallPyReleaseVersion = '0.9.2.25' import locale locale.setlocale(locale.LC_ALL, "") @@ -46,18 +46,12 @@ PY3 = sys.version[0] == '3' -if PY3: - HAS_PIPX = True if shutil.which('pipx') else False -else: - HAS_PIPX = False +HAS_PIPX = True if shutil.which('pipx') else False - -##### NO PYTHON2 -if PY3: - try: - from rich import print - except: - print('''Error: Module "rich" not found! +try: + from rich import print +except: + print('''Error: Module "rich" not found! Please install the above module and try again. @@ -81,8 +75,7 @@ python -m pip install --user rich ''') - sys.exit(1) -##### END NO PYTHON2 + sys.exit(1) # import logging # logger = logging.getLogger(__name__) @@ -96,19 +89,13 @@ def print_pipx_error(): Please install [bold green]pipx[/bold green] and try again. ''' - if PY3: - print(msg) - else: - print(re.sub(r'\[[^\[]+\]', '', msg)) + print(msg) def print_distro_packages(): msg = '''To succesfully complete [magenta]PyRadio[/magenta]'s installation, please refer to this page: [plum]https://github.com/coderholic/pyradio/blob/master/build.md[/plum] ''' - if PY3: - print(msg) - else: - print(re.sub(r'\[[^\[]+\]', '', msg)) + print(msg) def is_externally_managed(): files = [ @@ -133,46 +120,11 @@ def print_pyradio_on(): __/ | |___/ [/bold magenta] - [bold]installation script - running on[/bold] -''' - if PY3: - print(msg) - else: - print(msg.replace('[bold]', '').replace('[/bold]', '').replace('[bold magenta]', '').replace('[/bold magenta]', '')) - -def print_python2(): - print(r''' _____ _ _ ___ - | __ \ | | | | |__ \\ - | |__) | _| |_| |__ ___ _ __ ) | - | ___/ | | | __| '_ \ / _ \| '_ \ / / - | | | |_| | |_| | | | (_) | | | | / /_ - |_| \__, |\__|_| |_|\___/|_| |_| |____| - __/ | - |___/ - - - ''') - -def print_python3(): - msg = r'''[bold green] _____ _ _ ____ - | __ \ | | | | |___ \\ - | |__) | _| |_| |__ ___ _ __ __) | - | ___/ | | | __| '_ \ / _ \| '_ \ |__ < - | | | |_| | |_| | | | (_) | | | | ___) | - |_| \__, |\__|_| |_|\___/|_| |_| |____/ - __/ | - |___/ -[/bold green] + [bold]installation script[/bold] - ''' +''' print(msg) -def print_no_python2(): - print(''' not Supported!!! - Please upgade to Python 3 -''') - def print_trying_to_install(): print(' trying to install for') @@ -331,11 +283,8 @@ def get_github_long_description( url += '?sha=master' url += '&per_page=50' try: - if sys.version_info < (3, 0): - ret = urlopen(url).read() - else: - with urlopen(url) as https_response: - ret = https_response.read() + with urlopen(url) as https_response: + ret = https_response.read() except: if do_not_exit: ret = None @@ -474,10 +423,7 @@ def WindowExists(title): def open_cache_dir(): c = PyRadioCache() if not c.exists(): - if PY3: - print('[magenta]PyRadio Cache[/magenta]: [red]not found[/red]\n') - else: - print('PyRadio Cache: not found\n') + print('[magenta]PyRadio Cache[/magenta]: [red]not found[/red]\n') sys.exit(1) if platform.system().lower() == 'windows': os.startfile(c.cache_dir) @@ -551,42 +497,23 @@ def list(self): ''' return a string the string is a list of file in the cache ''' - if PY3: - if self.exists(): - from rich.console import Console - console = Console() - if self.files: - max_len = max([len(x) for x in self._files]) + 4 - console.print('[magenta]PyRadio Cache[/magenta]:') - for i, n in enumerate(self._files): - if i < 5: - s = os.path.join(self._cache_dir, n) - console.print(' [green]{0}[/green]. {1} [bold]{2}MB[/bold]'.format(i+1, n.ljust(max_len), self.get_size(s, 'mb')), highlight=False) - else: - console.print('plus [green]{}[/green] more files'.format(len(self._files)-5), highlight=False) - break - else: - print('[magenta]PyRadio Cache[/magenta]: [bold cyan]empty[/bold cyan]') + if self.exists(): + from rich.console import Console + console = Console() + if self.files: + max_len = max([len(x) for x in self._files]) + 4 + console.print('[magenta]PyRadio Cache[/magenta]:') + for i, n in enumerate(self._files): + if i < 5: + s = os.path.join(self._cache_dir, n) + console.print(' [green]{0}[/green]. {1} [bold]{2}MB[/bold]'.format(i+1, n.ljust(max_len), self.get_size(s, 'mb')), highlight=False) + else: + console.print('plus [green]{}[/green] more files'.format(len(self._files)-5), highlight=False) + break else: - print('[magenta]PyRadio Cache[/magenta]: [bold red]not found[/bold red]') + print('[magenta]PyRadio Cache[/magenta]: [bold cyan]empty[/bold cyan]') else: - if self.exists(): - if self.files: - max_len = max([len(x) for x in self._files]) + 4 - print('PyRadio Cache:') - for i, n in enumerate(self._files): - if i < 5: - s = os.path.join(self._cache_dir, n) - print(' {0}. {1} {2}MB'.format( - i+1, n.ljust(max_len), self.get_size(s, 'mb') - )) - else: - print('plus {} more files'.format(len(self._files)-5)) - break - else: - print('PyRadio Cache: empty') - else: - print('PyRadio Cache: not found') + print('[magenta]PyRadio Cache[/magenta]: [bold red]not found[/bold red]') print('') @property @@ -699,18 +626,12 @@ def print_usage(self, file=None): if file is None: file = sys.stdout usage = self.format_usage() - if PY3: - print(self._add_colors(self.format_usage())) - else: - print(self.format_usage()) + print(self._add_colors(self.format_usage())) def print_help(self, file=None): if file is None: file = sys.stdout - if PY3: - print(self._add_colors(self.format_help())) - else: - print(self.format_help()) + print(self._add_colors(self.format_help())) def _add_colors(self, txt): t = txt.replace('show this help', 'Show this help').replace('usage:', 'Usage:').replace('options:', 'Options:').replace('[', '|').replace(']', '||') @@ -853,7 +774,6 @@ class PyRadioUpdate(object): install = False user = True - python2 = False _python_exec = None @@ -865,7 +785,6 @@ def __init__(self, package=0, user=True, github_long_description=None, - python_version_to_use=3, pix_isolated=False ): if platform.system().lower().startswith('win'): @@ -875,10 +794,8 @@ def __init__(self, self.user = user self._github_long_description = github_long_description self._python_exec = PythonExecutable( - python_version_to_use, terminate_if_not_found=True ) - self.python2 = True if python_version_to_use == 2 else False self._pix_isolated = pix_isolated def update_pyradio(self, win_open_dir=False): @@ -1086,7 +1003,7 @@ def _do_it(self, mode='update'): self._change_git_discription_in_config_py() - param = ' 2' if self.python2 else '' + param = '' isol = ' -i ' if self._pix_isolated else ' ' if mode == 'update': ''' install pyradio ''' @@ -1211,10 +1128,7 @@ def _empty_dir(self, name=None): r_dir = os.path.join(ddir, 'pyradio-source') shutil.rmtree(r_dir, ignore_errors=True) if os.path.exists(r_dir): - if PY3: - print('[red]Error:[/red] Cannot remove "{}"'.format(r_dir)) - else: - print('Error: Cannot remove "{}"'.format(r_dir)) + print('[red]Error:[/red] Cannot remove "{}"'.format(r_dir)) print(' Please close all open programs and try again...') sys.exit(1) else: @@ -1244,10 +1158,7 @@ def _download_file(self, url, filename): print(' url: "{}"'.format(url)) print(' filename: "{}"'.format(filename)) if os.path.exists(filename): - if PY3: - print(' [magenta]** file found in cache![/magenta]') - else: - print(' ** file found in cache!') + print(' [magenta]** file found in cache![/magenta]') else: try: r = requests.get(url) @@ -1270,7 +1181,6 @@ def __init__(self, fromTUI=False, package=0, github_long_description=None, - python_version_to_use=3, pix_isolated=False ): if not platform.system().lower().startswith('win'): @@ -1280,10 +1190,8 @@ def __init__(self, self._fromTUI = fromTUI self._github_long_description = github_long_description self._python_exec = PythonExecutable( - python_version_to_use, terminate_if_not_found=True ) - self.python2 = True if python_version_to_use == 2 else False self._pix_isolated = pix_isolated self._get_cache = False @@ -1328,20 +1236,6 @@ def _do_it(self, mode='update'): if __name__ == '__main__': - # x = PyRadioCache() - # x.list() - # sys.exit() - #exe = find_pyradio_win_exe() - #print(exe) - #sys.exit() - # l=get_github_long_description() - # print(l) - # print(get_devel_version()) - # sys.exit() - #print_pyradio_on() - #print_python3() if PY3 else print_python2() - # print(get_devel_version()) - # sys.exit() parser = MyArgParser( description='Curses based Internet radio player', epilog='When executed without an argument, it installs PyRadio (stable release).' @@ -1353,7 +1247,7 @@ def _do_it(self, mode='update'): parser.add_argument('-f', '--force', action='store_true', help='Force installation (even if already installed).') if not platform.system().lower().startswith('win'): - if PY3 and HAS_PIPX: + if HAS_PIPX: parser.add_argument('-i', '--isolate', action='store_true', help='Install using pipx in an fully Isolated Environment (all dependencies will be installed in a virtual environment); the default is to have pipx depend on distro python packages.') parser.add_argument('-oc', '--open-cache', action='store_true', @@ -1372,17 +1266,11 @@ def _do_it(self, mode='update'): help='Download source code, keep it in the cache and exit.') else: parser.add_argument('-gc', '--get-cache', action='store_true', help=SUPPRESS) - if not platform.system().lower().startswith('darwin'): - parser.add_argument('--python2', action='store_true', - help='Install using python 2.') - else: - parser.add_argument('--python2', action='store_true', help=SUPPRESS) else: parser.add_argument('-oc', '--open-cache', action='store_true', help=SUPPRESS) parser.add_argument('-sc', '--show-cache', action='store_true', help=SUPPRESS) parser.add_argument('-cc', '--clear-cache', action='store_true', help=SUPPRESS) parser.add_argument('-i', '--isolate', action='store_true', help=SUPPRESS) - parser.add_argument('--python2', action='store_true', help=SUPPRESS) parser.add_argument('-R', '--uninstall', action='store_true', help='Uninstall PyRadio.') @@ -1427,27 +1315,18 @@ def _do_it(self, mode='update'): if c.exists(): if len(c.files) > 1: c.clear() - if PY3: - print('[magenta]PyRadio Cache[/magenta]: [green]cleared[/green]\n') - else: - print('PyRadio Cache: cleared\n') + print('[magenta]PyRadio Cache[/magenta]: [green]cleared[/green]\n') sys.exit() c.list() sys.exit(1) if args.version: - if PY3: - print('[bold green]install.py[/bold green]: installation script for [bold magenta]PyRadio {}[/bold magenta]\n'.format(PyRadioInstallPyReleaseVersion )) - else: - print('install.py: installation script for PyRadio {}\n'.format(PyRadioInstallPyReleaseVersion )) + print('[bold green]install.py[/bold green]: installation script for [bold magenta]PyRadio {}[/bold magenta]\n'.format(PyRadioInstallPyReleaseVersion )) sys.exit() if not platform.system().lower().startswith('win'): if os.getuid() == 0 or os.getgid() == 0: - if PY3: - print('[red]Error:[/red] You must not run this script as [green]root[/green]\n') - else: - print('Error: You must not run this script as root\n') + print('[red]Error:[/red] You must not run this script as [green]root[/green]\n') sys.exit(1) if is_externally_managed() and \ @@ -1457,34 +1336,18 @@ def _do_it(self, mode='update'): print_distro_packages() sys.exit() use_logo = False if args.no_logo else True - if platform.system().lower().startswith('darwin'): - ''' get python version ''' - if sys.version_info < (3, 0): - print('Error: Python 2 is not supported any more!') - print(' Please install Python 3 and execute the command:') - print('\n python3 install.py') - print('\n to install PyRadio.\n\n') - sys.exit(1) - - if platform.system().lower().startswith('win') and \ - (not PY3 or args.python2): - print_pyradio_on() - print_python2() - print_no_python2() + ''' get python version ''' + if not PY3: + print('Error: Python 2 is not supported any more!') + print(' Please install Python 3 and execute the command:') + print('\n python3 install.py') + print('\n to install PyRadio.\n\n') sys.exit(1) if use_logo and not args.open_cache: print_pyradio_on() - if PY3 and not args.python2: - print_python3() - else: - print_python2() - python_version_to_use = 2 if args.python2 else 3 - if platform.system().lower().startswith('darwin'): - python_version_to_use = 3 python_exec = PythonExecutable( - python_version_to_use, terminate_if_not_found=True ) @@ -1537,17 +1400,11 @@ def _do_it(self, mode='update'): self._get_cache = False if platform.system().lower().startswith('win'): ''' ok, create BAT file on Windows''' - uni = PyRadioUpdateOnWindows( - package=package, - python_version_to_use=python_version_to_use - ) + uni = PyRadioUpdateOnWindows(package=package) uni.update_or_uninstall_on_windows(mode='uninstall-open') uni.print_uninstall_bat_created() else: - uni = PyRadioUpdate( - package=package, - python_version_to_use=python_version_to_use - ) + uni = PyRadioUpdate(package=package) uni.remove_pyradio() sys.exit() elif args.update: @@ -1556,7 +1413,6 @@ def _do_it(self, mode='update'): upd = PyRadioUpdateOnWindows( package=package, github_long_description=github_long_description, - python_version_to_use=python_version_to_use, pix_isolated=args.isolate ) upd.update_or_uninstall_on_windows(mode='update-open') @@ -1565,7 +1421,6 @@ def _do_it(self, mode='update'): upd = PyRadioUpdate( package=package, github_long_description=github_long_description, - python_version_to_use=python_version_to_use, pix_isolated=args.isolate ) if args.get_cache and HAS_PIPX: @@ -1577,7 +1432,6 @@ def _do_it(self, mode='update'): ''' coming from uninstall BAT file on Windows''' uni = PyRadioUpdateOnWindows( package=package, - python_version_to_use=python_version_to_use, pix_isolated=args.isolate ) uni.remove_pyradio() @@ -1587,7 +1441,6 @@ def _do_it(self, mode='update'): upd = PyRadioUpdateOnWindows( package=package, github_long_description=github_long_description, - python_version_to_use=python_version_to_use, pix_isolated=args.isolate ) upd.update_pyradio() @@ -1649,7 +1502,6 @@ def _do_it(self, mode='update'): uni = PyRadioUpdateOnWindows( package=package, github_long_description=github_long_description, - python_version_to_use=python_version_to_use, pix_isolated=args.isolate ) uni.update_or_uninstall_on_windows( @@ -1680,7 +1532,6 @@ def _do_it(self, mode='update'): uni = PyRadioUpdate( package=package, github_long_description=github_long_description, - python_version_to_use=python_version_to_use, pix_isolated=args.isolate ) uni.install = True diff --git a/pyradio/log.py b/pyradio/log.py index 09880c79..567d310b 100644 --- a/pyradio/log.py +++ b/pyradio/log.py @@ -34,6 +34,14 @@ if platform.lower().startswith('win'): import ctypes +def fix_chars(s): + out = [s] + from_str = ('\r', '\n', '\\"', "\\'") + to_str = ('' , '', '"', "'") + for n in range(len(to_str)): + out.append(out[-1].replace(from_str[n], to_str[n])) + return out[-1].strip() + class Log(object): ''' Log class that outputs text to a curses screen ''' @@ -192,11 +200,11 @@ def write(self, self.cursesScreen.erase() d_msg = '' try: - d_msg = self.msg.strip()[0: self.width].replace('\r', '').replace('\n', '') + d_msg = fix_chars(self.msg.strip()[0: self.width]) self.cursesScreen.addstr(0, 1, d_msg) except: try: - d_msg = self.msg.encode('utf-8', 'replace').strip()[0: self.width].replace('\r', '').replace('\n', '') + d_msg = fix_chars(self.msg.encode('utf-8', 'replace').strip()[0: self.width]) self.cursesScreen.addstr(0, 1, d_msg) except: pass diff --git a/pyradio/main.py b/pyradio/main.py index 6e3b8f6a..0176448b 100644 --- a/pyradio/main.py +++ b/pyradio/main.py @@ -577,34 +577,20 @@ def shell(): print('Error reading online version.\nPlease make sure you are connected to the internet and try again.') sys.exit(1) - python_version_to_use = 3 if PY3 else 2 try: - upd = PyRadioUpdate( - package=package, - python_version_to_use=python_version_to_use - ) + upd = PyRadioUpdate(package=package) upd.update_pyradio() except RuntimeError: - upd = PyRadioUpdateOnWindows( - package=package, - python_version_to_use=python_version_to_use - ) + upd = PyRadioUpdateOnWindows(package=package) upd.update_or_uninstall_on_windows(mode='update-open') sys.exit() if args.uninstall: - python_version_to_use = 3 if PY3 else 2 try: - upd = PyRadioUpdate( - package=package, - python_version_to_use=python_version_to_use - ) + upd = PyRadioUpdate(package=package) upd.remove_pyradio() except RuntimeError: - upd = PyRadioUpdateOnWindows( - package=package, - python_version_to_use=python_version_to_use - ) + upd = PyRadioUpdateOnWindows(package=package) upd.update_or_uninstall_on_windows( mode='uninstall-open', from_pyradio=True @@ -689,7 +675,6 @@ def shell(): upd = PyRadioUpdate( package=0, # always get latest stable release github_long_description=None, - python_version_to_use=3, pix_isolated=False ) upd._get_cache = True diff --git a/pyradio/radio.py b/pyradio/radio.py index 37f2bc25..a0f13207 100644 --- a/pyradio/radio.py +++ b/pyradio/radio.py @@ -4436,19 +4436,35 @@ def _print_config_save_error(self): is_message=True) def _print_update_notification(self): - txt = ''' - A new |PyRadio| release (|{0}|) is available! + if PY3: + txt = ''' + A new |PyRadio| release (|{0}|) is available! - You are strongly encouraged to update now, so that - you enjoy new features and bug fixes. + You are strongly encouraged to update now, so that + you enjoy new features and bug fixes. - Press |y| to update or any other key to cancel. - ''' - self._show_help(txt.format(self._update_version_do_display), - mode_to_set=self.ws.UPDATE_NOTIFICATION_MODE, - caption=' Update Notification ', - prompt='', - is_message=True) + Press |y| to update or any other key to cancel. + ''' + self._show_help(txt.format(self._update_version_do_display), + mode_to_set=self.ws.UPDATE_NOTIFICATION_MODE, + caption=' Update Notification ', + prompt='', + is_message=True) + else: + txt = ''' + A new |PyRadio| release (|{0}|) is available! + + |PyRadio| has dropped |Python2| support since + version| 0.9.2.25|, but you are still using |Python2|. + + If you want to be able to use a newer version, please + upgrade to |Python3|. + ''' + self._show_help(txt.format(self._update_version_do_display), + mode_to_set=self.ws.UPDATE_NOTIFICATION_MODE, + caption=' Update Notification ', + prompt='', + is_message=True) self._update_version = '' def _print_update_ok_notification(self): @@ -8624,10 +8640,11 @@ def keypress(self, char): with self._update_notify_lock: self._update_version = '' self.ws.close_window() - if char == ord('y'): - self._print_update_ok_notification() - else: - self._print_update_nok_notification() + if PY3: + if char == ord('y'): + self._print_update_ok_notification() + else: + self._print_update_nok_notification() self.refreshBody() return