1
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
14 "test": "TestCommand",
15
16
17 "create_sqlite_file": "CreateSqliteFileCommand",
18 "create_db": "CreateDBCommand",
19 "drop_db": "DropDBCommand",
20
21
22 "create_chroot": "CreateChrootCommand",
23 "alter_chroot": "AlterChrootCommand",
24 "display_chroots": "DisplayChrootsCommand",
25 "drop_chroot": "DropChrootCommand",
26
27
28 "alter_user": "AlterUserCommand",
29 "add_user": "AddUserCommand",
30 "dump_user": "DumpUserCommand",
31
32
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 "delete_orphans": "DeleteOrphansCommand",
46 }
47
48 if os.getuid() == 0:
49 sys.stderr.write("Please don't run this script as a 'root' user, use:\n")
50 sys.stderr.write("$ sudo -u copr-fe {}\n".format(
51 ' '.join([pipes.quote(arg) for arg in sys.argv])))
52 sys.exit(1)
53
54 manager = Manager(app)
55 for cmdname, clsname in commands.items():
56 module = importlib.import_module("commands.{0}".format(cmdname))
57 cls = getattr(module, clsname)
58 manager.add_command(cmdname, cls())
59
60
61 if __name__ == "__main__":
62 manager.run()
63