Skip to content

Commit

Permalink
version display: add -V/--version flag to wb-manager and wayback/pywb…
Browse files Browse the repository at this point in the history
… commands to display version and exit (webrecorder#654)

update CHANGES
comment out default locales in config.yaml
only show warning for installing i18n extra when locales actually specified in config

bump to 2.6.0b3
  • Loading branch information
ikreymer authored Jun 24, 2021
1 parent cff2a9e commit 8130878
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
pywb 2.6.0b3 changelist
~~~~~~~~~~~~~~~~~~~~~~~

* Display 'ignoring locales' warning only if locales specified (don't specify any by default)

* Add -V flag to wb-manager and pywb/wayback commands to display current version and exit


pywb 2.6.0b2 changelist
~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
12 changes: 9 additions & 3 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ enable_memento: true
# Replay content in an iframe
framed_replay: true

locales:
- en
- es

# uncomment and change to set default locale
# default_locale: en

# uncomment to set available locales
# locales:
# - en
# - es

9 changes: 9 additions & 0 deletions pywb/apps/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
from argparse import ArgumentParser

import logging
import pkg_resources


#=============================================================================
def get_version():
"""Get version of the pywb"""
return "pywb " + pkg_resources.get_distribution("pywb").version


#=============================================================================
Expand Down Expand Up @@ -40,6 +47,8 @@ def __init__(self, args=None, default_port=8080, desc=''):
:param str desc: The description for the application to be started
"""
parser = ArgumentParser(description=desc)
parser.add_argument("-V", "--version", action="version", version=get_version())

parser.add_argument('-p', '--port', type=int, default=default_port,
help='Port to listen on (default %s)' % default_port)
parser.add_argument('-b', '--bind', default='0.0.0.0',
Expand Down
8 changes: 7 additions & 1 deletion pywb/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import six

from distutils.util import strtobool
from pkg_resources import resource_string
from pkg_resources import resource_string, get_distribution

from argparse import ArgumentParser, RawTextHelpFormatter

Expand All @@ -28,8 +28,12 @@ def get_input(msg): # pragma: no cover
return input(msg)

#=============================================================================
def get_version():
"""Get version of the pywb"""
return "wb-manager " + get_distribution("pywb").version


#=============================================================================
class CollectionsManager(object):
""" This utility is designed to
simplify the creation and management of web archive collections
Expand Down Expand Up @@ -335,6 +339,8 @@ def main(args=None):
# epilog=epilog,
formatter_class=RawTextHelpFormatter)

parser.add_argument("-V", "--version", action="version", version=get_version())

subparsers = parser.add_subparsers(dest='type')
subparsers.required = True

Expand Down
2 changes: 1 addition & 1 deletion pywb/rewrite/templateview.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def init_loc(self, locales_root_dir, locales, loc_map, default_locale):
default_locale = default_locale or 'en'
self.default_locale = default_locale

if locales_root_dir:
if locales:
try:
from babel.support import Translations
for loc in locales:
Expand Down
2 changes: 1 addition & 1 deletion pywb/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '2.6.0b2'
__version__ = '2.6.0b3'

if __name__ == '__main__':
print(__version__)

0 comments on commit 8130878

Please sign in to comment.