Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | # |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 3 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
Gilad Arnold | 0b8c3f3 | 2012-09-19 14:35:44 -0700 | [diff] [blame] | 7 | import Queue |
Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 8 | import cherrypy |
Chris Sosa | 9164ca3 | 2012-03-28 11:04:50 -0700 | [diff] [blame] | 9 | import os |
Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 10 | import shutil |
| 11 | import tempfile |
Gilad Arnold | 0b8c3f3 | 2012-09-19 14:35:44 -0700 | [diff] [blame] | 12 | import threading |
Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 13 | |
| 14 | import devserver_util |
| 15 | |
| 16 | |
| 17 | class Downloader(object): |
| 18 | """Download images to the devsever. |
| 19 | |
| 20 | Given a URL to a build on the archive server: |
| 21 | |
| 22 | - Determine if the build already exists. |
| 23 | - Download and extract the build to a staging directory. |
| 24 | - Package autotest tests. |
| 25 | - Install components to static dir. |
| 26 | """ |
| 27 | |
Chris Masone | a22d938 | 2012-05-18 12:38:51 -0700 | [diff] [blame] | 28 | _LOG_TAG = 'DOWNLOAD' |
Alex Miller | a44d502 | 2012-07-27 11:34:16 -0700 | [diff] [blame] | 29 | # This filename must be kept in sync with clean_staged_images.py |
| 30 | _TIMESTAMP_FILENAME = 'staged.timestamp' |
Chris Masone | a22d938 | 2012-05-18 12:38:51 -0700 | [diff] [blame] | 31 | |
Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 32 | def __init__(self, static_dir): |
| 33 | self._static_dir = static_dir |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 34 | self._build_dir = None |
| 35 | self._staging_dir = None |
Gilad Arnold | 0b8c3f3 | 2012-09-19 14:35:44 -0700 | [diff] [blame] | 36 | self._status_queue = Queue.Queue(maxsize=1) |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 37 | self._lock_tag = None |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 38 | |
| 39 | @staticmethod |
Chris Sosa | cde6bf4 | 2012-05-31 18:36:39 -0700 | [diff] [blame] | 40 | def ParseUrl(archive_url): |
Yu-Ju Hong | d49d7f4 | 2012-06-25 12:23:11 -0700 | [diff] [blame] | 41 | """Parse archive_url into rel_path and short_build |
| 42 | e.g. gs://chromeos-image-archive/{rel_path}/{short_build} |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 43 | |
| 44 | @param archive_url: a URL at which build artifacts are archived. |
Yu-Ju Hong | d49d7f4 | 2012-06-25 12:23:11 -0700 | [diff] [blame] | 45 | @return a tuple of (build relative path, short build name) |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 46 | """ |
Yu-Ju Hong | d49d7f4 | 2012-06-25 12:23:11 -0700 | [diff] [blame] | 47 | # The archive_url is of the form gs://server/[some_path/target]/...]/build |
| 48 | # This function discards 'gs://server/' and extracts the [some_path/target] |
| 49 | # as rel_path and the build as short_build. |
| 50 | sub_url = archive_url.partition('://')[2] |
| 51 | split_sub_url = sub_url.split('/') |
| 52 | rel_path = '/'.join(split_sub_url[1:-1]) |
| 53 | short_build = split_sub_url[-1] |
| 54 | return rel_path, short_build |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 55 | |
| 56 | @staticmethod |
Yu-Ju Hong | d49d7f4 | 2012-06-25 12:23:11 -0700 | [diff] [blame] | 57 | def GenerateLockTag(rel_path, short_build): |
| 58 | """Generate a name for a lock scoped to this rel_path/build pair. |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 59 | |
Yu-Ju Hong | d49d7f4 | 2012-06-25 12:23:11 -0700 | [diff] [blame] | 60 | @param rel_path: the relative path for the build. |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 61 | @param short_build: short build name |
| 62 | @return a name to use with AcquireLock that will scope the lock. |
| 63 | """ |
Yu-Ju Hong | d49d7f4 | 2012-06-25 12:23:11 -0700 | [diff] [blame] | 64 | return '/'.join([rel_path, short_build]) |
Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 65 | |
Chris Sosa | 9164ca3 | 2012-03-28 11:04:50 -0700 | [diff] [blame] | 66 | @staticmethod |
Alex Miller | a44d502 | 2012-07-27 11:34:16 -0700 | [diff] [blame] | 67 | def _TouchTimestampForStaged(directory_path): |
| 68 | file_name = os.path.join(directory_path, Downloader._TIMESTAMP_FILENAME) |
| 69 | # Easiest python version of |touch file_name| |
| 70 | with file(file_name, 'a'): |
| 71 | os.utime(file_name, None) |
| 72 | |
| 73 | @staticmethod |
Chris Sosa | 9164ca3 | 2012-03-28 11:04:50 -0700 | [diff] [blame] | 74 | def BuildStaged(archive_url, static_dir): |
| 75 | """Returns True if the build is already staged.""" |
Yu-Ju Hong | d49d7f4 | 2012-06-25 12:23:11 -0700 | [diff] [blame] | 76 | rel_path, short_build = Downloader.ParseUrl(archive_url) |
| 77 | sub_directory = Downloader.GenerateLockTag(rel_path, short_build) |
Alex Miller | a44d502 | 2012-07-27 11:34:16 -0700 | [diff] [blame] | 78 | directory_path = os.path.join(static_dir, sub_directory) |
| 79 | exists = os.path.isdir(directory_path) |
| 80 | # If the build exists, then touch the timestamp to tell |
| 81 | # clean_stages_images.py that we're using this build. |
| 82 | if exists: |
| 83 | Downloader._TouchTimestampForStaged(directory_path) |
| 84 | return exists |
Chris Sosa | 9164ca3 | 2012-03-28 11:04:50 -0700 | [diff] [blame] | 85 | |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 86 | def Download(self, archive_url, background=False): |
| 87 | """Downloads the given build artifacts defined by the |archive_url|. |
| 88 | |
| 89 | If background is set to True, will return back early before all artifacts |
| 90 | have been downloaded. The artifacts that can be backgrounded are all those |
| 91 | that are not set as synchronous. |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 92 | |
| 93 | TODO: refactor this into a common Download method, once unit tests are |
| 94 | fixed up to make iterating on the code easier. |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 95 | """ |
Yu-Ju Hong | d49d7f4 | 2012-06-25 12:23:11 -0700 | [diff] [blame] | 96 | # Parse archive_url into rel_path (contains the build target) and |
| 97 | # short_build. |
| 98 | # e.g. gs://chromeos-image-archive/{rel_path}/{short_build} |
| 99 | rel_path, short_build = self.ParseUrl(archive_url) |
Chris Sosa | cde6bf4 | 2012-05-31 18:36:39 -0700 | [diff] [blame] | 100 | # This should never happen. The Devserver should only try to call this |
| 101 | # method if no previous downloads have been staged for this archive_url. |
| 102 | assert not Downloader.BuildStaged(archive_url, self._static_dir) |
Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 103 | # Bind build_dir and staging_dir here so we can tell if we need to do any |
| 104 | # cleanup after an exception occurs before build_dir is set. |
Yu-Ju Hong | d49d7f4 | 2012-06-25 12:23:11 -0700 | [diff] [blame] | 105 | self._lock_tag = self.GenerateLockTag(rel_path, short_build) |
Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 106 | try: |
| 107 | # Create Dev Server directory for this build and tell other Downloader |
| 108 | # instances we have processed this build. |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 109 | self._build_dir = devserver_util.AcquireLock( |
| 110 | static_dir=self._static_dir, tag=self._lock_tag) |
Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 111 | |
Yu-Ju Hong | 1a83a71 | 2012-06-27 09:11:34 -0700 | [diff] [blame] | 112 | # Replace '/' with '_' in rel_path because it may contain multiple levels |
| 113 | # which would not be qualified as part of the suffix. |
| 114 | self._staging_dir = tempfile.mkdtemp(suffix='_'.join( |
Chris Sosa | f097564 | 2012-06-29 13:53:42 -0700 | [diff] [blame] | 115 | [rel_path.replace('/', '_'), short_build])) |
Alex Miller | a44d502 | 2012-07-27 11:34:16 -0700 | [diff] [blame] | 116 | Downloader._TouchTimestampForStaged(self._staging_dir) |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 117 | cherrypy.log('Gathering download requirements %s' % archive_url, |
Chris Masone | a22d938 | 2012-05-18 12:38:51 -0700 | [diff] [blame] | 118 | self._LOG_TAG) |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 119 | artifacts = self.GatherArtifactDownloads( |
| 120 | self._staging_dir, archive_url, short_build, self._build_dir) |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 121 | devserver_util.PrepareBuildDirectory(self._build_dir) |
Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 122 | |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 123 | cherrypy.log('Downloading foreground artifacts from %s' % archive_url, |
Chris Masone | a22d938 | 2012-05-18 12:38:51 -0700 | [diff] [blame] | 124 | self._LOG_TAG) |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 125 | background_artifacts = [] |
| 126 | for artifact in artifacts: |
| 127 | if artifact.Synchronous(): |
| 128 | artifact.Download() |
| 129 | artifact.Stage() |
| 130 | else: |
| 131 | background_artifacts.append(artifact) |
Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 132 | |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 133 | if background: |
Chris Sosa | cde6bf4 | 2012-05-31 18:36:39 -0700 | [diff] [blame] | 134 | self._DownloadArtifactsInBackground(background_artifacts) |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 135 | else: |
| 136 | self._DownloadArtifactsSerially(background_artifacts) |
| 137 | |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 138 | except Exception, e: |
Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 139 | # Release processing lock, which will remove build components directory |
| 140 | # so future runs can retry. |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 141 | if self._build_dir: |
| 142 | devserver_util.ReleaseLock(static_dir=self._static_dir, |
| 143 | tag=self._lock_tag) |
| 144 | |
| 145 | self._status_queue.put(e) |
| 146 | self._Cleanup() |
Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 147 | raise |
Frank Farzan | 37761d1 | 2011-12-01 14:29:08 -0800 | [diff] [blame] | 148 | |
| 149 | return 'Success' |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 150 | |
| 151 | def _Cleanup(self): |
| 152 | """Cleans up the staging dir for this downloader instanfce.""" |
| 153 | if self._staging_dir: |
| 154 | cherrypy.log('Cleaning up staging directory %s' % self._staging_dir, |
Chris Masone | a22d938 | 2012-05-18 12:38:51 -0700 | [diff] [blame] | 155 | self._LOG_TAG) |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 156 | shutil.rmtree(self._staging_dir) |
| 157 | |
| 158 | self._staging_dir = None |
| 159 | |
| 160 | def _DownloadArtifactsSerially(self, artifacts): |
| 161 | """Simple function to download all the given artifacts serially.""" |
Gilad Arnold | 0b8c3f3 | 2012-09-19 14:35:44 -0700 | [diff] [blame] | 162 | cherrypy.log('Downloading artifacts serially.', self._LOG_TAG) |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 163 | try: |
| 164 | for artifact in artifacts: |
| 165 | artifact.Download() |
| 166 | artifact.Stage() |
| 167 | except Exception, e: |
| 168 | self._status_queue.put(e) |
| 169 | |
| 170 | # Release processing lock, which will remove build components directory |
| 171 | # so future runs can retry. |
| 172 | if self._build_dir: |
| 173 | devserver_util.ReleaseLock(static_dir=self._static_dir, |
| 174 | tag=self._lock_tag) |
| 175 | else: |
| 176 | self._status_queue.put('Success') |
| 177 | finally: |
| 178 | self._Cleanup() |
| 179 | |
Chris Sosa | cde6bf4 | 2012-05-31 18:36:39 -0700 | [diff] [blame] | 180 | def _DownloadArtifactsInBackground(self, artifacts): |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 181 | """Downloads |artifacts| in the background and signals when complete.""" |
Gilad Arnold | 0b8c3f3 | 2012-09-19 14:35:44 -0700 | [diff] [blame] | 182 | cherrypy.log('Invoking background download of artifacts', self._LOG_TAG) |
| 183 | thread = threading.Thread(target=self._DownloadArtifactsSerially, |
| 184 | args=(artifacts,)) |
| 185 | thread.start() |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 186 | |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 187 | def GatherArtifactDownloads(self, main_staging_dir, archive_url, short_build, |
| 188 | build_dir): |
| 189 | """Wrapper around devserver_util.GatherArtifactDownloads(). |
| 190 | |
| 191 | The wrapper allows mocking and overriding in derived classes. |
| 192 | """ |
| 193 | return devserver_util.GatherArtifactDownloads(main_staging_dir, archive_url, |
| 194 | short_build, build_dir) |
| 195 | |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 196 | def GetStatusOfBackgroundDownloads(self): |
| 197 | """Returns the status of the background downloads. |
| 198 | |
| 199 | This commands returns the status of the background downloads and blocks |
| 200 | until a status is returned. |
| 201 | """ |
| 202 | status = self._status_queue.get() |
| 203 | # In case anyone else is calling. |
| 204 | self._status_queue.put(status) |
Alex Miller | 92ed359 | 2012-08-15 16:27:46 -0700 | [diff] [blame] | 205 | # If someone is curious about the status of a build, then we should |
| 206 | # probably keep it around for a bit longer. |
| 207 | if os.path.exists(self._staging_dir): |
| 208 | Downloader._TouchTimestampForStaged(self._staging_dir) |
Chris Sosa | 47a7d4e | 2012-03-28 11:26:55 -0700 | [diff] [blame] | 209 | # It's possible we received an exception, if so, re-raise it here. |
| 210 | if isinstance(status, Exception): |
| 211 | raise status |
| 212 | |
| 213 | return status |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 214 | |
| 215 | |
| 216 | class SymbolDownloader(Downloader): |
| 217 | """Download and stage debug symbols for a build on the devsever. |
| 218 | |
| 219 | Given a URL to a build on the archive server: |
| 220 | |
| 221 | - Determine if the build already exists. |
| 222 | - Download and extract the debug symbols to a staging directory. |
| 223 | - Install symbols to static dir. |
| 224 | """ |
| 225 | |
| 226 | _DONE_FLAG = 'done' |
Chris Masone | a22d938 | 2012-05-18 12:38:51 -0700 | [diff] [blame] | 227 | _LOG_TAG = 'SYMBOL_DOWNLOAD' |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 228 | |
| 229 | @staticmethod |
Yu-Ju Hong | d49d7f4 | 2012-06-25 12:23:11 -0700 | [diff] [blame] | 230 | def GenerateLockTag(rel_path, short_build): |
| 231 | return '/'.join([rel_path, short_build, 'symbols']) |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 232 | |
Chris Sosa | cde6bf4 | 2012-05-31 18:36:39 -0700 | [diff] [blame] | 233 | def Download(self, archive_url, _background=False): |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 234 | """Downloads debug symbols for the build defined by the |archive_url|. |
| 235 | |
| 236 | The symbols will be downloaded synchronously |
| 237 | """ |
Yu-Ju Hong | d49d7f4 | 2012-06-25 12:23:11 -0700 | [diff] [blame] | 238 | # Parse archive_url into rel_path (contains the build target) and |
| 239 | # short_build. |
| 240 | # e.g. gs://chromeos-image-archive/{rel_path}/{short_build} |
| 241 | rel_path, short_build = self.ParseUrl(archive_url) |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 242 | |
| 243 | # Bind build_dir and staging_dir here so we can tell if we need to do any |
| 244 | # cleanup after an exception occurs before build_dir is set. |
Yu-Ju Hong | d49d7f4 | 2012-06-25 12:23:11 -0700 | [diff] [blame] | 245 | self._lock_tag = self.GenerateLockTag(rel_path, short_build) |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 246 | if self.SymbolsStaged(archive_url, self._static_dir): |
| 247 | cherrypy.log( |
| 248 | 'Symbols for build %s have already been staged.' % self._lock_tag, |
Chris Masone | a22d938 | 2012-05-18 12:38:51 -0700 | [diff] [blame] | 249 | self._LOG_TAG) |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 250 | return 'Success' |
| 251 | |
| 252 | try: |
| 253 | # Create Dev Server directory for this build and tell other Downloader |
| 254 | # instances we have processed this build. |
| 255 | self._build_dir = devserver_util.AcquireLock( |
| 256 | static_dir=self._static_dir, tag=self._lock_tag) |
| 257 | |
Yu-Ju Hong | 1a83a71 | 2012-06-27 09:11:34 -0700 | [diff] [blame] | 258 | # Replace '/' with '_' in rel_path because it may contain multiple levels |
| 259 | # which would not be qualified as part of the suffix. |
| 260 | self._staging_dir = tempfile.mkdtemp(suffix='_'.join( |
Chris Sosa | f097564 | 2012-06-29 13:53:42 -0700 | [diff] [blame] | 261 | [rel_path.replace('/', '_'), short_build])) |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 262 | cherrypy.log('Downloading debug symbols from %s' % archive_url, |
Chris Masone | a22d938 | 2012-05-18 12:38:51 -0700 | [diff] [blame] | 263 | self._LOG_TAG) |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 264 | |
| 265 | [symbol_artifact] = self.GatherArtifactDownloads( |
| 266 | self._staging_dir, archive_url, '', self._static_dir) |
| 267 | symbol_artifact.Download() |
| 268 | symbol_artifact.Stage() |
Chris Masone | a22d938 | 2012-05-18 12:38:51 -0700 | [diff] [blame] | 269 | self.MarkSymbolsStaged() |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 270 | |
| 271 | except Exception: |
| 272 | # Release processing "lock", which will indicate to future runs that we |
| 273 | # did not succeed, and so they should try again. |
| 274 | if self._build_dir: |
| 275 | devserver_util.ReleaseLock(static_dir=self._static_dir, |
| 276 | tag=self._lock_tag) |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 277 | raise |
Chris Masone | a22d938 | 2012-05-18 12:38:51 -0700 | [diff] [blame] | 278 | finally: |
| 279 | self._Cleanup() |
Chris Sosa | 4d9c4d4 | 2012-06-29 15:23:23 -0700 | [diff] [blame] | 280 | |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 281 | return 'Success' |
| 282 | |
| 283 | def GatherArtifactDownloads(self, temp_download_dir, archive_url, short_build, |
| 284 | static_dir): |
| 285 | """Call SymbolDownloader-appropriate artifact gathering method. |
| 286 | |
| 287 | @param temp_download_dir: the tempdir into which we're downloading artifacts |
| 288 | prior to staging them. |
| 289 | @param archive_url: the google storage url of the bucket where the debug |
| 290 | symbols for the desired build are stored. |
| 291 | @param short_build: IGNORED |
| 292 | @param staging_dir: the dir into which to stage the symbols |
| 293 | |
| 294 | @return an iterable of one DebugTarball pointing to the right debug symbols. |
| 295 | This is an iterable so that it's similar to GatherArtifactDownloads. |
| 296 | Also, it's possible that someday we might have more than one. |
| 297 | """ |
| 298 | return devserver_util.GatherSymbolArtifactDownloads(temp_download_dir, |
| 299 | archive_url, |
| 300 | static_dir) |
| 301 | |
| 302 | def MarkSymbolsStaged(self): |
| 303 | """Puts a flag file on disk to signal that symbols are staged.""" |
| 304 | with open(os.path.join(self._build_dir, self._DONE_FLAG), 'w') as flag: |
| 305 | flag.write(self._DONE_FLAG) |
| 306 | |
| 307 | def SymbolsStaged(self, archive_url, static_dir): |
| 308 | """Returns True if the build is already staged.""" |
Yu-Ju Hong | d49d7f4 | 2012-06-25 12:23:11 -0700 | [diff] [blame] | 309 | rel_path, short_build = self.ParseUrl(archive_url) |
| 310 | sub_directory = self.GenerateLockTag(rel_path, short_build) |
Chris Masone | 816e38c | 2012-05-02 12:22:36 -0700 | [diff] [blame] | 311 | return os.path.isfile(os.path.join(static_dir, |
| 312 | sub_directory, |
| 313 | self._DONE_FLAG)) |