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 "branch_fedora": "BranchFedoraCommand",
27 "comment_chroot": "CommentChrootCommand",
28
29
30 "alter_user": "AlterUserCommand",
31 "add_user": "AddUserCommand",
32 "dump_user": "DumpUserCommand",
33
34
35 "update_indexes": "UpdateIndexesCommand",
36 "update_indexes_quick": "UpdateIndexesQuickCommand",
37 "update_indexes_required": "UpdateIndexesRequiredCommand",
38
39
40 "get_admins": "GetAdminsCommand",
41 "fail_build": "FailBuildCommand",
42 "rawhide_to_release": "RawhideToReleaseCommand",
43 "backend_rawhide_to_release": "BackendRawhideToReleaseCommand",
44 "update_graphs": "UpdateGraphsDataCommand",
45 "vacuum_graphs": "RemoveGraphsDataCommand",
46 "notify_outdated_chroots": "NotifyOutdatedChrootsCommand",
47 "delete_outdated_chroots": "DeleteOutdatedChrootsCommand",
48 "clean_expired_projects": "CleanExpiredProjectsCommand",
49 "clean_old_builds": "DeleteOldBuilds",
50 "delete_orphans": "DeleteOrphansCommand",
51 }
52
53 if os.getuid() == 0:
54 sys.stderr.write("Please don't run this script as a 'root' user, use:\n")
55 sys.stderr.write("$ sudo -u copr-fe {}\n".format(
56 ' '.join([pipes.quote(arg) for arg in sys.argv])))
57 sys.exit(1)
58
59 manager = Manager(app)
60 for cmdname, clsname in commands.items():
61 module = importlib.import_module("commands.{0}".format(cmdname))
62 cls = getattr(module, clsname)
63 manager.add_command(cmdname, cls())
64
65
66 if __name__ == "__main__":
67 manager.run()
68