Skip to content
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

pylint fix for readthedocs.projects #5662

Merged
merged 1 commit into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion readthedocs/projects/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
('other', 'Other'),
)

LOG_TEMPLATE = '(Build) [{project}:{version}] {msg}'
LOG_TEMPLATE = '(Build) [%(project)s:%(version)s] %(msg)s'

PROJECT_PK_REGEX = r'(?:[-\w]+)'
PROJECT_SLUG_REGEX = r'(?:[-\w]+)'
Expand Down
18 changes: 11 additions & 7 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,18 +924,22 @@ def update_stable_version(self):
)
if identifier_updated and current_stable.machine:
log.info(
'Update stable version: {project}:{version}'.format(
project=self.slug,
version=new_stable.identifier,
),
'Update stable version: %(project)s:%(version)s',
{
'project': self.slug,
'version': new_stable.identifier,
}
)
current_stable.identifier = new_stable.identifier
current_stable.save()
return new_stable
else:
log.info(
'Creating new stable version: {project}:{version}'
.format(project=self.slug, version=new_stable.identifier),
'Creating new stable version: %(project)s:%(version)s',
{
'project': self.slug,
'version': new_stable.identifier,
}
)
current_stable = self.versions.create_stable(
type=new_stable.type,
Expand Down Expand Up @@ -1161,7 +1165,7 @@ class HTMLFile(ImportedFile):
This tracks only the HTML files for indexing to search.
"""

class Meta(object):
class Meta:
proxy = True

objects = HTMLFileManager()
Expand Down
121 changes: 66 additions & 55 deletions readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,12 @@ def sync_repo(self):
identifier=self.version.identifier,
)
log.info(
LOG_TEMPLATE.format(
project=self.project.slug,
version=self.version.slug,
msg=msg,
),
LOG_TEMPLATE,
{
'project': self.project.slug,
'version': self.version.slug,
'msg': msg,
}
)
version_repo = self.get_vcs_repo()
version_repo.update()
Expand Down Expand Up @@ -484,11 +485,12 @@ def run_setup(self, record=True):
self.setup_env.failure,
)
log.info(
LOG_TEMPLATE.format(
project=self.project.slug,
version=self.version.slug,
msg=msg,
),
LOG_TEMPLATE,
{
'project': self.project.slug,
'version': self.version.slug,
'msg': msg,
}
)

# Send notification to users only if the build didn't fail because
Expand Down Expand Up @@ -545,11 +547,12 @@ def run_build(self, docker, record):
python_env_cls = Virtualenv
if self.config.conda is not None:
log.info(
LOG_TEMPLATE.format(
project=self.project.slug,
version=self.version.slug,
msg='Using conda',
),
LOG_TEMPLATE,
{
'project': self.project.slug,
'version': self.version.slug,
'msg': 'Using conda',
}
)
python_env_cls = Conda
self.python_env = python_env_cls(
Expand Down Expand Up @@ -624,11 +627,12 @@ def setup_vcs(self):
self.setup_env.update_build(state=BUILD_STATE_CLONING)

log.info(
LOG_TEMPLATE.format(
project=self.project.slug,
version=self.version.slug,
msg='Updating docs from VCS',
),
LOG_TEMPLATE,
{
'project': self.project.slug,
'version': self.version.slug,
'msg': 'Updating docs from VCS',
}
)
try:
self.sync_repo()
Expand Down Expand Up @@ -1028,11 +1032,12 @@ def move_files(
storage.delete(storage_path)

log.debug(
LOG_TEMPLATE.format(
project=version.project.slug,
version=version.slug,
msg='Moving files',
),
LOG_TEMPLATE,
{
'project': version.project.slug,
'version': version.slug,
'msg': 'Moving files',
}
)

if html:
Expand Down Expand Up @@ -1178,24 +1183,26 @@ def fileify(version_pk, commit):

if not commit:
log.warning(
LOG_TEMPLATE.format(
project=project.slug,
version=version.slug,
msg=(
LOG_TEMPLATE,
{
'project': project.slug,
'version': version.slug,
'msg': (
'Search index 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',
),
LOG_TEMPLATE,
{
'project': version.project.slug,
'version': version.slug,
'msg': 'Creating ImportedFiles',
}
)
try:
_manage_imported_files(version, path, commit)
Expand Down Expand Up @@ -1414,11 +1421,12 @@ def email_notification(version, build, email):
:param email: Email recipient address
"""
log.debug(
LOG_TEMPLATE.format(
project=version.project.slug,
version=version.slug,
msg='sending email to: %s' % email,
),
LOG_TEMPLATE,
{
'project': version.project.slug,
'version': version.slug,
'msg': 'sending email to: %s' % email,
}
)

# We send only what we need from the Django model objects here to avoid
Expand Down Expand Up @@ -1482,11 +1490,12 @@ def webhook_notification(version, build, hook_url):
},
})
log.debug(
LOG_TEMPLATE.format(
project=project.slug,
version='',
msg='sending notification to: %s' % hook_url,
),
LOG_TEMPLATE,
{
'project': project.slug,
'version': '',
'msg': 'sending notification to: %s' % hook_url,
}
)
try:
requests.post(hook_url, data=data)
Expand Down Expand Up @@ -1515,11 +1524,12 @@ def update_static_metadata(project_pk, path=None):
path = project.static_metadata_path()

log.info(
LOG_TEMPLATE.format(
project=project.slug,
version='',
msg='Updating static metadata',
),
LOG_TEMPLATE,
{
'project': project.slug,
'version': '',
'msg': 'Updating static metadata',
}
)
translations = [trans.language for trans in project.translations.all()]
languages = set(translations)
Expand All @@ -1538,11 +1548,12 @@ def update_static_metadata(project_pk, path=None):
fh.close()
except (AttributeError, IOError) as e:
log.debug(
LOG_TEMPLATE.format(
project=project.slug,
version='',
msg='Cannot write to metadata.json: {}'.format(e),
),
LOG_TEMPLATE,
{
'project': project.slug,
'version': '',
'msg': 'Cannot write to metadata.json: {}'.format(e),
}
)


Expand Down