1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00

make manager commands working with python3 (#279)

This commit is contained in:
raffaele messuti 2018-01-16 07:09:14 +00:00 committed by Ilya Kreymer
parent 85f093e356
commit a7d9494363

View File

@ -17,14 +17,18 @@ from warcio.timeutils import timestamp20_now
from pywb import DEFAULT_CONFIG from pywb import DEFAULT_CONFIG
from six.moves import input
#============================================================================= #=============================================================================
# to allow testing by mocking get_input # to allow testing by mocking get_input
def get_input(msg): #pragma: no cover
return raw_input(msg)
def get_input(msg): # pragma: no cover
return input(msg)
#============================================================================= #=============================================================================
class CollectionsManager(object): class CollectionsManager(object):
""" This utility is designed to """ This utility is designed to
simplify the creation and management of web archive collections simplify the creation and management of web archive collections
@ -319,13 +323,13 @@ def main(args=None):
description = """ description = """
Create manage file based web archive collections Create manage file based web archive collections
""" """
#format(os.path.basename(sys.argv[0])) # format(os.path.basename(sys.argv[0]))
logging.basicConfig(format='%(asctime)s: [%(levelname)s]: %(message)s', logging.basicConfig(format='%(asctime)s: [%(levelname)s]: %(message)s',
level=logging.DEBUG) level=logging.DEBUG)
parser = ArgumentParser(description=description, parser = ArgumentParser(description=description,
#epilog=epilog, # epilog=epilog,
formatter_class=RawTextHelpFormatter) formatter_class=RawTextHelpFormatter)
subparsers = parser.add_subparsers(dest='type') subparsers = parser.add_subparsers(dest='type')
@ -360,7 +364,6 @@ Create manage file based web archive collections
addwarc.add_argument('files', nargs='+') addwarc.add_argument('files', nargs='+')
addwarc.set_defaults(func=do_add) addwarc.set_defaults(func=do_add)
# Reindex All # Reindex All
def do_reindex(r): def do_reindex(r):
m = CollectionsManager(r.coll_name) m = CollectionsManager(r.coll_name)
@ -429,7 +432,7 @@ Create manage file based web archive collections
# special wrapper for cli to avoid printing stack trace # special wrapper for cli to avoid printing stack trace
def main_wrap_exc(): #pragma: no cover def main_wrap_exc(): # pragma: no cover
try: try:
main() main()
except Exception as e: except Exception as e: