|
1 | 1 | """Defines serializers for each of our models."""
|
2 | 2 |
|
3 |
| -import re |
4 |
| - |
5 | 3 | from allauth.socialaccount.models import SocialAccount
|
6 |
| -from django.conf import settings |
7 | 4 | from rest_framework import serializers
|
8 | 5 |
|
9 | 6 | from readthedocs.builds.models import Build, BuildCommandResult, Version
|
@@ -130,41 +127,11 @@ class VersionAdminSerializer(VersionSerializer):
|
130 | 127 | class BuildCommandSerializer(serializers.ModelSerializer):
|
131 | 128 |
|
132 | 129 | run_time = serializers.ReadOnlyField()
|
133 |
| - command = serializers.SerializerMethodField() |
134 | 130 |
|
135 | 131 | class Meta:
|
136 | 132 | model = BuildCommandResult
|
137 | 133 | exclude = []
|
138 | 134 |
|
139 |
| - def get_command(self, obj): |
140 |
| - # HACK: remove unreadable paths from the command outputs when returning it from the API. |
141 |
| - # We could make this change at build level, but we want to avoid undoable issues from now |
142 |
| - # and hack a small solution to fix the immediate problem. |
143 |
| - # |
144 |
| - # This converts: |
145 |
| - # $ /usr/src/app/checkouts/readthedocs.org/user_builds/ |
146 |
| - # <container_hash>/<project_slug>/envs/<version_slug>/bin/python |
147 |
| - # $ /home/docs/checkouts/readthedocs.org/user_builds/ |
148 |
| - # <project_slug>/envs/<version_slug>/bin/python |
149 |
| - # into |
150 |
| - # $ python |
151 |
| - project_slug = obj.build.version.project.slug |
152 |
| - version_slug = obj.build.version.slug |
153 |
| - docroot = settings.DOCROOT.rstrip("/") # remove trailing '/' |
154 |
| - |
155 |
| - # Remove Docker hash from DOCROOT when running it locally |
156 |
| - # DOCROOT contains the Docker container hash (e.g. b7703d1b5854). |
157 |
| - # We have to remove it from the DOCROOT it self since it changes each time |
158 |
| - # we spin up a new Docker instance locally. |
159 |
| - container_hash = "/" |
160 |
| - if settings.RTD_DOCKER_COMPOSE: |
161 |
| - docroot = re.sub("/[0-9a-z]+/?$", "", settings.DOCROOT, count=1) |
162 |
| - container_hash = "/[0-9a-z]+/" |
163 |
| - |
164 |
| - regex = f"{docroot}{container_hash}{project_slug}/envs/{version_slug}(/bin/)?" |
165 |
| - command = re.sub(regex, "", obj.command, count=1) |
166 |
| - return command |
167 |
| - |
168 | 135 |
|
169 | 136 | class BuildSerializer(serializers.ModelSerializer):
|
170 | 137 |
|
|
0 commit comments