Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: pkg/docgen/bin/upload_docgen.py

Issue 166093006: pkg/docgen: removed py files, doc/README.txt, fixed analyzer warning (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/python
2 #
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file.
6
7 """ This file will run docgen.dart on the SDK libraries, and upload them to
8 Google Cloud Storage for the documentation viewer.
9 """
10
11 import optparse
12 import os
13 from os.path import join, dirname, abspath, exists
14 import platform
15 import subprocess
16 import sys
17 sys.path.append(abspath(join(dirname(__file__), '../../../tools')))
18 import utils
19
20
21 DART = abspath(join(dirname(__file__), '../../../%s/%s/dart-sdk/bin/dart'
22 % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release',
23 utils.GuessArchitecture()))))
24 PACKAGE_ROOT = abspath(join(dirname(__file__), '../../../%s/%s/packages/'
25 % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release',
26 utils.GuessArchitecture()))))
27 GSUTIL = utils.GetBuildbotGSUtilPath()
28 GS_SITE = 'gs://dartlang-docgen'
29 DESCRIPTION='Runs docgen.dart on the SDK libraries, and uploads them to Google \
30 Cloud Storage for the dartdoc-viewer. '
31 # Allow us to override checking SVN's revision number. Useful for development
32 # so we can upload docs from a branch using an SDK that was built on a
33 # revision newer than when the branch was forked.
34 trustSVN = None
35
36 def GetOptions():
37 parser = optparse.OptionParser(description=DESCRIPTION)
38 parser.add_option('--package-root', dest='pkg_root',
39 help='The package root for dart. (Default is in the build directory.)',
40 action='store', default=PACKAGE_ROOT)
41 parser.add_option('--dontTrustSVN', dest='dontTrustSVN', default=False,
42 help='Don''t rely on the SVN revision number, check the DART SDK instead',
43 action='store_true')
44 (options, args) = parser.parse_args()
45 SetPackageRoot(options.pkg_root)
46 trustSVN = not options.dontTrustSVN
47
48 def SetPackageRoot(path):
49 global PACKAGE_ROOT
50 if exists(path):
51 PACKAGE_ROOT = abspath(path)
52
53
54 def SetGsutil():
55 """ If not on buildbots, find gsutil relative to docgen. """
56 global GSUTIL
57 if not exists(GSUTIL):
58 GSUTIL = abspath(join(dirname(__file__),
59 '../../../third_party/gsutil/gsutil'))
60
61
62 def Upload(source, target):
63 """ Upload files to Google Storage. """
64 cmd = [GSUTIL, '-m', 'cp', '-q', '-a', 'public-read', '-r', source, target]
65 (status, output) = utils.ExecuteCommand(cmd)
66 return status
67
68
69 def main():
70 GetOptions()
71
72 SetGsutil()
73
74 # Execute Docgen.dart on the SDK.
75 utils.ExecuteCommand(['python', 'dartdoc.py', '-d'])
76
77 # Use SVN Revision to get the revision number.
78 revision = None
79 if trustSVN:
80 revision = utils.GetSVNRevision()
81
82 if revision is None:
83 # Try to find the version from the dart-sdk folder.
84 revision_file_location = abspath(join(dirname(__file__),
85 '../../../%s/%s/dart-sdk/revision' % (utils.BUILD_ROOT[utils.GuessOS()],
86 utils.GetBuildConf('release', utils.GuessArchitecture()))))
87 with open(revision_file_location, 'r') as revision_file:
88 revision = revision_file.readline(5)
89 revision_file.close()
90
91 if revision is None:
92 raise Exception("Unable to find revision. ")
93
94 # Upload the all files in Docs into a folder based off Revision number on
95 # Cloud Storage.
96 # TODO(alanknight): If we give it ./docs/* it fails to upload files in the
97 # subdirectory, probably due to escaping. Work around it by changing dir.
98 # Better, generalize this to be less dependent on the working directory.
99 os.chdir('docs')
100 Upload('.', GS_SITE + '/' + revision + '/')
101 os.chdir('..')
102
103 # Update VERSION file in Cloud Storage.
104 with open('VERSION', 'w') as version_file:
105 version_file.write(revision)
106 version_file.close()
107 Upload('./VERSION', GS_SITE + '/VERSION')
108 Upload('./VERSION', GS_SITE + '/' + revision + '/' + 'VERSION')
109
110 # Clean up the files it creates.
111 utils.ExecuteCommand(['rm', '-rf', './docs'])
112 utils.ExecuteCommand(['rm', '-f', './VERSION'])
113
114
115 if __name__ == '__main__':
116 main()
OLDNEW
« no previous file with comments | « pkg/docgen/bin/dartdoc.py ('k') | pkg/docgen/doc/README.txt » ('j') | pkg/docgen/lib/docgen.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698