From e1c444024f859385ff352c07e7d36e65df6e7656 Mon Sep 17 00:00:00 2001 From: Ville Ranki Date: Mon, 23 Dec 2019 18:34:58 +0200 Subject: [PATCH] Fixed dockerfile, always setup googlecal files. --- Dockerfile | 12 +++++++----- README.md | 5 +++-- modules/googlecal.py | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4cfe6ee..1127252 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,14 +3,16 @@ FROM python:3 WORKDIR /bot RUN pip install pipenv COPY Pipfile . -RUN pipenv install --pre --system +RUN pipenv install --pre COPY bot.py . COPY modules modules -# Uncomment for google calendar: +# Make sure these exist +RUN touch credentials.json +RUN touch token.pickle -#COPY credentials.json . -#COPY token.pickle . +COPY credentials.json . +COPY token.pickle . -CMD [ "python", "-u", "./bot.py" ] +CMD [ "pipenv", "run", "python", "-u", "./bot.py" ] diff --git a/README.md b/README.md index 1a748e1..56a951d 100644 --- a/README.md +++ b/README.md @@ -63,14 +63,15 @@ To set up, you'll need to generate oauth2 credentials.json file - see https://co Run the bot on *local* machine as OAuth2 wants to open localhost url in your browser. I haven't found out an easy way to do this on server. -When credentials.json is present, you must authenticate the bot to access calendar. There will be a link in console like this: +There is a empty credentials.json file in the bot directory. Replace it with yours. When credentials.json is present, you must +authenticate the bot to access calendar. There will be a link in console like this: ``` text Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=907.... ``` Open the link and authenticate as needed. A new file token.pickle will be created in the directory and bot will read it in future. -Save the token.pickle and ship it with the bot to your server. Edit Dockerfile to copy it in container if needed. +Save the token.pickle and ship it with the bot to your server. Now the bot should be usable. diff --git a/modules/googlecal.py b/modules/googlecal.py index be8215a..475f304 100644 --- a/modules/googlecal.py +++ b/modules/googlecal.py @@ -30,7 +30,7 @@ class MatrixModule: creds = None - if not os.path.exists(self.credentials_file): + if not os.path.exists(self.credentials_file) or os.path.getsize(self.credentials_file) == 0: return # No-op if not set up if os.path.exists('token.pickle'):