|  | 
| 8 | 8 | # The full license is in the file LICENSE, distributed with this software. | 
| 9 | 9 | # ----------------------------------------------------------------------------- | 
| 10 | 10 | 
 | 
|  | 11 | +import click | 
|  | 12 | + | 
| 11 | 13 | from qiita_db.util import ( | 
| 12 |  | -    purge_filepaths, empty_trash_upload_folder, purge_files_from_filesystem) | 
|  | 14 | +    purge_filepaths as qiita_purge_filepaths, | 
|  | 15 | +    empty_trash_upload_folder as qiita_empty_trash_upload_folder, | 
|  | 16 | +    purge_files_from_filesystem as qiita_purge_files_from_filesystem) | 
| 13 | 17 | from qiita_db.meta_util import ( | 
| 14 |  | -    update_redis_stats, generate_biom_and_metadata_release) | 
|  | 18 | +    update_redis_stats as qiita_update_redis_stats, | 
|  | 19 | +    generate_biom_and_metadata_release as | 
|  | 20 | +    qiita_generate_biom_and_metadata_release) | 
| 15 | 21 | 
 | 
| 16 | 22 | 
 | 
| 17 |  | -# This script will perform these jobs: | 
| 18 |  | -# 1. purge_filepaths: remove files from that are leftover in the | 
| 19 |  | -#    qiita.filepath and are present in the filesystem | 
| 20 |  | -# 2. empty_trash_upload_folder: remove files that are present in the trash | 
| 21 |  | -#    of the upload folders | 
| 22 |  | -# 3. update_redis_stats: updates the redis stats information | 
| 23 |  | -# 4. generate public releases of biom tables and metadata | 
| 24 |  | -# | 
| 25 |  | -# Note that is responsability of the Qiita install system admin to add to a | 
| 26 |  | -# cron job this script and responsible to define how often it should run | 
|  | 23 | +@click.group() | 
|  | 24 | +def commands(): | 
|  | 25 | +    pass | 
|  | 26 | + | 
|  | 27 | + | 
|  | 28 | +@commands.command() | 
|  | 29 | +@click.option('--remove/--no-remove', default=True, | 
|  | 30 | +              help='remove any filepaths from the qiita.filepath table that ' | 
|  | 31 | +              'are not linked to any other table') | 
|  | 32 | +def purge_filepaths(remove): | 
|  | 33 | +    qiita_purge_filepaths(remove) | 
|  | 34 | + | 
|  | 35 | + | 
|  | 36 | +@commands.command() | 
|  | 37 | +@click.option('--remove/--no-remove', default=False, | 
|  | 38 | +              help='check the filesystem mounts and remove files not used in ' | 
|  | 39 | +              'the database') | 
|  | 40 | +def purge_files_from_filesystem(remove): | 
|  | 41 | +    qiita_purge_files_from_filesystem(remove) | 
|  | 42 | + | 
|  | 43 | + | 
|  | 44 | +@commands.command() | 
|  | 45 | +@click.option('--remove/--no-remove', default=True, | 
|  | 46 | +              help='remove files from the trash folder within the upload ' | 
|  | 47 | +              'folders') | 
|  | 48 | +def empty_trash_upload_folder(remove): | 
|  | 49 | +    qiita_empty_trash_upload_folder(remove) | 
|  | 50 | + | 
|  | 51 | + | 
|  | 52 | +@commands.command() | 
|  | 53 | +def update_redis_stats(): | 
|  | 54 | +    qiita_update_redis_stats() | 
| 27 | 55 | 
 | 
| 28 | 56 | 
 | 
| 29 |  | -def main(): | 
| 30 |  | -    purge_filepaths(True) | 
| 31 |  | -    purge_files_from_filesystem(False) | 
| 32 |  | -    empty_trash_upload_folder(True) | 
| 33 |  | -    update_redis_stats() | 
| 34 |  | -    generate_biom_and_metadata_release('public') | 
|  | 57 | +@commands.command() | 
|  | 58 | +def generate_biom_and_metadata_release(): | 
|  | 59 | +    qiita_generate_biom_and_metadata_release('public') | 
| 35 | 60 | 
 | 
| 36 | 61 | 
 | 
| 37 | 62 | if __name__ == "__main__": | 
| 38 |  | -    main() | 
|  | 63 | +    commands() | 
0 commit comments