Source

trustlink / trustlink / django / management / commands / trustlink_update.py

Full commit
import time
import os.path

from django.core.management.base import BaseCommand, CommandError
from django.conf import settings

from trustlink.client import TrustlinkDownloader
from trustlink.util import set_lock

class Command(BaseCommand):
    help = 'Update trustlink local database'

    def handle(self, *args, **options):
        lock_file = os.path.join(settings.TRUSTLINK_DATA_DIR, 'trustlink_update.lock')
        if not set_lock(lock_file):
            raise Exception('Could not set lock on lock file: %s' % lock_file)

        tl = TrustlinkDownloader(
            trustlink_user=settings.TRUSTLINK_USER,
            host=settings.TRUSTLINK_HOST,
            data_dir=settings.TRUSTLINK_DATA_DIR
        )
        tl.download()