xyb/baidupcsleecher

View on GitHub
task/management/commands/runsamplingdownloader.py

Summary

Maintainability
C
1 day
Test Coverage
A
95%
Similar blocks of code found in 3 locations. Consider refactoring.
import logging
Similar blocks of code found in 3 locations. Consider refactoring.
from time import sleep
Similar blocks of code found in 3 locations. Consider refactoring.
 
Similar blocks of code found in 3 locations. Consider refactoring.
from django.conf import settings
Similar blocks of code found in 3 locations. Consider refactoring.
from django.core.management.base import BaseCommand
Similar blocks of code found in 3 locations. Consider refactoring.
 
Similar blocks of code found in 3 locations. Consider refactoring.
from task.baidupcs import get_baidupcs_client
Similar blocks of code found in 3 locations. Consider refactoring.
from task.leecher import sampling
Similar blocks of code found in 3 locations. Consider refactoring.
from task.models import Task
Similar blocks of code found in 3 locations. Consider refactoring.
 
Similar blocks of code found in 3 locations. Consider refactoring.
logger = logging.getLogger("runsamplingdownloader")
Similar blocks of code found in 3 locations. Consider refactoring.
 
Similar blocks of code found in 3 locations. Consider refactoring.
 
Similar blocks of code found in 3 locations. Consider refactoring.
class Command(BaseCommand):
Similar blocks of code found in 3 locations. Consider refactoring.
help = "download sampling files."
Similar blocks of code found in 3 locations. Consider refactoring.
 
Similar blocks of code found in 3 locations. Consider refactoring.
def add_arguments(self, parser):
Similar blocks of code found in 3 locations. Consider refactoring.
parser.add_argument(
Similar blocks of code found in 3 locations. Consider refactoring.
"--once",
Similar blocks of code found in 3 locations. Consider refactoring.
action="store_true",
Similar blocks of code found in 3 locations. Consider refactoring.
help="download for exists tasks and exit immediately.",
Similar blocks of code found in 3 locations. Consider refactoring.
)
Similar blocks of code found in 3 locations. Consider refactoring.
 
Similar blocks of code found in 3 locations. Consider refactoring.
def handle(self, *args, **options):
Similar blocks of code found in 3 locations. Consider refactoring.
logger.info("sampling downlader started.")
Similar blocks of code found in 3 locations. Consider refactoring.
client = get_baidupcs_client()
Similar blocks of code found in 3 locations. Consider refactoring.
while True:
Similar blocks of code found in 3 locations. Consider refactoring.
for task in Task.filter_transferd():
Similar blocks of code found in 3 locations. Consider refactoring.
sampling(client, task)
Similar blocks of code found in 3 locations. Consider refactoring.
 
Similar blocks of code found in 3 locations. Consider refactoring.
if options["once"]:
Similar blocks of code found in 3 locations. Consider refactoring.
return
Similar blocks of code found in 3 locations. Consider refactoring.
sleep(settings.RUNNER_SLEEP_SECONDS)