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 pipes 
 7  import importlib 
 8  from flask_script import Manager 
 9  from coprs import app 
10   
11   
12  commands = { 
13      # General commands 
14      "test": "TestCommand", 
15   
16      # Database commands 
17      "create_sqlite_file": "CreateSqliteFileCommand", 
18      "create_db": "CreateDBCommand", 
19      "drop_db": "DropDBCommand", 
20   
21      # Chroot commands 
22      "create_chroot": "CreateChrootCommand", 
23      "alter_chroot": "AlterChrootCommand", 
24      "display_chroots": "DisplayChrootsCommand", 
25      "drop_chroot": "DropChrootCommand", 
26   
27      # User commands 
28      "alter_user": "AlterUserCommand", 
29      "add_user": "AddUserCommand", 
30      "dump_user": "DumpUserCommand", 
31   
32      # Other 
33      "get_admins": "GetAdminsCommand", 
34      "fail_build": "FailBuildCommand", 
35      "update_indexes": "UpdateIndexesCommand", 
36      "update_indexes_quick": "UpdateIndexesQuickCommand", 
37      "rawhide_to_release": "RawhideToReleaseCommand", 
38      "backend_rawhide_to_release": "BackendRawhideToReleaseCommand", 
39      "update_graphs": "UpdateGraphsDataCommand", 
40      "vacuum_graphs": "RemoveGraphsDataCommand", 
41      "notify_outdated_chroots": "NotifyOutdatedChrootsCommand", 
42      "delete_outdated_chroots": "DeleteOutdatedChrootsCommand", 
43      "clean_expired_projects": "CleanExpiredProjectsCommand", 
44      "clean_old_builds": "DeleteOldBuilds", 
45  } 
46   
47  if os.getuid() == 0: 
48      sys.stderr.write("Please don't run this script as a 'root' user, use:\n") 
49      sys.stderr.write("$ sudo -u copr-fe {}\n".format( 
50              ' '.join([pipes.quote(arg) for arg in sys.argv]))) 
51      sys.exit(1) 
52   
53  manager = Manager(app) 
54  for cmdname, clsname in commands.items(): 
55      module = importlib.import_module("commands.{0}".format(cmdname)) 
56      cls = getattr(module, clsname) 
57      manager.add_command(cmdname, cls()) 
58   
59   
60  if __name__ == "__main__": 
61      manager.run() 
62