From 81747a5577342391100c6a80805f9af4621cba85 Mon Sep 17 00:00:00 2001 From: UlrichB22 <97119703+UlrichB22@users.noreply.github.com> Date: Mon, 28 Aug 2023 22:15:04 +0200 Subject: [PATCH] Remove import19 from quickinstall, add logging conf example, upd docs. --- docs/admin/index.rst | 8 ++--- docs/admin/install.rst | 2 -- docs/admin/upgrade.rst | 15 ++++---- docs/examples/config/logging/logfile_cli | 43 +++++++++++++++++++++++ quickinstall.py | 26 ++++---------- src/moin/cli/migration/moin19/import19.py | 8 ++--- 6 files changed, 64 insertions(+), 38 deletions(-) create mode 100644 docs/examples/config/logging/logfile_cli diff --git a/docs/admin/index.rst b/docs/admin/index.rst index 4270663a0..54dd8932e 100644 --- a/docs/admin/index.rst +++ b/docs/admin/index.rst @@ -40,11 +40,11 @@ has one parameter - the index directory:: the `temporary location`. -moin index script reference -=========================== -You can use the ``moin index-*`` group of script commands to manage indexes. +moin index subcommand reference +=============================== +You can use the ``moin index-*`` group of cli subcommands to manage indexes. -Many of the script commands for index management support a `--tmp` option to use +Many of the cli commands for index management support a `--tmp` option to use the temporary index location. This is useful if you want to do index operations in parallel to a running wiki which is still using the index at the normal index location. diff --git a/docs/admin/install.rst b/docs/admin/install.rst index 7c16da596..f9b8d9d0d 100644 --- a/docs/admin/install.rst +++ b/docs/admin/install.rst @@ -195,7 +195,6 @@ Typing "./m" (or "m" on Windows) will display a menu similar to: new-wiki create empty wiki sample create wiki and load sample data restore * create wiki and restore wiki/backup.moin *option, specify file - import19 import a moin 1.9 wiki/data instance from run * run built-in wiki server *options (--port 8081) backup * roll 3 prior backups and create new backup *option, specify file @@ -265,7 +264,6 @@ help by reporting bugs), then some logical menu choices are:: ./m docs # create docs, see User tab, Documentation (local) ./m del-wiki # get rid of the sample data ./m new-wiki # create empty wiki or - ./m import19 ... # import moin 1.9 data ./m backup # backup wiki data as needed or as scheduled If you installed moin2 by cloning the repository, diff --git a/docs/admin/upgrade.rst b/docs/admin/upgrade.rst index 51068be54..e8bdb2c43 100644 --- a/docs/admin/upgrade.rst +++ b/docs/admin/upgrade.rst @@ -83,17 +83,18 @@ log for each deleted page. Importing your moin 1.9 data ---------------------------- -Assuming you have no moin2 storage and no index directories created yet, include the --s and -i options to create the storage and an index. +Before importing your existing wiki data please ensure you have created an instance +and index as described in the install section above using commands:: -The import19 argument to the `moin` script will read your 1.9 data_dir (pages, attachments and users), + moin create-instance + moin index-create + +The import19 cli subcommand will read your 1.9 data_dir (pages, attachments and users), convert the data, write it to your moin2 storage and build the index:: - moin import19 -s -i --data_dir //wiki/data 1>import19out.log 2>import19err.log + moin import19 --data_dir //wiki/data -If you use the command as given, it will write all stdout and stderr output into two log files. -Please review them to find out whether the importer had critical issues with your -data. +Please review the logfile to find out whether the importer had critical issues with your data. By default, all items using moin 1.9 markup are converted to moin 2 markup. The converted revision will have a timestamp one second later than the last revision's timestamp to preserve diff --git a/docs/examples/config/logging/logfile_cli b/docs/examples/config/logging/logfile_cli new file mode 100644 index 000000000..00256f0f6 --- /dev/null +++ b/docs/examples/config/logging/logfile_cli @@ -0,0 +1,43 @@ +[DEFAULT] +# Logfile to create. +# Make sure the running moin process has create/write rights there. +logfile=/var/log/moin.cli.log + +# Default loglevel, to adjust verbosity: DEBUG, INFO, WARNING, ERROR, CRITICAL +loglevel=DEBUG + +[loggers] +disable_existing_loggers=1 +keys=root + +[handlers] +keys=logfile,console + +[formatters] +keys=logfile,console + +[logger_root] +level=%(loglevel)s +propagate=0 +handlers=logfile,console + +[handler_logfile] +class=FileHandler +formatter=logfile +level=%(loglevel)s +args=('%(logfile)s', 'a') + +[handler_console] +class=StreamHandler +level=INFO +formatter=console +args=(sys.stdout,) + +[formatter_logfile] +format=%(asctime)s %(levelname)s %(name)s:%(lineno)d %(message)s +datefmt= +class=logging.Formatter + +[formatter_console] +format=%(asctime)s %(levelname)s %(message)s + diff --git a/quickinstall.py b/quickinstall.py index bc8dcbdbc..2da31d77b 100755 --- a/quickinstall.py +++ b/quickinstall.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 # Copyright: 2013 MoinMoin:BastianBlank # Copyright: 2013-2018 MoinMoin:RogerHaase +# Copyright: 2023 MoinMoin:UlrichB # License: GNU GPL v2 (or any later version), see LICENSE.txt for details. """ Create a virtual environment and install moin2 and all requirements in development mode. @@ -112,8 +113,6 @@ new-wiki create empty wiki sample create wiki and load sample data restore * create wiki and restore wiki/backup.moin *option, specify file -import19 import a moin1.9 wiki/data instance from with - where = "--markup_out moinwiki" or markdown,rst,html,... run * run built-in wiki server *options (--port 8081) backup * roll 3 prior backups and create new backup *option, specify file @@ -344,7 +343,7 @@ def log_help(logs): def cmd_new_wiki(self, *args): """create empty wiki""" - command = 'moin index-create -s -i' + command = 'moin index-create' print('Creating a new empty wiki...') make_wiki(command) # share code with loading sample data and restoring backups @@ -354,7 +353,7 @@ def cmd_sample(self): def cmd_restore(self, *args): """create wiki and load data from wiki/backup.moin or user specified path""" - command = 'moin index-create -s -i{0} moin load --file %s{0} moin index-build'.format(SEP) + command = 'moin index-create{0} moin load --file %s{0} moin index-build'.format(SEP) filename = BACKUP_FILENAME if args: filename = args[0] @@ -367,26 +366,13 @@ def cmd_restore(self, *args): self.run_time('Restore') def cmd_import19(self, *args): - """import a moin 1.9 wiki directory named dir""" - if args: - dirname = args[0] - if os.path.isdir(dirname): - command = 'moin import19 -s -i --data_dir {0}'.format(dirname) - if len(args) > 1: - # expect "--markup markdown" or ? - command += ' ' + ' '.join(args[1:]) - print('Creating a new wiki populated with data from {0}...'.format(dirname)) - make_wiki(command) - else: - print('Error: cannot create wiki because {0} does not exist.'.format(dirname)) - else: - print('Error: a path to the Moin 1.9 wiki/data data directory is required.') - self.run_time('Import19') + """import a moin 1.9 wiki""" + print("Error: Subcommand import19 not supported. Please use 'moin import19'.") def cmd_index(self, *args): """delete and rebuild index""" if wiki_exists(): - command = 'moin index-create -i{0} moin index-build'.format(SEP) + command = 'moin index-create{0} moin index-build'.format(SEP) print('Rebuilding indexes...') try: with open(INDEX, 'w') as messages: diff --git a/src/moin/cli/migration/moin19/import19.py b/src/moin/cli/migration/moin19/import19.py index ec6679eec..c98b5fc80 100644 --- a/src/moin/cli/migration/moin19/import19.py +++ b/src/moin/cli/migration/moin19/import19.py @@ -88,9 +88,9 @@ def cli(): def migr_logging(msg_id, log_msg): ''' - logging function writes first messages of each type with warning level - and the rest with debug level only. - TODO: add example of logging.conf + The logging function writes the first messages of each type + with warning level and the rest with debug level only. + See docs/examples/config/logging/logfile_cli for logging configuration example ''' migr_stat[msg_id] += 1 if migr_stat[msg_id] < migr_warn_max: @@ -531,8 +531,6 @@ def process_categories(meta, data, item_category_regex): # unexpected text before and after categories survives, any text between categories is deleted start = matches[0].start() end = matches[-1].end() - # TODO: remove these comment lines - # print(' Converted Categories to Tags: {0}'.format(tags)) rest = categories[:start] + categories[end:] data += '\r\n' + rest.lstrip() data = data.rstrip() + '\r\n'