-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Refactoring task files #3943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Refactoring task files #3943
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9681ebf
Refactoring a single function to test
shubham76 53e3118
first four functions moved and removed unnecessory imports
shubham76 d44bded
moved the last four functions
shubham76 b4febee
fixed linting errors
shubham76 53a1bac
Updated builds/tasks.py
shubham76 4daf677
removed duplicated function
shubham76 0e44d7e
fixed in other places according refactoring
shubham76 caec686
Fixed liinting errors
shubham76 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,84 @@ | ||
|
||
from __future__ import absolute_import | ||
|
||
import datetime | ||
import hashlib | ||
import json | ||
import logging | ||
import os | ||
import shutil | ||
import socket | ||
from collections import defaultdict | ||
|
||
import requests | ||
from builtins import str | ||
from celery import Task | ||
from celery.exceptions import SoftTimeLimitExceeded | ||
from django.conf import settings | ||
from django.core.urlresolvers import reverse | ||
from django.db.models import Q | ||
from django.utils.translation import ugettext_lazy as _ | ||
from readthedocs_build.config import ConfigError | ||
from slumber.exceptions import HttpClientError | ||
|
||
from readthedocs.builds.constants import (LATEST, | ||
BUILD_STATE_CLONING, | ||
BUILD_STATE_INSTALLING, | ||
BUILD_STATE_BUILDING, | ||
BUILD_STATE_FINISHED) | ||
from readthedocs.builds.models import Build, Version, APIVersion | ||
from readthedocs.builds.signals import build_complete | ||
from readthedocs.builds.syncers import Syncer | ||
from readthedocs.cdn.purge import purge | ||
from readthedocs.core.resolver import resolve_path | ||
from readthedocs.core.symlink import PublicSymlink, PrivateSymlink | ||
from readthedocs.core.utils import send_email, broadcast | ||
from readthedocs.doc_builder.config import load_yaml_config | ||
from readthedocs.doc_builder.constants import DOCKER_LIMITS | ||
from readthedocs.doc_builder.environments import (LocalBuildEnvironment, | ||
DockerBuildEnvironment) | ||
from readthedocs.doc_builder.exceptions import BuildEnvironmentError | ||
from readthedocs.doc_builder.loader import get_builder_class | ||
from readthedocs.doc_builder.python_environments import Virtualenv, Conda | ||
from readthedocs.projects.models import APIProject | ||
from readthedocs.restapi.client import api as api_v2 | ||
from readthedocs.restapi.utils import index_search_request | ||
from readthedocs.search.parse_json import process_all_json_files | ||
from readthedocs.vcs_support import utils as vcs_support_utils | ||
from readthedocs.worker import app | ||
|
||
|
||
log = logging.getLogger(__name__) | ||
|
||
HTML_ONLY = getattr(settings, 'HTML_ONLY_PROJECTS', ()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't look used either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Right. 👍 |
||
|
||
|
||
@app.task(queue='web') | ||
def fileify(version_pk, commit): | ||
""" | ||
Create ImportedFile objects for all of a version's files. | ||
|
||
This is so we have an idea of what files we have in the database. | ||
""" | ||
version = Version.objects.get(pk=version_pk) | ||
project = version.project | ||
|
||
if not commit: | ||
log.info(LOG_TEMPLATE | ||
.format(project=project.slug, version=version.slug, | ||
msg=('Imported File not being built because no commit ' | ||
'information'))) | ||
return | ||
|
||
path = project.rtd_build_path(version.slug) | ||
if path: | ||
log.info(LOG_TEMPLATE | ||
.format(project=version.project.slug, version=version.slug, | ||
msg='Creating ImportedFiles')) | ||
_manage_imported_files(version, path, commit) | ||
else: | ||
log.info(LOG_TEMPLATE | ||
.format(project=project.slug, version=version.slug, | ||
msg='No ImportedFile files')) | ||
|
||
|
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like almost all of these imports are not used, these should be clean up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I will do that. 👍