Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Move tasks.py back to the source folder

Roland Geiderd0813d24295f
diff --git a/.travis.yml b/.travis.yml
index 083e0e4b8..5316f5f12 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,8 +24,8 @@ install:
- sh -c "if [ '$DB' = 'postgresql' ]; then pip install psycopg2; fi"
- pip install -r requirements_devel.txt
- - sh -c "if [ '$DB' = 'sqlite' ]; then invoke --root wger create_settings; fi"
- - sh -c "if [ '$DB' = 'postgresql' ]; then invoke --root wger create_settings --database-type postgresql; fi"
+ - sh -c "if [ '$DB' = 'sqlite' ]; then invoke create_settings; fi"
+ - sh -c "if [ '$DB' = 'postgresql' ]; then invoke create_settings --database-type postgresql; fi"
# Create test databases
before_script:
diff --git a/MANIFEST.in b/MANIFEST.in
index a85b00b96..d21d80738 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -3,6 +3,7 @@ include AUTHORS.txt
include AGPL.txt
include CC-BY-SA.txt
include requirements.txt
+include tasks.py
recursive-include wger *.*
recursive-exclude wger *.pyc
diff --git a/README.rst b/README.rst
index c03d32327..19137b09e 100644
--- a/README.rst
+++ b/README.rst
@@ -55,10 +55,10 @@ and stable state.
$ git clone https://github.com/rolandgeider/wger.git
$ cd wger
$ pip install -r requirements.txt # or requirements_devel.txt to develop
- $ invoke --root wger create_settings \
+ $ invoke create_settings \
--settings-path /home/wger/wger/settings.py \
--database-path /home/wger/wger/database.sqlite
- $ invoke --root wger bootstrap_wger
+ $ invoke bootstrap_wger
--settings-path /home/wger/wger/settings.py \
--no-start-server
$ python manage.py runserver
diff --git a/docs/development.rst b/docs/development.rst
index bc16e8375..bf45203c4 100644
--- a/docs/development.rst
+++ b/docs/development.rst
@@ -14,10 +14,10 @@ and populate it with data on the first run::
$ git clone https://github.com/rolandgeider/wger.git
$ cd wger
$ pip install -r requirements_devel.txt
- $ invoke --root wger create_settings \
+ $ invoke create_settings \
--settings-path /home/wger/wger/settings.py \
--database-path /home/wger/wger/database.sqlite
- $ invoke --root wger bootstrap_wger
+ $ invoke bootstrap_wger
--settings-path /home/wger/wger/settings.py \
--no-start-server
$ python manage.py runserver
diff --git a/extras/docker/apache/Dockerfile b/extras/docker/apache/Dockerfile
index f6de492da..c5c004569 100644
--- a/extras/docker/apache/Dockerfile
+++ b/extras/docker/apache/Dockerfile
@@ -30,10 +30,10 @@ RUN npm install bower \
&& . /home/wger/venv/bin/activate \
&& pip install --upgrade pip \
&& pip install -r requirements.txt \
- && invoke --root wger create_settings \
+ && invoke create_settings \
--settings-path /home/wger/src/settings.py \
--database-path /home/wger/db/database.sqlite \
- && invoke --root wger bootstrap_wger \
+ && invoke bootstrap_wger \
--settings-path /home/wger/src/settings.py \
--no-start-server
diff --git a/extras/docker/development/Dockerfile b/extras/docker/development/Dockerfile
index 40af459b6..b2c4529ad 100644
--- a/extras/docker/development/Dockerfile
+++ b/extras/docker/development/Dockerfile
@@ -27,10 +27,10 @@ RUN virtualenv --python python3 /home/wger/venv
RUN . /home/wger/venv/bin/activate \
&& pip install --upgrade pip \
&& pip install -r requirements_devel.txt \
- && invoke --root wger create_settings \
+ && invoke create_settings \
--settings-path /home/wger/src/settings.py \
--database-path /home/wger/db/database.sqlite \
- && invoke --root wger bootstrap_wger \
+ && invoke bootstrap_wger \
--settings-path /home/wger/src/settings.py \
--no-start-server
diff --git a/manage.py b/manage.py
index c31ee8353..2f6e4057b 100755
--- a/manage.py
+++ b/manage.py
@@ -3,18 +3,13 @@ import sys
from django.core.management import execute_from_command_line
-from wger.tasks import (
+from tasks import (
setup_django_environment,
get_user_config_path
)
if __name__ == "__main__":
- # Add the current directory to the system path. This is needed because
- # tasks.py removes it, read the comment the on why this clutch is needed.
- # Otherwise "local" setting files could not be imported
- sys.path.append('.')
-
# If user passed the settings flag ignore the default wger settings
if not any('--settings' in s for s in sys.argv):
setup_django_environment(get_user_config_path('wger', 'settings.py'))
diff --git a/wger/tasks.py b/tasks.py
similarity index 93%
rename from wger/tasks.py
rename to tasks.py
index f83a3c0c3..c35aebcd1 100644
--- a/wger/tasks.py
+++ b/tasks.py
@@ -16,16 +16,6 @@
import sys
-#
-# This is an ugly and terrible hack, please don't do this!
-#
-# The reason we do this is that during django's setup later in this script, it
-# tries to load the standard library's "mail" module which collides with our
-# (perhaps unluckily named) app with the same name. Since this script is only
-# used for installation and does not depend on anything from wger proper, it
-# is kind of OK to change the system path.
-sys.path = sys.path[1:]
-
import time
import logging
import threading
@@ -108,7 +98,7 @@ def bootstrap_wger(settings_path=None,
create_or_reset_admin(settings_path=settings_path)
# Download JS libraries with bower
- os.chdir(os.path.dirname(os.path.abspath(__file__)))
+ os.chdir(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'wger'))
run('npm install bower')
call_command('bower', 'install')
@@ -143,7 +133,7 @@ def create_settings(settings_path=None, database_path=None, url=None, database_t
url = 'http://localhost:8000'
# Fill in the config file template
- settings_template = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'settings.tpl')
+ settings_template = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'wger', 'settings.tpl')
with open(settings_template, 'r') as settings_file:
settings_content = settings_file.read()
@@ -210,7 +200,7 @@ def create_or_reset_admin(settings_path=None):
# current_dir = os.path.join(os.getcwd(), 'wger')
current_dir = os.path.dirname(os.path.abspath(__file__))
- path = os.path.join(current_dir, 'core', 'fixtures/')
+ path = os.path.join(current_dir, 'wger', 'core', 'fixtures/')
call_command("loaddata", path + "users.json")
@@ -241,11 +231,11 @@ def load_fixtures(settings_path=None):
current_dir = os.path.dirname(os.path.abspath(__file__))
# Gym
- path = os.path.join(current_dir, 'gym', 'fixtures/')
+ path = os.path.join(current_dir, 'wger', 'gym', 'fixtures/')
call_command("loaddata", path + "gym.json")
# Core
- path = os.path.join(current_dir, 'core', 'fixtures/')
+ path = os.path.join(current_dir, 'wger', 'core', 'fixtures/')
call_command("loaddata", path + "languages.json")
call_command("loaddata", path + "groups.json")
call_command("loaddata", path + "users.json")
@@ -253,7 +243,7 @@ def load_fixtures(settings_path=None):
call_command("loaddata", path + "days_of_week.json")
# Config
- path = os.path.join(current_dir, 'config', 'fixtures/')
+ path = os.path.join(current_dir, 'wger', 'config', 'fixtures/')
call_command("loaddata", path + "language_config.json")
call_command("loaddata", path + "gym_config.json")
@@ -261,20 +251,20 @@ def load_fixtures(settings_path=None):
# path = os.path.join(current_dir, 'manager', 'fixtures/')
# Exercises
- path = os.path.join(current_dir, 'exercises', 'fixtures/')
+ path = os.path.join(current_dir, 'wger', 'exercises', 'fixtures/')
call_command("loaddata", path + "equipment.json")
call_command("loaddata", path + "muscles.json")
call_command("loaddata", path + "categories.json")
call_command("loaddata", path + "exercises.json")
# Nutrition
- path = os.path.join(current_dir, 'nutrition', 'fixtures/')
+ path = os.path.join(current_dir, 'wger', 'nutrition', 'fixtures/')
call_command("loaddata", path + "ingredients.json")
call_command("loaddata", path + "weight_units.json")
call_command("loaddata", path + "ingredient_units.json")
# Gym
- path = os.path.join(current_dir, 'gym', 'fixtures/')
+ path = os.path.join(current_dir, 'wger', 'gym', 'fixtures/')
call_command("loaddata", path + "gym.json")
call_command("loaddata", path + "gym-config.json")
call_command("loaddata", path + "gym-adminconfig.json")
diff --git a/wger/__main__.py b/wger/__main__.py
index f53b2d7e5..63620b38e 100644
--- a/wger/__main__.py
+++ b/wger/__main__.py
@@ -24,10 +24,7 @@ version of the application. It simply redirects all arguments to the invoke
command, which does all the work.
'''
-# Get the absolute path so we can pass it to invoke. This is only needed
-# for the packaged version.
-tasks_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'wger')
-invoke_cmd = 'invoke --root {} '.format(tasks_path)
+invoke_cmd = 'invoke '
def main():