コード例 #1
0
ファイル: parts.py プロジェクト: point-source/WhatManager2
def auto_pop(request):
    front = QueueItem.get_front()
    if not front:
        LogEntry.add(request.user, u'info', 'Auto pop: queue is empty.')
        return {
            'success': False,
            'error': 'Queue is empty.'
        }
    try:
        ratio_delta = get_auto_pop_ratio_delta(WhatUserSnapshot.get_last())
    except WhatUserSnapshot.DoesNotExist:
        LogEntry.add(request.user, u'info', 'Auto pop: User profile not updated, skipping pop.')
        return {
            'success': False,
            'error': u'User profile not updated, skipping pop.'
        }
    if ratio_delta >= front.torrent_size:
        return do_pop(request)
    else:
        message = u'Auto pop: ratio delta {0} < {1}, skipping pop.'.format(
            filesizeformat(ratio_delta),
            filesizeformat(front.torrent_size)
        )
        LogEntry.add(request.user, u'info', message)
        return {
            'success': False,
            'error': u'Buffer is {0}, skipping pop.'.format(message)
        }
コード例 #2
0
ファイル: parts.py プロジェクト: point-source/WhatManager2
def torrent_stats(request):
    what_buffer = 0
    try:
        what_buffer = WhatUserSnapshot.get_last().buffer_105
    except WhatUserSnapshot.DoesNotExist:
        pass
    data = {
        'master': ReplicaSet.get_what_master(),
        'buffer': what_buffer,
    }
    return render(request, 'home/part_ui/torrent_stats.html', data)
コード例 #3
0
def sync_profile(request):
    user_id = settings.WHAT_USER_ID
    interval = settings.WHAT_PROFILE_SNAPSHOT_INTERVAL
    try:
        last_snap = WhatUserSnapshot.get_last()
        if (timezone.now() - last_snap.datetime).total_seconds() < interval - 30:
            return
    except WhatUserSnapshot.DoesNotExist:
        pass
    what = get_what_client(request)
    WhatUserSnapshot.get(what, user_id).save()
コード例 #4
0
ファイル: parts.py プロジェクト: point-source/WhatManager2
def queue_stats(request):
    ratio_delta = '-'
    try:
        ratio_delta = get_auto_pop_ratio_delta(WhatUserSnapshot.get_last())
    except (WhatUserSnapshot.DoesNotExist, IndexError):
        pass
    data = {
        'item_count': QueueItem.objects.count(),
        'total_size': QueueItem.objects.aggregate(Sum('torrent_size'))['torrent_size__sum'],
        'auto_pop_ratio_delta': ratio_delta,
    }
    return render(request, 'queue/part_ui/queue_stats.html', data)
コード例 #5
0
def sync_profile(request):
    user_id = settings.WHAT_USER_ID
    interval = settings.WHAT_PROFILE_SNAPSHOT_INTERVAL
    try:
        last_snap = WhatUserSnapshot.get_last()
        if (timezone.now() -
                last_snap.datetime).total_seconds() < interval - 30:
            return
    except WhatUserSnapshot.DoesNotExist:
        pass
    what = get_what_client(request)
    WhatUserSnapshot.get(what, user_id).save()
コード例 #6
0
ファイル: views.py プロジェクト: valentine/WhatManager2
def profile(request):
    try:
        data = {
            "delta_hour": WhatUserSnapshot.buffer_delta(datetime.timedelta(hours=1)),
            "delta_day": WhatUserSnapshot.buffer_delta(datetime.timedelta(days=1)),
            "delta_week": WhatUserSnapshot.buffer_delta(datetime.timedelta(days=7)),
            "delta_month": WhatUserSnapshot.buffer_delta(datetime.timedelta(days=30)),
            "buffer": WhatUserSnapshot.get_last().buffer_105,
        }
    except WhatUserSnapshot.DoesNotExist:
        data = {"delta_hour": "-", "delta_day": "-", "delta_week": "-", "delta_month": "-", "buffer": "-"}

    return render(request, "what_profile/profile.html", data)
コード例 #7
0
ファイル: views.py プロジェクト: jimrollenhagen/WhatManager2
def profile(request):
    try:
        WhatUserSnapshot.objects.first()
        data = {
            'delta_hour': WhatUserSnapshot.buffer_delta(datetime.timedelta(hours=1)),
            'delta_day': WhatUserSnapshot.buffer_delta(datetime.timedelta(days=1)),
            'delta_week': WhatUserSnapshot.buffer_delta(datetime.timedelta(days=7)),
            'delta_month': WhatUserSnapshot.buffer_delta(datetime.timedelta(days=30)),
            'buffer': WhatUserSnapshot.get_last().buffer_105,
        }
    except (WhatUserSnapshot.DoesNotExist, IndexError):
        data = {
            'delta_hour': '-',
            'delta_day': '-',
            'delta_week': '-',
            'delta_month': '-',
            'buffer': '-',
        }
    return render(request, 'what_profile/profile.html', data)
コード例 #8
0
ファイル: views.py プロジェクト: point-source/WhatManager2
def profile(request):
    try:
        data = {
            'delta_hour':
            WhatUserSnapshot.buffer_delta(datetime.timedelta(hours=1)),
            'delta_day':
            WhatUserSnapshot.buffer_delta(datetime.timedelta(days=1)),
            'delta_week':
            WhatUserSnapshot.buffer_delta(datetime.timedelta(days=7)),
            'delta_month':
            WhatUserSnapshot.buffer_delta(datetime.timedelta(days=30)),
            'buffer':
            WhatUserSnapshot.get_last().buffer_105,
        }
    except WhatUserSnapshot.DoesNotExist:
        data = {
            'delta_hour': '-',
            'delta_day': '-',
            'delta_week': '-',
            'delta_month': '-',
            'buffer': '-',
        }

    return render(request, 'what_profile/profile.html', data)