Skip to content

Commit

Permalink
Deprecate COBOT_ROOT
Browse files Browse the repository at this point in the history
Issue a warning to use BOT_ROOT, if
COBOT_ROOT is in use.

Closes #371
  • Loading branch information
EverWinter23 committed May 26, 2018
1 parent e4564d3 commit d1223b7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
FROM python:3-alpine

ENV COBOT_ROOT=/opt/errbot
ENV BOT_ROOT=/opt/errbot

ADD requirements.txt $COBOT_ROOT/requirements.txt
ADD requirements.txt $BOT_ROOT/requirements.txt

RUN apk add --no-cache libffi openssl git \
&& apk add --no-cache --virtual .build-deps \
gcc \
libc-dev \
libffi-dev \
openssl-dev \
&& pip install -r $COBOT_ROOT/requirements.txt \
&& pip install -r $BOT_ROOT/requirements.txt \
&& pip install slackclient python-telegram-bot \
&& apk del .build-deps

ADD . $COBOT_ROOT
ADD . $BOT_ROOT

RUN addgroup -S errbot \
&& adduser -h $COBOT_ROOT -G errbot -S errbot \
&& mkdir -p $COBOT_ROOT/data $COBOT_ROOT/plugins \
&& chown -R errbot:errbot $COBOT_ROOT
&& adduser -h $BOT_ROOT -G errbot -S errbot \
&& mkdir -p $BOT_ROOT/data $BOT_ROOT/plugins \
&& chown -R errbot:errbot $BOT_ROOT

USER errbot
WORKDIR /opt/errbot
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Read more about what `corobo` could do for you

## Environment Variables

1. `COBOT_ROOT` - absolute path of the project root.
1. `BOT_ROOT` - absolute path of the project root.
2. `BOT_PREFIX` - prefix to use for issuing bot commands.
3. `BOT_ADMINS` - Admins of the errbot instance.
4. `ROOMS` - Space separated list of rooms to join on startup. e.g.
Expand Down
18 changes: 13 additions & 5 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import logging
import os

COBOT_ROOT = os.environ.get('COBOT_ROOT', os.getcwd())
BOT_ROOT_KEY = 'BOT_ROOT'

if 'COBOT_ROOT' in os.environ and BOT_ROOT_KEY not in os.environ:
logging.warning(
"Environment variable COBOT_ROOT is deprecated, use {} instead."
.format(BOT_ROOT_KEY))
BOT_ROOT_KEY = 'COBOT_ROOT'
BOT_ROOT = os.environ.get(BOT_ROOT_KEY, os.getcwd())


_BOT_IDENTITY_KEYS = (
'endpoint',
Expand Down Expand Up @@ -34,7 +42,7 @@
BACKEND = 'Text'

if BACKEND == 'Gitter':
BOT_EXTRA_BACKEND_DIR = os.path.join(COBOT_ROOT, 'err-backend-gitter')
BOT_EXTRA_BACKEND_DIR = os.path.join(BOT_ROOT, 'err-backend-gitter')
else:
BOT_EXTRA_BACKEND_DIR = None

Expand All @@ -46,10 +54,10 @@

HIDE_RESTRICTED_COMMANDS = True

BOT_DATA_DIR = os.path.join(COBOT_ROOT, 'data')
BOT_EXTRA_PLUGIN_DIR = COBOT_ROOT
BOT_DATA_DIR = os.path.join(BOT_ROOT, 'data')
BOT_EXTRA_PLUGIN_DIR = BOT_ROOT

BOT_LOG_FILE = os.path.join(COBOT_ROOT, 'errbot.log')
BOT_LOG_FILE = os.path.join(BOT_ROOT, 'errbot.log')
BOT_LOG_LEVEL = logging.DEBUG

BOT_PREFIX = os.environ.get('BOT_PREFIX', 'corobo ')
Expand Down
6 changes: 3 additions & 3 deletions utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Utils(BotPlugin):
@botcmd(admin_only=True)
def sync(self, msg, arg):
"""Sync the repository from github.""" # Ignore QuotesBear
repo = git.Repo(self.bot_config.COBOT_ROOT)
repo = git.Repo(self.bot_config.BOT_ROOT)
try:
repo.remote('origin').pull('--rebase')
yield 'Sync\'d successfully! :tada:'
Expand All @@ -27,14 +27,14 @@ def sync(self, msg, arg):
@botcmd
def get_head(self, msg, arg):
"""Yields the head commit.""" # Ignore QuotesBear
repo = git.Repo(self.bot_config.COBOT_ROOT)
repo = git.Repo(self.bot_config.BOT_ROOT)
head = repo.commit('HEAD')
yield '`{}`: {}'.format(head.hexsha, head.message)

@botcmd(admin_only=True)
def install_requirements(self, msg, arg):
"""Installs requirements""" # Ignore QuotesBear
os.chdir(self.bot_config.COBOT_ROOT)
os.chdir(self.bot_config.BOT_ROOT)
ran = run('pip install -r requirements.txt')
yield 'installing requirements...'
yield ran.stdout.read().decode('utf-8')
Expand Down

0 comments on commit d1223b7

Please sign in to comment.