cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / build_server.py
blobf31eaa00d8c77ec524878caa104392fbf338b773
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 # This script is used to copy all dependencies into the local directory.
7 # The package of files can then be uploaded to App Engine.
8 import os
9 import shutil
10 import stat
11 import sys
13 SRC_DIR = os.path.join(sys.path[0], os.pardir, os.pardir, os.pardir, os.pardir,
14 os.pardir)
15 THIRD_PARTY_DIR = os.path.join(SRC_DIR, 'third_party')
16 LOCAL_THIRD_PARTY_DIR = os.path.join(sys.path[0], 'third_party')
17 TOOLS_DIR = os.path.join(SRC_DIR, 'tools')
18 SCHEMA_COMPILER_FILES = ['memoize.py',
19 'model.py',
20 'idl_schema.py',
21 'schema_util.py',
22 'json_parse.py',
23 'json_schema.py']
25 def MakeInit(path):
26 path = os.path.join(path, '__init__.py')
27 with open(os.path.join(path), 'w') as f:
28 os.utime(os.path.join(path), None)
30 def OnError(function, path, excinfo):
31 os.chmod(path, stat.S_IWUSR)
32 function(path)
34 def CopyThirdParty(src, dest, files=None, make_init=True):
35 dest_path = os.path.join(LOCAL_THIRD_PARTY_DIR, dest)
36 if not files:
37 shutil.copytree(src, dest_path)
38 if make_init:
39 MakeInit(dest_path)
40 return
41 try:
42 os.makedirs(dest_path)
43 except Exception:
44 pass
45 if make_init:
46 MakeInit(dest_path)
47 for filename in files:
48 shutil.copy(os.path.join(src, filename), os.path.join(dest_path, filename))
50 def main():
51 if os.path.isdir(LOCAL_THIRD_PARTY_DIR):
52 try:
53 shutil.rmtree(LOCAL_THIRD_PARTY_DIR, False, OnError)
54 except OSError:
55 print('*-------------------------------------------------------------*\n'
56 '| If you are receiving an upload error, try removing |\n'
57 '| chrome/common/extensions/docs/server2/third_party manually. |\n'
58 '*-------------------------------------------------------------*\n')
61 CopyThirdParty(os.path.join(THIRD_PARTY_DIR, 'motemplate'), 'motemplate')
62 CopyThirdParty(os.path.join(THIRD_PARTY_DIR, 'markdown'), 'markdown',
63 make_init=False)
64 CopyThirdParty(os.path.join(SRC_DIR, 'ppapi', 'generators'),
65 'json_schema_compiler')
66 CopyThirdParty(os.path.join(THIRD_PARTY_DIR, 'ply'),
67 os.path.join('json_schema_compiler', 'ply'))
68 CopyThirdParty(os.path.join(TOOLS_DIR, 'json_schema_compiler'),
69 'json_schema_compiler',
70 SCHEMA_COMPILER_FILES)
71 CopyThirdParty(os.path.join(TOOLS_DIR, 'json_comment_eater'),
72 'json_schema_compiler',
73 ['json_comment_eater.py'])
74 CopyThirdParty(os.path.join(THIRD_PARTY_DIR, 'simplejson'),
75 os.path.join('json_schema_compiler', 'simplejson'),
76 make_init=False)
77 MakeInit(LOCAL_THIRD_PARTY_DIR)
79 CopyThirdParty(os.path.join(THIRD_PARTY_DIR, 'google_appengine_cloudstorage',
80 'cloudstorage'), 'cloudstorage')
82 # To be able to use the Motemplate class we need this import in __init__.py.
83 with open(os.path.join(LOCAL_THIRD_PARTY_DIR,
84 'motemplate',
85 '__init__.py'), 'a') as f:
86 f.write('from motemplate import Motemplate\n')
88 if __name__ == '__main__':
89 main()