-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into google-drive-support
- Loading branch information
Showing
64 changed files
with
1,432 additions
and
624 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: python | ||
python: | ||
- "3.3" | ||
services: | ||
- mongodb | ||
- redis-server | ||
- rabbitmq | ||
install: | ||
- "pip install -r requirements.txt" | ||
- "cp tapiriik/local_settings.py.example tapiriik/local_settings.py" | ||
script: "python runtests.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from tapiriik.database import db, close_connections | ||
from tapiriik.settings import RABBITMQ_BROKER_URL, MONGO_HOST, MONGO_FULL_WRITE_CONCERN | ||
from tapiriik import settings | ||
from datetime import datetime | ||
|
||
from celery import Celery | ||
from celery.signals import worker_shutdown | ||
from datetime import datetime | ||
|
||
class _celeryConfig: | ||
CELERY_ROUTES = { | ||
"rollback_worker.rollback_task": {"queue": "tapiriik-rollback"} | ||
} | ||
CELERYD_CONCURRENCY = 1 | ||
CELERYD_PREFETCH_MULTIPLIER = 1 | ||
|
||
celery_app = Celery('rollback_worker', broker=RABBITMQ_BROKER_URL) | ||
celery_app.config_from_object(_celeryConfig()) | ||
|
||
@worker_shutdown.connect | ||
def celery_shutdown(): | ||
close_connections() | ||
|
||
@celery_app.task() | ||
def rollback_task(task_id): | ||
from tapiriik.services.rollback import RollbackTask | ||
print("Starting rollback task %s" % task_id) | ||
task = RollbackTask.Get(task_id) | ||
task.Execute() | ||
|
||
def schedule_rollback_task(task_id): | ||
rollback_task.apply_async(args=[task_id]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from tapiriik.database import db, close_connections | ||
from tapiriik.settings import RABBITMQ_BROKER_URL, MONGO_FULL_WRITE_CONCERN | ||
from datetime import datetime | ||
from celery import Celery | ||
from celery.signals import worker_shutdown | ||
|
||
class _celeryConfig: | ||
CELERY_ROUTES = { | ||
"sync_remote_triggers.trigger_remote": {"queue": "tapiriik-remote-trigger"} | ||
} | ||
CELERYD_CONCURRENCY = 1 # Otherwise the GC rate limiting breaks since file locking is per-process. | ||
CELERYD_PREFETCH_MULTIPLIER = 1 # The message queue could use some exercise. | ||
|
||
celery_app = Celery('sync_remote_triggers', broker=RABBITMQ_BROKER_URL) | ||
celery_app.config_from_object(_celeryConfig()) | ||
|
||
@worker_shutdown.connect | ||
def celery_shutdown(): | ||
close_connections() | ||
|
||
@celery_app.task() | ||
def trigger_remote(service_id, affected_connection_external_ids): | ||
from tapiriik.auth import User | ||
from tapiriik.services import Service | ||
svc = Service.FromID(service_id) | ||
db.connections.update({"Service": svc.ID, "ExternalID": {"$in": affected_connection_external_ids}}, {"$set":{"TriggerPartialSync": True, "TriggerPartialSyncTimestamp": datetime.utcnow()}}, multi=True, w=MONGO_FULL_WRITE_CONCERN) | ||
affected_connection_ids = db.connections.find({"Service": svc.ID, "ExternalID": {"$in": affected_connection_external_ids}}, {"_id": 1}) | ||
affected_connection_ids = [x["_id"] for x in affected_connection_ids] | ||
trigger_users_query = User.PaidUserMongoQuery() | ||
trigger_users_query.update({"ConnectedServices.ID": {"$in": affected_connection_ids}}) | ||
trigger_users_query.update({"Config.suppress_auto_sync": {"$ne": True}}) | ||
db.users.update(trigger_users_query, {"$set": {"NextSynchronization": datetime.utcnow()}}, multi=True) # It would be nicer to use the Sync.Schedule... method, but I want to cleanly do this in bulk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.