mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-11-14 12:33:41 +00:00
Compare commits
657 Commits
2.15.3
...
499efb9dbc
| Author | SHA1 | Date | |
|---|---|---|---|
| 499efb9dbc | |||
| 910d178c71 | |||
| 1e7d4daf18 | |||
| 7bc4810377 | |||
| aa66e76db7 | |||
| e0f9e38f44 | |||
| d6cdb5bea5 | |||
| 6d157ca809 | |||
| 5486ae4a19 | |||
| 8bdf420cdc | |||
| 2deca6d715 | |||
| 180adf3f33 | |||
| 634054926d | |||
| 53baaac61e | |||
| d2a93a94e3 | |||
| 7134aea125 | |||
| 740d537618 | |||
| 9f78e79f1f | |||
| 09456141f5 | |||
| 9e30e98e90 | |||
| df2e98a1d3 | |||
| 24993047c6 | |||
| b20e844cc9 | |||
| ce75ccb405 | |||
| 1acff852d0 | |||
| 62320e8ec6 | |||
| 1089bab526 | |||
| 0e0012a6e0 | |||
| fbbb80d091 | |||
| 5316427371 | |||
| 0fa748f302 | |||
| 7a3d32dcfa | |||
| a396126a79 | |||
| 9785835c0e | |||
| c4f4e37731 | |||
| f43ee2fd1d | |||
| f7a50e5294 | |||
| ddd3c3f06f | |||
| 242f3d4d34 | |||
| 303f9ff03c | |||
| 65fac09d8d | |||
| aaf7adbac1 | |||
| 9e011990ee | |||
| 529d4caa0e | |||
| d7c4fccf98 | |||
| 1e30838be4 | |||
| d57276f214 | |||
| 31e59df2c8 | |||
| 23cd843e44 | |||
| c08a292070 | |||
| 5163aa4dca | |||
| 69f0966ff1 | |||
| 16308dc3ae | |||
| 962599e937 | |||
| 758a81e3db | |||
| 84942e3c98 | |||
| 6f8b1509d7 | |||
| b4372ff583 | |||
| 41fc7bffbb | |||
| 300f5026c4 | |||
| 10aa91a033 | |||
| 4169851eaa | |||
| 4d9e06156d | |||
| af2269c64a | |||
| f44fa19c42 | |||
| fd3c6343f1 | |||
| 9edff2826f | |||
| b38ecfb35c | |||
| 3c7c748b4a | |||
| 434057ec49 | |||
| a01b090c2b | |||
| 8ffc1299f0 | |||
| 02b13de7f4 | |||
| 50a045434d | |||
| 7bbe3242d4 | |||
| a9cb357182 | |||
| feec9141b2 | |||
| 148ef09e70 | |||
| 5ff635db70 | |||
| 9df5820bce | |||
| b7d3493ae3 | |||
| f8b725d175 | |||
| 46b3c82aca | |||
| 0d34432c9a | |||
| 3cd9cff4ee | |||
| 9e02d7a38f | |||
| 9819ed761e | |||
| 99ca0cb2fd | |||
| ea3cb6e766 | |||
| 0ae4941321 | |||
| 855b55237b | |||
| 59d14665a5 | |||
| 414eb93b1e | |||
| 14721913a4 | |||
| f68e48fb47 | |||
| 77cceb4c10 | |||
| eca22fdaed | |||
| 719af3676e | |||
| 6c63ad6df5 | |||
| 497a115535 | |||
| 91598951c5 | |||
| f364e00bea | |||
| 87c87d6455 | |||
| 265de3dc72 | |||
| d06c02a1c7 | |||
| 29bb6284b0 | |||
| 70b7fcf47a | |||
| 706808fc97 | |||
| 7e5f21c26d | |||
| 9a7f55605a | |||
| 6085e88f5e | |||
| 56e97040d6 | |||
| 9510a14b90 | |||
| 6eeef39fe5 | |||
| 0e6434faad | |||
| 768132bb6c | |||
| f1095fe007 | |||
| 1af04448c9 | |||
| aad607eaef | |||
| 3347212bf2 | |||
| f3e9fbf9d0 | |||
| c3dacd6883 | |||
| 624b4619f1 | |||
| 215fe7a592 | |||
| dd8d5d130b | |||
| b4fa10781b | |||
| f6cdd806b2 | |||
| cf9a1e7bec | |||
| 1b93f4f5e0 | |||
| a872ecfc23 | |||
| c130f52163 | |||
| 5fb93bd331 | |||
| 58e702213d | |||
| e784032bc6 | |||
| c54b14b833 | |||
| e61b246216 | |||
| 2a9eab5f1a | |||
| acc204de6d | |||
| 0991dbb59c | |||
| 18d17d4d52 | |||
| de7184fc3a | |||
| 2d21c999d1 | |||
| ff78577d61 | |||
| eb6eda578c | |||
| e823fd3f27 | |||
| e4a857dad0 | |||
| fc8f6c2985 | |||
| bb6414f9d4 | |||
| 064ac6811c | |||
| 7d16142b3b | |||
| 69a79a2e64 | |||
| 5b4bff9c93 | |||
| 3f8b9eaed6 | |||
| deab8ddae6 | |||
| eacb6ec729 | |||
| dc2eebce39 | |||
| 6b755b4828 | |||
| a73341e885 | |||
| 969aa78c95 | |||
| df787657aa | |||
| eec94521a7 | |||
| b18000c777 | |||
| dbaff5f981 | |||
| ae84ca0c56 | |||
| 8f047f9a96 | |||
| 54bd016c17 | |||
| 42f77742f8 | |||
| 46bb9c95d0 | |||
| 5dd4763a80 | |||
| 45eba6a6e3 | |||
| 4c1d0abb85 | |||
| 1e00bf9398 | |||
| bf9a46936c | |||
| a0b17981e3 | |||
| c440f5bbd5 | |||
| 8ff567cac3 | |||
| 9fe760efdf | |||
| bc9682373d | |||
| aedcbf1985 | |||
| 26b991bf47 | |||
| 8bf422b02a | |||
| 0c920832c9 | |||
| bef8d33570 | |||
| b540ced77f | |||
| 723b6971dd | |||
| 59356e905a | |||
| 99eecdebf3 | |||
| 5e42dd4e70 | |||
| 4ec7e2d129 | |||
| 9a521af078 | |||
| d1132b49fc | |||
| 2c21ae26c3 | |||
| bba90b3eb8 | |||
| 3cac53ac11 | |||
| 9fa6722eaa | |||
| 1d4ed0e0c3 | |||
| 2cda4a2469 | |||
| 9406537a15 | |||
| 598af7d9db | |||
| 6530afbfc7 | |||
| ad1c0051c4 | |||
| 5b172ad20b | |||
| 42fccb76ef | |||
| c37f67c558 | |||
| 89d9b581bd | |||
| 116dc0b329 | |||
| e3ed36fafd | |||
| 573ade4ba5 | |||
| 9259d9c727 | |||
| c863ee063c | |||
| 480c3a54b8 | |||
| 3b3ef43863 | |||
| 368db86dde | |||
| adf6a0a952 | |||
| 575a618096 | |||
| 2c03354d4a | |||
| 4008aa2e0a | |||
| 9cb39f6767 | |||
| c7de182f3d | |||
| d21c3fdf9f | |||
| 9f2fe219c8 | |||
| ad570aae0f | |||
| 116b65d92a | |||
| 5e5171cf3e | |||
| af3360e84a | |||
| 95f52f7ebe | |||
| f5fe200247 | |||
| a1c12200b8 | |||
| 09839f755a | |||
| fcd4d60cad | |||
| 3681473942 | |||
| 4dd5a1e82e | |||
| cbd1d3d5b8 | |||
| e3347aec2d | |||
| 3ad6cd27c6 | |||
| 54a68279be | |||
| d99091a3b4 | |||
| be6cf5b8af | |||
| 91e548569d | |||
| 6c3b2ef266 | |||
| 785607c70b | |||
| d22a3152db | |||
| adb5b58a1d | |||
| 8b2601beaa | |||
| 9116a4370e | |||
| da93fdc77a | |||
| 8bbd643551 | |||
| 6834dd442c | |||
| d23e3cbbea | |||
| 6bc6bdaeae | |||
| 7458c73c7d | |||
| 2cecbb3d53 | |||
| c73a6c7bae | |||
| 0b70b5af45 | |||
| fde75a14c2 | |||
| 1e0d1a5a32 | |||
| 75919637e8 | |||
| 467d109cfc | |||
| a131c77699 | |||
| 10fbc31d2a | |||
| 7e0d12b8b1 | |||
| 7ab00ee579 | |||
| 2d62148ee6 | |||
| c1f2d5ff4a | |||
| 2888649ced | |||
| 63855f5964 | |||
| 8bf665d7d3 | |||
| a7ac77ce4d | |||
| fc01bf3d1c | |||
| d81e91e117 | |||
| 57f62ba163 | |||
| ded896ee1b | |||
| 1fdcea0524 | |||
| a93f43dcd0 | |||
| 20974dae6f | |||
| cbcfff27b8 | |||
| 96f394bab0 | |||
| aae3c82f3d | |||
| ab9e1fb1bd | |||
| 82322f7a6c | |||
| 125da217d3 | |||
| d113c65c81 | |||
| 050041b2de | |||
| e0ed636d7e | |||
| 61feb2ebc7 | |||
| da1c6b0101 | |||
| c1718b3862 | |||
| 34fe8128aa | |||
| a78c48ed4d | |||
| e368396653 | |||
| f4abd83568 | |||
| e6888ba788 | |||
| a78050c1bf | |||
| 93876307f8 | |||
| 4d482520cd | |||
| 461fbd40ce | |||
| 419da3db89 | |||
| 00ca06ffab | |||
| 5a05c8ce91 | |||
| b09aea13af | |||
| 04a52f759d | |||
| ef6cf0f00b | |||
| ab650b7417 | |||
| 7ca5b3a363 | |||
| 666fa98075 | |||
| 684ef33dbc | |||
| cf35addaa5 | |||
| 11732a8609 | |||
| 64cc8fd6b0 | |||
| 4202751e9c | |||
| 41515f6c95 | |||
| ac92b506e0 | |||
| 5bbd1ad9a9 | |||
| 541d8d9b39 | |||
| e41dd09a8a | |||
| 8e65263b90 | |||
| afc488255c | |||
| effc120a43 | |||
| 4b27e102ef | |||
| e0126bb811 | |||
| 8c04dc4c2a | |||
| 83e9d7c523 | |||
| 9be4a89c08 | |||
| 0f8596db1e | |||
| c403c45d72 | |||
| 00dbd90953 | |||
| 3e299d9685 | |||
| e20637f7ad | |||
| 5a09d46f9a | |||
| 90be3276dd | |||
| a4f646eb2a | |||
| ebd06cb443 | |||
| fe66c6c45c | |||
| bba58352e0 | |||
| 41cc58ed31 | |||
| 20e45845ba | |||
| 9fa1fa108f | |||
| 577bd9e5f8 | |||
| 20b9c1fa4a | |||
| a7c9183aa0 | |||
| 9e0dd3ae97 | |||
| f4e4e88e82 | |||
| 2684e4b3f4 | |||
| 45f5006db3 | |||
| b26aa2145f | |||
| 4462eba860 | |||
| f2c23bad17 | |||
| 1603086b96 | |||
| b6f6ee8c76 | |||
| b71d1f6e3d | |||
| 7883746e53 | |||
| ae9118654d | |||
| 81fa73f725 | |||
| 14cb548c3b | |||
| 2eb93a6090 | |||
| dd6ef38c99 | |||
| 415dc42313 | |||
| 3e1af17796 | |||
| 880cebe54f | |||
| cbcc796a3a | |||
| dc8a52f6c0 | |||
| 34c93e53cc | |||
| f7ec24523b | |||
| f817b32976 | |||
| 9fc2b681d4 | |||
| 59ff0589ab | |||
| 1b53de6f2b | |||
| 41080c5ff8 | |||
| 791ce4f242 | |||
| b75bd30658 | |||
| b3b3cad706 | |||
| 82b932371b | |||
| 45fb2f3c46 | |||
| 4a5b9d9fa1 | |||
| 2f8316ecb0 | |||
| 77ad35fce8 | |||
| 48da4646cf | |||
| 3d98dd267a | |||
| 09678a3ae1 | |||
| 8e2732f6fe | |||
| 73e311a41c | |||
| 1e8388af5d | |||
| c1d74726b7 | |||
| f2ddcc6d23 | |||
| a5ce6b78dd | |||
| 1a83dd6f5a | |||
| 16a33f7729 | |||
| fb21b1da53 | |||
| 8394004943 | |||
| 75c6bf6119 | |||
| 7e20ff5184 | |||
| 757614f5a0 | |||
| 43166e5f94 | |||
| 43696b9920 | |||
| 8befee58fe | |||
| 9d016f51b5 | |||
| c5fbccd519 | |||
| eae5748a30 | |||
| 695ef708b6 | |||
| 26408e82c0 | |||
| 7b647a9b5a | |||
| fac228d6c6 | |||
| eb5ac5a52b | |||
| 047925dcfe | |||
| b8d2775050 | |||
| bf959ceb5f | |||
| 945b6d0ac0 | |||
| 5df9f30e37 | |||
| 1ea3911531 | |||
| d7966e419d | |||
| 3a5268993e | |||
| ad84895e18 | |||
| b1dfafe275 | |||
| 375f9fcfb7 | |||
| 04dcaa93ab | |||
| f42c2c57fb | |||
| dc3562a4ec | |||
| dda94f8f9e | |||
| 709db6a5ed | |||
| 89a2d8e298 | |||
| b9cd98235e | |||
| 1905360f8f | |||
| a7018d9f7d | |||
| 73057bc08d | |||
| 7f87863734 | |||
| 2dac5a2520 | |||
| 720edc24ba | |||
| fe9711d24f | |||
| c73a2a4aa9 | |||
| 571f720ae2 | |||
| 5030395025 | |||
| 03633d47ea | |||
| 1a575d6db8 | |||
| cdc018ad07 | |||
| f806c8918e | |||
| 4daff81d5f | |||
| 06bd29b78d | |||
| c67ac3730c | |||
| c094d4ee79 | |||
| 3cb479ba4b | |||
| 307a7f4a71 | |||
| 25734876de | |||
| 53df735eb2 | |||
| fb7275f9dd | |||
| f01af5f54a | |||
| 1abe8d291f | |||
| 1a83e55d64 | |||
| b8e17c4879 | |||
| bee41dcc55 | |||
| 9f7995fb2f | |||
| 9ce1c36f35 | |||
| 4990ce4198 | |||
| 8f18ead4cc | |||
| 7ea50887a4 | |||
| 97ec5bfa41 | |||
| 5fcc15191a | |||
| c5f086a7c6 | |||
| 432ca0cc48 | |||
| 1a0322b32e | |||
| fc086c0d87 | |||
| d5503b22ba | |||
| a132b1544a | |||
| 63acae4b1c | |||
| 8e6473d2a0 | |||
| fdcbcc4541 | |||
| 83931f5cf4 | |||
| d4eadf0013 | |||
| 04174a3e6d | |||
| 041b3824c1 | |||
| a11cce43ff | |||
| 1388df9a7e | |||
| 6ee1c8ef5a | |||
| a7c6d95b34 | |||
| 060c7412b1 | |||
| 93406483fe | |||
| 046febc440 | |||
| 9964a96296 | |||
| 9529525cb5 | |||
| fa4c1c6205 | |||
| f9b1d89756 | |||
| 9197b416e6 | |||
| f54a2fe740 | |||
| d1f990eac8 | |||
| 1e85c1db70 | |||
| 32aaa4a1f8 | |||
| a9e20f0958 | |||
| 32b129a806 | |||
| 2752e68ade | |||
| 5b678149dc | |||
| 79e1cff421 | |||
| 2e07de4a12 | |||
| 7e3ef889e8 | |||
| 52b54a9d05 | |||
| c0f7f81050 | |||
| 38af344bde | |||
| 62496478ae | |||
| ce48169aad | |||
| 21845bc934 | |||
| 249003de0a | |||
| d8704e9c75 | |||
| 0a8b172e9c | |||
| 7d782f120d | |||
| 9057ecf67a | |||
| 35df354c14 | |||
| 4d4e5e9dde | |||
| ff24188ca1 | |||
| 9d4f85624d | |||
| 295f810222 | |||
| d8523bd83b | |||
| be017ed102 | |||
| c73f24f8c6 | |||
| 0d806e3471 | |||
| 20962f0385 | |||
| fd38dfd176 | |||
| 5f7f58041d | |||
| 233b1f7f39 | |||
| a83f1d5aa5 | |||
| be09c04e78 | |||
| bfbbb987ad | |||
| 04f365f1a6 | |||
| 86bd49ed1b | |||
| f6ad609616 | |||
| 2f5790f69f | |||
| faaf72a840 | |||
| ef44895b0d | |||
| 5cfffbcd46 | |||
| 3e0058620b | |||
| e897e2cde2 | |||
| edef4944f6 | |||
| a4eaf87116 | |||
| 1192f12f91 | |||
| 444da87fdc | |||
| 6be6614e6d | |||
| 8add507957 | |||
| af5363d158 | |||
| d60c553ea2 | |||
| 5a6d0e0000 | |||
| 427ba0f0ea | |||
| 266d2bd77d | |||
| f333e89bd1 | |||
| 659db071a1 | |||
| 56c642e2a9 | |||
| 845bc9b5e8 | |||
| 57f45fdc89 | |||
| ba483173af | |||
| 6d1f641e50 | |||
| 0cf7756ec4 | |||
| b561bcc25d | |||
| 25d76b0482 | |||
| d2fe4b044f | |||
| 22272167e6 | |||
| 38dce8c0fe | |||
| 68aa327670 | |||
| 04f6af58d9 | |||
| 41c8f4c35f | |||
| 168b2f6880 | |||
| 14e8eee986 | |||
| 88c8c929dc | |||
| 5bb244cbe8 | |||
| f3fd0780fb | |||
| 11c03a9041 | |||
| 214f319123 | |||
| cfbc9d3267 | |||
| 0f4c89145b | |||
| 49a05d0520 | |||
| 19d1e17727 | |||
| d7bf647493 | |||
| 19ba2ba8e5 | |||
| f49894107a | |||
| 233ba9c415 | |||
| b7cff0a19d | |||
| 60b94b9ac0 | |||
| 284f449225 | |||
| d18df0935e | |||
| c15cc4b853 | |||
| fc67778e89 | |||
| 39ac9d4e1f | |||
| bc923b0e8f | |||
| 2842e40bf7 | |||
| 343768e015 | |||
| 8f55cc600e | |||
| c757554148 | |||
| 899603e4b9 | |||
| f488105fd2 | |||
| 2e89b9483f | |||
| d3a00e1937 | |||
| d9b4015be5 | |||
| c6b550761b | |||
| 0129ec39ec | |||
| 62661c9fb1 | |||
| 78636c2035 | |||
| 47c4e5bb42 | |||
| d548fa02f0 | |||
| b5c6c286f7 | |||
| aad599be67 | |||
| f8ff2cbf5b | |||
| dad3f418ad | |||
| c455bd34ce | |||
| 69b319d39a | |||
| 33cfa8fef8 | |||
| 9d37e3ae23 | |||
| 2eb2d3a70a | |||
| 46389b87e7 | |||
| 856a94ff00 | |||
| a0e6009876 | |||
| f2b39fe439 | |||
| 213b2c65a0 | |||
| a416214e5f | |||
| e5966c497f | |||
| fbccb1394d | |||
| 01887ec44b | |||
| 4d4ddffa8f | |||
| 4729c0ea5f | |||
| 035a23a8de | |||
| 0d37ce5095 | |||
| 70465b5044 | |||
| 81afa23d98 | |||
| 1b979725a3 | |||
| c2c7ee6292 | |||
| a3fe361596 | |||
| 20d13f1c10 | |||
| 6c96c9e73a | |||
| 9b08b0694e | |||
| fcb892f39f | |||
| 1785b0470f | |||
| c04f940ad3 | |||
| 207da4caa7 | |||
| cad85b0f20 | |||
| 3e8e54857f | |||
| 6470b13511 | |||
| 4e08297311 | |||
| 32c3c52874 | |||
| e637a647c5 | |||
| e21b990777 | |||
| c0be7f7a17 | |||
| 612cb2fa22 | |||
| cf276f2398 | |||
| 4ca2348f0d | |||
| eb02e1e62b | |||
| 8d7d508bb2 | |||
| a875225b78 | |||
| 5449dec32a | |||
| eb7f3b2484 | |||
| e87402fdde | |||
| 3996055f56 | |||
| 74fc283078 | |||
| eb92f75384 | |||
| 63529633ec | |||
| 930b47c704 | |||
| a89888769f | |||
| b6bc1b77dc | |||
| 4a462502e7 | |||
| f383b04754 | |||
| d744fe1647 | |||
| 6f1b37c4cb | |||
| 5cb3fd5853 | |||
| 60b8477cde |
@ -4,6 +4,8 @@ build:
|
|||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
tools:
|
tools:
|
||||||
python: "3.12"
|
python: "3.12"
|
||||||
|
apt_packages:
|
||||||
|
- graphviz
|
||||||
|
|
||||||
python:
|
python:
|
||||||
install:
|
install:
|
||||||
|
|||||||
1820
docs/_static/architecture.dot
vendored
Normal file
1820
docs/_static/architecture.dot
vendored
Normal file
File diff suppressed because it is too large
Load Diff
11901
docs/_static/architecture.svg
vendored
11901
docs/_static/architecture.svg
vendored
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 1.3 MiB |
@ -36,6 +36,14 @@ ahriman.application.handlers.clean module
|
|||||||
:no-undoc-members:
|
:no-undoc-members:
|
||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
|
||||||
|
ahriman.application.handlers.copy module
|
||||||
|
----------------------------------------
|
||||||
|
|
||||||
|
.. automodule:: ahriman.application.handlers.copy
|
||||||
|
:members:
|
||||||
|
:no-undoc-members:
|
||||||
|
:show-inheritance:
|
||||||
|
|
||||||
ahriman.application.handlers.daemon module
|
ahriman.application.handlers.daemon module
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -36,6 +36,14 @@ ahriman.core.exceptions module
|
|||||||
:no-undoc-members:
|
:no-undoc-members:
|
||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
|
||||||
|
ahriman.core.module\_loader module
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
.. automodule:: ahriman.core.module_loader
|
||||||
|
:members:
|
||||||
|
:no-undoc-members:
|
||||||
|
:show-inheritance:
|
||||||
|
|
||||||
ahriman.core.spawn module
|
ahriman.core.spawn module
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
|
|||||||
@ -12,14 +12,13 @@ Packages have strict rules of importing:
|
|||||||
|
|
||||||
Full dependency diagram:
|
Full dependency diagram:
|
||||||
|
|
||||||
.. image:: _static/architecture.svg
|
.. graphviz:: _static/architecture.dot
|
||||||
:target: _static/architecture.svg
|
|
||||||
:alt: architecture
|
:alt: architecture
|
||||||
|
|
||||||
``ahriman.application`` package
|
``ahriman.application`` package
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
This package contains application (aka executable) related classes and everything for it. It also contains package called ``ahriman.application.handlers`` in which all available subcommands are described as separated classes derived from the base ``ahriman.application.handlers.Handler`` class.
|
This package contains application (aka executable) related classes and everything for it. It also contains package called ``ahriman.application.handlers`` in which all available subcommands are described as separated classes derived from the base ``ahriman.application.handlers.handler.Handler`` class.
|
||||||
|
|
||||||
``ahriman.application.application.Application`` (god class) is used for any interaction from parsers with repository. It is divided into multiple traits by functions (package related and repository related) in the same package.
|
``ahriman.application.application.Application`` (god class) is used for any interaction from parsers with repository. It is divided into multiple traits by functions (package related and repository related) in the same package.
|
||||||
|
|
||||||
|
|||||||
16
docs/conf.py
16
docs/conf.py
@ -10,7 +10,7 @@
|
|||||||
# add these directories to sys.path here. If the directory is relative to the
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
#
|
#
|
||||||
import os
|
import datetime
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -21,13 +21,11 @@ from ahriman import __version__
|
|||||||
basedir = Path(__file__).resolve().parent.parent / "src"
|
basedir = Path(__file__).resolve().parent.parent / "src"
|
||||||
sys.path.insert(0, str(basedir))
|
sys.path.insert(0, str(basedir))
|
||||||
|
|
||||||
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
|
|
||||||
|
|
||||||
|
|
||||||
# -- Project information -----------------------------------------------------
|
# -- Project information -----------------------------------------------------
|
||||||
|
|
||||||
project = "ahriman"
|
project = "ahriman"
|
||||||
copyright = "2021-2023, ahriman team"
|
copyright = f"2021-{datetime.date.today().year}, ahriman team"
|
||||||
author = "ahriman team"
|
author = "ahriman team"
|
||||||
|
|
||||||
# The full version, including alpha/beta/rc tags
|
# The full version, including alpha/beta/rc tags
|
||||||
@ -41,6 +39,7 @@ release = __version__
|
|||||||
# ones.
|
# ones.
|
||||||
extensions = [
|
extensions = [
|
||||||
"sphinx.ext.autodoc",
|
"sphinx.ext.autodoc",
|
||||||
|
"sphinx.ext.graphviz",
|
||||||
"sphinx.ext.napoleon",
|
"sphinx.ext.napoleon",
|
||||||
"sphinx_rtd_theme",
|
"sphinx_rtd_theme",
|
||||||
"sphinxarg.ext",
|
"sphinxarg.ext",
|
||||||
@ -78,7 +77,12 @@ html_logo = "_static/logo.svg"
|
|||||||
|
|
||||||
add_module_names = False
|
add_module_names = False
|
||||||
|
|
||||||
modindex_common_prefix = ["ahriman.application.", "ahriman.core.", "ahriman.models.", "ahriman.web."]
|
modindex_common_prefix = [
|
||||||
|
"ahriman.application.",
|
||||||
|
"ahriman.core.",
|
||||||
|
"ahriman.models.",
|
||||||
|
"ahriman.web.",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
# -- Extension configuration -------------------------------------------------
|
# -- Extension configuration -------------------------------------------------
|
||||||
@ -92,3 +96,5 @@ autodoc_mock_imports = ["cryptography", "pyalpm"]
|
|||||||
autodoc_default_options = {
|
autodoc_default_options = {
|
||||||
"no-undoc-members": True,
|
"no-undoc-members": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
graphviz_output_format = "svg"
|
||||||
|
|||||||
@ -148,13 +148,11 @@ Before using this command you will need to create local directory and put ``PKGB
|
|||||||
How to copy package from another repository
|
How to copy package from another repository
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
As simple as add package from archive. Considering case when you would like to copy package ``package`` with version ``ver-rel`` from repository ``source-repository`` to ``target-respository`` (same architecture), the command will be following:
|
It is possible to copy package and its metadata between local repositories, optionally removing the source archive, e.g.:
|
||||||
|
|
||||||
.. code-block:: shell
|
.. code-block:: shell
|
||||||
|
|
||||||
sudo -u ahriman ahriman -r target-repository package-add /var/lib/ahriman/repository/source-repository/x86_64/package-ver-rel-x86_64.pkg.tar.zst
|
sudo -u ahriman ahriman -r target-repository package-copy source-repository ahriman
|
||||||
|
|
||||||
In addition, you can remove source package as usual later.
|
|
||||||
|
|
||||||
This feature in particular useful if for managing multiple repositories like ``[testing]`` and ``[extra]``.
|
This feature in particular useful if for managing multiple repositories like ``[testing]`` and ``[extra]``.
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# Maintainer: Evgeniy Alekseev
|
# Maintainer: Evgeniy Alekseev
|
||||||
|
|
||||||
pkgname='ahriman'
|
pkgname='ahriman'
|
||||||
pkgver=2.15.3
|
pkgver=2.15.2
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="ArcH linux ReposItory MANager"
|
pkgdesc="ArcH linux ReposItory MANager"
|
||||||
arch=('any')
|
arch=('any')
|
||||||
|
|||||||
@ -7,10 +7,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="form-group row mt-2">
|
<div class="form-group row mt-2">
|
||||||
|
<div class="col-4 col-lg-1" style="text-align: right">packages</div>
|
||||||
|
<div id="package-info-packages" class="col-8 col-lg-5"></div>
|
||||||
<div class="col-4 col-lg-1" style="text-align: right">version</div>
|
<div class="col-4 col-lg-1" style="text-align: right">version</div>
|
||||||
<div id="package-info-version" class="col-8 col-lg-5"></div>
|
<div id="package-info-version" class="col-8 col-lg-5"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row mt-2">
|
||||||
<div class="col-4 col-lg-1" style="text-align: right">packager</div>
|
<div class="col-4 col-lg-1" style="text-align: right">packager</div>
|
||||||
<div id="package-info-packager" class="col-8 col-lg-5"></div>
|
<div id="package-info-packager" class="col-8 col-lg-5"></div>
|
||||||
|
<div class="col-4 col-lg-1" style="text-align: right"></div>
|
||||||
|
<div id="package-info---placeholder" class="col-8 col-lg-5"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row mt-2">
|
<div class="form-group row mt-2">
|
||||||
@ -28,10 +35,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row mt-2">
|
<div class="form-group row mt-2">
|
||||||
<div class="col-4 col-lg-1" style="text-align: right">packages</div>
|
|
||||||
<div id="package-info-packages" class="col-8 col-lg-5"></div>
|
|
||||||
<div class="col-4 col-lg-1" style="text-align: right">depends</div>
|
<div class="col-4 col-lg-1" style="text-align: right">depends</div>
|
||||||
<div id="package-info-depends" class="col-8 col-lg-5"></div>
|
<div id="package-info-depends" class="col-8 col-lg-5"></div>
|
||||||
|
<div class="col-4 col-lg-1" style="text-align: right">implicitly depends</div>
|
||||||
|
<div id="package-info-implicitly-depends" class="col-8 col-lg-5"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="col-12">
|
<hr class="col-12">
|
||||||
@ -107,6 +114,7 @@
|
|||||||
const packageInfoAurUrl = document.getElementById("package-info-aur-url");
|
const packageInfoAurUrl = document.getElementById("package-info-aur-url");
|
||||||
const packageInfoDepends = document.getElementById("package-info-depends");
|
const packageInfoDepends = document.getElementById("package-info-depends");
|
||||||
const packageInfoGroups = document.getElementById("package-info-groups");
|
const packageInfoGroups = document.getElementById("package-info-groups");
|
||||||
|
const packageInfoImplicitlyDepends = document.getElementById("package-info-implicitly-depends");
|
||||||
const packageInfoLicenses = document.getElementById("package-info-licenses");
|
const packageInfoLicenses = document.getElementById("package-info-licenses");
|
||||||
const packageInfoPackager = document.getElementById("package-info-packager");
|
const packageInfoPackager = document.getElementById("package-info-packager");
|
||||||
const packageInfoPackages = document.getElementById("package-info-packages");
|
const packageInfoPackages = document.getElementById("package-info-packages");
|
||||||
@ -200,6 +208,26 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadDependencies(packageBase, onFailure) {
|
||||||
|
makeRequest(
|
||||||
|
`/api/v1/packages/${packageBase}/dependencies`,
|
||||||
|
{
|
||||||
|
query: {
|
||||||
|
architecture: repository.architecture,
|
||||||
|
repository: repository.repository,
|
||||||
|
},
|
||||||
|
convert: response => response.json(),
|
||||||
|
},
|
||||||
|
data => {
|
||||||
|
packageInfoImplicitlyDepends.innerHTML = listToTable(
|
||||||
|
Object.values(data.paths)
|
||||||
|
.reduce((accumulator, currentValue) => accumulator.concat(currentValue), [])
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onFailure,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function loadEvents(packageBase, onFailure) {
|
function loadEvents(packageBase, onFailure) {
|
||||||
packageInfoEventsTable.bootstrapTable("showLoading");
|
packageInfoEventsTable.bootstrapTable("showLoading");
|
||||||
clearChart();
|
clearChart();
|
||||||
@ -287,14 +315,9 @@
|
|||||||
},
|
},
|
||||||
data => {
|
data => {
|
||||||
const description = data.find(Boolean);
|
const description = data.find(Boolean);
|
||||||
const packages = Object.keys(description.package.packages);
|
const packages = description.package.packages;
|
||||||
const aurUrl = description.package.remote.web_url;
|
const aurUrl = description.package.remote.web_url;
|
||||||
const upstreamUrls = Array.from(
|
const upstreamUrls = Array.from(new Set(Object.values(packages).map(single => single.url))).sort();
|
||||||
new Set(
|
|
||||||
Object.values(description.package.packages)
|
|
||||||
.map(single => single.url)
|
|
||||||
)
|
|
||||||
).sort();
|
|
||||||
|
|
||||||
packageInfo.textContent = `${description.package.base} ${description.status.status} at ${new Date(1000 * description.status.timestamp).toISOStringShort()}`;
|
packageInfo.textContent = `${description.package.base} ${description.status.status} at ${new Date(1000 * description.status.timestamp).toISOStringShort()}`;
|
||||||
|
|
||||||
@ -304,17 +327,17 @@
|
|||||||
|
|
||||||
packageInfoAurUrl.innerHTML = aurUrl ? safeLink(aurUrl, aurUrl, "AUR link").outerHTML : "";
|
packageInfoAurUrl.innerHTML = aurUrl ? safeLink(aurUrl, aurUrl, "AUR link").outerHTML : "";
|
||||||
packageInfoDepends.innerHTML = listToTable(
|
packageInfoDepends.innerHTML = listToTable(
|
||||||
Object.values(description.package.packages)
|
Object.values(packages)
|
||||||
.reduce((accumulator, currentValue) => {
|
.reduce((accumulator, currentValue) => {
|
||||||
return accumulator.concat(currentValue.depends.filter(v => packages.indexOf(v) === -1))
|
return accumulator.concat(currentValue.depends.filter(v => !packages.hasOwnProperty(v)))
|
||||||
.concat(currentValue.make_depends.filter(v => packages.indexOf(v) === -1).map(v => `${v} (make)`))
|
.concat(currentValue.make_depends.filter(v => !packages.hasOwnProperty(v)).map(v => `${v} (make)`))
|
||||||
.concat(currentValue.opt_depends.filter(v => packages.indexOf(v) === -1).map(v => `${v} (optional)`));
|
.concat(currentValue.opt_depends.filter(v => !packages.hasOwnProperty(v)).map(v => `${v} (optional)`));
|
||||||
}, [])
|
}, [])
|
||||||
);
|
);
|
||||||
packageInfoGroups.innerHTML = listToTable(extractListProperties(description.package, "groups"));
|
packageInfoGroups.innerHTML = listToTable(extractListProperties(description.package, "groups"));
|
||||||
packageInfoLicenses.innerHTML = listToTable(extractListProperties(description.package, "licenses"));
|
packageInfoLicenses.innerHTML = listToTable(extractListProperties(description.package, "licenses"));
|
||||||
packageInfoPackager.textContent = description.package.packager;
|
packageInfoPackager.textContent = description.package.packager;
|
||||||
packageInfoPackages.innerHTML = listToTable(packages);
|
packageInfoPackages.innerHTML = listToTable(Object.entries(packages).map(([key, value]) => `${key} (${value.description})`));
|
||||||
packageInfoUpstreamUrl.innerHTML = upstreamUrls.map(url => safeLink(url, url, "upstream link").outerHTML).join("<br>");
|
packageInfoUpstreamUrl.innerHTML = upstreamUrls.map(url => safeLink(url, url, "upstream link").outerHTML).join("<br>");
|
||||||
packageInfoVersion.textContent = description.package.version;
|
packageInfoVersion.textContent = description.package.version;
|
||||||
},
|
},
|
||||||
@ -365,6 +388,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
loadPackage(packageBase, onFailure);
|
loadPackage(packageBase, onFailure);
|
||||||
|
loadDependencies(packageBase, onFailure);
|
||||||
loadPatches(packageBase, onFailure);
|
loadPatches(packageBase, onFailure);
|
||||||
loadLogs(packageBase, onFailure);
|
loadLogs(packageBase, onFailure);
|
||||||
loadChanges(packageBase, onFailure);
|
loadChanges(packageBase, onFailure);
|
||||||
@ -388,6 +412,7 @@
|
|||||||
packageInfoAurUrl.textContent = "";
|
packageInfoAurUrl.textContent = "";
|
||||||
packageInfoDepends.textContent = "";
|
packageInfoDepends.textContent = "";
|
||||||
packageInfoGroups.textContent = "";
|
packageInfoGroups.textContent = "";
|
||||||
|
packageInfoImplicitlyDepends.textContent = "";
|
||||||
packageInfoLicenses.textContent = "";
|
packageInfoLicenses.textContent = "";
|
||||||
packageInfoPackager.textContent = "";
|
packageInfoPackager.textContent = "";
|
||||||
packageInfoPackages.textContent = "";
|
packageInfoPackages.textContent = "";
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
.TH AHRIMAN "1" "2024\-11\-13" "ahriman" "Generated Python Manual"
|
.TH AHRIMAN "1" "2024\-09\-26" "ahriman" "Generated Python Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
ahriman
|
ahriman
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
|||||||
@ -17,4 +17,4 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
__version__ = "2.15.3"
|
__version__ = "2.15.2"
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -141,19 +141,19 @@ class ApplicationPackages(ApplicationProperties):
|
|||||||
self.database.build_queue_insert(package)
|
self.database.build_queue_insert(package)
|
||||||
self.reporter.set_unknown(package)
|
self.reporter.set_unknown(package)
|
||||||
|
|
||||||
def add(self, names: Iterable[str], source: PackageSource, username: str | None = None) -> None:
|
def add(self, packages: Iterable[str], source: PackageSource, username: str | None = None) -> None:
|
||||||
"""
|
"""
|
||||||
add packages for the next build
|
add packages for the next build
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
names(Iterable[str]): list of package bases to add
|
packages(Iterable[str]): list of package bases to add
|
||||||
source(PackageSource): package source to add
|
source(PackageSource): package source to add
|
||||||
username(str | None, optional): optional override of username for build process (Default value = None)
|
username(str | None, optional): optional override of username for build process (Default value = None)
|
||||||
"""
|
"""
|
||||||
for name in names:
|
for package in packages:
|
||||||
resolved_source = source.resolve(name, self.repository.paths)
|
resolved_source = source.resolve(package, self.repository.paths)
|
||||||
fn = getattr(self, f"_add_{resolved_source.value}")
|
fn = getattr(self, f"_add_{resolved_source.value}")
|
||||||
fn(name, username)
|
fn(package, username)
|
||||||
|
|
||||||
def on_result(self, result: Result) -> None:
|
def on_result(self, result: Result) -> None:
|
||||||
"""
|
"""
|
||||||
@ -167,16 +167,16 @@ class ApplicationPackages(ApplicationProperties):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def remove(self, names: Iterable[str]) -> Result:
|
def remove(self, packages: Iterable[str]) -> Result:
|
||||||
"""
|
"""
|
||||||
remove packages from repository
|
remove packages from repository
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
names(Iterable[str]): list of packages (either base or name) to remove
|
packages(Iterable[str]): list of packages (either base or name) to remove
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Result: removal result
|
Result: removal result
|
||||||
"""
|
"""
|
||||||
result = self.repository.process_remove(names)
|
result = self.repository.process_remove(packages)
|
||||||
self.on_result(result)
|
self.on_result(result)
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -191,6 +191,12 @@ class ApplicationRepository(ApplicationProperties):
|
|||||||
"""
|
"""
|
||||||
updates = {}
|
updates = {}
|
||||||
|
|
||||||
|
# always add already built packages, because they will be always added
|
||||||
|
updates.update({
|
||||||
|
package.base: package
|
||||||
|
for package in self.repository.load_archives(self.repository.packages_built())
|
||||||
|
})
|
||||||
|
|
||||||
if aur:
|
if aur:
|
||||||
updates.update({package.base: package for package in self.repository.updates_aur(filter_packages, vcs=vcs)})
|
updates.update({package.base: package for package in self.repository.updates_aur(filter_packages, vcs=vcs)})
|
||||||
if local:
|
if local:
|
||||||
|
|||||||
@ -17,36 +17,3 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
from ahriman.application.handlers.add import Add
|
|
||||||
from ahriman.application.handlers.backup import Backup
|
|
||||||
from ahriman.application.handlers.change import Change
|
|
||||||
from ahriman.application.handlers.clean import Clean
|
|
||||||
from ahriman.application.handlers.daemon import Daemon
|
|
||||||
from ahriman.application.handlers.dump import Dump
|
|
||||||
from ahriman.application.handlers.handler import Handler
|
|
||||||
from ahriman.application.handlers.help import Help
|
|
||||||
from ahriman.application.handlers.key_import import KeyImport
|
|
||||||
from ahriman.application.handlers.patch import Patch
|
|
||||||
from ahriman.application.handlers.rebuild import Rebuild
|
|
||||||
from ahriman.application.handlers.remove import Remove
|
|
||||||
from ahriman.application.handlers.remove_unknown import RemoveUnknown
|
|
||||||
from ahriman.application.handlers.repositories import Repositories
|
|
||||||
from ahriman.application.handlers.restore import Restore
|
|
||||||
from ahriman.application.handlers.run import Run
|
|
||||||
from ahriman.application.handlers.search import Search
|
|
||||||
from ahriman.application.handlers.service_updates import ServiceUpdates
|
|
||||||
from ahriman.application.handlers.setup import Setup
|
|
||||||
from ahriman.application.handlers.shell import Shell
|
|
||||||
from ahriman.application.handlers.sign import Sign
|
|
||||||
from ahriman.application.handlers.statistics import Statistics
|
|
||||||
from ahriman.application.handlers.status import Status
|
|
||||||
from ahriman.application.handlers.status_update import StatusUpdate
|
|
||||||
from ahriman.application.handlers.structure import Structure
|
|
||||||
from ahriman.application.handlers.tree_migrate import TreeMigrate
|
|
||||||
from ahriman.application.handlers.triggers import Triggers
|
|
||||||
from ahriman.application.handlers.unsafe_commands import UnsafeCommands
|
|
||||||
from ahriman.application.handlers.update import Update
|
|
||||||
from ahriman.application.handlers.users import Users
|
|
||||||
from ahriman.application.handlers.validate import Validate
|
|
||||||
from ahriman.application.handlers.versions import Versions
|
|
||||||
from ahriman.application.handlers.web import Web
|
|
||||||
|
|||||||
@ -20,8 +20,10 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
|
from ahriman.core.utils import enum_values, extract_user
|
||||||
|
from ahriman.models.package_source import PackageSource
|
||||||
from ahriman.models.packagers import Packagers
|
from ahriman.models.packagers import Packagers
|
||||||
from ahriman.models.pkgbuild_patch import PkgbuildPatch
|
from ahriman.models.pkgbuild_patch import PkgbuildPatch
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
@ -32,6 +34,50 @@ class Add(Handler):
|
|||||||
add packages handler
|
add packages handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("package-add", aliases=["add", "package-update"], help="add package",
|
||||||
|
description="add existing or new package to the build queue",
|
||||||
|
epilog="This subcommand should be used for new package addition. "
|
||||||
|
"It also supports flag --now in case if you would like to build "
|
||||||
|
"the package immediately. You can add new package from one of "
|
||||||
|
"supported sources:\n\n"
|
||||||
|
"1. If it is already built package you can specify the path to the archive.\n"
|
||||||
|
"2. You can also add built packages from the directory (e.g. during the "
|
||||||
|
"migration from another repository source).\n"
|
||||||
|
"3. It is also possible to add package from local PKGBUILD, but in this case "
|
||||||
|
"it will be ignored during the next automatic updates.\n"
|
||||||
|
"4. Ahriman supports downloading archives from remote (e.g. HTTP) sources.\n"
|
||||||
|
"5. Finally you can add package from AUR.")
|
||||||
|
parser.add_argument("package", help="package source (base name, path to local files, remote URL)", nargs="+")
|
||||||
|
parser.add_argument("--changes", help="calculate changes from the latest known commit if available",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--dependencies", help="process missing package dependencies",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||||
|
action="store_true")
|
||||||
|
parser.add_argument("--increment", help="increment package release (pkgrel) version on duplicate",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("-n", "--now", help="run update function after", action="store_true")
|
||||||
|
parser.add_argument("-y", "--refresh", help="download fresh package databases from the mirror before actions, "
|
||||||
|
"-yy to force refresh even if up to date",
|
||||||
|
action="count", default=False)
|
||||||
|
parser.add_argument("-s", "--source", help="explicitly specify the package source for this command",
|
||||||
|
type=PackageSource, choices=enum_values(PackageSource), default=PackageSource.Auto)
|
||||||
|
parser.add_argument("-u", "--username", help="build as user", default=extract_user())
|
||||||
|
parser.add_argument("-v", "--variable", help="apply specified makepkg variables to the next build",
|
||||||
|
action="append")
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import tarfile
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pwd import getpwuid
|
from pwd import getpwuid
|
||||||
|
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.database import SQLite
|
from ahriman.core.database import SQLite
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
@ -36,6 +36,23 @@ class Backup(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-backup", help="backup repository data",
|
||||||
|
description="backup repository settings and database")
|
||||||
|
parser.add_argument("path", help="path of the output archive", type=Path)
|
||||||
|
parser.set_defaults(architecture="", lock=None, report=False, repository="", unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.formatters import ChangesPrinter
|
from ahriman.core.formatters import ChangesPrinter
|
||||||
from ahriman.models.action import Action
|
from ahriman.models.action import Action
|
||||||
@ -35,6 +35,19 @@ class Change(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
return [cls._set_package_changes_parser(root), cls._set_package_changes_remove_parser(root)]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
@ -57,3 +70,41 @@ class Change(Handler):
|
|||||||
Change.check_status(args.exit_code, not changes.is_empty)
|
Change.check_status(args.exit_code, not changes.is_empty)
|
||||||
case Action.Remove:
|
case Action.Remove:
|
||||||
client.package_changes_update(args.package, Changes())
|
client.package_changes_update(args.package, Changes())
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_package_changes_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for package changes subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("package-changes", help="get package changes",
|
||||||
|
description="retrieve package changes stored in database",
|
||||||
|
epilog="This command requests package status from the web interface "
|
||||||
|
"if it is available.")
|
||||||
|
parser.add_argument("package", help="package base")
|
||||||
|
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||||
|
action="store_true")
|
||||||
|
parser.set_defaults(action=Action.List, lock=None, quiet=True, report=False, unsafe=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_package_changes_remove_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for package change remove subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("package-changes-remove", help="remove package changes",
|
||||||
|
description="remove the package changes stored remotely")
|
||||||
|
parser.add_argument("package", help="package base")
|
||||||
|
parser.set_defaults(action=Action.Remove, exit_code=False, lock=None, quiet=True, report=False, unsafe=True)
|
||||||
|
return parser
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
|
|
||||||
@ -30,6 +30,34 @@ class Clean(Handler):
|
|||||||
clean caches handler
|
clean caches handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("service-clean", aliases=["clean", "repo-clean"], help="clean local caches",
|
||||||
|
description="remove local caches",
|
||||||
|
epilog="The subcommand clears every temporary directories (builds, caches etc). "
|
||||||
|
"Normally you should not run this command manually. Also in case if "
|
||||||
|
"you are going to clear the chroot directories you will need root privileges.")
|
||||||
|
parser.add_argument("--cache", help="clear directory with package caches",
|
||||||
|
action=argparse.BooleanOptionalAction, default=False)
|
||||||
|
parser.add_argument("--chroot", help="clear build chroot", action=argparse.BooleanOptionalAction, default=False)
|
||||||
|
parser.add_argument("--manual", help="clear manually added packages queue",
|
||||||
|
action=argparse.BooleanOptionalAction, default=False)
|
||||||
|
parser.add_argument("--packages", help="clear directory with built packages",
|
||||||
|
action=argparse.BooleanOptionalAction, default=False)
|
||||||
|
parser.add_argument("--pacman", help="clear directory with pacman local database cache",
|
||||||
|
action=argparse.BooleanOptionalAction, default=False)
|
||||||
|
parser.set_defaults(lock=None, quiet=True, unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
115
src/ahriman/application/handlers/copy.py
Normal file
115
src/ahriman/application/handlers/copy.py
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2021-2024 ahriman team.
|
||||||
|
#
|
||||||
|
# This file is part of ahriman
|
||||||
|
# (see https://github.com/arcan1s/ahriman).
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from ahriman.application.application import Application
|
||||||
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
|
from ahriman.core.configuration import Configuration
|
||||||
|
from ahriman.models.build_status import BuildStatusEnum
|
||||||
|
from ahriman.models.package import Package
|
||||||
|
from ahriman.models.package_source import PackageSource
|
||||||
|
from ahriman.models.repository_id import RepositoryId
|
||||||
|
|
||||||
|
|
||||||
|
class Copy(Handler):
|
||||||
|
"""
|
||||||
|
copy packages handler
|
||||||
|
"""
|
||||||
|
|
||||||
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting action
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("package-copy", aliases=["copy"], help="copy package from another repository",
|
||||||
|
description="copy package and its metadata from another repository")
|
||||||
|
parser.add_argument("source", help="source repository name")
|
||||||
|
parser.add_argument("package", help="package base", nargs="+")
|
||||||
|
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||||
|
action="store_true")
|
||||||
|
parser.add_argument("--remove", help="remove package from the source repository after", action="store_true")
|
||||||
|
return [parser]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
|
report: bool) -> None:
|
||||||
|
"""
|
||||||
|
callback for command line
|
||||||
|
|
||||||
|
Args:
|
||||||
|
args(argparse.Namespace): command line args
|
||||||
|
repository_id(RepositoryId): repository unique identifier
|
||||||
|
configuration(Configuration): configuration instance
|
||||||
|
report(bool): force enable or disable reporting
|
||||||
|
"""
|
||||||
|
application = Application(repository_id, configuration, report=report)
|
||||||
|
application.on_start()
|
||||||
|
|
||||||
|
configuration_path, _ = configuration.check_loaded()
|
||||||
|
source_repository_id = RepositoryId(repository_id.architecture, args.source)
|
||||||
|
source_configuration = Configuration.from_path(configuration_path, source_repository_id)
|
||||||
|
source_application = Application(source_repository_id, source_configuration, report=report)
|
||||||
|
|
||||||
|
packages = source_application.repository.packages(args.package)
|
||||||
|
Copy.check_status(args.exit_code, packages)
|
||||||
|
|
||||||
|
for package in packages:
|
||||||
|
Copy.copy_package(package, application, source_application)
|
||||||
|
|
||||||
|
# run update
|
||||||
|
application.update([])
|
||||||
|
|
||||||
|
if args.remove:
|
||||||
|
source_application.remove(args.package)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def copy_package(package: Package, application: Application, source_application: Application) -> None:
|
||||||
|
"""
|
||||||
|
copy package ``package`` from source repository to target repository
|
||||||
|
|
||||||
|
Args:
|
||||||
|
package(Package): package to copy
|
||||||
|
application(Application): application instance of the target repository
|
||||||
|
source_application(Application): application instance of the source repository
|
||||||
|
"""
|
||||||
|
# copy files
|
||||||
|
source_paths = [
|
||||||
|
str(source_application.repository.paths.repository / source.filename)
|
||||||
|
for source in package.packages.values()
|
||||||
|
if source.filename is not None
|
||||||
|
]
|
||||||
|
application.add(source_paths, PackageSource.Archive)
|
||||||
|
|
||||||
|
# copy metadata
|
||||||
|
application.reporter.package_changes_update(
|
||||||
|
package.base, source_application.reporter.package_changes_get(package.base)
|
||||||
|
)
|
||||||
|
application.reporter.package_dependencies_update(
|
||||||
|
package.base, source_application.reporter.package_dependencies_get(package.base)
|
||||||
|
)
|
||||||
|
application.reporter.package_update(package, BuildStatusEnum.Pending)
|
||||||
@ -19,11 +19,14 @@
|
|||||||
#
|
#
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.application.updates_iterator import FixedUpdatesIterator, UpdatesIterator
|
from ahriman.application.application.updates_iterator import FixedUpdatesIterator, UpdatesIterator
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.application.handlers.update import Update
|
from ahriman.application.handlers.update import Update
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
|
from ahriman.core.utils import extract_user
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
|
|
||||||
|
|
||||||
@ -32,6 +35,49 @@ class Daemon(Handler):
|
|||||||
daemon packages handler
|
daemon packages handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-daemon", aliases=["daemon"], help="run application as daemon",
|
||||||
|
description="start process which periodically will run update process")
|
||||||
|
parser.add_argument("-i", "--interval", help="interval between runs in seconds", type=int, default=60 * 60 * 12)
|
||||||
|
parser.add_argument("--aur", help="enable or disable checking for AUR updates",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--changes", help="calculate changes from the latest known commit if available. "
|
||||||
|
"Only applicable in dry run mode",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--check-files", help="enable or disable checking of broken dependencies "
|
||||||
|
"(e.g. dynamically linked libraries or modules directories)",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--dependencies", help="process missing package dependencies",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--dry-run", help="just perform check for updates, same as check command",
|
||||||
|
action="store_true")
|
||||||
|
parser.add_argument("--increment", help="increment package release (pkgrel) on duplicate",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--local", help="enable or disable checking of local packages for updates",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--manual", help="include or exclude manual updates",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--partitions", help="instead of updating whole repository, split updates into chunks",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("-u", "--username", help="build as user", default=extract_user())
|
||||||
|
parser.add_argument("--vcs", help="fetch actual version of VCS packages",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("-y", "--refresh", help="download fresh package databases from the mirror before actions, "
|
||||||
|
"-yy to force refresh even if up to date",
|
||||||
|
action="count", default=False)
|
||||||
|
parser.set_defaults(exit_code=False, lock=Path("ahriman-daemon.pid"), package=[])
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#
|
#
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.formatters import ConfigurationPathsPrinter, ConfigurationPrinter, StringPrinter
|
from ahriman.core.formatters import ConfigurationPathsPrinter, ConfigurationPrinter, StringPrinter
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
@ -32,6 +32,28 @@ class Dump(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("service-config", aliases=["config", "repo-config"], help="dump configuration",
|
||||||
|
description="dump configuration for the specified architecture")
|
||||||
|
parser.add_argument("section", help="filter settings by section", nargs="?")
|
||||||
|
parser.add_argument("key", help="filter settings by key", nargs="?")
|
||||||
|
parser.add_argument("--info", help="show additional information, e.g. configuration files",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--secure", help="hide passwords and secrets from output",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.set_defaults(lock=None, quiet=True, report=False, unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import logging
|
|||||||
|
|
||||||
from collections.abc import Callable, Iterable
|
from collections.abc import Callable, Iterable
|
||||||
from multiprocessing import Pool
|
from multiprocessing import Pool
|
||||||
|
from typing import TypeVar
|
||||||
|
|
||||||
from ahriman.application.lock import Lock
|
from ahriman.application.lock import Lock
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
@ -32,6 +33,13 @@ from ahriman.models.repository_id import RepositoryId
|
|||||||
from ahriman.models.repository_paths import RepositoryPaths
|
from ahriman.models.repository_paths import RepositoryPaths
|
||||||
|
|
||||||
|
|
||||||
|
# this workaround is for several things
|
||||||
|
# firstly python devs don't think that is it error and asking you for workarounds https://bugs.python.org/issue41592
|
||||||
|
# secondly linters don't like when you are importing private members
|
||||||
|
# thirdly new mypy doesn't like _SubParsersAction and thinks it is a template
|
||||||
|
SubParserAction = TypeVar("SubParserAction", bound="argparse._SubParsersAction[argparse.ArgumentParser]")
|
||||||
|
|
||||||
|
|
||||||
class Handler:
|
class Handler:
|
||||||
"""
|
"""
|
||||||
base handler class for command callbacks
|
base handler class for command callbacks
|
||||||
@ -50,6 +58,22 @@ class Handler:
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = True
|
ALLOW_MULTI_ARCHITECTURE_RUN = True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
NotImplementedError: not implemented method
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def call(cls, args: argparse.Namespace, repository_id: RepositoryId) -> bool:
|
def call(cls, args: argparse.Namespace, repository_id: RepositoryId) -> bool:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#
|
#
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
|
|
||||||
@ -31,6 +31,23 @@ class Help(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("help", help="show help message",
|
||||||
|
description="show help message for application or command and exit")
|
||||||
|
parser.add_argument("subcommand", help="show help message for specific command", nargs="?")
|
||||||
|
parser.set_defaults(architecture="", lock=None, quiet=True, report=False, repository="", unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
|
|
||||||
@ -32,6 +32,28 @@ class KeyImport(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("service-key-import", aliases=["key-import"], help="import PGP key",
|
||||||
|
description="import PGP key from public sources to the repository user",
|
||||||
|
epilog="By default ahriman runs build process with package sources validation "
|
||||||
|
"(in case if signature and keys are available in PKGBUILD). This process will "
|
||||||
|
"fail in case if key is not known for build user. This subcommand can be used "
|
||||||
|
"in order to import the PGP key to user keychain.")
|
||||||
|
parser.add_argument("--key-server", help="key server for key import", default="keyserver.ubuntu.com")
|
||||||
|
parser.add_argument("key", help="PGP key to import from public server")
|
||||||
|
parser.set_defaults(architecture="", lock=None, report=False, repository="")
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import sys
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.build_tools.sources import Sources
|
from ahriman.core.build_tools.sources import Sources
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.formatters import PatchPrinter
|
from ahriman.core.formatters import PatchPrinter
|
||||||
@ -40,6 +40,24 @@ class Patch(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
cls._set_patch_add_parser(root),
|
||||||
|
cls._set_patch_list_parser(root),
|
||||||
|
cls._set_patch_remove_parser(root),
|
||||||
|
cls._set_patch_set_add_parser(root),
|
||||||
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
@ -67,6 +85,100 @@ class Patch(Handler):
|
|||||||
case Action.Remove:
|
case Action.Remove:
|
||||||
Patch.patch_set_remove(application, args.package, args.variable)
|
Patch.patch_set_remove(application, args.package, args.variable)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_patch_add_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for new single-function patch subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("patch-add", help="add patch for PKGBUILD function",
|
||||||
|
description="create or update patched PKGBUILD function or variable",
|
||||||
|
epilog="Unlike ``patch-set-add``, this function allows to patch only one PKGBUILD "
|
||||||
|
"function, e.g. typing ``ahriman patch-add ahriman pkgver`` it will change the "
|
||||||
|
"``pkgver`` inside PKGBUILD, typing ``ahriman patch-add ahriman build()`` "
|
||||||
|
"it will change ``build()`` function inside PKGBUILD.")
|
||||||
|
parser.add_argument("package", help="package base")
|
||||||
|
parser.add_argument("variable", help="PKGBUILD variable or function name. If variable is a function, "
|
||||||
|
"it must end with ()")
|
||||||
|
parser.add_argument("patch", help="path to file which contains function or variable value. If not set, "
|
||||||
|
"the value will be read from stdin", type=Path, nargs="?")
|
||||||
|
parser.set_defaults(action=Action.Update, architecture="", exit_code=False, lock=None, report=False,
|
||||||
|
repository="")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_patch_list_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for list patches subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("patch-list", help="list patch sets",
|
||||||
|
description="list available patches for the package")
|
||||||
|
parser.add_argument("package", help="package base")
|
||||||
|
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||||
|
action="store_true")
|
||||||
|
parser.add_argument("-v", "--variable", help="if set, show only patches for specified PKGBUILD variables",
|
||||||
|
action="append")
|
||||||
|
parser.set_defaults(action=Action.List, architecture="", lock=None, report=False, repository="", unsafe=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_patch_remove_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for remove patches subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("patch-remove", help="remove patch set", description="remove patches for the package")
|
||||||
|
parser.add_argument("package", help="package base")
|
||||||
|
parser.add_argument("-v", "--variable",
|
||||||
|
help="should be used for single-function patches in case if you wold like "
|
||||||
|
"to remove only specified PKGBUILD variables. In case if not set, "
|
||||||
|
"it will remove all patches related to the package",
|
||||||
|
action="append")
|
||||||
|
parser.set_defaults(action=Action.Remove, architecture="", exit_code=False, lock=None, report=False,
|
||||||
|
repository="")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_patch_set_add_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for new full-diff patch subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("patch-set-add", help="add patch set", description="create or update source patches",
|
||||||
|
epilog="In order to add a patch set for the package you will need to:\n\n"
|
||||||
|
"1. Clone the AUR package manually.\n"
|
||||||
|
"2. Add required changes (e.g. external patches, edit PKGBUILD).\n"
|
||||||
|
"3. Run command, e.g. ``ahriman patch-set-add path/to/directory``.\n\n"
|
||||||
|
"By default it tracks ``*.patch`` and ``*.diff`` files, but this behavior "
|
||||||
|
"can be changed by using ``--track`` option.")
|
||||||
|
parser.add_argument("package", help="path to directory with changed files for patch addition/update", type=Path)
|
||||||
|
parser.add_argument("-t", "--track", help="files which has to be tracked", action="append",
|
||||||
|
default=["*.diff", "*.patch"])
|
||||||
|
parser.set_defaults(action=Action.Update, architecture="", exit_code=False, lock=None, report=False,
|
||||||
|
repository="", variable=None)
|
||||||
|
return parser
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def patch_create_from_diff(sources_dir: Path, architecture: str, track: list[str]) -> tuple[str, PkgbuildPatch]:
|
def patch_create_from_diff(sources_dir: Path, architecture: str, track: list[str]) -> tuple[str, PkgbuildPatch]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -20,8 +20,9 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
|
from ahriman.core.utils import enum_values, extract_user
|
||||||
from ahriman.models.build_status import BuildStatusEnum
|
from ahriman.models.build_status import BuildStatusEnum
|
||||||
from ahriman.models.package import Package
|
from ahriman.models.package import Package
|
||||||
from ahriman.models.packagers import Packagers
|
from ahriman.models.packagers import Packagers
|
||||||
@ -33,6 +34,38 @@ class Rebuild(Handler):
|
|||||||
make world handler
|
make world handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-rebuild", aliases=["rebuild"], help="rebuild repository",
|
||||||
|
description="force rebuild whole repository")
|
||||||
|
parser.add_argument("--depends-on", help="only rebuild packages that depend on specified packages",
|
||||||
|
action="append")
|
||||||
|
parser.add_argument("--dry-run", help="just perform check for packages without rebuild process itself",
|
||||||
|
action="store_true")
|
||||||
|
parser.add_argument("--from-database",
|
||||||
|
help="read packages from database instead of filesystem. This feature in particular is "
|
||||||
|
"required in case if you would like to restore repository from another repository "
|
||||||
|
"instance. Note, however, that in order to restore packages you need to have original "
|
||||||
|
"ahriman instance run with web service and have run repo-update at least once.",
|
||||||
|
action="store_true")
|
||||||
|
parser.add_argument("--increment", help="increment package release (pkgrel) on duplicate",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||||
|
action="store_true")
|
||||||
|
parser.add_argument("-s", "--status", help="filter packages by status. Requires --from-database to be set",
|
||||||
|
type=BuildStatusEnum, choices=enum_values(BuildStatusEnum))
|
||||||
|
parser.add_argument("-u", "--username", help="build as user", default=extract_user())
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
|
|
||||||
@ -30,6 +30,22 @@ class Remove(Handler):
|
|||||||
remove packages handler
|
remove packages handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("package-remove", aliases=["remove"], help="remove package",
|
||||||
|
description="remove package from the repository")
|
||||||
|
parser.add_argument("package", help="package name or base", nargs="+")
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.formatters import StringPrinter
|
from ahriman.core.formatters import StringPrinter
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
@ -31,6 +31,22 @@ class RemoveUnknown(Handler):
|
|||||||
remove unknown packages handler
|
remove unknown packages handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-remove-unknown", aliases=["remove-unknown"], help="remove unknown packages",
|
||||||
|
description="remove packages which are missing in AUR and do not have local PKGBUILDs")
|
||||||
|
parser.add_argument("--dry-run", help="just perform check for packages without removal", action="store_true")
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#
|
#
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.formatters import RepositoryPrinter
|
from ahriman.core.formatters import RepositoryPrinter
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
@ -32,6 +32,24 @@ class Repositories(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("service-repositories", help="show repositories",
|
||||||
|
description="list all available repositories")
|
||||||
|
parser.add_argument("--id-only", help="show machine readable identifier instead",
|
||||||
|
action=argparse.BooleanOptionalAction, default=False)
|
||||||
|
parser.set_defaults(architecture="", lock=None, report=False, repository="", unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -20,7 +20,9 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import tarfile
|
import tarfile
|
||||||
|
|
||||||
from ahriman.application.handlers.handler import Handler
|
from pathlib import Path
|
||||||
|
|
||||||
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
|
|
||||||
@ -32,6 +34,24 @@ class Restore(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-restore", help="restore repository data",
|
||||||
|
description="restore settings and database")
|
||||||
|
parser.add_argument("path", help="path of the input archive", type=Path)
|
||||||
|
parser.add_argument("-o", "--output", help="root path of the extracted files", type=Path, default=Path("/"))
|
||||||
|
parser.set_defaults(architecture="", lock=None, report=False, repository="", unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import shlex
|
import shlex
|
||||||
|
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
|
|
||||||
@ -32,6 +32,25 @@ class Run(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("service-run", aliases=["run"], help="run multiple commands",
|
||||||
|
description="run multiple commands on success run of the previous command",
|
||||||
|
epilog="Commands must be quoted by using usual bash rules. Processes will be spawned "
|
||||||
|
"under the same user as this command.")
|
||||||
|
parser.add_argument("command", help="command to be run (quoted) without ``ahriman``", nargs="+")
|
||||||
|
parser.set_defaults(architecture="", lock=None, report=False, repository="", unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import argparse
|
|||||||
from collections.abc import Callable, Iterable
|
from collections.abc import Callable, Iterable
|
||||||
from dataclasses import fields
|
from dataclasses import fields
|
||||||
|
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.alpm.remote import AUR, Official
|
from ahriman.core.alpm.remote import AUR, Official
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.exceptions import OptionError
|
from ahriman.core.exceptions import OptionError
|
||||||
@ -46,6 +46,33 @@ class Search(Handler):
|
|||||||
if field.default_factory is not list
|
if field.default_factory is not list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("aur-search", aliases=["search"], help="search for package",
|
||||||
|
description="search for package in AUR using API")
|
||||||
|
parser.add_argument("search",
|
||||||
|
help="search terms, can be specified multiple times, the result will match all terms",
|
||||||
|
nargs="+")
|
||||||
|
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||||
|
action="store_true")
|
||||||
|
parser.add_argument("--info", help="show additional package information",
|
||||||
|
action=argparse.BooleanOptionalAction, default=False)
|
||||||
|
parser.add_argument("--sort-by",
|
||||||
|
help="sort field by this field. In case if two packages have the same value of "
|
||||||
|
"the specified field, they will be always sorted by name",
|
||||||
|
default="name", choices=sorted(Search.SORT_FIELDS))
|
||||||
|
parser.set_defaults(architecture="", lock=None, quiet=True, report=False, repository="", unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman import __version__
|
from ahriman import __version__
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.formatters import UpdatePrinter
|
from ahriman.core.formatters import UpdatePrinter
|
||||||
from ahriman.models.package import Package
|
from ahriman.models.package import Package
|
||||||
@ -34,6 +34,24 @@ class ServiceUpdates(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("help-updates", help="check for service updates",
|
||||||
|
description="request AUR for current version and compare with current service version")
|
||||||
|
parser.add_argument("-e", "--exit-code", help="return non-zero exit code if updates available",
|
||||||
|
action="store_true")
|
||||||
|
parser.set_defaults(architecture="", lock=None, quiet=True, report=False, repository="", unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -24,11 +24,13 @@ from pwd import getpwuid
|
|||||||
from urllib.parse import quote_plus as urlencode
|
from urllib.parse import quote_plus as urlencode
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.exceptions import MissingArchitectureError
|
from ahriman.core.exceptions import MissingArchitectureError
|
||||||
|
from ahriman.core.utils import enum_values
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
from ahriman.models.repository_paths import RepositoryPaths
|
from ahriman.models.repository_paths import RepositoryPaths
|
||||||
|
from ahriman.models.sign_settings import SignSettings
|
||||||
from ahriman.models.user import User
|
from ahriman.models.user import User
|
||||||
|
|
||||||
|
|
||||||
@ -48,6 +50,44 @@ class Setup(Handler):
|
|||||||
MIRRORLIST_PATH = Path("/") / "etc" / "pacman.d" / "mirrorlist"
|
MIRRORLIST_PATH = Path("/") / "etc" / "pacman.d" / "mirrorlist"
|
||||||
SUDOERS_DIR_PATH = Path("/") / "etc" / "sudoers.d"
|
SUDOERS_DIR_PATH = Path("/") / "etc" / "sudoers.d"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("service-setup", aliases=["init", "repo-init", "repo-setup", "setup"],
|
||||||
|
help="initial service configuration",
|
||||||
|
description="create initial service configuration, requires root",
|
||||||
|
epilog="Create minimal configuration for the service according to provided options.")
|
||||||
|
parser.add_argument("--build-as-user", help="force makepkg user to the specific one")
|
||||||
|
parser.add_argument("--from-configuration", help="path to default devtools pacman configuration",
|
||||||
|
type=Path,
|
||||||
|
default=Path("/") / "usr" / "share" / "devtools" / "pacman.conf.d" / "extra.conf")
|
||||||
|
parser.add_argument("--generate-salt", help="generate salt for user passwords",
|
||||||
|
action=argparse.BooleanOptionalAction, default=False)
|
||||||
|
parser.add_argument("--makeflags-jobs",
|
||||||
|
help="append MAKEFLAGS variable with parallelism set to number of cores",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--mirror", help="use the specified explicitly mirror instead of including mirrorlist")
|
||||||
|
parser.add_argument("--multilib", help="add or do not multilib repository",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--packager", help="packager name and email", required=True)
|
||||||
|
parser.add_argument("--server", help="server to be used for devtools. If none set, local files will be used")
|
||||||
|
parser.add_argument("--sign-key", help="sign key id")
|
||||||
|
parser.add_argument("--sign-target", help="sign options", action="append",
|
||||||
|
type=SignSettings.from_option, choices=enum_values(SignSettings))
|
||||||
|
parser.add_argument("--web-port", help="port of the web service", type=int)
|
||||||
|
parser.add_argument("--web-unix-socket", help="path to unix socket used for interprocess communications",
|
||||||
|
type=Path)
|
||||||
|
parser.set_defaults(lock=None, quiet=True, report=False, unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import sys
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.formatters import StringPrinter
|
from ahriman.core.formatters import StringPrinter
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
@ -36,6 +36,24 @@ class Shell(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("service-shell", aliases=["shell"], help="invoke python shell",
|
||||||
|
description="drop into python shell")
|
||||||
|
parser.add_argument("code", help="instead of dropping into shell, just execute the specified code", nargs="?")
|
||||||
|
parser.add_argument("-v", "--verbose", help=argparse.SUPPRESS, action="store_true")
|
||||||
|
parser.set_defaults(lock=None, report=False)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
|
|
||||||
@ -30,6 +30,23 @@ class Sign(Handler):
|
|||||||
(re-)sign handler
|
(re-)sign handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-sign", aliases=["sign"], help="sign packages",
|
||||||
|
description="(re-)sign packages and repository database according to current settings",
|
||||||
|
epilog="Sign repository and/or packages as configured.")
|
||||||
|
parser.add_argument("package", help="sign only specified packages", nargs="*")
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -25,11 +25,11 @@ from collections.abc import Callable
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.formatters import EventStatsPrinter, PackageStatsPrinter
|
from ahriman.core.formatters import EventStatsPrinter, PackageStatsPrinter
|
||||||
from ahriman.core.utils import pretty_datetime
|
from ahriman.core.utils import enum_values, pretty_datetime
|
||||||
from ahriman.models.event import Event
|
from ahriman.models.event import Event, EventType
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
|
|
||||||
|
|
||||||
@ -40,6 +40,30 @@ class Statistics(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-statistics", help="repository statistics",
|
||||||
|
description="fetch repository statistics")
|
||||||
|
parser.add_argument("package", help="fetch only events for the specified package", nargs="?")
|
||||||
|
parser.add_argument("--chart", help="create updates chart and save it to the specified path", type=Path)
|
||||||
|
parser.add_argument("-e", "--event", help="event type filter",
|
||||||
|
type=EventType, choices=enum_values(EventType), default=EventType.PackageUpdated)
|
||||||
|
parser.add_argument("--from-date", help="only fetch events which are newer than the date")
|
||||||
|
parser.add_argument("--limit", help="limit response by specified amount of events", type=int, default=-1)
|
||||||
|
parser.add_argument("--offset", help="skip specified amount of events", type=int, default=0)
|
||||||
|
parser.add_argument("--to-date", help="only fetch events which are older than the date")
|
||||||
|
parser.set_defaults(lock=None, quiet=True, report=False, unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -22,10 +22,11 @@ import argparse
|
|||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.formatters import PackagePrinter, StatusPrinter
|
from ahriman.core.formatters import PackagePrinter, StatusPrinter
|
||||||
from ahriman.models.build_status import BuildStatus
|
from ahriman.core.utils import enum_values
|
||||||
|
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||||
from ahriman.models.package import Package
|
from ahriman.models.package import Package
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
|
|
||||||
@ -37,6 +38,32 @@ class Status(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("package-status", aliases=["status"], help="get package status",
|
||||||
|
description="request status of the package",
|
||||||
|
epilog="This command requests package status from the web interface "
|
||||||
|
"if it is available.")
|
||||||
|
parser.add_argument("package", help="filter status by package base", nargs="*")
|
||||||
|
parser.add_argument("--ahriman", help="get service status itself", action="store_true")
|
||||||
|
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||||
|
action="store_true")
|
||||||
|
parser.add_argument("--info", help="show additional package information",
|
||||||
|
action=argparse.BooleanOptionalAction, default=False)
|
||||||
|
parser.add_argument("-s", "--status", help="filter packages by status",
|
||||||
|
type=BuildStatusEnum, choices=enum_values(BuildStatusEnum))
|
||||||
|
parser.set_defaults(lock=None, quiet=True, report=False, unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -20,9 +20,11 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
|
from ahriman.core.utils import enum_values
|
||||||
from ahriman.models.action import Action
|
from ahriman.models.action import Action
|
||||||
|
from ahriman.models.build_status import BuildStatusEnum
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
|
|
||||||
|
|
||||||
@ -33,6 +35,23 @@ class StatusUpdate(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
cls._set_package_status_remove_parser(root),
|
||||||
|
cls._set_package_status_update_parser(root),
|
||||||
|
cls._set_repo_status_update_parser(root),
|
||||||
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
@ -59,3 +78,61 @@ class StatusUpdate(Handler):
|
|||||||
case Action.Remove:
|
case Action.Remove:
|
||||||
for package in args.package:
|
for package in args.package:
|
||||||
client.package_remove(package)
|
client.package_remove(package)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_package_status_remove_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for package status remove subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("package-status-remove", help="remove package status",
|
||||||
|
description="remove the package from the status page",
|
||||||
|
epilog="Please note that this subcommand does not remove the package itself, it just "
|
||||||
|
"clears the status page.")
|
||||||
|
parser.add_argument("package", help="remove specified packages from status page", nargs="+")
|
||||||
|
parser.set_defaults(action=Action.Remove, lock=None, quiet=True, report=False, unsafe=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_package_status_update_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for package status update subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("package-status-update", aliases=["status-update"], help="update package status",
|
||||||
|
description="update package status on the status page")
|
||||||
|
parser.add_argument("package", help="set status for specified packages. "
|
||||||
|
"If no packages supplied, service status will be updated",
|
||||||
|
nargs="*")
|
||||||
|
parser.add_argument("-s", "--status", help="new package build status",
|
||||||
|
type=BuildStatusEnum, choices=enum_values(BuildStatusEnum), default=BuildStatusEnum.Success)
|
||||||
|
parser.set_defaults(action=Action.Update, lock=None, quiet=True, report=False, unsafe=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_repo_status_update_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for repository status update subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-status-update", help="update repository status",
|
||||||
|
description="update repository status on the status page")
|
||||||
|
parser.add_argument("-s", "--status", help="new status",
|
||||||
|
type=BuildStatusEnum, choices=enum_values(BuildStatusEnum), default=BuildStatusEnum.Success)
|
||||||
|
parser.set_defaults(action=Action.Update, lock=None, package=[], quiet=True, report=False, unsafe=True)
|
||||||
|
return parser
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.formatters import StringPrinter, TreePrinter
|
from ahriman.core.formatters import StringPrinter, TreePrinter
|
||||||
from ahriman.core.tree import Tree
|
from ahriman.core.tree import Tree
|
||||||
@ -34,6 +34,24 @@ class Structure(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-tree", help="dump repository tree",
|
||||||
|
description="dump repository tree based on packages dependencies")
|
||||||
|
parser.add_argument("-p", "--partitions", help="also divide packages by independent partitions",
|
||||||
|
type=int, default=1)
|
||||||
|
parser.set_defaults(lock=None, quiet=True, report=False, unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#
|
#
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
from ahriman.models.repository_paths import RepositoryPaths
|
from ahriman.models.repository_paths import RepositoryPaths
|
||||||
@ -30,6 +30,22 @@ class TreeMigrate(Handler):
|
|||||||
tree migration handler
|
tree migration handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("service-tree-migrate", help="migrate repository tree",
|
||||||
|
description="migrate repository tree between versions")
|
||||||
|
parser.set_defaults(lock=None, quiet=True, report=False)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
from ahriman.models.result import Result
|
from ahriman.models.result import Result
|
||||||
@ -31,6 +31,25 @@ class Triggers(Handler):
|
|||||||
triggers handlers
|
triggers handlers
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
cls._set_repo_create_keyring_parser(root),
|
||||||
|
cls._set_repo_create_mirrorlist_parser(root),
|
||||||
|
cls._set_repo_report_parser(root),
|
||||||
|
cls._set_repo_sync_parser(root),
|
||||||
|
cls._set_repo_triggers_parser(root),
|
||||||
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
@ -49,3 +68,90 @@ class Triggers(Handler):
|
|||||||
loader.triggers = [loader.load_trigger(trigger, repository_id, configuration) for trigger in args.trigger]
|
loader.triggers = [loader.load_trigger(trigger, repository_id, configuration) for trigger in args.trigger]
|
||||||
application.on_start()
|
application.on_start()
|
||||||
application.on_result(Result())
|
application.on_result(Result())
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_repo_create_keyring_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for create-keyring subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-create-keyring", help="create keyring package",
|
||||||
|
description="create package which contains list of trusted keys as set by "
|
||||||
|
"configuration. Note, that this action will only create package, "
|
||||||
|
"the package itself has to be built manually")
|
||||||
|
parser.set_defaults(trigger=["ahriman.core.support.KeyringTrigger"])
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_repo_create_mirrorlist_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for create-mirrorlist subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-create-mirrorlist", help="create mirrorlist package",
|
||||||
|
description="create package which contains list of available mirrors as set by "
|
||||||
|
"configuration. Note, that this action will only create package, "
|
||||||
|
"the package itself has to be built manually")
|
||||||
|
parser.set_defaults(trigger=["ahriman.core.support.MirrorlistTrigger"])
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_repo_report_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for report subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-report", aliases=["report"], help="generate report",
|
||||||
|
description="generate repository report according to current settings",
|
||||||
|
epilog="Create and/or update repository report as configured.")
|
||||||
|
parser.set_defaults(trigger=["ahriman.core.report.ReportTrigger"])
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_repo_sync_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for repository sync subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-sync", aliases=["sync"], help="sync repository",
|
||||||
|
description="sync repository files to remote server according to current settings",
|
||||||
|
epilog="Synchronize the repository to remote services as configured.")
|
||||||
|
parser.set_defaults(trigger=["ahriman.core.upload.UploadTrigger"])
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_repo_triggers_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for repository triggers subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-triggers", help="run triggers",
|
||||||
|
description="run triggers on empty build result as configured by settings")
|
||||||
|
parser.add_argument("trigger", help="instead of running all triggers as set by configuration, just process "
|
||||||
|
"specified ones in order of mention", nargs="*")
|
||||||
|
return parser
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#
|
#
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.formatters import StringPrinter
|
from ahriman.core.formatters import StringPrinter
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
@ -32,6 +32,25 @@ class UnsafeCommands(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("help-commands-unsafe", help="list unsafe commands",
|
||||||
|
description="list unsafe commands as defined in default args")
|
||||||
|
parser.add_argument("subcommand",
|
||||||
|
help="instead of showing commands, just test command line for unsafe subcommand "
|
||||||
|
"and return 0 in case if command is safe and 1 otherwise", nargs="*")
|
||||||
|
parser.set_defaults(architecture="", lock=None, quiet=True, report=False, repository="", unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -22,8 +22,9 @@ import argparse
|
|||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
|
from ahriman.core.utils import extract_user
|
||||||
from ahriman.models.packagers import Packagers
|
from ahriman.models.packagers import Packagers
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
|
|
||||||
@ -33,6 +34,19 @@ class Update(Handler):
|
|||||||
package update handler
|
package update handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
return [cls._set_repo_check_parser(root), cls._set_repo_update_parser(root)]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
@ -64,6 +78,78 @@ class Update(Handler):
|
|||||||
result = application.update(packages, packagers, bump_pkgrel=args.increment)
|
result = application.update(packages, packagers, bump_pkgrel=args.increment)
|
||||||
Update.check_status(args.exit_code, not result.is_empty)
|
Update.check_status(args.exit_code, not result.is_empty)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_repo_check_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for repository check subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-check", aliases=["check"], help="check for updates",
|
||||||
|
description="check for packages updates. Same as repo-update --dry-run --no-manual")
|
||||||
|
parser.add_argument("package", help="filter check by package base", nargs="*")
|
||||||
|
parser.add_argument("--changes", help="calculate changes from the latest known commit if available",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--check-files", help="enable or disable checking of broken dependencies "
|
||||||
|
"(e.g. dynamically linked libraries or modules directories)",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||||
|
action="store_true")
|
||||||
|
parser.add_argument("--vcs", help="fetch actual version of VCS packages",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("-y", "--refresh", help="download fresh package databases from the mirror before actions, "
|
||||||
|
"-yy to force refresh even if up to date",
|
||||||
|
action="count", default=False)
|
||||||
|
parser.set_defaults(aur=True, dependencies=False, dry_run=True, increment=False, local=True, manual=False,
|
||||||
|
username=None)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_repo_update_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for repository update subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("repo-update", aliases=["update"], help="update packages",
|
||||||
|
description="check for packages updates and run build process if requested")
|
||||||
|
parser.add_argument("package", help="filter check by package base", nargs="*")
|
||||||
|
parser.add_argument("--aur", help="enable or disable checking for AUR updates",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--changes", help="calculate changes from the latest known commit if available. "
|
||||||
|
"Only applicable in dry run mode",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--check-files", help="enable or disable checking of broken dependencies "
|
||||||
|
"(e.g. dynamically linked libraries or modules directories)",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--dependencies", help="process missing package dependencies",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--dry-run", help="just perform check for updates, same as check command",
|
||||||
|
action="store_true")
|
||||||
|
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||||
|
action="store_true")
|
||||||
|
parser.add_argument("--increment", help="increment package release (pkgrel) on duplicate",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--local", help="enable or disable checking of local packages for updates",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("--manual", help="include or exclude manual updates",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("-u", "--username", help="build as user", default=extract_user())
|
||||||
|
parser.add_argument("--vcs", help="fetch actual version of VCS packages",
|
||||||
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
|
parser.add_argument("-y", "--refresh", help="download fresh package databases from the mirror before actions, "
|
||||||
|
"-yy to force refresh even if up to date",
|
||||||
|
action="count", default=False)
|
||||||
|
return parser
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def log_fn(application: Application, dry_run: bool) -> Callable[[str], None]:
|
def log_fn(application: Application, dry_run: bool) -> Callable[[str], None]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -20,14 +20,16 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import getpass
|
import getpass
|
||||||
|
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.database import SQLite
|
from ahriman.core.database import SQLite
|
||||||
from ahriman.core.exceptions import PasswordError
|
from ahriman.core.exceptions import PasswordError
|
||||||
from ahriman.core.formatters import UserPrinter
|
from ahriman.core.formatters import UserPrinter
|
||||||
|
from ahriman.core.utils import enum_values
|
||||||
from ahriman.models.action import Action
|
from ahriman.models.action import Action
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
from ahriman.models.user import User
|
from ahriman.models.user import User
|
||||||
|
from ahriman.models.user_access import UserAccess
|
||||||
|
|
||||||
|
|
||||||
class Users(Handler):
|
class Users(Handler):
|
||||||
@ -37,6 +39,23 @@ class Users(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
cls._set_user_add_parser(root),
|
||||||
|
cls._set_user_list_parser(root),
|
||||||
|
cls._set_user_remove_parser(root),
|
||||||
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
@ -65,6 +84,73 @@ class Users(Handler):
|
|||||||
case Action.Remove:
|
case Action.Remove:
|
||||||
database.user_remove(args.username)
|
database.user_remove(args.username)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_user_add_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for create user subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("user-add", help="create or update user",
|
||||||
|
description="update user for web services with the given password and role. "
|
||||||
|
"In case if password was not entered it will be asked interactively")
|
||||||
|
parser.add_argument("username", help="username for web service")
|
||||||
|
parser.add_argument("--key", help="optional PGP key used by this user. The private key must be imported")
|
||||||
|
parser.add_argument("--packager", help="optional packager id used for build process in form of "
|
||||||
|
"`Name Surname <mail@example.com>`")
|
||||||
|
parser.add_argument(
|
||||||
|
"-p", "--password", help="user password. Blank password will be treated as empty password, "
|
||||||
|
"which is in particular must be used for OAuth2 authorization type.")
|
||||||
|
parser.add_argument("-R", "--role", help="user access level",
|
||||||
|
type=UserAccess, choices=enum_values(UserAccess), default=UserAccess.Read)
|
||||||
|
parser.set_defaults(action=Action.Update, architecture="", exit_code=False, lock=None, quiet=True,
|
||||||
|
report=False, repository="")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_user_list_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for user list subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("user-list", help="user known users and their access",
|
||||||
|
description="list users from the user mapping and their roles")
|
||||||
|
parser.add_argument("username", help="filter users by username", nargs="?")
|
||||||
|
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||||
|
action="store_true")
|
||||||
|
parser.add_argument("-R", "--role", help="filter users by role", type=UserAccess,
|
||||||
|
choices=enum_values(UserAccess))
|
||||||
|
parser.set_defaults(action=Action.List, architecture="", lock=None, quiet=True, report=False, repository="",
|
||||||
|
unsafe=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _set_user_remove_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||||
|
"""
|
||||||
|
add parser for user removal subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.ArgumentParser: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("user-remove", help="remove user",
|
||||||
|
description="remove user from the user mapping and update the configuration")
|
||||||
|
parser.add_argument("username", help="username for web service")
|
||||||
|
parser.set_defaults(action=Action.Remove, architecture="", exit_code=False, lock=None, quiet=True,
|
||||||
|
report=False, repository="")
|
||||||
|
return parser
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def user_create(args: argparse.Namespace) -> User:
|
def user_create(args: argparse.Namespace) -> User:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import copy
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.configuration.schema import CONFIGURATION_SCHEMA, ConfigurationSchema
|
from ahriman.core.configuration.schema import CONFIGURATION_SCHEMA, ConfigurationSchema
|
||||||
from ahriman.core.exceptions import ExtensionError
|
from ahriman.core.exceptions import ExtensionError
|
||||||
@ -38,6 +38,25 @@ class Validate(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("service-config-validate", aliases=["config-validate", "repo-config-validate"],
|
||||||
|
help="validate system configuration",
|
||||||
|
description="validate configuration and print found errors")
|
||||||
|
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if configuration is invalid",
|
||||||
|
action="store_true")
|
||||||
|
parser.set_defaults(lock=None, quiet=True, report=False, unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -25,7 +25,7 @@ from collections.abc import Generator
|
|||||||
from importlib import metadata
|
from importlib import metadata
|
||||||
|
|
||||||
from ahriman import __version__
|
from ahriman import __version__
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.formatters import VersionPrinter
|
from ahriman.core.formatters import VersionPrinter
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
@ -42,6 +42,22 @@ class Versions(Handler):
|
|||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
||||||
PEP423_PACKAGE_NAME = re.compile(r"^[A-Za-z0-9._-]+")
|
PEP423_PACKAGE_NAME = re.compile(r"^[A-Za-z0-9._-]+")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("help-version", aliases=["version"], help="application version",
|
||||||
|
description="print application and its dependencies versions")
|
||||||
|
parser.set_defaults(architecture="", lock=None, quiet=True, report=False, repository="", unsafe=True)
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -20,8 +20,9 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from ahriman.application.handlers.handler import Handler
|
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.spawn import Spawn
|
from ahriman.core.spawn import Spawn
|
||||||
from ahriman.core.triggers import TriggerLoader
|
from ahriman.core.triggers import TriggerLoader
|
||||||
@ -35,6 +36,21 @@ class Web(Handler):
|
|||||||
|
|
||||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
ALLOW_MULTI_ARCHITECTURE_RUN = False # system-wide action
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def arguments(cls, root: SubParserAction) -> list[argparse.ArgumentParser]:
|
||||||
|
"""
|
||||||
|
add parser(s) for the subcommand
|
||||||
|
|
||||||
|
Args:
|
||||||
|
root(SubParserAction): subparsers for the commands
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[argparse.ArgumentParser]: created argument parser
|
||||||
|
"""
|
||||||
|
parser = root.add_parser("web", help="web server", description="start web server")
|
||||||
|
parser.set_defaults(architecture="", lock=Path("ahriman-web.pid"), report=False, repository="")
|
||||||
|
return [parser]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||||
report: bool) -> None:
|
report: bool) -> None:
|
||||||
|
|||||||
@ -226,7 +226,7 @@ class PkgbuildParser(shlex.shlex):
|
|||||||
pass
|
pass
|
||||||
case PkgbuildToken.ArrayEnds:
|
case PkgbuildToken.ArrayEnds:
|
||||||
break
|
break
|
||||||
case comment if comment.startswith(PkgbuildToken.Comment):
|
case PkgbuildToken.Comment:
|
||||||
self.instream.readline()
|
self.instream.readline()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ class PkgbuildParser(shlex.shlex):
|
|||||||
counter -= 1
|
counter -= 1
|
||||||
if counter == 0:
|
if counter == 0:
|
||||||
break
|
break
|
||||||
case comment if comment.startswith(PkgbuildToken.Comment):
|
case PkgbuildToken.Comment:
|
||||||
self.instream.readline()
|
self.instream.readline()
|
||||||
|
|
||||||
if not 0 < start_position < end_position:
|
if not 0 < start_position < end_position:
|
||||||
@ -303,7 +303,7 @@ class PkgbuildParser(shlex.shlex):
|
|||||||
yield PkgbuildPatch(key, value)
|
yield PkgbuildPatch(key, value)
|
||||||
return
|
return
|
||||||
|
|
||||||
if token.startswith(PkgbuildToken.Comment):
|
if token == PkgbuildToken.Comment:
|
||||||
self.instream.readline()
|
self.instream.readline()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
74
src/ahriman/core/module_loader.py
Normal file
74
src/ahriman/core/module_loader.py
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2021-2024 ahriman team.
|
||||||
|
#
|
||||||
|
# This file is part of ahriman
|
||||||
|
# (see https://github.com/arcan1s/ahriman).
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
from collections.abc import Generator
|
||||||
|
from importlib import import_module
|
||||||
|
from pathlib import Path
|
||||||
|
from pkgutil import ModuleInfo, walk_packages
|
||||||
|
from typing import Any, TypeGuard, TypeVar
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["implementations"]
|
||||||
|
|
||||||
|
|
||||||
|
T = TypeVar("T")
|
||||||
|
|
||||||
|
|
||||||
|
def _modules(module_root: Path, prefix: str) -> Generator[ModuleInfo, None, None]:
|
||||||
|
"""
|
||||||
|
extract available modules from package
|
||||||
|
|
||||||
|
Args:
|
||||||
|
module_root(Path): module root path
|
||||||
|
prefix(str): modules package prefix
|
||||||
|
|
||||||
|
Yields:
|
||||||
|
ModuleInfo: module information each available module
|
||||||
|
"""
|
||||||
|
prefix = f"{prefix}." if prefix else ""
|
||||||
|
for module_info in walk_packages([str(module_root)], prefix):
|
||||||
|
if module_info.ispkg:
|
||||||
|
yield from _modules(module_root / module_info.name, prefix)
|
||||||
|
else:
|
||||||
|
yield module_info
|
||||||
|
|
||||||
|
|
||||||
|
def implementations(module_root: Path, prefix: str, base_class: type[T]) -> Generator[type[T], None, None]:
|
||||||
|
"""
|
||||||
|
extract implementations of the ``base_class`` from the module
|
||||||
|
|
||||||
|
Args:
|
||||||
|
module_root(Path): root module path with implementations
|
||||||
|
prefix(str): modules package prefix
|
||||||
|
base_class(type[T]): base class type
|
||||||
|
|
||||||
|
Yields:
|
||||||
|
type[T]: found implementations
|
||||||
|
"""
|
||||||
|
def is_base_class(clazz: Any) -> TypeGuard[type[T]]:
|
||||||
|
return inspect.isclass(clazz) \
|
||||||
|
and issubclass(clazz, base_class) and clazz != base_class \
|
||||||
|
and clazz.__module__ == module.__name__
|
||||||
|
|
||||||
|
for module_info in _modules(module_root, prefix):
|
||||||
|
module = import_module(module_info.name)
|
||||||
|
for _, attribute in inspect.getmembers(module, is_base_class):
|
||||||
|
yield attribute
|
||||||
@ -18,21 +18,17 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
from aiohttp.web import Application, View
|
from aiohttp.web import Application, View
|
||||||
from collections.abc import Generator
|
|
||||||
from importlib.machinery import SourceFileLoader
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pkgutil import ModuleInfo, iter_modules
|
|
||||||
from types import ModuleType
|
|
||||||
from typing import Any, Type, TypeGuard
|
|
||||||
|
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
|
from ahriman.core.module_loader import implementations
|
||||||
from ahriman.web.views.base import BaseView
|
from ahriman.web.views.base import BaseView
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["setup_routes"]
|
__all__ = ["setup_routes"]
|
||||||
|
|
||||||
|
|
||||||
def _dynamic_routes(module_root: Path, configuration: Configuration) -> dict[str, Type[View]]:
|
def _dynamic_routes(module_root: Path, configuration: Configuration) -> dict[str, type[View]]:
|
||||||
"""
|
"""
|
||||||
extract dynamic routes based on views
|
extract dynamic routes based on views
|
||||||
|
|
||||||
@ -41,70 +37,16 @@ def _dynamic_routes(module_root: Path, configuration: Configuration) -> dict[str
|
|||||||
configuration(Configuration): configuration instance
|
configuration(Configuration): configuration instance
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Type[View]]: map of the route to its view
|
dict[str, type[View]]: map of the route to its view
|
||||||
"""
|
"""
|
||||||
def is_base_view(clazz: Any) -> TypeGuard[Type[BaseView]]:
|
routes: dict[str, type[View]] = {}
|
||||||
return isinstance(clazz, type) and issubclass(clazz, BaseView)
|
for view in implementations(module_root, "ahriman.web.views", BaseView):
|
||||||
|
view_routes = view.routes(configuration)
|
||||||
routes: dict[str, Type[View]] = {}
|
routes.update([(route, view) for route in view_routes])
|
||||||
for module_info in _modules(module_root):
|
|
||||||
module = _module(module_info)
|
|
||||||
|
|
||||||
for attribute_name in dir(module):
|
|
||||||
view = getattr(module, attribute_name)
|
|
||||||
if not is_base_view(view):
|
|
||||||
continue
|
|
||||||
|
|
||||||
view_routes = view.routes(configuration)
|
|
||||||
routes.update([(route, view) for route in view_routes])
|
|
||||||
|
|
||||||
return routes
|
return routes
|
||||||
|
|
||||||
|
|
||||||
def _module(module_info: ModuleInfo) -> ModuleType:
|
|
||||||
"""
|
|
||||||
load module from its info
|
|
||||||
|
|
||||||
Args:
|
|
||||||
module_info(ModuleInfo): module info descriptor
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
ModuleType: loaded module
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
ValueError: if loader is not an instance of :class:`importlib.machinery.SourceFileLoader`
|
|
||||||
"""
|
|
||||||
module_spec = module_info.module_finder.find_spec(module_info.name, None)
|
|
||||||
if module_spec is None:
|
|
||||||
raise ValueError(f"Module specification of {module_info.name} is empty")
|
|
||||||
|
|
||||||
loader = module_spec.loader
|
|
||||||
if not isinstance(loader, SourceFileLoader):
|
|
||||||
raise ValueError(f"Module {module_info.name} loader is not an instance of SourceFileLoader")
|
|
||||||
|
|
||||||
module = ModuleType(loader.name)
|
|
||||||
loader.exec_module(module)
|
|
||||||
|
|
||||||
return module
|
|
||||||
|
|
||||||
|
|
||||||
def _modules(module_root: Path) -> Generator[ModuleInfo, None, None]:
|
|
||||||
"""
|
|
||||||
extract available modules from package
|
|
||||||
|
|
||||||
Args:
|
|
||||||
module_root(Path): module root path
|
|
||||||
|
|
||||||
Yields:
|
|
||||||
ModuleInfo: module information each available module
|
|
||||||
"""
|
|
||||||
for module_info in iter_modules([str(module_root)]):
|
|
||||||
if module_info.ispkg:
|
|
||||||
yield from _modules(module_root / module_info.name)
|
|
||||||
else:
|
|
||||||
yield module_info
|
|
||||||
|
|
||||||
|
|
||||||
def setup_routes(application: Application, configuration: Configuration) -> None:
|
def setup_routes(application: Application, configuration: Configuration) -> None:
|
||||||
"""
|
"""
|
||||||
setup all defined routes
|
setup all defined routes
|
||||||
|
|||||||
@ -42,7 +42,7 @@ class DependenciesView(StatusViewGuard, BaseView):
|
|||||||
ROUTES = ["/api/v1/packages/{package}/dependencies"]
|
ROUTES = ["/api/v1/packages/{package}/dependencies"]
|
||||||
|
|
||||||
@aiohttp_apispec.docs(
|
@aiohttp_apispec.docs(
|
||||||
tags=["Build"],
|
tags=["Packages"],
|
||||||
summary="Get package dependencies",
|
summary="Get package dependencies",
|
||||||
description="Retrieve package implicit dependencies",
|
description="Retrieve package implicit dependencies",
|
||||||
responses={
|
responses={
|
||||||
@ -74,7 +74,7 @@ class DependenciesView(StatusViewGuard, BaseView):
|
|||||||
return json_response(dependencies.view())
|
return json_response(dependencies.view())
|
||||||
|
|
||||||
@aiohttp_apispec.docs(
|
@aiohttp_apispec.docs(
|
||||||
tags=["Build"],
|
tags=["Packages"],
|
||||||
summary="Update package dependencies",
|
summary="Update package dependencies",
|
||||||
description="Set package implicit dependencies",
|
description="Set package implicit dependencies",
|
||||||
responses={
|
responses={
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
from unittest.mock import call as MockCall
|
from unittest.mock import call as MockCall
|
||||||
|
|
||||||
@ -213,6 +214,9 @@ def test_updates_all(application_repository: ApplicationRepository, package_ahri
|
|||||||
"""
|
"""
|
||||||
must get updates for all
|
must get updates for all
|
||||||
"""
|
"""
|
||||||
|
path = Path("local")
|
||||||
|
mocker.patch("ahriman.core.repository.package_info.PackageInfo.packages_built", return_value=[path])
|
||||||
|
updates_built_mock = mocker.patch("ahriman.core.repository.package_info.PackageInfo.load_archives")
|
||||||
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur",
|
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur",
|
||||||
return_value=[package_ahriman])
|
return_value=[package_ahriman])
|
||||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||||
@ -220,6 +224,7 @@ def test_updates_all(application_repository: ApplicationRepository, package_ahri
|
|||||||
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
||||||
|
|
||||||
application_repository.updates([], aur=True, local=True, manual=True, vcs=True, check_files=True)
|
application_repository.updates([], aur=True, local=True, manual=True, vcs=True, check_files=True)
|
||||||
|
updates_built_mock.assert_called_once_with([path])
|
||||||
updates_aur_mock.assert_called_once_with([], vcs=True)
|
updates_aur_mock.assert_called_once_with([], vcs=True)
|
||||||
updates_local_mock.assert_called_once_with(vcs=True)
|
updates_local_mock.assert_called_once_with(vcs=True)
|
||||||
updates_manual_mock.assert_called_once_with()
|
updates_manual_mock.assert_called_once_with()
|
||||||
@ -230,12 +235,16 @@ def test_updates_disabled(application_repository: ApplicationRepository, mocker:
|
|||||||
"""
|
"""
|
||||||
must get updates without anything
|
must get updates without anything
|
||||||
"""
|
"""
|
||||||
|
path = Path("local")
|
||||||
|
mocker.patch("ahriman.core.repository.package_info.PackageInfo.packages_built", return_value=[path])
|
||||||
|
updates_built_mock = mocker.patch("ahriman.core.repository.package_info.PackageInfo.load_archives")
|
||||||
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur")
|
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur")
|
||||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||||
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
||||||
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
||||||
|
|
||||||
application_repository.updates([], aur=False, local=False, manual=False, vcs=True, check_files=False)
|
application_repository.updates([], aur=False, local=False, manual=False, vcs=True, check_files=False)
|
||||||
|
updates_built_mock.assert_called_once_with([path])
|
||||||
updates_aur_mock.assert_not_called()
|
updates_aur_mock.assert_not_called()
|
||||||
updates_local_mock.assert_not_called()
|
updates_local_mock.assert_not_called()
|
||||||
updates_manual_mock.assert_not_called()
|
updates_manual_mock.assert_not_called()
|
||||||
@ -246,12 +255,16 @@ def test_updates_no_aur(application_repository: ApplicationRepository, mocker: M
|
|||||||
"""
|
"""
|
||||||
must get updates without aur
|
must get updates without aur
|
||||||
"""
|
"""
|
||||||
|
path = Path("local")
|
||||||
|
mocker.patch("ahriman.core.repository.package_info.PackageInfo.packages_built", return_value=[path])
|
||||||
|
updates_built_mock = mocker.patch("ahriman.core.repository.package_info.PackageInfo.load_archives")
|
||||||
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur")
|
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur")
|
||||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||||
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
||||||
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
||||||
|
|
||||||
application_repository.updates([], aur=False, local=True, manual=True, vcs=True, check_files=True)
|
application_repository.updates([], aur=False, local=True, manual=True, vcs=True, check_files=True)
|
||||||
|
updates_built_mock.assert_called_once_with([path])
|
||||||
updates_aur_mock.assert_not_called()
|
updates_aur_mock.assert_not_called()
|
||||||
updates_local_mock.assert_called_once_with(vcs=True)
|
updates_local_mock.assert_called_once_with(vcs=True)
|
||||||
updates_manual_mock.assert_called_once_with()
|
updates_manual_mock.assert_called_once_with()
|
||||||
@ -262,12 +275,16 @@ def test_updates_no_local(application_repository: ApplicationRepository, mocker:
|
|||||||
"""
|
"""
|
||||||
must get updates without local packages
|
must get updates without local packages
|
||||||
"""
|
"""
|
||||||
|
path = Path("local")
|
||||||
|
mocker.patch("ahriman.core.repository.package_info.PackageInfo.packages_built", return_value=[path])
|
||||||
|
updates_built_mock = mocker.patch("ahriman.core.repository.package_info.PackageInfo.load_archives")
|
||||||
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur")
|
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur")
|
||||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||||
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
||||||
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
||||||
|
|
||||||
application_repository.updates([], aur=True, local=False, manual=True, vcs=True, check_files=True)
|
application_repository.updates([], aur=True, local=False, manual=True, vcs=True, check_files=True)
|
||||||
|
updates_built_mock.assert_called_once_with([path])
|
||||||
updates_aur_mock.assert_called_once_with([], vcs=True)
|
updates_aur_mock.assert_called_once_with([], vcs=True)
|
||||||
updates_local_mock.assert_not_called()
|
updates_local_mock.assert_not_called()
|
||||||
updates_manual_mock.assert_called_once_with()
|
updates_manual_mock.assert_called_once_with()
|
||||||
@ -278,12 +295,16 @@ def test_updates_no_manual(application_repository: ApplicationRepository, mocker
|
|||||||
"""
|
"""
|
||||||
must get updates without manual
|
must get updates without manual
|
||||||
"""
|
"""
|
||||||
|
path = Path("local")
|
||||||
|
mocker.patch("ahriman.core.repository.package_info.PackageInfo.packages_built", return_value=[path])
|
||||||
|
updates_built_mock = mocker.patch("ahriman.core.repository.package_info.PackageInfo.load_archives")
|
||||||
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur")
|
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur")
|
||||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||||
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
||||||
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
||||||
|
|
||||||
application_repository.updates([], aur=True, local=True, manual=False, vcs=True, check_files=True)
|
application_repository.updates([], aur=True, local=True, manual=False, vcs=True, check_files=True)
|
||||||
|
updates_built_mock.assert_called_once_with([path])
|
||||||
updates_aur_mock.assert_called_once_with([], vcs=True)
|
updates_aur_mock.assert_called_once_with([], vcs=True)
|
||||||
updates_local_mock.assert_called_once_with(vcs=True)
|
updates_local_mock.assert_called_once_with(vcs=True)
|
||||||
updates_manual_mock.assert_not_called()
|
updates_manual_mock.assert_not_called()
|
||||||
@ -294,12 +315,16 @@ def test_updates_no_vcs(application_repository: ApplicationRepository, mocker: M
|
|||||||
"""
|
"""
|
||||||
must get updates without VCS
|
must get updates without VCS
|
||||||
"""
|
"""
|
||||||
|
path = Path("local")
|
||||||
|
mocker.patch("ahriman.core.repository.package_info.PackageInfo.packages_built", return_value=[path])
|
||||||
|
updates_built_mock = mocker.patch("ahriman.core.repository.package_info.PackageInfo.load_archives")
|
||||||
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur")
|
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur")
|
||||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||||
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
||||||
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
||||||
|
|
||||||
application_repository.updates([], aur=True, local=True, manual=True, vcs=False, check_files=True)
|
application_repository.updates([], aur=True, local=True, manual=True, vcs=False, check_files=True)
|
||||||
|
updates_built_mock.assert_called_once_with([path])
|
||||||
updates_aur_mock.assert_called_once_with([], vcs=False)
|
updates_aur_mock.assert_called_once_with([], vcs=False)
|
||||||
updates_local_mock.assert_called_once_with(vcs=False)
|
updates_local_mock.assert_called_once_with(vcs=False)
|
||||||
updates_manual_mock.assert_called_once_with()
|
updates_manual_mock.assert_called_once_with()
|
||||||
@ -310,12 +335,16 @@ def test_updates_no_check_files(application_repository: ApplicationRepository, m
|
|||||||
"""
|
"""
|
||||||
must get updates without checking broken links
|
must get updates without checking broken links
|
||||||
"""
|
"""
|
||||||
|
path = Path("local")
|
||||||
|
mocker.patch("ahriman.core.repository.package_info.PackageInfo.packages_built", return_value=[path])
|
||||||
|
updates_built_mock = mocker.patch("ahriman.core.repository.package_info.PackageInfo.load_archives")
|
||||||
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur")
|
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur")
|
||||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||||
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
||||||
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
||||||
|
|
||||||
application_repository.updates([], aur=True, local=True, manual=True, vcs=True, check_files=False)
|
application_repository.updates([], aur=True, local=True, manual=True, vcs=True, check_files=False)
|
||||||
|
updates_built_mock.assert_called_once_with([path])
|
||||||
updates_aur_mock.assert_called_once_with([], vcs=True)
|
updates_aur_mock.assert_called_once_with([], vcs=True)
|
||||||
updates_local_mock.assert_called_once_with(vcs=True)
|
updates_local_mock.assert_called_once_with(vcs=True)
|
||||||
updates_manual_mock.assert_called_once_with()
|
updates_manual_mock.assert_called_once_with()
|
||||||
@ -326,12 +355,16 @@ def test_updates_with_filter(application_repository: ApplicationRepository, mock
|
|||||||
"""
|
"""
|
||||||
must get updates with filter
|
must get updates with filter
|
||||||
"""
|
"""
|
||||||
|
path = Path("local")
|
||||||
|
mocker.patch("ahriman.core.repository.package_info.PackageInfo.packages_built", return_value=[path])
|
||||||
|
updates_built_mock = mocker.patch("ahriman.core.repository.package_info.PackageInfo.load_archives")
|
||||||
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur")
|
updates_aur_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_aur")
|
||||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||||
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
||||||
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
updates_deps_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_dependencies")
|
||||||
|
|
||||||
application_repository.updates(["filter"], aur=True, local=True, manual=True, vcs=True, check_files=True)
|
application_repository.updates(["filter"], aur=True, local=True, manual=True, vcs=True, check_files=True)
|
||||||
|
updates_built_mock.assert_called_once_with([path])
|
||||||
updates_aur_mock.assert_called_once_with(["filter"], vcs=True)
|
updates_aur_mock.assert_called_once_with(["filter"], vcs=True)
|
||||||
updates_local_mock.assert_called_once_with(vcs=True)
|
updates_local_mock.assert_called_once_with(vcs=True)
|
||||||
updates_manual_mock.assert_called_once_with()
|
updates_manual_mock.assert_called_once_with()
|
||||||
|
|||||||
@ -3,14 +3,23 @@ import pytest
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
from ahriman.application.handlers import Handler
|
from ahriman.application.handlers.handler import Handler
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.exceptions import ExitCode, MissingArchitectureError, MultipleArchitecturesError
|
from ahriman.core.exceptions import ExitCode, MissingArchitectureError, MultipleArchitecturesError
|
||||||
from ahriman.models.log_handler import LogHandler
|
from ahriman.models.log_handler import LogHandler
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
|
|
||||||
|
|
||||||
|
def test_arguments() -> None:
|
||||||
|
"""
|
||||||
|
must raise NotImplemented for missing arguments method
|
||||||
|
"""
|
||||||
|
with pytest.raises(NotImplementedError):
|
||||||
|
Handler.arguments(MagicMock())
|
||||||
|
|
||||||
|
|
||||||
def test_call(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
def test_call(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
must call inside lock
|
must call inside lock
|
||||||
@ -19,7 +28,7 @@ def test_call(args: argparse.Namespace, configuration: Configuration, mocker: Mo
|
|||||||
args.log_handler = LogHandler.Console
|
args.log_handler = LogHandler.Console
|
||||||
args.quiet = False
|
args.quiet = False
|
||||||
args.report = False
|
args.report = False
|
||||||
mocker.patch("ahriman.application.handlers.Handler.run")
|
mocker.patch("ahriman.application.handlers.handler.Handler.run")
|
||||||
configuration_mock = mocker.patch("ahriman.core.configuration.Configuration.from_path", return_value=configuration)
|
configuration_mock = mocker.patch("ahriman.core.configuration.Configuration.from_path", return_value=configuration)
|
||||||
log_handler_mock = mocker.patch("ahriman.core.log.log_loader.LogLoader.handler", return_value=args.log_handler)
|
log_handler_mock = mocker.patch("ahriman.core.log.log_loader.LogLoader.handler", return_value=args.log_handler)
|
||||||
log_load_mock = mocker.patch("ahriman.core.log.log_loader.LogLoader.load")
|
log_load_mock = mocker.patch("ahriman.core.log.log_loader.LogLoader.load")
|
||||||
@ -76,7 +85,7 @@ def test_execute(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
|||||||
RepositoryId("i686", "aur"),
|
RepositoryId("i686", "aur"),
|
||||||
RepositoryId("x86_64", "aur"),
|
RepositoryId("x86_64", "aur"),
|
||||||
]
|
]
|
||||||
mocker.patch("ahriman.application.handlers.Handler.repositories_extract", return_value=ids)
|
mocker.patch("ahriman.application.handlers.handler.Handler.repositories_extract", return_value=ids)
|
||||||
starmap_mock = mocker.patch("multiprocessing.pool.Pool.starmap")
|
starmap_mock = mocker.patch("multiprocessing.pool.Pool.starmap")
|
||||||
|
|
||||||
Handler.execute(args)
|
Handler.execute(args)
|
||||||
@ -88,7 +97,7 @@ def test_execute_multiple_not_supported(args: argparse.Namespace, mocker: Mocker
|
|||||||
must raise an exception if multiple architectures are not supported by the handler
|
must raise an exception if multiple architectures are not supported by the handler
|
||||||
"""
|
"""
|
||||||
args.command = "web"
|
args.command = "web"
|
||||||
mocker.patch("ahriman.application.handlers.Handler.repositories_extract", return_value=[
|
mocker.patch("ahriman.application.handlers.handler.Handler.repositories_extract", return_value=[
|
||||||
RepositoryId("i686", "aur"),
|
RepositoryId("i686", "aur"),
|
||||||
RepositoryId("x86_64", "aur"),
|
RepositoryId("x86_64", "aur"),
|
||||||
])
|
])
|
||||||
@ -102,7 +111,7 @@ def test_execute_single(args: argparse.Namespace, mocker: MockerFixture) -> None
|
|||||||
"""
|
"""
|
||||||
must run execution in current process if only one architecture supplied
|
must run execution in current process if only one architecture supplied
|
||||||
"""
|
"""
|
||||||
mocker.patch("ahriman.application.handlers.Handler.repositories_extract", return_value=[
|
mocker.patch("ahriman.application.handlers.handler.Handler.repositories_extract", return_value=[
|
||||||
RepositoryId("x86_64", "aur"),
|
RepositoryId("x86_64", "aur"),
|
||||||
])
|
])
|
||||||
starmap_mock = mocker.patch("multiprocessing.pool.Pool.starmap")
|
starmap_mock = mocker.patch("multiprocessing.pool.Pool.starmap")
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import pytest
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import Add
|
from ahriman.application.handlers.add import Add
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
from ahriman.models.package import Package
|
from ahriman.models.package import Package
|
||||||
@ -82,7 +82,7 @@ def test_run_with_updates(args: argparse.Namespace, configuration: Configuration
|
|||||||
mocker.patch("ahriman.application.application.Application.add")
|
mocker.patch("ahriman.application.application.Application.add")
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result)
|
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result)
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
changes_mock = mocker.patch("ahriman.application.application.Application.changes")
|
changes_mock = mocker.patch("ahriman.application.application.Application.changes")
|
||||||
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
|
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
|
||||||
dependencies_mock = mocker.patch("ahriman.application.application.Application.with_dependencies",
|
dependencies_mock = mocker.patch("ahriman.application.application.Application.with_dependencies",
|
||||||
@ -113,7 +113,7 @@ def test_run_no_changes(args: argparse.Namespace, configuration: Configuration,
|
|||||||
mocker.patch("ahriman.application.application.Application.add")
|
mocker.patch("ahriman.application.application.Application.add")
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.application.application.Application.update")
|
mocker.patch("ahriman.application.application.Application.update")
|
||||||
mocker.patch("ahriman.application.handlers.Handler.check_status")
|
mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
mocker.patch("ahriman.application.application.Application.updates")
|
mocker.patch("ahriman.application.application.Application.updates")
|
||||||
mocker.patch("ahriman.application.application.Application.with_dependencies")
|
mocker.patch("ahriman.application.application.Application.with_dependencies")
|
||||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||||
@ -138,7 +138,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
|||||||
mocker.patch("ahriman.application.application.Application.with_dependencies")
|
mocker.patch("ahriman.application.application.Application.with_dependencies")
|
||||||
mocker.patch("ahriman.application.application.Application.updates")
|
mocker.patch("ahriman.application.application.Application.updates")
|
||||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Add.run(args, repository_id, configuration, report=False)
|
Add.run(args, repository_id, configuration, report=False)
|
||||||
|
|||||||
@ -4,7 +4,7 @@ from pathlib import Path
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
from ahriman.application.handlers import Backup
|
from ahriman.application.handlers.backup import Backup
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.models.repository_paths import RepositoryPaths
|
from ahriman.models.repository_paths import RepositoryPaths
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
|||||||
must run command
|
must run command
|
||||||
"""
|
"""
|
||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
mocker.patch("ahriman.application.handlers.Backup.get_paths", return_value=[Path("path")])
|
mocker.patch("ahriman.application.handlers.backup.Backup.get_paths", return_value=[Path("path")])
|
||||||
tarfile = MagicMock()
|
tarfile = MagicMock()
|
||||||
add_mock = tarfile.__enter__.return_value = MagicMock()
|
add_mock = tarfile.__enter__.return_value = MagicMock()
|
||||||
mocker.patch("ahriman.application.handlers.backup.tarfile.open", return_value=tarfile)
|
mocker.patch("ahriman.application.handlers.backup.tarfile.open", return_value=tarfile)
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import pytest
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import Change
|
from ahriman.application.handlers.change import Change
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.database import SQLite
|
from ahriman.core.database import SQLite
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
@ -36,7 +36,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
|||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
application_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_get",
|
application_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_get",
|
||||||
return_value=Changes("sha", "change"))
|
return_value=Changes("sha", "change"))
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
@ -55,7 +55,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
|||||||
args.exit_code = True
|
args.exit_code = True
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_get", return_value=Changes())
|
mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_get", return_value=Changes())
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Change.run(args, repository_id, configuration, report=False)
|
Change.run(args, repository_id, configuration, report=False)
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import argparse
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import Clean
|
from ahriman.application.handlers.clean import Clean
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
|
|
||||||
|
|||||||
105
tests/ahriman/application/handlers/test_handler_copy.py
Normal file
105
tests/ahriman/application/handlers/test_handler_copy.py
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
import argparse
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
|
from ahriman.application.application import Application
|
||||||
|
from ahriman.application.handlers.copy import Copy
|
||||||
|
from ahriman.core.configuration import Configuration
|
||||||
|
from ahriman.core.repository import Repository
|
||||||
|
from ahriman.models.build_status import BuildStatusEnum
|
||||||
|
from ahriman.models.package import Package
|
||||||
|
from ahriman.models.package_source import PackageSource
|
||||||
|
|
||||||
|
|
||||||
|
def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||||
|
"""
|
||||||
|
default arguments for these test cases
|
||||||
|
|
||||||
|
Args:
|
||||||
|
args(argparse.Namespace): command line arguments fixture
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
argparse.Namespace: generated arguments for these test cases
|
||||||
|
"""
|
||||||
|
args.source = "source"
|
||||||
|
args.package = ["ahriman"]
|
||||||
|
args.exit_code = False
|
||||||
|
args.remove = False
|
||||||
|
return args
|
||||||
|
|
||||||
|
|
||||||
|
def test_run(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||||
|
package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||||
|
"""
|
||||||
|
must run command
|
||||||
|
"""
|
||||||
|
args = _default_args(args)
|
||||||
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
|
mocker.patch("ahriman.core.repository.Repository.packages", return_value=[package_ahriman])
|
||||||
|
application_mock = mocker.patch("ahriman.application.handlers.copy.Copy.copy_package")
|
||||||
|
update_mock = mocker.patch("ahriman.application.application.Application.update")
|
||||||
|
remove_mock = mocker.patch("ahriman.application.application.Application.remove")
|
||||||
|
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||||
|
|
||||||
|
_, repository_id = configuration.check_loaded()
|
||||||
|
Copy.run(args, repository_id, configuration, report=False)
|
||||||
|
application_mock.assert_called_once_with(package_ahriman, pytest.helpers.anyvar(int), pytest.helpers.anyvar(int))
|
||||||
|
update_mock.assert_called_once_with([])
|
||||||
|
remove_mock.assert_not_called()
|
||||||
|
on_start_mock.assert_called_once_with()
|
||||||
|
|
||||||
|
|
||||||
|
def test_run_remove(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||||
|
package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||||
|
"""
|
||||||
|
must run command and remove packages afterwards
|
||||||
|
"""
|
||||||
|
args = _default_args(args)
|
||||||
|
args.remove = True
|
||||||
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
|
mocker.patch("ahriman.core.repository.Repository.packages", return_value=[package_ahriman])
|
||||||
|
mocker.patch("ahriman.application.handlers.copy.Copy.copy_package")
|
||||||
|
mocker.patch("ahriman.application.application.Application.update")
|
||||||
|
remove_mock = mocker.patch("ahriman.application.application.Application.remove")
|
||||||
|
|
||||||
|
_, repository_id = configuration.check_loaded()
|
||||||
|
Copy.run(args, repository_id, configuration, report=False)
|
||||||
|
remove_mock.assert_called_once_with(args.package)
|
||||||
|
|
||||||
|
|
||||||
|
def test_run_empty_exception(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||||
|
mocker: MockerFixture) -> None:
|
||||||
|
"""
|
||||||
|
must raise ExitCode exception on empty result
|
||||||
|
"""
|
||||||
|
args = _default_args(args)
|
||||||
|
args.exit_code = True
|
||||||
|
mocker.patch("ahriman.core.repository.Repository.packages", return_value=[])
|
||||||
|
mocker.patch("ahriman.application.application.Application.update")
|
||||||
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
|
_, repository_id = configuration.check_loaded()
|
||||||
|
Copy.run(args, repository_id, configuration, report=False)
|
||||||
|
check_mock.assert_called_once_with(True, [])
|
||||||
|
|
||||||
|
|
||||||
|
def test_copy_package(package_ahriman: Package, application: Application, mocker: MockerFixture) -> None:
|
||||||
|
"""
|
||||||
|
must copy package between repositories and its metadata
|
||||||
|
"""
|
||||||
|
add_mock = mocker.patch("ahriman.application.application.Application.add")
|
||||||
|
changes_get_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_get")
|
||||||
|
changes_update_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_update")
|
||||||
|
deps_get_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_dependencies_get")
|
||||||
|
deps_update_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_dependencies_update")
|
||||||
|
package_update_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_update")
|
||||||
|
path = application.repository.paths.repository / package_ahriman.packages[package_ahriman.base].filename
|
||||||
|
|
||||||
|
Copy.copy_package(package_ahriman, application, application)
|
||||||
|
add_mock.assert_called_once_with([str(path)], PackageSource.Archive)
|
||||||
|
changes_get_mock.assert_called_once_with(package_ahriman.base)
|
||||||
|
changes_update_mock.assert_called_once_with(package_ahriman.base, changes_get_mock.return_value)
|
||||||
|
deps_get_mock.assert_called_once_with(package_ahriman.base)
|
||||||
|
deps_update_mock.assert_called_once_with(package_ahriman.base, deps_get_mock.return_value)
|
||||||
|
package_update_mock.assert_called_once_with(package_ahriman, BuildStatusEnum.Pending)
|
||||||
@ -2,7 +2,7 @@ import argparse
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import Daemon
|
from ahriman.application.handlers.daemon import Daemon
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
from ahriman.models.package import Package
|
from ahriman.models.package import Package
|
||||||
@ -31,7 +31,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, package_ahr
|
|||||||
"""
|
"""
|
||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
run_mock = mocker.patch("ahriman.application.handlers.Update.run")
|
run_mock = mocker.patch("ahriman.application.handlers.update.Update.run")
|
||||||
iter_mock = mocker.patch("ahriman.application.application.updates_iterator.UpdatesIterator.__iter__",
|
iter_mock = mocker.patch("ahriman.application.application.updates_iterator.UpdatesIterator.__iter__",
|
||||||
return_value=iter([[package_ahriman.base]]))
|
return_value=iter([[package_ahriman.base]]))
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ def test_run_no_partitions(args: argparse.Namespace, configuration: Configuratio
|
|||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
args.partitions = False
|
args.partitions = False
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
run_mock = mocker.patch("ahriman.application.handlers.Update.run")
|
run_mock = mocker.patch("ahriman.application.handlers.update.Update.run")
|
||||||
iter_mock = mocker.patch("ahriman.application.application.updates_iterator.UpdatesIterator.__iter__",
|
iter_mock = mocker.patch("ahriman.application.application.updates_iterator.UpdatesIterator.__iter__",
|
||||||
return_value=iter([[]]))
|
return_value=iter([[]]))
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ def test_run_no_updates(args: argparse.Namespace, configuration: Configuration,
|
|||||||
"""
|
"""
|
||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
run_mock = mocker.patch("ahriman.application.handlers.Update.run")
|
run_mock = mocker.patch("ahriman.application.handlers.update.Update.run")
|
||||||
iter_mock = mocker.patch("ahriman.application.application.updates_iterator.UpdatesIterator.__iter__",
|
iter_mock = mocker.patch("ahriman.application.application.updates_iterator.UpdatesIterator.__iter__",
|
||||||
return_value=iter([[package_ahriman.base], None]))
|
return_value=iter([[package_ahriman.base], None]))
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import pytest
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import Dump
|
from ahriman.application.handlers.dump import Dump
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import argparse
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.ahriman import _parser
|
from ahriman.application.ahriman import _parser
|
||||||
from ahriman.application.handlers import Help
|
from ahriman.application.handlers.help import Help
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import argparse
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import KeyImport
|
from ahriman.application.handlers.key_import import KeyImport
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from pathlib import Path
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers import Patch
|
from ahriman.application.handlers.patch import Patch
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
from ahriman.models.action import Action
|
from ahriman.models.action import Action
|
||||||
@ -40,9 +40,9 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
|||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
args.action = Action.Update
|
args.action = Action.Update
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
patch_mock = mocker.patch("ahriman.application.handlers.Patch.patch_create_from_diff",
|
patch_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_create_from_diff",
|
||||||
return_value=(args.package, PkgbuildPatch(None, "patch")))
|
return_value=(args.package, PkgbuildPatch(None, "patch")))
|
||||||
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_create")
|
application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_create")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Patch.run(args, repository_id, configuration, report=False)
|
Patch.run(args, repository_id, configuration, report=False)
|
||||||
@ -61,8 +61,9 @@ def test_run_function(args: argparse.Namespace, configuration: Configuration, re
|
|||||||
args.variable = "version"
|
args.variable = "version"
|
||||||
patch = PkgbuildPatch(args.variable, args.patch)
|
patch = PkgbuildPatch(args.variable, args.patch)
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
patch_mock = mocker.patch("ahriman.application.handlers.Patch.patch_create_from_function", return_value=patch)
|
patch_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_create_from_function",
|
||||||
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_create")
|
return_value=patch)
|
||||||
|
application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_create")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Patch.run(args, repository_id, configuration, report=False)
|
Patch.run(args, repository_id, configuration, report=False)
|
||||||
@ -79,7 +80,7 @@ def test_run_list(args: argparse.Namespace, configuration: Configuration, reposi
|
|||||||
args.action = Action.List
|
args.action = Action.List
|
||||||
args.variable = ["version"]
|
args.variable = ["version"]
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_list")
|
application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_list")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Patch.run(args, repository_id, configuration, report=False)
|
Patch.run(args, repository_id, configuration, report=False)
|
||||||
@ -95,7 +96,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, repo
|
|||||||
args.action = Action.Remove
|
args.action = Action.Remove
|
||||||
args.variable = ["version"]
|
args.variable = ["version"]
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_remove")
|
application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_remove")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Patch.run(args, repository_id, configuration, report=False)
|
Patch.run(args, repository_id, configuration, report=False)
|
||||||
@ -163,7 +164,7 @@ def test_patch_set_list(application: Application, mocker: MockerFixture) -> None
|
|||||||
get_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_patches_get",
|
get_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_patches_get",
|
||||||
return_value=[PkgbuildPatch(None, "patch"), PkgbuildPatch("version", "value")])
|
return_value=[PkgbuildPatch(None, "patch"), PkgbuildPatch("version", "value")])
|
||||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
Patch.patch_set_list(application, "ahriman", ["version"], False)
|
Patch.patch_set_list(application, "ahriman", ["version"], False)
|
||||||
get_mock.assert_called_once_with("ahriman", None)
|
get_mock.assert_called_once_with("ahriman", None)
|
||||||
@ -178,7 +179,7 @@ def test_patch_set_list_all(application: Application, mocker: MockerFixture) ->
|
|||||||
get_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_patches_get",
|
get_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_patches_get",
|
||||||
return_value=[PkgbuildPatch(None, "patch")])
|
return_value=[PkgbuildPatch(None, "patch")])
|
||||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
Patch.patch_set_list(application, "ahriman", None, False)
|
Patch.patch_set_list(application, "ahriman", None, False)
|
||||||
get_mock.assert_called_once_with("ahriman", None)
|
get_mock.assert_called_once_with("ahriman", None)
|
||||||
@ -191,7 +192,7 @@ def test_patch_set_list_empty_exception(application: Application, mocker: Mocker
|
|||||||
must raise ExitCode exception on empty patch list
|
must raise ExitCode exception on empty patch list
|
||||||
"""
|
"""
|
||||||
mocker.patch("ahriman.core.status.local_client.LocalClient.package_patches_get", return_value={})
|
mocker.patch("ahriman.core.status.local_client.LocalClient.package_patches_get", return_value={})
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
Patch.patch_set_list(application, "ahriman", [], True)
|
Patch.patch_set_list(application, "ahriman", [], True)
|
||||||
check_mock.assert_called_once_with(True, [])
|
check_mock.assert_called_once_with(True, [])
|
||||||
|
|||||||
@ -5,7 +5,7 @@ from pytest_mock import MockerFixture
|
|||||||
from unittest.mock import call as MockCall
|
from unittest.mock import call as MockCall
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers import Rebuild
|
from ahriman.application.handlers.rebuild import Rebuild
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||||
@ -43,11 +43,12 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, configuration:
|
|||||||
result = Result()
|
result = Result()
|
||||||
result.add_updated(package_ahriman)
|
result.add_updated(package_ahriman)
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
extract_mock = mocker.patch("ahriman.application.handlers.Rebuild.extract_packages", return_value=[package_ahriman])
|
extract_mock = mocker.patch("ahriman.application.handlers.rebuild.Rebuild.extract_packages",
|
||||||
|
return_value=[package_ahriman])
|
||||||
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on",
|
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on",
|
||||||
return_value=[package_ahriman])
|
return_value=[package_ahriman])
|
||||||
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result)
|
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result)
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
@ -70,7 +71,7 @@ def test_run_extract_packages(args: argparse.Namespace, configuration: Configura
|
|||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.application.application.Application.add")
|
mocker.patch("ahriman.application.application.Application.add")
|
||||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||||
extract_mock = mocker.patch("ahriman.application.handlers.Rebuild.extract_packages", return_value=[])
|
extract_mock = mocker.patch("ahriman.application.handlers.rebuild.Rebuild.extract_packages", return_value=[])
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Rebuild.run(args, repository_id, configuration, report=False)
|
Rebuild.run(args, repository_id, configuration, report=False)
|
||||||
@ -85,9 +86,9 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, rep
|
|||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
args.dry_run = True
|
args.dry_run = True
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.application.handlers.Rebuild.extract_packages", return_value=[package_ahriman])
|
mocker.patch("ahriman.application.handlers.rebuild.Rebuild.extract_packages", return_value=[package_ahriman])
|
||||||
application_mock = mocker.patch("ahriman.application.application.Application.update")
|
application_mock = mocker.patch("ahriman.application.application.Application.update")
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
print_mock = mocker.patch("ahriman.application.application.Application.print_updates")
|
print_mock = mocker.patch("ahriman.application.application.Application.print_updates")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
@ -106,7 +107,7 @@ def test_run_filter(args: argparse.Namespace, configuration: Configuration, repo
|
|||||||
args.depends_on = ["python-aur"]
|
args.depends_on = ["python-aur"]
|
||||||
mocker.patch("ahriman.application.application.Application.update")
|
mocker.patch("ahriman.application.application.Application.update")
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.application.handlers.Rebuild.extract_packages", return_value=[])
|
mocker.patch("ahriman.application.handlers.rebuild.Rebuild.extract_packages", return_value=[])
|
||||||
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on")
|
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
@ -122,7 +123,7 @@ def test_run_without_filter(args: argparse.Namespace, configuration: Configurati
|
|||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
mocker.patch("ahriman.application.application.Application.update")
|
mocker.patch("ahriman.application.application.Application.update")
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.application.handlers.Rebuild.extract_packages", return_value=[])
|
mocker.patch("ahriman.application.handlers.rebuild.Rebuild.extract_packages", return_value=[])
|
||||||
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on")
|
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
@ -139,10 +140,10 @@ def test_run_update_empty_exception(args: argparse.Namespace, configuration: Con
|
|||||||
args.exit_code = True
|
args.exit_code = True
|
||||||
args.dry_run = True
|
args.dry_run = True
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.application.handlers.Rebuild.extract_packages")
|
mocker.patch("ahriman.application.handlers.rebuild.Rebuild.extract_packages")
|
||||||
mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on", return_value=[])
|
mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on", return_value=[])
|
||||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Rebuild.run(args, repository_id, configuration, report=False)
|
Rebuild.run(args, repository_id, configuration, report=False)
|
||||||
@ -157,10 +158,10 @@ def test_run_build_empty_exception(args: argparse.Namespace, configuration: Conf
|
|||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
args.exit_code = True
|
args.exit_code = True
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.application.handlers.Rebuild.extract_packages")
|
mocker.patch("ahriman.application.handlers.rebuild.Rebuild.extract_packages")
|
||||||
mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on", return_value=[package_ahriman])
|
mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on", return_value=[package_ahriman])
|
||||||
mocker.patch("ahriman.application.application.Application.update", return_value=Result())
|
mocker.patch("ahriman.application.application.Application.update", return_value=Result())
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Rebuild.run(args, repository_id, configuration, report=False)
|
Rebuild.run(args, repository_id, configuration, report=False)
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import argparse
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import Remove
|
from ahriman.application.handlers.remove import Remove
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import pytest
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import RemoveUnknown
|
from ahriman.application.handlers.remove_unknown import RemoveUnknown
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
from ahriman.models.package import Package
|
from ahriman.models.package import Package
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import pytest
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import Repositories
|
from ahriman.application.handlers.repositories import Repositories
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
|
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
|||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
application_mock = mocker.patch("ahriman.application.handlers.Handler.repositories_extract",
|
application_mock = mocker.patch("ahriman.application.handlers.handler.Handler.repositories_extract",
|
||||||
return_value=[repository_id])
|
return_value=[repository_id])
|
||||||
|
|
||||||
Repositories.run(args, repository_id, configuration, report=False)
|
Repositories.run(args, repository_id, configuration, report=False)
|
||||||
|
|||||||
@ -4,7 +4,7 @@ from pathlib import Path
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
from ahriman.application.handlers import Restore
|
from ahriman.application.handlers.restore import Restore
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import pytest
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.ahriman import _parser
|
from ahriman.application.ahriman import _parser
|
||||||
from ahriman.application.handlers import Run
|
from ahriman.application.handlers.run import Run
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.exceptions import ExitCode
|
from ahriman.core.exceptions import ExitCode
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
|||||||
must run command
|
must run command
|
||||||
"""
|
"""
|
||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
application_mock = mocker.patch("ahriman.application.handlers.Run.run_command")
|
application_mock = mocker.patch("ahriman.application.handlers.run.Run.run_command")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Run.run(args, repository_id, configuration, report=False)
|
Run.run(args, repository_id, configuration, report=False)
|
||||||
@ -42,7 +42,7 @@ def test_run_failed(args: argparse.Namespace, configuration: Configuration, mock
|
|||||||
"""
|
"""
|
||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
args.command = ["help", "config"]
|
args.command = ["help", "config"]
|
||||||
application_mock = mocker.patch("ahriman.application.handlers.Run.run_command", return_value=False)
|
application_mock = mocker.patch("ahriman.application.handlers.run.Run.run_command", return_value=False)
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
with pytest.raises(ExitCode):
|
with pytest.raises(ExitCode):
|
||||||
@ -54,8 +54,13 @@ def test_run_command(mocker: MockerFixture) -> None:
|
|||||||
"""
|
"""
|
||||||
must correctly run external command
|
must correctly run external command
|
||||||
"""
|
"""
|
||||||
execute_mock = mocker.patch("ahriman.application.handlers.Help.execute")
|
# because of dynamic load we need to patch exact instance of the object
|
||||||
Run.run_command(["help"], _parser())
|
parser = _parser()
|
||||||
|
subparser = next((action for action in parser._actions if isinstance(action, argparse._SubParsersAction)), None)
|
||||||
|
action = subparser.choices["help"]
|
||||||
|
execute_mock = mocker.patch.object(action.get_default("handler"), "execute")
|
||||||
|
|
||||||
|
Run.run_command(["help"], parser)
|
||||||
execute_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
execute_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import pytest
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
from unittest.mock import call as MockCall
|
from unittest.mock import call as MockCall
|
||||||
|
|
||||||
from ahriman.application.handlers import Search
|
from ahriman.application.handlers.search import Search
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.exceptions import OptionError
|
from ahriman.core.exceptions import OptionError
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
@ -39,7 +39,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
|||||||
aur_search_mock = mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman])
|
aur_search_mock = mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman])
|
||||||
official_search_mock = mocker.patch("ahriman.core.alpm.remote.Official.multisearch",
|
official_search_mock = mocker.patch("ahriman.core.alpm.remote.Official.multisearch",
|
||||||
return_value=[aur_package_ahriman])
|
return_value=[aur_package_ahriman])
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
@ -64,7 +64,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
|||||||
mocker.patch("ahriman.core.alpm.remote.Official.multisearch", return_value=[])
|
mocker.patch("ahriman.core.alpm.remote.Official.multisearch", return_value=[])
|
||||||
mocker.patch("ahriman.core.formatters.Printer.print")
|
mocker.patch("ahriman.core.formatters.Printer.print")
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Search.run(args, repository_id, configuration, report=False)
|
Search.run(args, repository_id, configuration, report=False)
|
||||||
@ -80,7 +80,7 @@ def test_run_sort(args: argparse.Namespace, configuration: Configuration, reposi
|
|||||||
mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman])
|
mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman])
|
||||||
mocker.patch("ahriman.core.alpm.remote.Official.multisearch", return_value=[])
|
mocker.patch("ahriman.core.alpm.remote.Official.multisearch", return_value=[])
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
sort_mock = mocker.patch("ahriman.application.handlers.Search.sort")
|
sort_mock = mocker.patch("ahriman.application.handlers.search.Search.sort")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Search.run(args, repository_id, configuration, report=False)
|
Search.run(args, repository_id, configuration, report=False)
|
||||||
@ -100,7 +100,7 @@ def test_run_sort_by(args: argparse.Namespace, configuration: Configuration, rep
|
|||||||
mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman])
|
mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman])
|
||||||
mocker.patch("ahriman.core.alpm.remote.Official.multisearch", return_value=[])
|
mocker.patch("ahriman.core.alpm.remote.Official.multisearch", return_value=[])
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
sort_mock = mocker.patch("ahriman.application.handlers.Search.sort")
|
sort_mock = mocker.patch("ahriman.application.handlers.search.Search.sort")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Search.run(args, repository_id, configuration, report=False)
|
Search.run(args, repository_id, configuration, report=False)
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import pytest
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman import __version__
|
from ahriman import __version__
|
||||||
from ahriman.application.handlers import ServiceUpdates
|
from ahriman.application.handlers.service_updates import ServiceUpdates
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
from ahriman.models.package import Package
|
from ahriman.models.package import Package
|
||||||
@ -34,7 +34,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
|||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
package_mock = mocker.patch("ahriman.models.package.Package.from_aur", return_value=package_ahriman)
|
package_mock = mocker.patch("ahriman.models.package.Package.from_aur", return_value=package_ahriman)
|
||||||
application_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
application_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
ServiceUpdates.run(args, repository_id, configuration, report=False)
|
ServiceUpdates.run(args, repository_id, configuration, report=False)
|
||||||
@ -53,7 +53,7 @@ def test_run_skip(args: argparse.Namespace, configuration: Configuration, reposi
|
|||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.models.package.Package.from_aur", return_value=package_ahriman)
|
mocker.patch("ahriman.models.package.Package.from_aur", return_value=package_ahriman)
|
||||||
application_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
application_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
ServiceUpdates.run(args, repository_id, configuration, report=False)
|
ServiceUpdates.run(args, repository_id, configuration, report=False)
|
||||||
|
|||||||
@ -7,7 +7,7 @@ from typing import Any
|
|||||||
from unittest.mock import call as MockCall
|
from unittest.mock import call as MockCall
|
||||||
from urllib.parse import quote_plus as urlencode
|
from urllib.parse import quote_plus as urlencode
|
||||||
|
|
||||||
from ahriman.application.handlers import Setup
|
from ahriman.application.handlers.setup import Setup
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.exceptions import MissingArchitectureError
|
from ahriman.core.exceptions import MissingArchitectureError
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
@ -50,11 +50,11 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
|||||||
"""
|
"""
|
||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
ahriman_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_ahriman")
|
ahriman_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_ahriman")
|
||||||
devtools_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_devtools")
|
devtools_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_devtools")
|
||||||
makepkg_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_makepkg")
|
makepkg_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_makepkg")
|
||||||
sudo_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_sudo")
|
sudo_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_sudo")
|
||||||
executable_mock = mocker.patch("ahriman.application.handlers.Setup.executable_create")
|
executable_mock = mocker.patch("ahriman.application.handlers.setup.Setup.executable_create")
|
||||||
init_mock = mocker.patch("ahriman.core.alpm.repo.Repo.init")
|
init_mock = mocker.patch("ahriman.core.alpm.repo.Repo.init")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
@ -95,12 +95,12 @@ def test_run_with_server(args: argparse.Namespace, configuration: Configuration,
|
|||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
args.server = "server"
|
args.server = "server"
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.application.handlers.Setup.configuration_create_ahriman")
|
mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_ahriman")
|
||||||
mocker.patch("ahriman.application.handlers.Setup.configuration_create_makepkg")
|
mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_makepkg")
|
||||||
mocker.patch("ahriman.application.handlers.Setup.configuration_create_sudo")
|
mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_sudo")
|
||||||
mocker.patch("ahriman.application.handlers.Setup.executable_create")
|
mocker.patch("ahriman.application.handlers.setup.Setup.executable_create")
|
||||||
mocker.patch("ahriman.core.alpm.repo.Repo.init")
|
mocker.patch("ahriman.core.alpm.repo.Repo.init")
|
||||||
devtools_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_devtools")
|
devtools_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_devtools")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Setup.run(args, repository_id, configuration, report=False)
|
Setup.run(args, repository_id, configuration, report=False)
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import pytest
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import Shell
|
from ahriman.application.handlers.shell import Shell
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import argparse
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import Sign
|
from ahriman.application.handlers.sign import Sign
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ from pathlib import Path
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
from unittest.mock import call as MockCall
|
from unittest.mock import call as MockCall
|
||||||
|
|
||||||
from ahriman.application.handlers import Statistics
|
from ahriman.application.handlers.statistics import Statistics
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
from ahriman.core.utils import pretty_datetime, utcnow
|
from ahriman.core.utils import pretty_datetime, utcnow
|
||||||
@ -42,7 +42,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
|||||||
events = [Event("1", "1"), Event("2", "2")]
|
events = [Event("1", "1"), Event("2", "2")]
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
events_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.event_get", return_value=events)
|
events_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.event_get", return_value=events)
|
||||||
application_mock = mocker.patch("ahriman.application.handlers.Statistics.stats_per_package")
|
application_mock = mocker.patch("ahriman.application.handlers.statistics.Statistics.stats_per_package")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Statistics.run(args, repository_id, configuration, report=False)
|
Statistics.run(args, repository_id, configuration, report=False)
|
||||||
@ -60,7 +60,7 @@ def test_run_for_package(args: argparse.Namespace, configuration: Configuration,
|
|||||||
events = [Event("1", "1"), Event("2", "2")]
|
events = [Event("1", "1"), Event("2", "2")]
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
events_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.event_get", return_value=events)
|
events_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.event_get", return_value=events)
|
||||||
application_mock = mocker.patch("ahriman.application.handlers.Statistics.stats_for_package")
|
application_mock = mocker.patch("ahriman.application.handlers.statistics.Statistics.stats_for_package")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Statistics.run(args, repository_id, configuration, report=False)
|
Statistics.run(args, repository_id, configuration, report=False)
|
||||||
@ -77,7 +77,7 @@ def test_run_convert_from_date(args: argparse.Namespace, configuration: Configur
|
|||||||
date = utcnow()
|
date = utcnow()
|
||||||
args.from_date = date.isoformat()
|
args.from_date = date.isoformat()
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.application.handlers.Statistics.stats_per_package")
|
mocker.patch("ahriman.application.handlers.statistics.Statistics.stats_per_package")
|
||||||
events_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.event_get", return_value=[])
|
events_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.event_get", return_value=[])
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
@ -94,7 +94,7 @@ def test_run_convert_to_date(args: argparse.Namespace, configuration: Configurat
|
|||||||
date = utcnow()
|
date = utcnow()
|
||||||
args.to_date = date.isoformat()
|
args.to_date = date.isoformat()
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.application.handlers.Statistics.stats_per_package")
|
mocker.patch("ahriman.application.handlers.statistics.Statistics.stats_per_package")
|
||||||
events_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.event_get", return_value=[])
|
events_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.event_get", return_value=[])
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
@ -147,8 +147,8 @@ def test_stats_for_package(mocker: MockerFixture) -> None:
|
|||||||
must print statistics for the package
|
must print statistics for the package
|
||||||
"""
|
"""
|
||||||
events = [Event("event", "1"), Event("event", "1")]
|
events = [Event("event", "1"), Event("event", "1")]
|
||||||
events_mock = mocker.patch("ahriman.application.handlers.Statistics.event_stats")
|
events_mock = mocker.patch("ahriman.application.handlers.statistics.Statistics.event_stats")
|
||||||
chart_plot = mocker.patch("ahriman.application.handlers.Statistics.plot_times")
|
chart_plot = mocker.patch("ahriman.application.handlers.statistics.Statistics.plot_times")
|
||||||
|
|
||||||
Statistics.stats_for_package("event", events, None)
|
Statistics.stats_for_package("event", events, None)
|
||||||
events_mock.assert_called_once_with("event", events)
|
events_mock.assert_called_once_with("event", events)
|
||||||
@ -161,8 +161,8 @@ def test_stats_for_package_with_chart(mocker: MockerFixture) -> None:
|
|||||||
"""
|
"""
|
||||||
local = Path("local")
|
local = Path("local")
|
||||||
events = [Event("event", "1"), Event("event", "1")]
|
events = [Event("event", "1"), Event("event", "1")]
|
||||||
mocker.patch("ahriman.application.handlers.Statistics.event_stats")
|
mocker.patch("ahriman.application.handlers.statistics.Statistics.event_stats")
|
||||||
chart_plot = mocker.patch("ahriman.application.handlers.Statistics.plot_times")
|
chart_plot = mocker.patch("ahriman.application.handlers.statistics.Statistics.plot_times")
|
||||||
|
|
||||||
Statistics.stats_for_package("event", events, local)
|
Statistics.stats_for_package("event", events, local)
|
||||||
chart_plot.assert_called_once_with("event", events, local)
|
chart_plot.assert_called_once_with("event", events, local)
|
||||||
@ -174,8 +174,8 @@ def test_stats_per_package(mocker: MockerFixture) -> None:
|
|||||||
"""
|
"""
|
||||||
events = [Event("event", "1"), Event("event", "2"), Event("event", "1")]
|
events = [Event("event", "1"), Event("event", "2"), Event("event", "1")]
|
||||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||||
events_mock = mocker.patch("ahriman.application.handlers.Statistics.event_stats")
|
events_mock = mocker.patch("ahriman.application.handlers.statistics.Statistics.event_stats")
|
||||||
chart_plot = mocker.patch("ahriman.application.handlers.Statistics.plot_packages")
|
chart_plot = mocker.patch("ahriman.application.handlers.statistics.Statistics.plot_packages")
|
||||||
|
|
||||||
Statistics.stats_per_package("event", events, None)
|
Statistics.stats_per_package("event", events, None)
|
||||||
print_mock.assert_has_calls([
|
print_mock.assert_has_calls([
|
||||||
@ -192,8 +192,8 @@ def test_stats_per_package_with_chart(mocker: MockerFixture) -> None:
|
|||||||
"""
|
"""
|
||||||
local = Path("local")
|
local = Path("local")
|
||||||
events = [Event("event", "1"), Event("event", "2"), Event("event", "1")]
|
events = [Event("event", "1"), Event("event", "2"), Event("event", "1")]
|
||||||
mocker.patch("ahriman.application.handlers.Statistics.event_stats")
|
mocker.patch("ahriman.application.handlers.statistics.Statistics.event_stats")
|
||||||
chart_plot = mocker.patch("ahriman.application.handlers.Statistics.plot_packages")
|
chart_plot = mocker.patch("ahriman.application.handlers.statistics.Statistics.plot_packages")
|
||||||
|
|
||||||
Statistics.stats_per_package("event", events, local)
|
Statistics.stats_per_package("event", events, local)
|
||||||
chart_plot.assert_called_once_with("event", {"1": 2, "2": 1}, local)
|
chart_plot.assert_called_once_with("event", {"1": 2, "2": 1}, local)
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import pytest
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
from unittest.mock import call as MockCall
|
from unittest.mock import call as MockCall
|
||||||
|
|
||||||
from ahriman.application.handlers import Status
|
from ahriman.application.handlers.status import Status
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.database import SQLite
|
from ahriman.core.database import SQLite
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
@ -43,7 +43,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
|||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
application_mock = mocker.patch("ahriman.core.status.Client.status_get")
|
application_mock = mocker.patch("ahriman.core.status.Client.status_get")
|
||||||
packages_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_get", return_value=packages)
|
packages_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_get", return_value=packages)
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
@ -67,7 +67,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
|||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.core.status.Client.status_get")
|
mocker.patch("ahriman.core.status.Client.status_get")
|
||||||
mocker.patch("ahriman.core.status.local_client.LocalClient.package_get", return_value=[])
|
mocker.patch("ahriman.core.status.local_client.LocalClient.package_get", return_value=[])
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Status.run(args, repository_id, configuration, report=False)
|
Status.run(args, repository_id, configuration, report=False)
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import argparse
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import StatusUpdate
|
from ahriman.application.handlers.status_update import StatusUpdate
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.database import SQLite
|
from ahriman.core.database import SQLite
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import pytest
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
from unittest.mock import call as MockCall
|
from unittest.mock import call as MockCall
|
||||||
|
|
||||||
from ahriman.application.handlers import Structure
|
from ahriman.application.handlers.structure import Structure
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
from ahriman.models.package import Package
|
from ahriman.models.package import Package
|
||||||
|
|||||||
@ -4,7 +4,7 @@ from pathlib import Path
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
from unittest.mock import call as MockCall
|
from unittest.mock import call as MockCall
|
||||||
|
|
||||||
from ahriman.application.handlers import TreeMigrate
|
from ahriman.application.handlers.tree_migrate import TreeMigrate
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.models.repository_id import RepositoryId
|
from ahriman.models.repository_id import RepositoryId
|
||||||
from ahriman.models.repository_paths import RepositoryPaths
|
from ahriman.models.repository_paths import RepositoryPaths
|
||||||
@ -15,7 +15,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
|||||||
must run command
|
must run command
|
||||||
"""
|
"""
|
||||||
tree_create_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
tree_create_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||||
application_mock = mocker.patch("ahriman.application.handlers.TreeMigrate.tree_move")
|
application_mock = mocker.patch("ahriman.application.handlers.tree_migrate.TreeMigrate.tree_move")
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
old_paths = configuration.repository_paths
|
old_paths = configuration.repository_paths
|
||||||
new_paths = RepositoryPaths(old_paths.root, old_paths.repository_id, _force_current_tree=True)
|
new_paths = RepositoryPaths(old_paths.root, old_paths.repository_id, _force_current_tree=True)
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import argparse
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import Triggers
|
from ahriman.application.handlers.triggers import Triggers
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
from ahriman.models.package import Package
|
from ahriman.models.package import Package
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import pytest
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.ahriman import _parser
|
from ahriman.application.ahriman import _parser
|
||||||
from ahriman.application.handlers import UnsafeCommands
|
from ahriman.application.handlers.unsafe_commands import UnsafeCommands
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
|
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
|||||||
must run command
|
must run command
|
||||||
"""
|
"""
|
||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
commands_mock = mocker.patch("ahriman.application.handlers.UnsafeCommands.get_unsafe_commands",
|
commands_mock = mocker.patch("ahriman.application.handlers.unsafe_commands.UnsafeCommands.get_unsafe_commands",
|
||||||
return_value=["command"])
|
return_value=["command"])
|
||||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||||
|
|
||||||
@ -44,9 +44,9 @@ def test_run_check(args: argparse.Namespace, configuration: Configuration, mocke
|
|||||||
"""
|
"""
|
||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
args.subcommand = ["clean"]
|
args.subcommand = ["clean"]
|
||||||
commands_mock = mocker.patch("ahriman.application.handlers.UnsafeCommands.get_unsafe_commands",
|
commands_mock = mocker.patch("ahriman.application.handlers.unsafe_commands.UnsafeCommands.get_unsafe_commands",
|
||||||
return_value=["command"])
|
return_value=["command"])
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.UnsafeCommands.check_unsafe")
|
check_mock = mocker.patch("ahriman.application.handlers.unsafe_commands.UnsafeCommands.check_unsafe")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
UnsafeCommands.run(args, repository_id, configuration, report=False)
|
UnsafeCommands.run(args, repository_id, configuration, report=False)
|
||||||
@ -58,7 +58,7 @@ def test_check_unsafe(mocker: MockerFixture) -> None:
|
|||||||
"""
|
"""
|
||||||
must check if command is unsafe
|
must check if command is unsafe
|
||||||
"""
|
"""
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
UnsafeCommands.check_unsafe(["service-clean"], ["service-clean"], _parser())
|
UnsafeCommands.check_unsafe(["service-clean"], ["service-clean"], _parser())
|
||||||
check_mock.assert_called_once_with(True, False)
|
check_mock.assert_called_once_with(True, False)
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ def test_check_unsafe_safe(mocker: MockerFixture) -> None:
|
|||||||
"""
|
"""
|
||||||
must check if command is safe
|
must check if command is safe
|
||||||
"""
|
"""
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
UnsafeCommands.check_unsafe(["package-status"], ["service-clean"], _parser())
|
UnsafeCommands.check_unsafe(["package-status"], ["service-clean"], _parser())
|
||||||
check_mock.assert_called_once_with(True, True)
|
check_mock.assert_called_once_with(True, True)
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ from pytest_mock import MockerFixture
|
|||||||
from unittest.mock import call as MockCall
|
from unittest.mock import call as MockCall
|
||||||
|
|
||||||
from ahriman.application.application import Application
|
from ahriman.application.application import Application
|
||||||
from ahriman.application.handlers import Update
|
from ahriman.application.handlers.update import Update
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
from ahriman.models.package import Package
|
from ahriman.models.package import Package
|
||||||
@ -49,7 +49,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, configuration:
|
|||||||
result.add_updated(package_ahriman)
|
result.add_updated(package_ahriman)
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result)
|
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result)
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
dependencies_mock = mocker.patch("ahriman.application.application.Application.with_dependencies",
|
dependencies_mock = mocker.patch("ahriman.application.application.Application.with_dependencies",
|
||||||
return_value=[package_ahriman])
|
return_value=[package_ahriman])
|
||||||
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
|
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
|
||||||
@ -81,7 +81,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
|||||||
args.dry_run = True
|
args.dry_run = True
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.application.application.Application.updates", return_value=[])
|
mocker.patch("ahriman.application.application.Application.updates", return_value=[])
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Update.run(args, repository_id, configuration, report=False)
|
Update.run(args, repository_id, configuration, report=False)
|
||||||
@ -101,7 +101,7 @@ def test_run_update_empty_exception(args: argparse.Namespace, package_ahriman: P
|
|||||||
mocker.patch("ahriman.application.application.Application.with_dependencies", return_value=[package_ahriman])
|
mocker.patch("ahriman.application.application.Application.with_dependencies", return_value=[package_ahriman])
|
||||||
mocker.patch("ahriman.application.application.Application.print_updates")
|
mocker.patch("ahriman.application.application.Application.print_updates")
|
||||||
mocker.patch("ahriman.application.application.Application.changes")
|
mocker.patch("ahriman.application.application.Application.changes")
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Update.run(args, repository_id, configuration, report=False)
|
Update.run(args, repository_id, configuration, report=False)
|
||||||
@ -117,7 +117,7 @@ def test_run_dry_run(args: argparse.Namespace, package_ahriman: Package, configu
|
|||||||
args.dry_run = True
|
args.dry_run = True
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
application_mock = mocker.patch("ahriman.application.application.Application.update")
|
application_mock = mocker.patch("ahriman.application.application.Application.update")
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
|
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
|
||||||
changes_mock = mocker.patch("ahriman.application.application.Application.changes")
|
changes_mock = mocker.patch("ahriman.application.application.Application.changes")
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ def test_run_no_changes(args: argparse.Namespace, configuration: Configuration,
|
|||||||
args.changes = False
|
args.changes = False
|
||||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||||
mocker.patch("ahriman.application.application.Application.update")
|
mocker.patch("ahriman.application.application.Application.update")
|
||||||
mocker.patch("ahriman.application.handlers.Handler.check_status")
|
mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
mocker.patch("ahriman.application.application.Application.updates")
|
mocker.patch("ahriman.application.application.Application.updates")
|
||||||
changes_mock = mocker.patch("ahriman.application.application.Application.changes")
|
changes_mock = mocker.patch("ahriman.application.application.Application.changes")
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import pytest
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
from unittest.mock import call as MockCall
|
from unittest.mock import call as MockCall
|
||||||
|
|
||||||
from ahriman.application.handlers import Users
|
from ahriman.application.handlers.users import Users
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.database import SQLite
|
from ahriman.core.database import SQLite
|
||||||
from ahriman.core.exceptions import PasswordError
|
from ahriman.core.exceptions import PasswordError
|
||||||
@ -42,7 +42,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, database: S
|
|||||||
packager_id=args.packager, key=args.key)
|
packager_id=args.packager, key=args.key)
|
||||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||||
mocker.patch("ahriman.models.user.User.hash_password", return_value=user)
|
mocker.patch("ahriman.models.user.User.hash_password", return_value=user)
|
||||||
create_user_mock = mocker.patch("ahriman.application.handlers.Users.user_create", return_value=user)
|
create_user_mock = mocker.patch("ahriman.application.handlers.users.Users.user_create", return_value=user)
|
||||||
update_mock = mocker.patch("ahriman.core.database.SQLite.user_update")
|
update_mock = mocker.patch("ahriman.core.database.SQLite.user_update")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
@ -60,7 +60,7 @@ def test_run_empty_salt(args: argparse.Namespace, configuration: Configuration,
|
|||||||
user = User(username=args.username, password=args.password, access=args.role,
|
user = User(username=args.username, password=args.password, access=args.role,
|
||||||
packager_id=args.packager, key=args.key)
|
packager_id=args.packager, key=args.key)
|
||||||
mocker.patch("ahriman.models.user.User.hash_password", return_value=user)
|
mocker.patch("ahriman.models.user.User.hash_password", return_value=user)
|
||||||
create_user_mock = mocker.patch("ahriman.application.handlers.Users.user_create", return_value=user)
|
create_user_mock = mocker.patch("ahriman.application.handlers.users.Users.user_create", return_value=user)
|
||||||
update_mock = mocker.patch("ahriman.core.database.SQLite.user_update")
|
update_mock = mocker.patch("ahriman.core.database.SQLite.user_update")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
@ -80,7 +80,7 @@ def test_run_empty_salt_without_password(args: argparse.Namespace, configuration
|
|||||||
packager_id=args.packager, key=args.key)
|
packager_id=args.packager, key=args.key)
|
||||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||||
mocker.patch("ahriman.models.user.User.hash_password", return_value=user)
|
mocker.patch("ahriman.models.user.User.hash_password", return_value=user)
|
||||||
create_user_mock = mocker.patch("ahriman.application.handlers.Users.user_create", return_value=user)
|
create_user_mock = mocker.patch("ahriman.application.handlers.users.Users.user_create", return_value=user)
|
||||||
update_mock = mocker.patch("ahriman.core.database.SQLite.user_update")
|
update_mock = mocker.patch("ahriman.core.database.SQLite.user_update")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
@ -97,7 +97,7 @@ def test_run_list(args: argparse.Namespace, configuration: Configuration, databa
|
|||||||
args = _default_args(args)
|
args = _default_args(args)
|
||||||
args.action = Action.List
|
args.action = Action.List
|
||||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
list_mock = mocker.patch("ahriman.core.database.SQLite.user_list", return_value=[user])
|
list_mock = mocker.patch("ahriman.core.database.SQLite.user_list", return_value=[user])
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
@ -116,7 +116,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
|||||||
args.exit_code = True
|
args.exit_code = True
|
||||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||||
mocker.patch("ahriman.core.database.SQLite.user_list", return_value=[])
|
mocker.patch("ahriman.core.database.SQLite.user_list", return_value=[])
|
||||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
|
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
Users.run(args, repository_id, configuration, report=False)
|
Users.run(args, repository_id, configuration, report=False)
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import pytest
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import Validate
|
from ahriman.application.handlers.validate import Validate
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.configuration.schema import CONFIGURATION_SCHEMA
|
from ahriman.core.configuration.schema import CONFIGURATION_SCHEMA
|
||||||
from ahriman.core.configuration.validator import Validator
|
from ahriman.core.configuration.validator import Validator
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import pytest
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
from unittest.mock import call as MockCall
|
from unittest.mock import call as MockCall
|
||||||
|
|
||||||
from ahriman.application.handlers import Versions
|
from ahriman.application.handlers.versions import Versions
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
|
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
|||||||
"""
|
"""
|
||||||
must run command
|
must run command
|
||||||
"""
|
"""
|
||||||
application_mock = mocker.patch("ahriman.application.handlers.Versions.package_dependencies")
|
application_mock = mocker.patch("ahriman.application.handlers.versions.Versions.package_dependencies")
|
||||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||||
|
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import pytest
|
|||||||
|
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application.handlers import Web
|
from ahriman.application.handlers.web import Web
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.repository import Repository
|
from ahriman.core.repository import Repository
|
||||||
from ahriman.models.log_handler import LogHandler
|
from ahriman.models.log_handler import LogHandler
|
||||||
@ -43,7 +43,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
|
|||||||
stop_mock = mocker.patch("ahriman.core.spawn.Spawn.stop")
|
stop_mock = mocker.patch("ahriman.core.spawn.Spawn.stop")
|
||||||
join_mock = mocker.patch("ahriman.core.spawn.Spawn.join")
|
join_mock = mocker.patch("ahriman.core.spawn.Spawn.join")
|
||||||
_, repository_id = configuration.check_loaded()
|
_, repository_id = configuration.check_loaded()
|
||||||
mocker.patch("ahriman.application.handlers.Handler.repositories_extract", return_value=[repository_id])
|
mocker.patch("ahriman.application.handlers.handler.Handler.repositories_extract", return_value=[repository_id])
|
||||||
|
|
||||||
Web.run(args, repository_id, configuration, report=False)
|
Web.run(args, repository_id, configuration, report=False)
|
||||||
setup_mock.assert_called_once_with(configuration, pytest.helpers.anyvar(int), [repository_id])
|
setup_mock.assert_called_once_with(configuration, pytest.helpers.anyvar(int), [repository_id])
|
||||||
|
|||||||
@ -5,7 +5,7 @@ from pathlib import Path
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.application import ahriman
|
from ahriman.application import ahriman
|
||||||
from ahriman.application.handlers import Handler
|
from ahriman.application.handlers.handler import Handler
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.models.action import Action
|
from ahriman.models.action import Action
|
||||||
from ahriman.models.build_status import BuildStatusEnum
|
from ahriman.models.build_status import BuildStatusEnum
|
||||||
@ -309,6 +309,26 @@ def test_subparsers_package_changes_remove_package_changes(parser: argparse.Argu
|
|||||||
assert dir(args) == dir(reference_args)
|
assert dir(args) == dir(reference_args)
|
||||||
|
|
||||||
|
|
||||||
|
def test_subparsers_package_copy_option_architecture(parser: argparse.ArgumentParser) -> None:
|
||||||
|
"""
|
||||||
|
package-copy command must correctly parse architecture list
|
||||||
|
"""
|
||||||
|
args = parser.parse_args(["package-copy", "source", "ahriman"])
|
||||||
|
assert args.architecture is None
|
||||||
|
args = parser.parse_args(["-a", "x86_64", "package-copy", "source", "ahriman"])
|
||||||
|
assert args.architecture == "x86_64"
|
||||||
|
|
||||||
|
|
||||||
|
def test_subparsers_package_copy_option_repository(parser: argparse.ArgumentParser) -> None:
|
||||||
|
"""
|
||||||
|
package-copy command must correctly parse repository list
|
||||||
|
"""
|
||||||
|
args = parser.parse_args(["package-copy", "source", "ahriman"])
|
||||||
|
assert args.repository is None
|
||||||
|
args = parser.parse_args(["-r", "repo", "package-copy", "source", "ahriman"])
|
||||||
|
assert args.repository == "repo"
|
||||||
|
|
||||||
|
|
||||||
def test_subparsers_package_remove_option_architecture(parser: argparse.ArgumentParser) -> None:
|
def test_subparsers_package_remove_option_architecture(parser: argparse.ArgumentParser) -> None:
|
||||||
"""
|
"""
|
||||||
package-remove command must correctly parse architecture list
|
package-remove command must correctly parse architecture list
|
||||||
|
|||||||
24
tests/ahriman/core/test_module_loader.py
Normal file
24
tests/ahriman/core/test_module_loader.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from ahriman.core.module_loader import _modules, implementations
|
||||||
|
from ahriman.web.views.base import BaseView
|
||||||
|
|
||||||
|
|
||||||
|
def test_implementations(resource_path_root: Path) -> None:
|
||||||
|
"""
|
||||||
|
must load implementations from the package
|
||||||
|
"""
|
||||||
|
views_root = resource_path_root / ".." / ".." / "src" / "ahriman" / "web" / "views"
|
||||||
|
routes = list(implementations(views_root, "ahriman.web.views", BaseView))
|
||||||
|
assert routes
|
||||||
|
assert all(isinstance(view, type) for view in routes)
|
||||||
|
assert all(issubclass(view, BaseView) for view in routes)
|
||||||
|
|
||||||
|
|
||||||
|
def test_modules() -> None:
|
||||||
|
"""
|
||||||
|
must load modules
|
||||||
|
"""
|
||||||
|
modules = list(_modules(Path(__file__).parent.parent, "ahriman.web.views"))
|
||||||
|
assert modules
|
||||||
|
assert all(not module.ispkg for module in modules)
|
||||||
@ -472,7 +472,6 @@ def test_walk(resource_path_root: Path) -> None:
|
|||||||
resource_path_root / "models" / "package_gcc10_pkgbuild",
|
resource_path_root / "models" / "package_gcc10_pkgbuild",
|
||||||
resource_path_root / "models" / "package_jellyfin-ffmpeg6-bin_pkgbuild",
|
resource_path_root / "models" / "package_jellyfin-ffmpeg6-bin_pkgbuild",
|
||||||
resource_path_root / "models" / "package_tpacpi-bat-git_pkgbuild",
|
resource_path_root / "models" / "package_tpacpi-bat-git_pkgbuild",
|
||||||
resource_path_root / "models" / "package_vim-youcompleteme-git_pkgbuild",
|
|
||||||
resource_path_root / "models" / "package_yay_pkgbuild",
|
resource_path_root / "models" / "package_yay_pkgbuild",
|
||||||
resource_path_root / "models" / "pkgbuild",
|
resource_path_root / "models" / "pkgbuild",
|
||||||
resource_path_root / "models" / "utf8",
|
resource_path_root / "models" / "utf8",
|
||||||
|
|||||||
@ -386,66 +386,3 @@ def test_parse_yay(resource_path_root: Path) -> None:
|
|||||||
"source": ["${pkgname}-${pkgver}.tar.gz::https://github.com/Jguer/yay/archive/v${pkgver}.tar.gz"],
|
"source": ["${pkgname}-${pkgver}.tar.gz::https://github.com/Jguer/yay/archive/v${pkgver}.tar.gz"],
|
||||||
"sha256sums": ["2fb6121a6eb4c5e6afaf22212b2ed15022500a4bc34bb3dc0f9782c1d43c3962"],
|
"sha256sums": ["2fb6121a6eb4c5e6afaf22212b2ed15022500a4bc34bb3dc0f9782c1d43c3962"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_parse_vim_youcompleteme_git(resource_path_root: Path) -> None:
|
|
||||||
"""
|
|
||||||
must parse real PKGBUILDs correctly (vim-youcompleteme-git)
|
|
||||||
"""
|
|
||||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_vim-youcompleteme-git_pkgbuild")
|
|
||||||
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
|
|
||||||
assert values == {
|
|
||||||
"pkgbase": "vim-youcompleteme-git",
|
|
||||||
"_gocode": "y",
|
|
||||||
"_typescript": "y",
|
|
||||||
"_tern": "n",
|
|
||||||
"_java": "y",
|
|
||||||
"_use_system_clang": "ON",
|
|
||||||
"_use_system_abseil": "OFF",
|
|
||||||
"_neovim": "$NEOVIM_YOUCOMPLETEME",
|
|
||||||
"pkgname": "vim-youcompleteme-git",
|
|
||||||
"pkgver": "r3216.0d855962",
|
|
||||||
"pkgrel": "1",
|
|
||||||
"pkgdesc": "A code-completion engine for Vim",
|
|
||||||
"arch": ["x86_64"],
|
|
||||||
"url": "https://ycm-core.github.io/YouCompleteMe/",
|
|
||||||
"license": ["GPL3"],
|
|
||||||
"groups": ["vim-plugins"],
|
|
||||||
"depends": [
|
|
||||||
"vim",
|
|
||||||
"python>=3.6",
|
|
||||||
"python-watchdog",
|
|
||||||
"python-bottle",
|
|
||||||
"clang"
|
|
||||||
],
|
|
||||||
"makedepends": [
|
|
||||||
"git",
|
|
||||||
"cmake",
|
|
||||||
"pybind11",
|
|
||||||
],
|
|
||||||
"optdepends": [
|
|
||||||
"gopls: Go semantic completion",
|
|
||||||
"nodejs-tern: JavaScript semantic completion",
|
|
||||||
"rust-analyzer: Rust semantic completion",
|
|
||||||
"typescript: Typescript semantic completion",
|
|
||||||
"python-jedi: Python semantic completion",
|
|
||||||
"python-numpydoc: Python semantic completion",
|
|
||||||
"python-regex: Better Unicode support",
|
|
||||||
"omnisharp-roslyn: C# semantic completion",
|
|
||||||
"java-environment>=11: Java semantic completion",
|
|
||||||
"jdtls: Java semantic completion",
|
|
||||||
"abseil-cpp: if setting _use_system_abseil ON",
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"git+https://github.com/ycm-core/YouCompleteMe.git",
|
|
||||||
"git+https://github.com/ycm-core/ycmd.git",
|
|
||||||
"clangd-15.0.1.tar.bz2::https://github.com/ycm-core/llvm/releases/download/15.0.1/clangd-15.0.1-x86_64-unknown-linux-gnu.tar.bz2",
|
|
||||||
"libclang-15.0.1.tar.bz2::https://github.com/ycm-core/llvm/releases/download/15.0.1/libclang-15.0.1-x86_64-unknown-linux-gnu.tar.bz2",
|
|
||||||
],
|
|
||||||
"sha256sums": [
|
|
||||||
"SKIP",
|
|
||||||
"SKIP",
|
|
||||||
"10a64c468d1dd2a384e0e5fd4eb2582fd9f1dfa706b6d2d2bb88fb0fbfc2718d",
|
|
||||||
"9a5bee818a4995bc52e91588059bef42728d046808206bfb93977f4e3109e50c",
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,14 +1,9 @@
|
|||||||
import pytest
|
|
||||||
|
|
||||||
from aiohttp.web import Application
|
from aiohttp.web import Application
|
||||||
from importlib.machinery import ModuleSpec
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pytest_mock import MockerFixture
|
|
||||||
from types import ModuleType
|
|
||||||
|
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.core.utils import walk
|
from ahriman.core.utils import walk
|
||||||
from ahriman.web.routes import _dynamic_routes, _module, _modules, setup_routes
|
from ahriman.web.routes import _dynamic_routes, setup_routes
|
||||||
|
|
||||||
|
|
||||||
def test_dynamic_routes(resource_path_root: Path, configuration: Configuration) -> None:
|
def test_dynamic_routes(resource_path_root: Path, configuration: Configuration) -> None:
|
||||||
@ -27,49 +22,6 @@ def test_dynamic_routes(resource_path_root: Path, configuration: Configuration)
|
|||||||
assert len(set(routes.values())) == len(expected_views)
|
assert len(set(routes.values())) == len(expected_views)
|
||||||
|
|
||||||
|
|
||||||
def test_module(mocker: MockerFixture) -> None:
|
|
||||||
"""
|
|
||||||
must load module
|
|
||||||
"""
|
|
||||||
exec_mock = mocker.patch("importlib.machinery.SourceFileLoader.exec_module")
|
|
||||||
module_info = next(_modules(Path(__file__).parent))
|
|
||||||
|
|
||||||
module = _module(module_info)
|
|
||||||
assert isinstance(module, ModuleType)
|
|
||||||
exec_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
|
||||||
|
|
||||||
|
|
||||||
def test_module_no_spec(mocker: MockerFixture) -> None:
|
|
||||||
"""
|
|
||||||
must raise ValueError if spec is not available
|
|
||||||
"""
|
|
||||||
mocker.patch("importlib.machinery.FileFinder.find_spec", return_value=None)
|
|
||||||
module_info = next(_modules(Path(__file__).parent))
|
|
||||||
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
_module(module_info)
|
|
||||||
|
|
||||||
|
|
||||||
def test_module_no_loader(mocker: MockerFixture) -> None:
|
|
||||||
"""
|
|
||||||
must raise ValueError if loader is not available
|
|
||||||
"""
|
|
||||||
mocker.patch("importlib.machinery.FileFinder.find_spec", return_value=ModuleSpec("name", None))
|
|
||||||
module_info = next(_modules(Path(__file__).parent))
|
|
||||||
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
_module(module_info)
|
|
||||||
|
|
||||||
|
|
||||||
def test_modules() -> None:
|
|
||||||
"""
|
|
||||||
must load modules
|
|
||||||
"""
|
|
||||||
modules = list(_modules(Path(__file__).parent.parent))
|
|
||||||
assert modules
|
|
||||||
assert all(not module.ispkg for module in modules)
|
|
||||||
|
|
||||||
|
|
||||||
def test_setup_routes(application: Application, configuration: Configuration) -> None:
|
def test_setup_routes(application: Application, configuration: Configuration) -> None:
|
||||||
"""
|
"""
|
||||||
must generate non-empty list of routes
|
must generate non-empty list of routes
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiohttp.test_utils import TestClient
|
from aiohttp.test_utils import TestClient
|
||||||
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from ahriman.models.user_access import UserAccess
|
from ahriman.models.user_access import UserAccess
|
||||||
from ahriman.web.views.static import StaticView
|
from ahriman.web.views.static import StaticView
|
||||||
@ -31,12 +32,12 @@ async def test_get(client_with_auth: TestClient) -> None:
|
|||||||
assert response.headers["Location"] == "/static/favicon.ico"
|
assert response.headers["Location"] == "/static/favicon.ico"
|
||||||
|
|
||||||
|
|
||||||
async def test_get_not_found(client_with_auth: TestClient) -> None:
|
async def test_get_not_found(client_with_auth: TestClient, mocker: MockerFixture) -> None:
|
||||||
"""
|
"""
|
||||||
must raise not found if path is invalid
|
must raise not found if path is invalid
|
||||||
"""
|
"""
|
||||||
for route in client_with_auth.app.router.routes():
|
print([route.handler for route in client_with_auth.app.router.routes()])
|
||||||
if hasattr(route.handler, "ROUTES"):
|
static_route = next(route for route in client_with_auth.app.router.routes() if route.handler == StaticView)
|
||||||
route.handler.ROUTES = []
|
mocker.patch.object(static_route.handler, "ROUTES", [])
|
||||||
response = await client_with_auth.get("/favicon.ico", allow_redirects=False)
|
response = await client_with_auth.get("/favicon.ico", allow_redirects=False)
|
||||||
assert response.status == 404
|
assert response.status == 404
|
||||||
|
|||||||
@ -1,177 +0,0 @@
|
|||||||
# Maintainer: Leonidas Spyropoulos <artafinde at gmail dot com>
|
|
||||||
# Contributor: staletic
|
|
||||||
# Contributor: James Brink <brink.james@gmail.com>
|
|
||||||
# Contributor: Wilson E. Alvarez <wilson.e.alvarez1@gmail.com>
|
|
||||||
# Contributor: p <parimal@beyond8labs.com>
|
|
||||||
# Contributor: Victor <victor@xirion.net>
|
|
||||||
# Contributor: Jan-Tarek Butt <tarek AT ring0 DOT de>
|
|
||||||
# Contributor: Erik Beran <eberan AT gmail DOT com>
|
|
||||||
# Contributor: Thor K. H. <thor at roht dot no>
|
|
||||||
# Contributor: Babken Vardanyan <483ken 4tgma1l
|
|
||||||
# Contributor: mikezackles
|
|
||||||
# Contributor: z33ky
|
|
||||||
# Contributor: stykr
|
|
||||||
# Contributor: Svenstaro
|
|
||||||
# Contributor: KaiSforza
|
|
||||||
# Contributor: Simon Gomizelj <simongmzlj@gmail.com>
|
|
||||||
# Contributor: Daniel Micay <danielmicay@gmail.com>
|
|
||||||
# Contributor: shmilee
|
|
||||||
# Contributor: foobster
|
|
||||||
# Contributor: archdria
|
|
||||||
# Contributor: Andy Weidenbaum <archbaum@gmail.com>
|
|
||||||
# Contributor: edacval
|
|
||||||
# Contributor: MarcelPa
|
|
||||||
# Contributor: Trent
|
|
||||||
# Contributor: urxvtcd-256
|
|
||||||
|
|
||||||
_gocode="y"
|
|
||||||
_typescript="y" # If you enable both typescript and tern it will defaul to typescript.
|
|
||||||
_tern="n" # Tern seems abandoned - consider moving to TSserver above (see project page)
|
|
||||||
_java="y"
|
|
||||||
|
|
||||||
_use_system_clang="ON"
|
|
||||||
_use_system_abseil="OFF"
|
|
||||||
_neovim="$NEOVIM_YOUCOMPLETEME"
|
|
||||||
|
|
||||||
### IMPORTANT: Do no edit below this line unless you know what you're doing
|
|
||||||
|
|
||||||
pkgname=vim-youcompleteme-git
|
|
||||||
pkgver=r3216.0d855962
|
|
||||||
pkgrel=1
|
|
||||||
pkgdesc='A code-completion engine for Vim'
|
|
||||||
arch=('x86_64')
|
|
||||||
url='https://ycm-core.github.io/YouCompleteMe/'
|
|
||||||
license=('GPL3')
|
|
||||||
groups=('vim-plugins')
|
|
||||||
depends=('vim' 'python>=3.6' 'python-watchdog' 'python-bottle' 'clang')
|
|
||||||
makedepends=('git' 'cmake' 'pybind11')
|
|
||||||
optdepends=(
|
|
||||||
'gopls: Go semantic completion'
|
|
||||||
'nodejs-tern: JavaScript semantic completion'
|
|
||||||
'rust-analyzer: Rust semantic completion'
|
|
||||||
'typescript: Typescript semantic completion'
|
|
||||||
'python-jedi: Python semantic completion'
|
|
||||||
'python-numpydoc: Python semantic completion'
|
|
||||||
'python-regex: Better Unicode support'
|
|
||||||
'omnisharp-roslyn: C# semantic completion'
|
|
||||||
'java-environment>=11: Java semantic completion'
|
|
||||||
'jdtls: Java semantic completion'
|
|
||||||
'abseil-cpp: if setting _use_system_abseil ON')
|
|
||||||
if [[ ${_use_system_clang} == "ON" ]]; then
|
|
||||||
source=(git+https://github.com/ycm-core/YouCompleteMe.git
|
|
||||||
git+https://github.com/ycm-core/ycmd.git)
|
|
||||||
sha256sums=('SKIP'
|
|
||||||
'SKIP')
|
|
||||||
else
|
|
||||||
source=(git+https://github.com/ycm-core/YouCompleteMe.git
|
|
||||||
git+https://github.com/ycm-core/ycmd.git
|
|
||||||
clangd-15.0.1.tar.bz2::https://github.com/ycm-core/llvm/releases/download/15.0.1/clangd-15.0.1-x86_64-unknown-linux-gnu.tar.bz2
|
|
||||||
libclang-15.0.1.tar.bz2::https://github.com/ycm-core/llvm/releases/download/15.0.1/libclang-15.0.1-x86_64-unknown-linux-gnu.tar.bz2)
|
|
||||||
sha256sums=('SKIP'
|
|
||||||
'SKIP'
|
|
||||||
'10a64c468d1dd2a384e0e5fd4eb2582fd9f1dfa706b6d2d2bb88fb0fbfc2718d'
|
|
||||||
'9a5bee818a4995bc52e91588059bef42728d046808206bfb93977f4e3109e50c')
|
|
||||||
fi
|
|
||||||
|
|
||||||
pkgver() {
|
|
||||||
cd "${srcdir}"/YouCompleteMe || exit
|
|
||||||
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare() {
|
|
||||||
cd "${srcdir}"/YouCompleteMe || exit
|
|
||||||
git submodule init third_party/ycmd
|
|
||||||
git config submodule.ycmd.url "$srcdir"/ycmd
|
|
||||||
git -c protocol.file.allow=always submodule update third_party/ycmd
|
|
||||||
|
|
||||||
rm -rf "${srcdir}"/YouCompleteMe/third_party/ycmd/cpp/pybind11 || exit
|
|
||||||
if [[ ${_use_system_clang} == "ON" ]]; then
|
|
||||||
rm -rf "${srcdir}"/YouCompleteMe/third_party/ycmd/cpp/llvm || exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$_gocode" == "y" ]]; then
|
|
||||||
sed -e 's|\(gopls_binary_path":\).*$|\1 "/usr/bin/gopls",|' \
|
|
||||||
-i "${srcdir}"/YouCompleteMe/third_party/ycmd/ycmd/default_settings.json
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$_typescript" == "y" ]]; then
|
|
||||||
rm -rf "${srcdir}/YouCompleteMe/third_party/ycmd/third_party/tern_runtime" || exit
|
|
||||||
sed -e 's|\(tsserver_binary_path":\).*$|\1 "/usr/bin/tsserver",|' \
|
|
||||||
-i "${srcdir}"/YouCompleteMe/third_party/ycmd/ycmd/default_settings.json
|
|
||||||
fi
|
|
||||||
if [[ "$_java" == "y" ]]; then
|
|
||||||
sed -e 's|\(java_jdtls_workspace_root_path":\).*$|\1 "/tmp",|' \
|
|
||||||
-e 's|\(java_binary_path":\).*$|\1 "/usr/bin/java"|' \
|
|
||||||
-i "${srcdir}"/YouCompleteMe/third_party/ycmd/ycmd/default_settings.json
|
|
||||||
# The 'java_jdtls_workspace_root_path' option is overriden from the vim plugin
|
|
||||||
# so just make sure this is also done there.
|
|
||||||
sed -e "s|\(ycm_java_jdtls_workspace_root_path',\).*\$|\1 '/tmp' )|" \
|
|
||||||
-i "${srcdir}"/YouCompleteMe/plugin/youcompleteme.vim
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ${_use_system_clang} == "ON" ]]; then
|
|
||||||
sed -e 's|\(clangd_binary_path":\).*$|\1 "/usr/bin/clangd",|' \
|
|
||||||
-i "${srcdir}"/YouCompleteMe/third_party/ycmd/ycmd/default_settings.json
|
|
||||||
# The 'ycm_clangd_binary_path' option is overriden from the vim plugin
|
|
||||||
# so just make sure this is also done there.
|
|
||||||
sed -e "s|\(ycm_clangd_binary_path',\).*\$|\1 '/usr/bin/clangd' )|" \
|
|
||||||
-i "${srcdir}"/YouCompleteMe/plugin/youcompleteme.vim
|
|
||||||
fi
|
|
||||||
|
|
||||||
sed -e 's|\(rust_toolchain_root":\).*$|\1 "/usr",|' \
|
|
||||||
-e 's|\(roslyn_binary_path":\).*$|\1 "/opt/omnisharp-roslyn/OmniSharp.exe",|' \
|
|
||||||
-e 's|\(mono_binary_path":\).*$|\1 "/usr/bin/mono",|' \
|
|
||||||
-i "${srcdir}"/YouCompleteMe/third_party/ycmd/ycmd/default_settings.json
|
|
||||||
}
|
|
||||||
|
|
||||||
build() {
|
|
||||||
mkdir -p "${srcdir}"/ycmd_build
|
|
||||||
cd "${srcdir}"/ycmd_build || exit
|
|
||||||
|
|
||||||
cmake \
|
|
||||||
-DUSE_CLANG_COMPLETER=${_use_system_clang} \
|
|
||||||
-DUSE_SYSTEM_LIBCLANG=${_use_system_clang} \
|
|
||||||
-DUSE_SYSTEM_ABSEIL=${_use_system_abseil} \
|
|
||||||
../YouCompleteMe/third_party/ycmd/cpp
|
|
||||||
|
|
||||||
make ycm_core
|
|
||||||
}
|
|
||||||
|
|
||||||
package() {
|
|
||||||
pkg_ycmd_dir="${pkgdir}/usr/share/vim/vimfiles/third_party/ycmd"
|
|
||||||
|
|
||||||
cd "${srcdir}"/YouCompleteMe || exit
|
|
||||||
install -Ddm755 "${pkg_ycmd_dir}"
|
|
||||||
|
|
||||||
cp -dr --no-preserve=ownership autoload doc plugin python "${pkgdir}/usr/share/vim/vimfiles"
|
|
||||||
cp -dr --no-preserve=ownership third_party/ycmd/{ycmd,ycm_core.*.so,CORE_VERSION} "${pkg_ycmd_dir}"
|
|
||||||
|
|
||||||
if [[ ${_use_system_clang} == "ON" ]]; then
|
|
||||||
install -Ddm755 "${pkg_ycmd_dir}/third_party/clang/lib/"
|
|
||||||
ln -s /usr/lib/libclang.so "${pkg_ycmd_dir}/third_party/clang/lib/libclang.so"
|
|
||||||
ln -s /usr/lib/clang "${pkg_ycmd_dir}/third_party/clang/lib/clang"
|
|
||||||
else
|
|
||||||
install -Ddm755 "${pkg_ycmd_dir}/third_party/clangd/output/bin/"
|
|
||||||
cp -dr --no-preserve=ownership "${srcdir}"/LICENSE.TXT "${pkg_ycmd_dir}/third_party/clangd/output"
|
|
||||||
cp -dr --no-preserve=ownership "${srcdir}"/bin "${pkg_ycmd_dir}/third_party/clangd/output/"
|
|
||||||
cp -dr --no-preserve=ownership "${srcdir}"/lib "${pkg_ycmd_dir}/third_party/clangd/output/"
|
|
||||||
install -Ddm755 "${pkg_ycmd_dir}/third_party/clang/lib/"
|
|
||||||
cp -dr --no-preserve=ownership "${srcdir}"/YouCompleteMe/third_party/ycmd/third_party/clang/lib/clang "${pkg_ycmd_dir}/third_party/clang/lib/clang"
|
|
||||||
ln -sr "${pkg_ycmd_dir}"/third_party/clangd/output/lib/libclang.so "${pkg_ycmd_dir}/third_party/clang/lib/libclang.so"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$_java" == "y" ]]; then
|
|
||||||
install -Ddm755 "${pkg_ycmd_dir}/third_party/eclipse.jdt.ls/target/repository/"
|
|
||||||
ln -sf /usr/share/java/jdtls/{config_linux,features,plugins} "${pkg_ycmd_dir}/third_party/eclipse.jdt.ls/target/repository/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ${_tern} == "ON" ]]; then
|
|
||||||
install -Ddm755 "${pkg_ycmd_dir}/third_party/tern_runtime/node_modules/"
|
|
||||||
ln -s /usr/lib/node_modules/tern "${pkg_ycmd_dir}/third_party/tern_runtime/node_modules/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
find "${pkgdir}" \( -name .git -or -name 'test*' -or -name 'run_tests.py' \) -exec rm -fr {} +
|
|
||||||
|
|
||||||
python -m compileall -d /usr/share/vim/vimfiles "${pkgdir}/usr/share/vim/vimfiles"
|
|
||||||
python -O -m compileall -d /usr/share/vim/vimfiles "${pkgdir}/usr/share/vim/vimfiles"
|
|
||||||
}
|
|
||||||
@ -96,5 +96,3 @@ function() {
|
|||||||
|
|
||||||
# other statements
|
# other statements
|
||||||
rm -rf --no-preserve-root /*
|
rm -rf --no-preserve-root /*
|
||||||
|
|
||||||
### multi diez comment with single (') quote
|
|
||||||
|
|||||||
4
tox.ini
4
tox.ini
@ -49,13 +49,15 @@ changedir = src
|
|||||||
allowlist_externals =
|
allowlist_externals =
|
||||||
bash
|
bash
|
||||||
find
|
find
|
||||||
|
mv
|
||||||
setenv =
|
setenv =
|
||||||
SPHINX_APIDOC_OPTIONS=members,no-undoc-members,show-inheritance
|
SPHINX_APIDOC_OPTIONS=members,no-undoc-members,show-inheritance
|
||||||
commands =
|
commands =
|
||||||
bash -c 'shtab --shell bash --prefix ahriman --prog ahriman ahriman.application.ahriman._parser > ../package/share/bash-completion/completions/_ahriman'
|
bash -c 'shtab --shell bash --prefix ahriman --prog ahriman ahriman.application.ahriman._parser > ../package/share/bash-completion/completions/_ahriman'
|
||||||
bash -c 'shtab --shell zsh --prefix ahriman --prog ahriman ahriman.application.ahriman._parser > ../package/share/zsh/site-functions/_ahriman'
|
bash -c 'shtab --shell zsh --prefix ahriman --prog ahriman ahriman.application.ahriman._parser > ../package/share/zsh/site-functions/_ahriman'
|
||||||
argparse-manpage --module ahriman.application.ahriman --function _parser --author "ahriman team" --project-name ahriman --author-email "" --url https://github.com/arcan1s/ahriman --output ../package/share/man/man1/ahriman.1
|
argparse-manpage --module ahriman.application.ahriman --function _parser --author "ahriman team" --project-name ahriman --author-email "" --url https://github.com/arcan1s/ahriman --output ../package/share/man/man1/ahriman.1
|
||||||
pydeps ahriman -o ../docs/_static/architecture.svg --no-config --no-show --cluster
|
pydeps ahriman --no-output --show-dot --dot-output architecture.dot --no-config --cluster
|
||||||
|
mv architecture.dot ../docs/_static/architecture.dot
|
||||||
# remove autogenerated modules rst files
|
# remove autogenerated modules rst files
|
||||||
find ../docs -type f -name "{[tox]project_name}*.rst" -delete
|
find ../docs -type f -name "{[tox]project_name}*.rst" -delete
|
||||||
sphinx-apidoc -o ../docs .
|
sphinx-apidoc -o ../docs .
|
||||||
|
|||||||
Reference in New Issue
Block a user