Module manage
[hide private]
[frames] | no frames]

Source Code for Module manage

  1  #!/usr/bin/python3 
  2   
  3   
  4  import os 
  5  import sys 
  6  import copy 
  7  import pipes 
  8  import importlib 
  9  import click 
 10  from commands.flask3_wrapper import get_flask_wrapper_command 
 11  import commands.test 
 12  import commands.create_sqlite_file 
 13  import commands.create_db 
 14  import commands.drop_db 
 15  import commands.create_chroot 
 16  import commands.alter_chroot 
 17  import commands.display_chroots 
 18  import commands.drop_chroot 
 19  import commands.branch_fedora 
 20  import commands.comment_chroot 
 21  import commands.alter_user 
 22  import commands.add_user 
 23  import commands.dump_user 
 24  import commands.update_indexes 
 25  import commands.update_indexes_quick 
 26  import commands.update_indexes_required 
 27  import commands.get_admins 
 28  import commands.fail_build 
 29  import commands.rawhide_to_release 
 30  import commands.update_graphs 
 31  import commands.vacuum_graphs 
 32  import commands.notify_outdated_chroots 
 33  import commands.delete_outdated_chroots 
 34  import commands.clean_expired_projects 
 35  import commands.clean_old_builds 
 36  import commands.delete_orphans 
 37   
 38  from flask_script import Manager 
 39  from coprs import app 
 40   
 41  if os.getuid() == 0: 
 42      sys.stderr.write("Please don't run this script as a 'root' user, use:\n") 
 43      sys.stderr.write("$ sudo -u copr-fe {}\n".format( 
 44              ' '.join([pipes.quote(arg) for arg in sys.argv]))) 
 45      sys.exit(1) 
 46   
 47  commands_list = [ 
 48      # General commands 
 49      "test", 
 50   
 51      # Database commands 
 52      "create_sqlite_file", 
 53      "create_db", 
 54      "drop_db", 
 55   
 56      # Chroot commands 
 57      "create_chroot", 
 58      "alter_chroot", 
 59      "display_chroots", 
 60      "drop_chroot", 
 61      "branch_fedora", 
 62      "comment_chroot", 
 63   
 64      # User commands 
 65      "alter_user", 
 66      "add_user", 
 67      "dump_user", 
 68   
 69      # Whooshee indexes 
 70      "update_indexes", 
 71      "update_indexes_quick", 
 72      "update_indexes_required", 
 73   
 74      # Other 
 75      "get_admins", 
 76      "fail_build", 
 77      "rawhide_to_release", 
 78      "update_graphs", 
 79      "vacuum_graphs", 
 80      "notify_outdated_chroots", 
 81      "delete_outdated_chroots", 
 82      "clean_expired_projects", 
 83      "clean_old_builds", 
 84      "delete_orphans", 
 85  ] 
 86   
 87  for command in commands_list: 
 88      cmd_obj = getattr(getattr(commands, command), command) 
 89   
 90      # Add underscored commands, e.g. 'add_user' for 'add-user' for compatibility 
 91      # reasons.  TODO: we can drop this once we have the deployment scripts fixed 
 92      # to use the dash-variant commands. 
 93      if '_' in command and hasattr(cmd_obj, 'hidden'): 
 94          # hidden option is available on f30+ only (click v7.0) 
 95          alias = copy.deepcopy(cmd_obj) 
 96          alias.hidden = True 
 97          app.cli.add_command(alias, command) 
 98   
 99      app.cli.add_command(cmd_obj) 
100   
101   
102  app.cli.add_command(get_flask_wrapper_command('runserver')) 
103  app.cli.add_command(get_flask_wrapper_command('run')) 
104  app.cli.add_command(get_flask_wrapper_command('shell')) 
105   
106  if __name__ == "__main__": 
107      app.cli() 
108