mirror of
https://github.com/Py-KMS-Organization/py-kms.git
synced 2025-05-12 22:26:17 -04:00
Fix pytz and time localization
This commit is contained in:
parent
5de292e12a
commit
4a7376f17b
5 changed files with 10 additions and 5 deletions
|
@ -26,7 +26,7 @@ RUN apk add --no-cache --update \
|
||||||
sqlite-libs \
|
sqlite-libs \
|
||||||
py3-pip \
|
py3-pip \
|
||||||
build-base python3-dev && \
|
build-base python3-dev && \
|
||||||
pip3 install peewee tzlocal && \
|
pip3 install peewee tzlocal pytz && \
|
||||||
apk del git build-base python3-dev
|
apk del git build-base python3-dev
|
||||||
|
|
||||||
WORKDIR /home/py-kms
|
WORKDIR /home/py-kms
|
||||||
|
|
|
@ -29,7 +29,7 @@ RUN apk add --no-cache --update \
|
||||||
git clone https://github.com/coleifer/sqlite-web.git /tmp/sqlite_web && \
|
git clone https://github.com/coleifer/sqlite-web.git /tmp/sqlite_web && \
|
||||||
mv /tmp/sqlite_web/sqlite_web /home/ && \
|
mv /tmp/sqlite_web/sqlite_web /home/ && \
|
||||||
rm -rf /tmp/sqlite_web && \
|
rm -rf /tmp/sqlite_web && \
|
||||||
pip3 install peewee tzlocal pysqlite3 && \
|
pip3 install peewee tzlocal pytz pysqlite3 && \
|
||||||
chmod a+x /usr/bin/start.sh && \
|
chmod a+x /usr/bin/start.sh && \
|
||||||
apk del git build-base python3-dev
|
apk del git build-base python3-dev
|
||||||
|
|
||||||
|
|
0
docker/docker-py3-kms/start.sh
Normal file → Executable file
0
docker/docker-py3-kms/start.sh
Normal file → Executable file
|
@ -15,7 +15,7 @@ If you wish to get _py-kms_ just up and running without installing any dependenc
|
||||||
Docker also solves problems regarding the explicit IPv4 and IPv6 usage (it just supports both). The following
|
Docker also solves problems regarding the explicit IPv4 and IPv6 usage (it just supports both). The following
|
||||||
command will download, "install" and start _py-kms_ and also keep it alive after any service disruption.
|
command will download, "install" and start _py-kms_ and also keep it alive after any service disruption.
|
||||||
```bash
|
```bash
|
||||||
docker run -d --name py-kms --restart always -p 1688:1688 pykmsorg/py-kms
|
docker run -d --name py-kms --restart always -p 1688:1688 -v /etc/localtime:/etc/localtime:ro pykmsorg/py-kms
|
||||||
```
|
```
|
||||||
If you just want to use the image and don't want to build them yourself, you can always use the official image at the [Docker Hub](https://hub.docker.com/r/pykmsorg/py-kms) (`pykmsorg/py-kms`). To ensure that you are using always the
|
If you just want to use the image and don't want to build them yourself, you can always use the official image at the [Docker Hub](https://hub.docker.com/r/pykmsorg/py-kms) (`pykmsorg/py-kms`). To ensure that you are using always the
|
||||||
latest version you should check something like [watchtower](https://github.com/containrrr/watchtower) out !
|
latest version you should check something like [watchtower](https://github.com/containrrr/watchtower) out !
|
||||||
|
|
|
@ -119,11 +119,11 @@ class kmsBase:
|
||||||
|
|
||||||
# Localize the request time, if module "tzlocal" is available.
|
# Localize the request time, if module "tzlocal" is available.
|
||||||
try:
|
try:
|
||||||
|
from datetime import datetime
|
||||||
from tzlocal import get_localzone
|
from tzlocal import get_localzone
|
||||||
from pytz.exceptions import UnknownTimeZoneError
|
from pytz.exceptions import UnknownTimeZoneError
|
||||||
try:
|
try:
|
||||||
tz = get_localzone()
|
local_dt = datetime.fromisoformat(str(requestDatetime)).astimezone(get_localzone())
|
||||||
local_dt = tz.localize(requestDatetime)
|
|
||||||
except UnknownTimeZoneError:
|
except UnknownTimeZoneError:
|
||||||
pretty_printer(log_obj = loggersrv.warning,
|
pretty_printer(log_obj = loggersrv.warning,
|
||||||
put_text = "{reverse}{yellow}{bold}Unknown time zone ! Request time not localized.{end}")
|
put_text = "{reverse}{yellow}{bold}Unknown time zone ! Request time not localized.{end}")
|
||||||
|
@ -132,6 +132,11 @@ class kmsBase:
|
||||||
pretty_printer(log_obj = loggersrv.warning,
|
pretty_printer(log_obj = loggersrv.warning,
|
||||||
put_text = "{reverse}{yellow}{bold}Module 'tzlocal' not available ! Request time not localized.{end}")
|
put_text = "{reverse}{yellow}{bold}Module 'tzlocal' not available ! Request time not localized.{end}")
|
||||||
local_dt = requestDatetime
|
local_dt = requestDatetime
|
||||||
|
except Exception as e:
|
||||||
|
# Just in case something else goes wrong
|
||||||
|
loggersrv.warning('Okay, something went horribly wrong while localizing the request time (proceeding anyways): ' + str(e))
|
||||||
|
local_dt = requestDatetime
|
||||||
|
pass
|
||||||
|
|
||||||
# Activation threshold.
|
# Activation threshold.
|
||||||
# https://docs.microsoft.com/en-us/windows/deployment/volume-activation/activate-windows-10-clients-vamt
|
# https://docs.microsoft.com/en-us/windows/deployment/volume-activation/activate-windows-10-clients-vamt
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue