Chromium Code Reviews| Index: pkg/docgen/bin/upload_docgen.py |
| diff --git a/pkg/docgen/bin/upload_docgen.py b/pkg/docgen/bin/upload_docgen.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dbe85ebc8a22c305d8cc330297899472f1f68768 |
| --- /dev/null |
| +++ b/pkg/docgen/bin/upload_docgen.py |
| @@ -0,0 +1,81 @@ |
| +#!/usr/bin/python |
| +# |
| +# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +# for details. All rights reserved. Use of this source code is governed by a |
| +# BSD-style license that can be found in the LICENSE file. |
| + |
| +""" This file will run docgen.dart on the SDK libraries, and upload them to |
| + Google Cloud Storage for the documentation viewer. |
| +""" |
| + |
| +import os |
| +import platform |
| +import subprocess |
| +import sys |
| +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), |
|
Emily Fortuna
2013/07/11 22:41:24
here's a little trick that will make these lines l
janicejl
2013/07/11 22:53:11
Done.
|
| + '../../../tools'))) |
| +import utils |
| +from upload_sdk import ExecuteCommand |
| + |
| + |
| +DART = os.path.abspath(os.path.join(os.path.dirname(__file__), |
| + '../../../%s/%s/dart-sdk/bin/dart' % (utils.BUILD_ROOT[utils.GuessOS()], |
| + utils.GetBuildConf('release', utils.GuessArchitecture())))) |
| +GSUTIL = utils.GetBuildbotGSUtilPath() |
| +GS_SITE = 'gs://dartlang-docgen' |
| +print DART |
|
Emily Fortuna
2013/07/11 22:41:24
debug code?
janicejl
2013/07/11 22:53:11
Done.
|
| + |
| +def SetGsutil(): |
| + """ If not on buildbots, find gsutil relative to docgen. """ |
| + global GSUTIL |
| + if not os.path.exists(GSUTIL): |
| + GSUTIL = os.path.abspath(os.path.join(os.path.dirname(__file__), |
| + '../../../third_party/gsutil/gsutil')) |
| + |
| + |
| +def Upload(source, target): |
| + """ Upload files to Google Storage. """ |
| + cmd = [GSUTIL, '-m', 'cp', '-q', '-a', 'public-read', '-r', source, target] |
| + (status, output) = ExecuteCommand(cmd) |
| + return status |
| + |
| + |
| +def main(): |
| + SetGsutil() |
| + |
| + # Execute Docgen.dart on the SDK. |
| + ExecuteCommand([DART, os.path.abspath(os.path.join(os.path.dirname(__file__), |
| + 'docgen.dart')), '--parse-sdk']) |
| + |
| + # Use SVN Revision to get the revision number. |
| + revision = utils.GetSVNRevision() |
| + if revision is None: |
| + # Try to find the version from the dart-sdk folder. |
| + revision_file_location = os.path.abspath(os.path.join( |
| + os.path.dirname(__file__), '../../../%s/%s/dart-sdk/revision' |
| + % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release', |
| + utils.GuessArchitecture())))) |
| + with open(revision_file_location, 'r') as revision_file: |
| + revision = revision_file.readline(5) |
| + revision_file.close() |
| + |
| + if revision is None: |
| + raise Exception("Unable to find revision. ") |
| + |
| + # Upload the all files in Docs into a folder based off Revision number on |
| + # Cloud Storage. |
| + Upload('./docs/*', GS_SITE + '/' + revision + '/') |
| + |
| + # Update VERSION file in Cloud Storage. |
| + with open('VERSION', 'w') as version_file: |
| + version_file.write(revision) |
| + version_file.close() |
| + Upload('./VERSION', GS_SITE + '/VERSION') |
| + |
| + # Clean up the files it creates. |
| + ExecuteCommand(['rm', '-rf', './docs']) |
| + ExecuteCommand(['rm', '-f', './VERSION']) |
| + |
| + |
| +if __name__ == '__main__': |
| + main() |