From 9b55ea67f1d2f344dccea2738679dd3cf6e8e86c Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Wed, 3 Apr 2024 11:25:51 +0200 Subject: [PATCH 01/29] Update Python MongoDB Driver to 3.13.0 #1 https://github.com/BiP-org/airnotifier/issues/1 --- Pipfile | 2 +- Pipfile.lock | 293 --------------------------------------------------- 2 files changed, 1 insertion(+), 294 deletions(-) delete mode 100644 Pipfile.lock diff --git a/Pipfile b/Pipfile index d3219faf..68739f0b 100644 --- a/Pipfile +++ b/Pipfile @@ -11,7 +11,7 @@ test = "python -m unittest discover -s tests -p 'test_*.py'" [packages] netaddr = "==0.7.18" oauth2client = "==4.1.3" -pymongo = "==3.5.1" +pymongo = "==3.13.0" requests = "==2.21.0" tornado = "~=6.0" click = "*" diff --git a/Pipfile.lock b/Pipfile.lock deleted file mode 100644 index fa580aa6..00000000 --- a/Pipfile.lock +++ /dev/null @@ -1,293 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "7c77039e12d818dabb8de1461ecedf1cbbf34693340c8796243d7ab27106e5cb" - }, - "pipfile-spec": 6, - "requires": {}, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] - }, - "default": { - "aiocontextvars": { - "hashes": [ - "sha256:885daf8261818767d8f7cbd79f9d4482d118f024b6586ef6e67980236a27bfa3", - "sha256:f027372dc48641f683c559f247bd84962becaacdc9ba711d583c3871fb5652aa" - ], - "index": "pypi", - "version": "==0.2.2" - }, - "certifi": { - "hashes": [ - "sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3", - "sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f" - ], - "version": "==2019.11.28" - }, - "cffi": { - "hashes": [ - "sha256:0b49274afc941c626b605fb59b59c3485c17dc776dc3cc7cc14aca74cc19cc42", - "sha256:0e3ea92942cb1168e38c05c1d56b0527ce31f1a370f6117f1d490b8dcd6b3a04", - "sha256:135f69aecbf4517d5b3d6429207b2dff49c876be724ac0c8bf8e1ea99df3d7e5", - "sha256:19db0cdd6e516f13329cba4903368bff9bb5a9331d3410b1b448daaadc495e54", - "sha256:2781e9ad0e9d47173c0093321bb5435a9dfae0ed6a762aabafa13108f5f7b2ba", - "sha256:291f7c42e21d72144bb1c1b2e825ec60f46d0a7468f5346841860454c7aa8f57", - "sha256:2c5e309ec482556397cb21ede0350c5e82f0eb2621de04b2633588d118da4396", - "sha256:2e9c80a8c3344a92cb04661115898a9129c074f7ab82011ef4b612f645939f12", - "sha256:32a262e2b90ffcfdd97c7a5e24a6012a43c61f1f5a57789ad80af1d26c6acd97", - "sha256:3c9fff570f13480b201e9ab69453108f6d98244a7f495e91b6c654a47486ba43", - "sha256:415bdc7ca8c1c634a6d7163d43fb0ea885a07e9618a64bda407e04b04333b7db", - "sha256:42194f54c11abc8583417a7cf4eaff544ce0de8187abaf5d29029c91b1725ad3", - "sha256:4424e42199e86b21fc4db83bd76909a6fc2a2aefb352cb5414833c030f6ed71b", - "sha256:4a43c91840bda5f55249413037b7a9b79c90b1184ed504883b72c4df70778579", - "sha256:599a1e8ff057ac530c9ad1778293c665cb81a791421f46922d80a86473c13346", - "sha256:5c4fae4e9cdd18c82ba3a134be256e98dc0596af1e7285a3d2602c97dcfa5159", - "sha256:5ecfa867dea6fabe2a58f03ac9186ea64da1386af2159196da51c4904e11d652", - "sha256:62f2578358d3a92e4ab2d830cd1c2049c9c0d0e6d3c58322993cc341bdeac22e", - "sha256:6471a82d5abea994e38d2c2abc77164b4f7fbaaf80261cb98394d5793f11b12a", - "sha256:6d4f18483d040e18546108eb13b1dfa1000a089bcf8529e30346116ea6240506", - "sha256:71a608532ab3bd26223c8d841dde43f3516aa5d2bf37b50ac410bb5e99053e8f", - "sha256:74a1d8c85fb6ff0b30fbfa8ad0ac23cd601a138f7509dc617ebc65ef305bb98d", - "sha256:7b93a885bb13073afb0aa73ad82059a4c41f4b7d8eb8368980448b52d4c7dc2c", - "sha256:7d4751da932caaec419d514eaa4215eaf14b612cff66398dd51129ac22680b20", - "sha256:7f627141a26b551bdebbc4855c1157feeef18241b4b8366ed22a5c7d672ef858", - "sha256:8169cf44dd8f9071b2b9248c35fc35e8677451c52f795daa2bb4643f32a540bc", - "sha256:aa00d66c0fab27373ae44ae26a66a9e43ff2a678bf63a9c7c1a9a4d61172827a", - "sha256:ccb032fda0873254380aa2bfad2582aedc2959186cce61e3a17abc1a55ff89c3", - "sha256:d754f39e0d1603b5b24a7f8484b22d2904fa551fe865fd0d4c3332f078d20d4e", - "sha256:d75c461e20e29afc0aee7172a0950157c704ff0dd51613506bd7d82b718e7410", - "sha256:dcd65317dd15bc0451f3e01c80da2216a31916bdcffd6221ca1202d96584aa25", - "sha256:e570d3ab32e2c2861c4ebe6ffcad6a8abf9347432a37608fe1fbd157b3f0036b", - "sha256:fd43a88e045cf992ed09fa724b5315b790525f2676883a6ea64e3263bae6549d" - ], - "version": "==1.13.2" - }, - "chardet": { - "hashes": [ - "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", - "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" - ], - "version": "==3.0.4" - }, - "click": { - "hashes": [ - "sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13", - "sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7" - ], - "index": "pypi", - "version": "==7.0" - }, - "cryptography": { - "hashes": [ - "sha256:02079a6addc7b5140ba0825f542c0869ff4df9a69c360e339ecead5baefa843c", - "sha256:1df22371fbf2004c6f64e927668734070a8953362cd8370ddd336774d6743595", - "sha256:369d2346db5934345787451504853ad9d342d7f721ae82d098083e1f49a582ad", - "sha256:3cda1f0ed8747339bbdf71b9f38ca74c7b592f24f65cdb3ab3765e4b02871651", - "sha256:44ff04138935882fef7c686878e1c8fd80a723161ad6a98da31e14b7553170c2", - "sha256:4b1030728872c59687badcca1e225a9103440e467c17d6d1730ab3d2d64bfeff", - "sha256:58363dbd966afb4f89b3b11dfb8ff200058fbc3b947507675c19ceb46104b48d", - "sha256:6ec280fb24d27e3d97aa731e16207d58bd8ae94ef6eab97249a2afe4ba643d42", - "sha256:7270a6c29199adc1297776937a05b59720e8a782531f1f122f2eb8467f9aab4d", - "sha256:73fd30c57fa2d0a1d7a49c561c40c2f79c7d6c374cc7750e9ac7c99176f6428e", - "sha256:7f09806ed4fbea8f51585231ba742b58cbcfbfe823ea197d8c89a5e433c7e912", - "sha256:90df0cc93e1f8d2fba8365fb59a858f51a11a394d64dbf3ef844f783844cc793", - "sha256:971221ed40f058f5662a604bd1ae6e4521d84e6cad0b7b170564cc34169c8f13", - "sha256:a518c153a2b5ed6b8cc03f7ae79d5ffad7315ad4569b2d5333a13c38d64bd8d7", - "sha256:b0de590a8b0979649ebeef8bb9f54394d3a41f66c5584fff4220901739b6b2f0", - "sha256:b43f53f29816ba1db8525f006fa6f49292e9b029554b3eb56a189a70f2a40879", - "sha256:d31402aad60ed889c7e57934a03477b572a03af7794fa8fb1780f21ea8f6551f", - "sha256:de96157ec73458a7f14e3d26f17f8128c959084931e8997b9e655a39c8fde9f9", - "sha256:df6b4dca2e11865e6cfbfb708e800efb18370f5a46fd601d3755bc7f85b3a8a2", - "sha256:ecadccc7ba52193963c0475ac9f6fa28ac01e01349a2ca48509667ef41ffd2cf", - "sha256:fb81c17e0ebe3358486cd8cc3ad78adbae58af12fc2bf2bc0bb84e8090fa5ce8" - ], - "index": "pypi", - "version": "==2.8" - }, - "h2": { - "hashes": [ - "sha256:93cbd1013a2218539af05cdf9fc37b786655b93bbc94f5296b7dabd1c5cadf41", - "sha256:af35878673c83a44afbc12b13ac91a489da2819b5dc1e11768f3c2406f740fe9" - ], - "version": "==2.6.2" - }, - "hpack": { - "hashes": [ - "sha256:0edd79eda27a53ba5be2dfabf3b15780928a0dff6eb0c60a3d6767720e970c89", - "sha256:8eec9c1f4bfae3408a3f30500261f7e6a65912dc138526ea054f9ad98892e9d2" - ], - "version": "==3.0.0" - }, - "httplib2": { - "hashes": [ - "sha256:79751cc040229ec896aa01dced54de0cd0bf042f928e84d5761294422dde4454", - "sha256:de96d0a49f46d0ee7e0aae80141d37b8fcd6a68fb05d02e0b82c128592dd8261" - ], - "version": "==0.17.0" - }, - "hyper": { - "hashes": [ - "sha256:069514f54231fb7b5df2fb910a114663a83306d5296f588fffcb0a9be19407fc", - "sha256:12c82eacd122a659673484c1ea0d34576430afbe5aa6b8f63fe37fcb06a2458c" - ], - "index": "pypi", - "version": "==0.7.0" - }, - "hyperframe": { - "hashes": [ - "sha256:05f0e063e117c16fcdd13c12c93a4424a2c40668abfac3bb419a10f57698204e", - "sha256:4dcab11967482d400853b396d042038e4c492a15a5d2f57259e2b5f89a32f755" - ], - "version": "==3.2.0" - }, - "idna": { - "hashes": [ - "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", - "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" - ], - "version": "==2.8" - }, - "netaddr": { - "hashes": [ - "sha256:a1f5c9fcf75ac2579b9995c843dade33009543c04f218ff7c007b3c81695bd19", - "sha256:c64c570ac612e20e8b8a6eee72034c924fff9d76c7a46f50a9f919085f1bfbed", - "sha256:cb305179658334eb035860e515f054504e232b832abb4efc51c04bf8a72d3574" - ], - "index": "pypi", - "version": "==0.7.18" - }, - "oauth2client": { - "hashes": [ - "sha256:b8a81cc5d60e2d364f0b1b98f958dbd472887acaf1a5b05e21c28c31a2d6d3ac", - "sha256:d486741e451287f69568a4d26d70d9acd73a2bbfa275746c535b4209891cccc6" - ], - "index": "pypi", - "version": "==4.1.3" - }, - "pyasn1": { - "hashes": [ - "sha256:39c7e2ec30515947ff4e87fb6f456dfc6e84857d34be479c9d4a4ba4bf46aa5d", - "sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba" - ], - "version": "==0.4.8" - }, - "pyasn1-modules": { - "hashes": [ - "sha256:905f84c712230b2c592c19470d3ca8d552de726050d1d1716282a1f6146be65e", - "sha256:a50b808ffeb97cb3601dd25981f6b016cbb3d31fbf57a8b8a87428e6158d0c74" - ], - "version": "==0.2.8" - }, - "pycparser": { - "hashes": [ - "sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3" - ], - "version": "==2.19" - }, - "pyjwt": { - "hashes": [ - "sha256:5c6eca3c2940464d106b99ba83b00c6add741c9becaec087fb7ccdefea71350e", - "sha256:8d59a976fb773f3e6a39c85636357c4f0e242707394cadadd9814f5cbaa20e96" - ], - "index": "pypi", - "version": "==1.7.1" - }, - "pymongo": { - "hashes": [ - "sha256:0ce91b475d50b70388f512a2780bf91b0de643175d3f60bae3786ee4f133e751", - "sha256:0f0e2cd634a5f97fe84b8a860c52e86cee488764031505cdc7c855f01fed7bd4", - "sha256:166746d50df39c3d293ff26f18c64d728b4ac59b3d1940fb6475ad22820ba439", - "sha256:1863a7ee4080388a7e247c7f8040c2a1e1288cecc3792cdcbe25a4b55a3f4a75", - "sha256:2652d255b3a0b16a49c743879e882d6c3de40166282fa791075ad5db0285cbb4", - "sha256:28be0827bd176c844fc0c06d99dae95bf0f720b6ff3616099f3ab6d0e1742602", - "sha256:38fddffcd47b51415eef97290643dda4e72c7bf32af798df128d9ad94196f029", - "sha256:39961f650fca9b3c6a8294a47707c328283d42e298712030b1992083900f00c3", - "sha256:3eda499d1a6e584c448b8abb66c4cb7af02ba50f70a99a3063c4d9c460130e38", - "sha256:41c892df7f67ec9aa76f4e1b4e093ac18d9a9ebafa6c60fc4e57db68eadb0d87", - "sha256:4b68b6defa12b96e1087871e677ee8b9d67bbf57b1b70ee54ed19d2ee9dca538", - "sha256:521676f3f2739a6b92d8d7bd7141653594e609b5827a382b0b9d76da69eefb2e", - "sha256:57197ac3f47eeef633eec0ea46ddc3895904d0daf2bd271d85a5d691de539171", - "sha256:6c2b1b2ec87873c1d1e38b32378ad428409264d674cceaf1552d557d7f961e57", - "sha256:728a624a35383b147f2fca6051fb9604c7209ad0d9b65e35bf429e563d999e8a", - "sha256:8077f89268d702dfae5a633a389f7775122e4146e05e9d6c8b0ee12c91e4d84c", - "sha256:8946a46e3b9c4a7f0feb6909093594ab10771bda0fc4601901666b27043fc100", - "sha256:8de6afe3aa34be4800a0bc49ce8f0d05c5e936b4ec297322e64bb6db8e5fd754", - "sha256:906a13ad6081c5cb5c6862879bc22aa738a4ae12561c6b4ae64d2ff1b4fc47f5", - "sha256:a02035ab7ebef71f7fc4aaa0c2344bcc7d74c6de64a000464184f8cb9496966f", - "sha256:a11b456b549583d76a1ccca20a4a0ee710489e67753b3f3082cd929556693f31", - "sha256:a516bddf391ccded8a9fe75672200bfedb20449e09661f3f785e8e695a6b15e4", - "sha256:a7c3a6f32eb910fbdc0dde9aca9fb5407726cd21504d0a67334109f6aaade94e", - "sha256:abbcbdabe9fd64b107f3aef5c68a20f22906c5f941e75b8414a026e8860af489", - "sha256:bc2e6b5bc53269cad1f06ac32a86777a3b8761459f155c6bb14b25844720c0b1", - "sha256:c612ed53c88071da75a4998add30971d9e90e80c83339c86e3be5ebd6913e32b", - "sha256:cf8846fb59caffa587ba14da78f8fb23dba85017e009c1d752469b0005c444bf", - "sha256:d0e516d07979c43a65927cd98c8bda84c7620f09658e9f424ebfff8f28994f77", - "sha256:d2701658ea78ad484cd077fecb68de130de9a4ed784cc0a62d8d1d549d2b3fff", - "sha256:d3aabb3dfc564d4b797c3805f3f3b4ce24de6c7150041f9caad536f4c672110b", - "sha256:dd647f898031efefc093c14960b531ce13c10cd704dc0b43604cb93b168719e5", - "sha256:e820d93414f3bec1fa456c84afbd4af1b43ff41366321619db74e6bc065d6924", - "sha256:ef5dc292d27cb65a04776eaf0c9b5e6a87d6fd03f272a7043816fb8b946f4d8d", - "sha256:fd22e54beb634e3568638862f305ccd3a78a89fa14a2b62397255b3510eb6bca", - "sha256:ffaf9e135f9321423ac50035c4e3854b4f668e5a46c81d2e3341ae0504279ba3" - ], - "index": "pypi", - "version": "==3.5.1" - }, - "requests": { - "hashes": [ - "sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e", - "sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b" - ], - "index": "pypi", - "version": "==2.21.0" - }, - "rsa": { - "hashes": [ - "sha256:14ba45700ff1ec9eeb206a2ce76b32814958a98e372006c8fb76ba820211be66", - "sha256:1a836406405730121ae9823e19c6e806c62bbad73f890574fff50efa4122c487" - ], - "version": "==4.0" - }, - "sentry-sdk": { - "hashes": [ - "sha256:09e1e8f00f22ea580348f83bbbd880adf40b29f1dec494a8e4b33e22f77184fb", - "sha256:ff1fa7fb85703ae9414c8b427ee73f8363232767c9cd19158f08f6e4f0b58fc7" - ], - "index": "pypi", - "version": "==0.13.2" - }, - "six": { - "hashes": [ - "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a", - "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c" - ], - "version": "==1.14.0" - }, - "tornado": { - "hashes": [ - "sha256:349884248c36801afa19e342a77cc4458caca694b0eda633f5878e458a44cb2c", - "sha256:398e0d35e086ba38a0427c3b37f4337327231942e731edaa6e9fd1865bbd6f60", - "sha256:4e73ef678b1a859f0cb29e1d895526a20ea64b5ffd510a2307b5998c7df24281", - "sha256:559bce3d31484b665259f50cd94c5c28b961b09315ccd838f284687245f416e5", - "sha256:abbe53a39734ef4aba061fca54e30c6b4639d3e1f59653f0da37a0003de148c7", - "sha256:c845db36ba616912074c5b1ee897f8e0124df269468f25e4fe21fe72f6edd7a9", - "sha256:c9399267c926a4e7c418baa5cbe91c7d1cf362d505a1ef898fde44a07c9dd8a5" - ], - "index": "pypi", - "version": "==6.0.3" - }, - "urllib3": { - "hashes": [ - "sha256:2393a695cd12afedd0dcb26fe5d50d0cf248e5a66f75dbd89a3d4eb333a61af4", - "sha256:a637e5fae88995b256e3409dc4d52c2e2e0ba32c42a6365fee8bbd2238de3cfb" - ], - "version": "==1.24.3" - } - }, - "develop": {} -} From 6a3900626ddd4ba32a9bd014558126b1a2d8f755 Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Wed, 3 Apr 2024 11:28:27 +0200 Subject: [PATCH 02/29] Build Docker Container from cwd #3 Add python3-dev python3 depedency #2 https://github.com/BiP-org/airnotifier/issues/2 https://github.com/BiP-org/airnotifier/issues/3 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0f37abd5..880e1a10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,11 +6,11 @@ ENV DEBIAN_FRONTEND=noninteractive TERM=linux EXPOSE 8801 RUN apt-get update && \ - apt-get install -y --no-install-recommends git ca-certificates + apt-get install -y --no-install-recommends git ca-certificates python3-dev python3 RUN pip3 install pipenv -RUN git clone -b 2.x https://github.com/airnotifier/airnotifier.git /airnotifier +COPY . /airnotifier RUN mkdir -p /var/airnotifier/pemdir && \ mkdir -p /var/log/airnotifier From ce66e1f6418a801ac8f666ce710f3b24d8821839 Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Wed, 3 Apr 2024 12:13:10 +0200 Subject: [PATCH 03/29] fix file permissions --- admin.py | 0 app.py | 0 upgrade.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 admin.py mode change 100755 => 100644 app.py mode change 100755 => 100644 upgrade.py diff --git a/admin.py b/admin.py old mode 100755 new mode 100644 diff --git a/app.py b/app.py old mode 100755 new mode 100644 diff --git a/upgrade.py b/upgrade.py old mode 100755 new mode 100644 From a41010f4ee2c7fdf2f750dd12f8eec17200d6fc6 Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Wed, 3 Apr 2024 13:15:21 +0200 Subject: [PATCH 04/29] Bewegungsdaten nicht in git Aufnehmen #5 https://github.com/BiP-org/airnotifier/issues/5 --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index e724edb3..d4f53cd5 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ airnotifier.err airnotifier.log config.py .cache +mongo/ +logs/ +*~ From 0ad8b51a6d3411457e34412bb9697d8191b6f970 Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Wed, 3 Apr 2024 13:17:21 +0200 Subject: [PATCH 05/29] Fix Permissions #6 https://github.com/BiP-org/airnotifier/issues/6 --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 880e1a10..60c1e868 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,7 @@ EXPOSE 8801 RUN apt-get update && \ apt-get install -y --no-install-recommends git ca-certificates python3-dev python3 + RUN pip3 install pipenv COPY . /airnotifier @@ -21,4 +22,6 @@ RUN pipenv install --deploy ADD start.sh /airnotifier RUN chmod a+x /airnotifier/start.sh +RUN chmod a+x /airnotifier/install.py +RUN chmod a+x /airnotifier/app.py ENTRYPOINT /airnotifier/start.sh From 8ae90763f2a471200fa010ea5717f6d358617400 Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Wed, 3 Apr 2024 13:17:57 +0200 Subject: [PATCH 06/29] Allow Configuration of MongoDB Server/Port #7 https://github.com/BiP-org/airnotifier/issues/7 --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7615202a..df305fee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: image: mongo:latest container_name: mongodb ports: - - 27017:27017 + - ${MONGO_PORT:-27017}:27017 environment: - MONGO_DATA_DIR=/data/db - MONGO_LOG_DIR=/tmp/mongo/mongo.log @@ -29,4 +29,4 @@ services: - 8801:8801 environment: - MONGO_SERVER=mongodb - - MONGO_PORT=27017 + - MONGO_PORT=${MONGO_PORT:-27017} From 400ef44386df5df8a0cb11c752a384667461b36a Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Wed, 3 Apr 2024 13:21:22 +0200 Subject: [PATCH 07/29] Airnotifier should log to stdout/stderr for docker logs to work #8 https://github.com/BiP-org/airnotifier/issues/8 --- start.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/start.sh b/start.sh index 1b3329c9..390f176f 100755 --- a/start.sh +++ b/start.sh @@ -1,9 +1,9 @@ #!/bin/bash set -e -export LOGDIR=/var/log/airnotifier -export LOGFILE=$LOGDIR/airnotifier.log -export LOGFILE_ERR=$LOGDIR/airnotifier.err +export LOGDIR="${LOGDIR:/var/log/airnotifier}" +export LOGFILE="${LOGFILE:airnotifier.log}" +export LOGFILE_ERR="${LOGFILE_ERR:airnotifier.err}" if [ ! -f "./config.py" ]; then cp config.py-sample config.py @@ -15,17 +15,23 @@ if [ ! -f "./logging.ini" ]; then cp logging.ini-sample logging.ini fi -sed -i "s/mongouri = \"mongodb:\/\/localhost:27017\/\"/mongouri = \"mongodb:\/\/${MONGO_SERVER-localhost}:${MONGO_PORT-27017}\"/g" ./config.py - -if [ ! -f "$LOGFILE" ]; then - touch "$LOGFILE" +if [ ! -f "${LOGDIR}/${LOGFILE}" ]; then + ln -sf /dev/stdout "${LOGDIR}/${LOGFILE}" fi -if [ ! -f "$LOGFILE_ERR" ]; then - touch "$LOGFILE_ERR" +if [ ! -f "${LOGDIR}/${LOGFILE_ERR}" ]; then + ln -sf /dev/stderr "${LOGDIR}/${LOGFILE_ERR}" fi + +sed -i "s/mongouri = \"mongodb:\/\/localhost:27017\/\"/mongouri = \"mongodb:\/\/${MONGO_SERVER-localhost}:${MONGO_PORT-27017}\/\"/g" ./config.py +sed -i "s/mongohost = \"localhost\"/mongohost = \"mongodb\"/g" ./config.py + echo "Installing AirNotifier ..." pipenv run ./install.py + echo "Starting AirNotifier ..." -pipenv run ./app.py >> "$LOGFILE" 2>> "$LOGFILE_ERR" +__starttimestamp=`date +%s.%N` +pipenv run ./app.py +__runtime=$( echo "${__endtimestamp} - ${__starttimestamp}" | bc -l ) +echo ${__runtime} From 7c9ca2752dba4bef34f4770bd6a9caf1503f3dd2 Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Wed, 3 Apr 2024 13:22:03 +0200 Subject: [PATCH 08/29] Fix Permissions #6 https://github.com/BiP-org/airnotifier/issues/6 --- app.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 app.py diff --git a/app.py b/app.py old mode 100644 new mode 100755 From 92b5416b02504b56301d411041d5e0cd72b8b889 Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Wed, 3 Apr 2024 13:32:48 +0200 Subject: [PATCH 09/29] fix deprecation warnings #9 https://github.com/BiP-org/airnotifier/issues/9 --- app.py | 2 +- install.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 13999508..3172acf1 100755 --- a/app.py +++ b/app.py @@ -70,7 +70,7 @@ if options.sentrydsn: sentry_sdk.init(dsn=options.sentrydsn, integrations=[TornadoIntegration()]) else: - logging.warn("Sentry dsn is not set") + logging.warning("Sentry dsn is not set") mongodb = None while not mongodb: diff --git a/install.py b/install.py index 4de566bb..771cec35 100755 --- a/install.py +++ b/install.py @@ -61,7 +61,7 @@ mongodb = pymongo.MongoClient(options.mongouri) masterdb = mongodb[options.masterdb] - collection_names = masterdb.collection_names() + collection_names = masterdb.list_collection_names() try: if not "applications" in collection_names: masterdb.create_collection("applications") From 3cde470810270f7dc3e41b73e7466d8dd7ac7960 Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Wed, 3 Apr 2024 14:19:04 +0200 Subject: [PATCH 10/29] Allow Configuration of MongoDB Server/Port/Directories #7 https://github.com/BiP-org/airnotifier/issues/7 --- docker-compose.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index df305fee..680905ca 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,8 +12,8 @@ services: - MONGO_DATA_DIR=/data/db - MONGO_LOG_DIR=/tmp/mongo/mongo.log volumes: - - ./mongo/data:/data/db - - ./mongo/log:/tmp/mongo + - ${MONGO_DATA:-../var/mongo/data}:/data/db + - ${MONGO_LOG:-../var/mongo/log}:/tmp/mongo command: mongod --logpath=/dev/null # --quiet airnotifier: links: @@ -23,8 +23,8 @@ services: build: . container_name: airnotifier volumes: - - ./certs:/var/airnotifier/pemdir - - ./logs:/var/log/airnotifier + - ${AIRNOTIFIER_CERTS:-../var/airnotifier/certs}:/var/airnotifier/pemdir + - ${AIRNOTIFIER_LOGS:-../var/airnotifier/logs}:/var/log/airnotifier ports: - 8801:8801 environment: From 9ab2e139e56e4060627c27591b62410dbb2f04de Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Wed, 3 Apr 2024 14:22:31 +0200 Subject: [PATCH 11/29] Upgrade from python 3.6 (EOL since 2021-12) to python 3.9 (EOL in 2025-10) #11 https://github.com/BiP-org/airnotifier/issues/11 --- Dockerfile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 60c1e868..519623d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,21 @@ -FROM python:3.6 +FROM python:3.9 ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8 ENV DEBIAN_FRONTEND=noninteractive TERM=linux +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 EXPOSE 8801 -RUN apt-get update && \ - apt-get install -y --no-install-recommends git ca-certificates python3-dev python3 +# Configure APT +RUN echo "debconf debconf/frontend select ${DEBIAN_FRONTEND}" | debconf-set-selections \ + && echo 'APT::Install-Recommends "false";' | tee /etc/apt/apt.conf.d/99install-recommends \ + && echo 'APT::Get::Assume-Yes "true";' | tee /etc/apt/apt.conf.d/99assume-yes \ + && sed -Ei 's|^(DPkg::Pre-Install-Pkgs .*)|#\1|g' /etc/apt/apt.conf.d/70debconf \ + && debconf-show debconf + +RUN apt-get update -q -y && \ + apt-get install -q -y --no-install-recommends git ca-certificates python3-dev python3 RUN pip3 install pipenv From 9a8393e112ed5f6f359b37f748927da638d90615 Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Wed, 3 Apr 2024 14:23:00 +0200 Subject: [PATCH 12/29] Upgrade from python 3.6 (EOL since 2021-12) to python 3.9 (EOL in 2025-10) #11 https://github.com/BiP-org/airnotifier/issues/11 --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2cfd1f4a..66b3e4ae 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,9 @@ Please read [Installation guide](https://github.com/airnotifier/airnotifier/wiki ## Requirements -- [Python 3.6](http://www.python.org) +- [Python 3.9](http://www.python.org) - [MongoDB 4.0+](http://www.mongodb.org/) ## Copyright Copyright (c) Dongsheng Cai and individual contributors +Copyright (c) Georg Glas 2024 From f40962afdaa864423f02dad98c3c2ac8ff82a35c Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Wed, 3 Apr 2024 14:24:51 +0200 Subject: [PATCH 13/29] Documentation: How to rebuild #4 https://github.com/BiP-org/airnotifier/issues/4 --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 66b3e4ae..a34dc61f 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,10 @@ AirNotifier is a user friendly yet powerful application server for sending real- Please read [Installation guide](https://github.com/airnotifier/airnotifier/wiki/Installation) +## Rebuilding Docker container + +use ```docker-compose up --build``` to rebuild docker image + ## Web service documentation - [Web service interfaces](https://github.com/airnotifier/airnotifier/wiki/API) From 0ebfea4db1651273d3dae363ff982b6228aaa012 Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Fri, 5 Apr 2024 11:52:51 +0200 Subject: [PATCH 14/29] no need to expose port monogod port --- docker-compose.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 680905ca..d5d311ec 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,8 +6,6 @@ services: mongodb: image: mongo:latest container_name: mongodb - ports: - - ${MONGO_PORT:-27017}:27017 environment: - MONGO_DATA_DIR=/data/db - MONGO_LOG_DIR=/tmp/mongo/mongo.log @@ -28,5 +26,5 @@ services: ports: - 8801:8801 environment: - - MONGO_SERVER=mongodb + - MONGO_SERVER=${MONGO_SERVER:-mongodb} - MONGO_PORT=${MONGO_PORT:-27017} From e1c54a9bdc759f8c13d2e84018e6c02849d8bc30 Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Fri, 5 Apr 2024 11:54:07 +0200 Subject: [PATCH 15/29] selfcontained docker-compose runs monogod and airnotifiere in two docker containers --- docker-compose.yml => docker-compose-selfcontained.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docker-compose.yml => docker-compose-selfcontained.yml (100%) diff --git a/docker-compose.yml b/docker-compose-selfcontained.yml similarity index 100% rename from docker-compose.yml rename to docker-compose-selfcontained.yml From ee9814f968903bd5b2dea87986eaef8768046d2a Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Fri, 5 Apr 2024 12:30:17 +0200 Subject: [PATCH 16/29] Airnotifier using non-dockerized mongodb #491 https://github.com/BiP-org/bip-infrastructure/issues/491 --- .gitignore | 1 + docker-compose.yml | 17 +++++++++++++++++ start.sh | 2 ++ 3 files changed, 20 insertions(+) create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index d4f53cd5..0e527306 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ config.py mongo/ logs/ *~ +.env diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..7f47c6fe --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +# After staring container, don't forget to install db : +# docker exec -it airnotifier python /airnotifier/install.py + +version: "3" +services: + airnotifier: + network_mode: host + build: . + container_name: airnotifier + volumes: + - ${AIRNOTIFIER_CERTS:-../var/airnotifier/certs}:/var/airnotifier/pemdir + - ${AIRNOTIFIER_LOGS:-../var/airnotifier/logs}:/var/log/airnotifier +# ports: +# - 8801:8801 + environment: + - MONGO_SERVER=${MONGO_SERVER:-mongodb} + - MONGO_PORT=${MONGO_PORT:-27017} diff --git a/start.sh b/start.sh index 390f176f..15ed9070 100755 --- a/start.sh +++ b/start.sh @@ -23,6 +23,8 @@ if [ ! -f "${LOGDIR}/${LOGFILE_ERR}" ]; then ln -sf /dev/stderr "${LOGDIR}/${LOGFILE_ERR}" fi +echo "MONGO_SERVER: ${MONGO_SERVER-localhost}" +echo "MONGO_PORT: ${MONGO_PORT-27017}" sed -i "s/mongouri = \"mongodb:\/\/localhost:27017\/\"/mongouri = \"mongodb:\/\/${MONGO_SERVER-localhost}:${MONGO_PORT-27017}\/\"/g" ./config.py sed -i "s/mongohost = \"localhost\"/mongohost = \"mongodb\"/g" ./config.py From d42baa12fddb1f3b5c5cdd4ca8751bc41e8b44dd Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Fri, 5 Apr 2024 17:24:41 +0200 Subject: [PATCH 17/29] airnotifier upgrade to tornado >=6.3.4 [security] #16 security upgrade for tornado https://github.com/BiP-org/airnotifier/issues/16 --- Pipfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pipfile b/Pipfile index 68739f0b..7c998f9d 100644 --- a/Pipfile +++ b/Pipfile @@ -13,7 +13,7 @@ netaddr = "==0.7.18" oauth2client = "==4.1.3" pymongo = "==3.13.0" requests = "==2.21.0" -tornado = "~=6.0" +tornado = "~=6.4.0" click = "*" sentry-sdk = "==0.13.2" aiocontextvars = "*" From 09f3189dcba1ac1342d884c23f0292a95c2d0807 Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Fri, 12 Apr 2024 00:07:53 +0200 Subject: [PATCH 18/29] Allow Configuration of MongoDB Server/Port/Database/Option/SSL #7 https://github.com/BiP-org/airnotifier/issues/7 --- Dockerfile | 2 +- README.md | 3 ++- docker-compose.yml | 2 ++ start.sh | 52 ++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 519623d0..73a7cf73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN echo "debconf debconf/frontend select ${DEBIAN_FRONTEND}" | debconf-set-sele && debconf-show debconf RUN apt-get update -q -y && \ - apt-get install -q -y --no-install-recommends git ca-certificates python3-dev python3 + apt-get install -q -y --no-install-recommends git ca-certificates python3-dev python3 python3-dns RUN pip3 install pipenv diff --git a/README.md b/README.md index a34dc61f..a263cf3f 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,8 @@ Please read [Installation guide](https://github.com/airnotifier/airnotifier/wiki ## Rebuilding Docker container -use ```docker-compose up --build``` to rebuild docker image +use ```docker-compose up --build``` to rebuild docker image delete volume +first ```docker volume ls``` and ```docker volume rm ....``` ## Web service documentation - [Web service interfaces](https://github.com/airnotifier/airnotifier/wiki/API) diff --git a/docker-compose.yml b/docker-compose.yml index 7f47c6fe..3c79d088 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,3 +15,5 @@ services: environment: - MONGO_SERVER=${MONGO_SERVER:-mongodb} - MONGO_PORT=${MONGO_PORT:-27017} + env_file: + - .env diff --git a/start.sh b/start.sh index 15ed9070..0e4782a8 100755 --- a/start.sh +++ b/start.sh @@ -5,6 +5,36 @@ export LOGDIR="${LOGDIR:/var/log/airnotifier}" export LOGFILE="${LOGFILE:airnotifier.log}" export LOGFILE_ERR="${LOGFILE_ERR:airnotifier.err}" +if [ -f "./config.py" ]; then +# we do not assume passwordsalt and cookiesecrets contain a space or any escape char + if [ ! -z "${AIRNOTIFIER_PASSWORDSALT}" ] || [ ! -z "${AIRNOTIFIER_COOKIESECRETS}" ]; then + echo "WARNING: will ignore provided \"\${AIRNOTIFIER_PASSWORDSALT}\", \"\${AIRNOTIFIER_COOKIESECRETS}\" and \"\${MONGO_PROTOCOL}\", will read existing configuration from file \"./config.py\"" + fi + AIRNOTIFIER_PASSWORDSALT=$(grep passwordsalt config.py|grep -vE "[[:space:]]?#[[:space:]]?passwordsalt"|cut -d= -f2|tr -d " '\"") + AIRNOTIFIER_COOKIESECRETS=$(grep cookiesecret config.py|grep -vE "[[:space:]]?#[[:space:]]?cookiesecret"|cut -d= -f2|tr -d " '\"") + MONGO_PROTOCOL=$(grep mongouri config.py|grep -vE "[[:space:]]?#[[:space:]]?mongouri"|cut -d= -f2|tr -d " '\""|cut -d: -f1) + MONGO_USER=$(grep mongouri config.py|grep -vE "[[:space:]]?#[[:space:]]?mongouri"|cut -d= -f2|tr -d " '\""|grep @|cut -d/ -f3|cut -d: -f1) + MONGO_PASS=$(grep mongouri config.py|grep -vE "[[:space:]]?#[[:space:]]?mongouri"|cut -d= -f2|tr -d " '\""|grep @|cut -d/ -f3|cut -d: -f2|cut -d@ -f1) +fi + +# fall-back to random defaults 25 char defaults +__defaultpassordsalt=$(tr -dc 'A-Za-z0-9' Date: Fri, 12 Apr 2024 01:37:32 +0200 Subject: [PATCH 19/29] Allow Configuration of MongoDB Server/Port/Database/Option/SSL #7 https://github.com/BiP-org/airnotifier/issues/7 --- start.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/start.sh b/start.sh index 0e4782a8..55f321bc 100755 --- a/start.sh +++ b/start.sh @@ -27,13 +27,16 @@ MONGO_PORT=${MONGO_PORT-27017} AIRNOTIFIER_PASSWORDSALT=${AIRNOTIFIER_PASSWORDSALT-$(echo ${__defaultpassordsalt})} AIRNOTIFIER_COOKIESECRETS=${AIRNOTIFIER_COOKIESECRETS-$(echo ${__defaultcookiesecret})} MONGO_PROTOCOL=${MONGO_PROTOCOL-mongodb} +if [ ! -z "${MONGO_CA_PATH}" ]; then + __MONGO_SSL="\&tlsCAFile=${MONGO_CA_PATH}" +fi if [ ! -z "${MONGO_USER}" ]; then - MONGO_URL=${MONGO_PROTOCOL}://${MONGO_USER}:${MONGO_PASS}@${MONGO_SERVER}:${MONGO_PORT}/${MONGO_DATABASE}?${MONGO_OPTIONS} + MONGO_URL=${MONGO_PROTOCOL}://${MONGO_USER}:${MONGO_PASS}@${MONGO_SERVER}:${MONGO_PORT}/${MONGO_DATABASE}?${MONGO_OPTIONS}${__MONGO_SSL} else - MONGO_URL=${MONGO_PROTOCOL}://${MONGO_SERVER}:${MONGO_PORT}/${MONGO_DATABASE}?${MONGO_OPTIONS} + MONGO_URL=${MONGO_PROTOCOL}://${MONGO_SERVER}:${MONGO_PORT}/${MONGO_DATABASE}?${MONGO_OPTIONS}${__MONGO_SSL} fi #MONGO_URL_REGEX=$(echo "${MONGO_URL}"|sed "s#\\/#\\\\/#g"|sed "s#\\+#%2B#g"|sed "s#&#%26#g"|sed "s:=:%3D:g") -MONGO_URL_REGEX=$(echo "${MONGO_URL}"|sed "s#\\/#\\\\/#g"|sed "s#\\+#%2B#g"|sed "s#&#%26#g") +MONGO_URL_REGEX=$(echo "${MONGO_URL}"|sed "s#\\/#\\\\/#g"|sed "s#\\+#%2B#g") echo "MONGO_URL_REGEX: ${MONGO_URL_REGEX}" if [ ! -f "./config.py" ]; then cp config.py-sample config.py @@ -45,16 +48,16 @@ if [ ! -f "./logging.ini" ]; then cp logging.ini-sample logging.ini fi -if [ ! -f "${LOGDIR}/${LOGFILE}" ]; then +if [ ! -f "${LOGDIR}/${LOGFILE}" ] && [ ! -z "${LOGDIR}" ] && [ ! -z "${LOGFILE}"]; then ln -sf /dev/stdout "${LOGDIR}/${LOGFILE}" fi -if [ ! -f "${LOGDIR}/${LOGFILE_ERR}" ]; then +if [ ! -f "${LOGDIR}/${LOGFILE_ERR}" ] && [ ! -z "${LOGDIR}" ] && [ ! -z "${LOGFILE_ERR}"]; then ln -sf /dev/stderr "${LOGDIR}/${LOGFILE_ERR}" fi # update config.py with our settings (make sure to update these strings if you update config.py-sample -sed -i "s/mongouri = \"mongodb:\/\/localhost:27017\/\"/mongouri = \"${MONGO_URL_REGEX}\"/g" ./config.py +sed -i "s#mongouri = \"mongodb:\/\/localhost:27017\/\"#mongouri = \"${MONGO_URL_REGEX}\"#g" ./config.py sed -i "s/mongohost = \"localhost\"/mongohost = \"mongodb\"/g" ./config.py sed -i "s/passwordsalt = \'d2o0n1g2s0h3e1n1g\'/passwordsalt = \'${AIRNOTIFIER_PASSWORDSALT}\'/g" ./config.py sed -i "s/cookiesecret = \'airnotifiercookiesecret\'/cookiesecret = \'${AIRNOTIFIER_COOKIESECRETS}\'/g" ./config.py @@ -79,5 +82,6 @@ pipenv run ./install.py echo "Starting AirNotifier ..." __starttimestamp=`date +%s.%N` pipenv run ./app.py +__endtimestamp=`date +%s.%N` __runtime=$( echo "${__endtimestamp} - ${__starttimestamp}" | bc -l ) echo ${__runtime} From 669aa84e9fd0aba4432f54ac4bb2600fdd3d6a72 Mon Sep 17 00:00:00 2001 From: Christoph Kunerth <44638104+ChristophKunerth@users.noreply.github.com> Date: Fri, 12 Apr 2024 15:20:49 +0200 Subject: [PATCH 20/29] Attempt Forum Fix https://tracker.moodle.org/browse/MOBILE-3824 Vorschlag von Markus --- hooks/moodle.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hooks/moodle.py b/hooks/moodle.py index 462a2582..9ef06301 100644 --- a/hooks/moodle.py +++ b/hooks/moodle.py @@ -12,6 +12,8 @@ def process_pushnotification_payload(data): message = extra.get("smallmessage", None) notif = extra.get("notification", None) title = extra.get("sitefullname", None) + extra["notif"] = notif + del extra["notification"] if not message: message = extra.get("fullmessage", None) From 410c5bd890267ccd64361a9be2aec04f5cb5a29d Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Sun, 28 Apr 2024 15:10:42 +0200 Subject: [PATCH 21/29] fix mongodb+srv protocol parsing #22 add commit id to startup log #23 https://github.com/BiP-org/airnotifier/issues/22 https://github.com/BiP-org/airnotifier/issues/23 --- start.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/start.sh b/start.sh index 55f321bc..3b850f04 100755 --- a/start.sh +++ b/start.sh @@ -36,7 +36,7 @@ else MONGO_URL=${MONGO_PROTOCOL}://${MONGO_SERVER}:${MONGO_PORT}/${MONGO_DATABASE}?${MONGO_OPTIONS}${__MONGO_SSL} fi #MONGO_URL_REGEX=$(echo "${MONGO_URL}"|sed "s#\\/#\\\\/#g"|sed "s#\\+#%2B#g"|sed "s#&#%26#g"|sed "s:=:%3D:g") -MONGO_URL_REGEX=$(echo "${MONGO_URL}"|sed "s#\\/#\\\\/#g"|sed "s#\\+#%2B#g") +MONGO_URL_REGEX=$(echo "${MONGO_URL}"|sed "s#\\/#\\\\/#g"|sed "s#\\+#%2B#g"|sed "s#^mongodb%2Bsrv:#mongodb\\+srv:#g") echo "MONGO_URL_REGEX: ${MONGO_URL_REGEX}" if [ ! -f "./config.py" ]; then cp config.py-sample config.py @@ -63,6 +63,9 @@ sed -i "s/passwordsalt = \'d2o0n1g2s0h3e1n1g\'/passwordsalt = \'${AIRNOTIFIER_PA sed -i "s/cookiesecret = \'airnotifiercookiesecret\'/cookiesecret = \'${AIRNOTIFIER_COOKIESECRETS}\'/g" ./config.py # provide configuration settings to user +if [ -f .git/index ]; then + echo "GIT_ID: "$(git rev-parse --verify HEAD) +fi echo "MONGO_SERVER: ${MONGO_SERVER}" echo "MONGO_PORT: ${MONGO_PORT}" echo "AIRNOTIFIER_PASSWORDSALT: ${AIRNOTIFIER_PASSWORDSALT}" From 827df7b9c6bb69fa7c6d35eb81a1beac3a00cc49 Mon Sep 17 00:00:00 2001 From: GGeorggg Date: Mon, 29 Apr 2024 12:11:46 +0200 Subject: [PATCH 22/29] Create ghcr-publish.yml https://github.com/BiP-org/airnotifier/issues/25 --- .github/workflows/ghcr-publish.yml | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/ghcr-publish.yml diff --git a/.github/workflows/ghcr-publish.yml b/.github/workflows/ghcr-publish.yml new file mode 100644 index 00000000..d2ae488d --- /dev/null +++ b/.github/workflows/ghcr-publish.yml @@ -0,0 +1,49 @@ +name: Create and publish a Docker image + +# Configures this workflow to run every time a change is pushed to the branch called `release`. +on: + push: + branches: ['release'] + +# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. +jobs: + build-and-push-image: + runs-on: ubuntu-latest + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. + # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. + # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From e8032715176a8865ec18c08a7be40db210a94892 Mon Sep 17 00:00:00 2001 From: Georg Glas Date: Wed, 5 Jun 2024 18:35:05 +0200 Subject: [PATCH 23/29] https://github.com/BiP-org/airnotifier/issues/26 --- .dockerignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..3c02c68a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +**/.git +*~ From 1652a9a4d0ebbea145a9846001f313f57cb226f9 Mon Sep 17 00:00:00 2001 From: Robert Bartl Date: Tue, 17 Jun 2025 19:14:11 +0200 Subject: [PATCH 24/29] python 3.11 changes --- Dockerfile | 2 +- Pipfile | 4 ++++ README.md | 2 +- pushservices/apns.py | 14 +++++--------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 73a7cf73..f4b94cce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9 +FROM python:3.11 ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8 ENV DEBIAN_FRONTEND=noninteractive TERM=linux diff --git a/Pipfile b/Pipfile index 7c998f9d..9aef3cc9 100644 --- a/Pipfile +++ b/Pipfile @@ -3,6 +3,9 @@ name = "pypi" url = "https://pypi.org/simple" verify_ssl = true +[requires] +python_version = "3.11" + [scripts] test = "python -m unittest discover -s tests -p 'test_*.py'" @@ -20,3 +23,4 @@ aiocontextvars = "*" hyper = "*" pyjwt = "*" cryptography = "*" +httpx = "*" diff --git a/README.md b/README.md index a263cf3f..61ba03b7 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ first ```docker volume ls``` and ```docker volume rm ....``` ## Requirements -- [Python 3.9](http://www.python.org) +- [Python 3.11](http://www.python.org) - [MongoDB 4.0+](http://www.mongodb.org/) ## Copyright diff --git a/pushservices/apns.py b/pushservices/apns.py index bc4bf76b..74e1b623 100644 --- a/pushservices/apns.py +++ b/pushservices/apns.py @@ -4,7 +4,7 @@ from . import PushService from util import json_encode import logging -import hyper +import httpx import jwt import time @@ -32,7 +32,7 @@ def __init__(self, **kwargs): self.instanceid = kwargs["instanceid"] self.last_token_refresh = 0 self.token = None - self.http2 = hyper.HTTPConnection(BASE_URL_PROD) + self.http2 = httpx.Client(http2=True, base_url="https://api.push.apple.com") # self.http2dev = hyper.HTTPConnection(BASE_URL_DEV) def create_token(self): @@ -92,13 +92,9 @@ def process(self, **kwargs): PATH = "/3/device/{0}".format(token) self.headers = self.build_headers(push_type=apns["push_type"]) - self.http2.request("POST", PATH, self.payload, headers=self.headers) - resp = self.http2.get_response() + resp = self.http2.post(PATH, content=self.payload, headers=self.headers) - if resp.status >= 400: - # headers = resp.headers - # for k, v in headers.items(): - # logging.error("%s: %s" % (k.decode("utf-8"), v.decode("utf-8"))) - body = resp.read().decode("utf-8") + if resp.status_code >= 400: + body = resp.text logging.error(body) raise ApnsException(400, body) From 346dc9b4a9ccbabe045ee2bedac4d3ca0f15050b Mon Sep 17 00:00:00 2001 From: Robert Bartl Date: Tue, 17 Jun 2025 19:17:17 +0200 Subject: [PATCH 25/29] python 3.11 changes --- pushservices/apns.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pushservices/apns.py b/pushservices/apns.py index 74e1b623..1d70e737 100644 --- a/pushservices/apns.py +++ b/pushservices/apns.py @@ -32,7 +32,7 @@ def __init__(self, **kwargs): self.instanceid = kwargs["instanceid"] self.last_token_refresh = 0 self.token = None - self.http2 = httpx.Client(http2=True, base_url="https://api.push.apple.com") + self.http2 = httpx.Client(http2=True, base_url=f"https://{BASE_URL_PROD}") # self.http2dev = hyper.HTTPConnection(BASE_URL_DEV) def create_token(self): @@ -47,7 +47,7 @@ def create_token(self): headers={"alg": ALGORITHM, "kid": self.key_id}, ) self.last_token_refresh = now - self.token = token.decode("ascii") + self.token = token return self.token def build_headers(self, push_type="alert"): From f6c369ae36ca421911f0f06c5ff31413e9603e56 Mon Sep 17 00:00:00 2001 From: Robert Bartl Date: Mon, 25 Aug 2025 19:52:23 +0200 Subject: [PATCH 26/29] update github workflow to 3.10 --- .github/workflows/pythonapp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index ed6c0cad..2126d4b7 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Set up Python 3.8 + - name: Set up Python 3.10 uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: 3.10 - name: Install dependencies run: | python -m pip install --upgrade pip From 25b143f9a88f2ab0f7a003b8a1a61183222b219b Mon Sep 17 00:00:00 2001 From: Robert Bartl Date: Mon, 25 Aug 2025 19:53:22 +0200 Subject: [PATCH 27/29] update github workflow to 3.10 --- .github/workflows/pythonapp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 2126d4b7..a750afe3 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Set up Python 3.10 + - name: Set up Python 3.10.18 uses: actions/setup-python@v1 with: - python-version: 3.10 + python-version: 3.10.18 - name: Install dependencies run: | python -m pip install --upgrade pip From b09efa29df48dc2f24673a28526b620d40722382 Mon Sep 17 00:00:00 2001 From: Robert Bartl Date: Mon, 25 Aug 2025 19:54:50 +0200 Subject: [PATCH 28/29] update github workflow to 3.10 --- .github/workflows/pythonapp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index a750afe3..da5de03d 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Set up Python 3.10.18 + - name: Set up Python 3.11.13 uses: actions/setup-python@v1 with: - python-version: 3.10.18 + python-version: 3.11.13 - name: Install dependencies run: | python -m pip install --upgrade pip From 2f936530165bec7f14ba7b6a8335e2c2013a37f1 Mon Sep 17 00:00:00 2001 From: Robert Bartl Date: Mon, 25 Aug 2025 20:18:26 +0200 Subject: [PATCH 29/29] #783 - fix test and migrate to httpx --- Pipfile | 1 - tests/test_apns.py | 33 ++++++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Pipfile b/Pipfile index 9aef3cc9..590d6f0d 100644 --- a/Pipfile +++ b/Pipfile @@ -20,7 +20,6 @@ tornado = "~=6.4.0" click = "*" sentry-sdk = "==0.13.2" aiocontextvars = "*" -hyper = "*" pyjwt = "*" cryptography = "*" httpx = "*" diff --git a/tests/test_apns.py b/tests/test_apns.py index 12911958..840d7f9b 100644 --- a/tests/test_apns.py +++ b/tests/test_apns.py @@ -6,35 +6,29 @@ from util import json_decode -def mocked_http2(*args, **kwargs): +def mocked_httpx_client(*args, **kwargs): class Response: def __init__(self): - self.status = 200 + self.status_code = 200 + self.text = "{}" - def read(self): - return b"{}" - - class HTTP2: - def request(self, method, path, payload, **kwargs): + class HTTPXClient: + def __init__(self, *args, **kwargs): pass - def get_response(self): + def post(self, path, content, headers): return Response() - return HTTP2() + return HTTPXClient() def mocked_jwt_encode(*args, **kwargs): - class Token: - def decode(self, string): - return "encode_jwt" - - return Token() + return "encode_jwt" class TestAPNS(unittest.TestCase): @patch("jwt.encode", side_effect=mocked_jwt_encode) - @patch("hyper.HTTPConnection", side_effect=mocked_http2) + @patch("httpx.Client", side_effect=mocked_httpx_client) def test_apns(self, jwt, req): self.maxDiff = None kwargs = { @@ -47,6 +41,10 @@ def test_apns(self, jwt, req): "instanceid": "", } apns = ApnsClient(**kwargs) + # Reset token cache to ensure mock is used + apns.token = None + apns.last_token_refresh = 0 + apns_default = {"badge": None, "sound": "default", "push_type": "alert"} apns.process( token="aaa", alert="alert", apns={**apns_default, **{"badge": 12}}, @@ -66,6 +64,11 @@ def test_apns(self, jwt, req): apns.payload, '{"aps": {"alert": {"body": "alert", "title": "alert"}, "badge": 12, "sound": "default"}}', ) + + # Reset token cache again for second call + apns.token = None + apns.last_token_refresh = 0 + apns.process( token="aaa", alert="alert",