blob: 6559d47fdab4cae497836190c8ea9e47dbe4ffee [file] [log] [blame]
kjellander@webrtc.org89256622014-08-20 12:10:11 +00001#!/usr/bin/env python
2# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3#
4# Use of this source code is governed by a BSD-style license
5# that can be found in the LICENSE file in the root of the source
6# tree. An additional intellectual property rights grant can be found
7# in the file PATENTS. All contributing project authors may
8# be found in the AUTHORS file in the root of the source tree.
9
10"""Setup links to a Chromium checkout for WebRTC.
11
12WebRTC standalone shares a lot of dependencies and build tools with Chromium.
13To do this, many of the paths of a Chromium checkout is emulated by creating
14symlinks to files and directories. This script handles the setup of symlinks to
15achieve this.
kjellander@webrtc.org89256622014-08-20 12:10:11 +000016"""
17
18
19import ctypes
20import errno
21import logging
22import optparse
23import os
24import shelve
25import shutil
26import subprocess
27import sys
28import textwrap
29
30
31DIRECTORIES = [
32 'build',
33 'buildtools',
kjellandere26e7872016-03-04 14:39:28 -080034 'mojo', # TODO(kjellander): Remove, see webrtc:5629.
kjellander@webrtc.org89256622014-08-20 12:10:11 +000035 'testing',
metzmanf89a5712016-07-25 02:14:09 -070036 'third_party/afl',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000037 'third_party/binutils',
38 'third_party/boringssl',
ehmaldonado1249ddf2016-08-31 01:58:48 -070039 'third_party/closure_compiler',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000040 'third_party/colorama',
41 'third_party/drmemory',
42 'third_party/expat',
hbosa9a1d2a2016-01-11 10:19:02 -080043 'third_party/ffmpeg',
kjellander@webrtc.org4e4fe4f2014-10-01 08:03:19 +000044 'third_party/instrumented_libraries',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000045 'third_party/jsoncpp',
Henrik Kjellander26ab91b2015-11-26 10:26:32 +010046 'third_party/libc++-static',
kjellander@webrtc.org2addf3f2016-04-04 08:33:12 +020047 'third_party/libFuzzer',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000048 'third_party/libjpeg',
49 'third_party/libjpeg_turbo',
50 'third_party/libsrtp',
kjellandere26e7872016-03-04 14:39:28 -080051 'third_party/libvpx',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000052 'third_party/libyuv',
53 'third_party/llvm-build',
Patrik Höglundc92c23d2015-08-31 11:30:14 +020054 'third_party/lss',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000055 'third_party/nss',
tkchin@webrtc.org3a63a3c2015-01-06 07:21:34 +000056 'third_party/ocmock',
hbosa9a1d2a2016-01-11 10:19:02 -080057 'third_party/openh264',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000058 'third_party/openmax_dl',
59 'third_party/opus',
Patrik Höglundc92c23d2015-08-31 11:30:14 +020060 'third_party/proguard',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000061 'third_party/protobuf',
62 'third_party/sqlite',
63 'third_party/syzygy',
64 'third_party/usrsctp',
65 'third_party/yasm',
kjellander@webrtc.org3bd41562014-09-01 11:06:37 +000066 'third_party/zlib',
kjellander752f36f2016-03-22 16:56:01 -070067 'third_party/WebKit', # TODO(kjellander): Remove, see webrtc:5629.
kjellander@webrtc.org89256622014-08-20 12:10:11 +000068 'tools/clang',
ehmaldonadoa78213e2016-09-22 10:46:16 -070069 'tools/determinism',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000070 'tools/generate_library_loader',
hbos5602f652016-01-15 01:38:34 -080071 'tools/generate_stubs',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000072 'tools/gn',
ehmaldonado1249ddf2016-08-31 01:58:48 -070073 'tools/grit',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000074 'tools/gyp',
kjellandere532aec2016-04-17 20:08:20 -070075 'tools/luci-go',
kjellander17849fc2016-02-24 00:04:44 -080076 'tools/mb',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000077 'tools/memory',
78 'tools/protoc_wrapper',
79 'tools/python',
80 'tools/swarming_client',
81 'tools/valgrind',
Andrew MacDonald65de7d22015-05-19 11:37:34 -070082 'tools/vim',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000083 'tools/win',
Henrik Kjellander9589e2a2015-10-22 06:48:21 +020084 'tools/xdisplaycheck',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000085]
86
kjellander@webrtc.org3bd41562014-09-01 11:06:37 +000087from sync_chromium import get_target_os_list
Henrik Kjellanderca843022015-06-09 10:51:22 +020088target_os = get_target_os_list()
89if 'android' in target_os:
kjellander@webrtc.org3bd41562014-09-01 11:06:37 +000090 DIRECTORIES += [
91 'base',
ehmaldonado9f73f7a2016-07-28 01:20:22 -070092 'third_party/accessibility_test_framework',
Henrik Kjellander94a12322015-06-09 14:56:20 +020093 'third_party/android_platform',
kjellander@webrtc.org3bd41562014-09-01 11:06:37 +000094 'third_party/android_tools',
ehmaldonado9f73f7a2016-07-28 01:20:22 -070095 'third_party/apache_velocity',
kjellander@webrtc.orgcbe7ca82015-01-06 07:24:27 +000096 'third_party/appurify-python',
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +000097 'third_party/ashmem',
ehmaldonado9f73f7a2016-07-28 01:20:22 -070098 'third_party/bouncycastle',
ehmaldonadocd8ae612016-08-24 02:44:14 -070099 'third_party/byte_buddy',
kjellander34a70542015-12-06 10:32:34 -0800100 'third_party/catapult',
kjellanderf10976e2016-08-11 10:31:40 -0700101 'third_party/ced',
ehmaldonado9f73f7a2016-07-28 01:20:22 -0700102 'third_party/guava',
103 'third_party/hamcrest',
kjellander53761002015-11-10 10:58:22 -0800104 'third_party/icu',
ehmaldonado9f73f7a2016-07-28 01:20:22 -0700105 'third_party/icu4j',
Henrik Kjellandereecbab72015-09-16 19:19:04 +0200106 'third_party/ijar',
ehmaldonado9f73f7a2016-07-28 01:20:22 -0700107 'third_party/intellij',
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000108 'third_party/jsr-305',
Henrik Kjellander10ba3ee2015-04-29 14:47:53 +0200109 'third_party/junit',
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000110 'third_party/libxml',
Henrik Kjellander10ba3ee2015-04-29 14:47:53 +0200111 'third_party/mockito',
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000112 'third_party/modp_b64',
ehmaldonadocd8ae612016-08-24 02:44:14 -0700113 'third_party/objenesis',
ehmaldonado9f73f7a2016-07-28 01:20:22 -0700114 'third_party/ow2_asm',
kjellander@webrtc.orgcbe7ca82015-01-06 07:24:27 +0000115 'third_party/requests',
Henrik Kjellander10ba3ee2015-04-29 14:47:53 +0200116 'third_party/robolectric',
ehmaldonado9f73f7a2016-07-28 01:20:22 -0700117 'third_party/sqlite4java',
primianob332e5d2016-01-25 08:13:05 -0800118 'third_party/tcmalloc',
kjellander@webrtc.org3bd41562014-09-01 11:06:37 +0000119 'tools/android',
kjellander34a70542015-12-06 10:32:34 -0800120 'tools/telemetry',
kjellander@webrtc.org3bd41562014-09-01 11:06:37 +0000121 ]
tommide3b0292016-04-22 01:47:02 -0700122else:
123 DIRECTORIES += [
124 'base/third_party/libevent',
125 ]
126
Henrik Kjellanderca843022015-06-09 10:51:22 +0200127if 'ios' in target_os:
128 DIRECTORIES.append('third_party/class-dump')
kjellander@webrtc.org3bd41562014-09-01 11:06:37 +0000129
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000130FILES = {
Henrik Kjellanderd6d27e72015-09-25 22:19:11 +0200131 'tools/isolate_driver.py': None,
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000132 'third_party/BUILD.gn': None,
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000133}
134
kjellander@webrtc.orge94f83a2014-09-18 13:47:23 +0000135ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000136CHROMIUM_CHECKOUT = os.path.join('chromium', 'src')
137LINKS_DB = 'links'
138
139# Version management to make future upgrades/downgrades easier to support.
140SCHEMA_VERSION = 1
141
142
143def query_yes_no(question, default=False):
144 """Ask a yes/no question via raw_input() and return their answer.
145
146 Modified from http://stackoverflow.com/a/3041990.
147 """
148 prompt = " [%s/%%s]: "
149 prompt = prompt % ('Y' if default is True else 'y')
150 prompt = prompt % ('N' if default is False else 'n')
151
152 if default is None:
153 default = 'INVALID'
154
155 while True:
156 sys.stdout.write(question + prompt)
157 choice = raw_input().lower()
158 if choice == '' and default != 'INVALID':
159 return default
160
161 if 'yes'.startswith(choice):
162 return True
163 elif 'no'.startswith(choice):
164 return False
165
166 print "Please respond with 'yes' or 'no' (or 'y' or 'n')."
167
168
169# Actions
170class Action(object):
171 def __init__(self, dangerous):
172 self.dangerous = dangerous
173
174 def announce(self, planning):
175 """Log a description of this action.
176
177 Args:
178 planning - True iff we're in the planning stage, False if we're in the
179 doit stage.
180 """
181 pass
182
183 def doit(self, links_db):
184 """Execute the action, recording what we did to links_db, if necessary."""
185 pass
186
187
188class Remove(Action):
189 def __init__(self, path, dangerous):
190 super(Remove, self).__init__(dangerous)
191 self._priority = 0
192 self._path = path
193
194 def announce(self, planning):
195 log = logging.warn
196 filesystem_type = 'file'
197 if not self.dangerous:
198 log = logging.info
199 filesystem_type = 'link'
200 if planning:
201 log('Planning to remove %s: %s', filesystem_type, self._path)
202 else:
203 log('Removing %s: %s', filesystem_type, self._path)
204
Henrik Kjellander57e5fd22015-05-25 12:55:39 +0200205 def doit(self, _):
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000206 os.remove(self._path)
207
208
209class Rmtree(Action):
210 def __init__(self, path):
211 super(Rmtree, self).__init__(dangerous=True)
212 self._priority = 0
213 self._path = path
214
215 def announce(self, planning):
216 if planning:
217 logging.warn('Planning to remove directory: %s', self._path)
218 else:
219 logging.warn('Removing directory: %s', self._path)
220
Henrik Kjellander57e5fd22015-05-25 12:55:39 +0200221 def doit(self, _):
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000222 if sys.platform.startswith('win'):
223 # shutil.rmtree() doesn't work on Windows if any of the directories are
224 # read-only, which svn repositories are.
225 subprocess.check_call(['rd', '/q', '/s', self._path], shell=True)
226 else:
227 shutil.rmtree(self._path)
228
229
230class Makedirs(Action):
231 def __init__(self, path):
232 super(Makedirs, self).__init__(dangerous=False)
233 self._priority = 1
234 self._path = path
235
Henrik Kjellander57e5fd22015-05-25 12:55:39 +0200236 def doit(self, _):
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000237 try:
238 os.makedirs(self._path)
239 except OSError as e:
240 if e.errno != errno.EEXIST:
241 raise
242
243
244class Symlink(Action):
245 def __init__(self, source_path, link_path):
246 super(Symlink, self).__init__(dangerous=False)
247 self._priority = 2
248 self._source_path = source_path
249 self._link_path = link_path
250
251 def announce(self, planning):
252 if planning:
253 logging.info(
254 'Planning to create link from %s to %s', self._link_path,
255 self._source_path)
256 else:
257 logging.debug(
258 'Linking from %s to %s', self._link_path, self._source_path)
259
260 def doit(self, links_db):
261 # Files not in the root directory need relative path calculation.
262 # On Windows, use absolute paths instead since NTFS doesn't seem to support
263 # relative paths for symlinks.
264 if sys.platform.startswith('win'):
265 source_path = os.path.abspath(self._source_path)
266 else:
267 if os.path.dirname(self._link_path) != self._link_path:
268 source_path = os.path.relpath(self._source_path,
269 os.path.dirname(self._link_path))
270
271 os.symlink(source_path, os.path.abspath(self._link_path))
272 links_db[self._source_path] = self._link_path
273
274
275class LinkError(IOError):
276 """Failed to create a link."""
277 pass
278
279
kjellander844dd2a2016-04-05 00:13:58 -0700280# Use junctions instead of symlinks on the Windows platform.
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000281if sys.platform.startswith('win'):
282 def symlink(source_path, link_path):
kjellander844dd2a2016-04-05 00:13:58 -0700283 if os.path.isdir(source_path):
284 subprocess.check_call(['cmd.exe', '/c', 'mklink', '/J', link_path,
285 source_path])
286 else:
287 # Don't create symlinks to files on Windows, just copy the file instead
288 # (there's no way to create a link without administrator's privileges).
289 shutil.copy(source_path, link_path)
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000290 os.symlink = symlink
291
292
Henrik Kjellander57e5fd22015-05-25 12:55:39 +0200293class WebRTCLinkSetup(object):
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000294 def __init__(self, links_db, force=False, dry_run=False, prompt=False):
295 self._force = force
296 self._dry_run = dry_run
297 self._prompt = prompt
298 self._links_db = links_db
299
300 def CreateLinks(self, on_bot):
301 logging.debug('CreateLinks')
302 # First, make a plan of action
303 actions = []
304
305 for source_path, link_path in FILES.iteritems():
306 actions += self._ActionForPath(
307 source_path, link_path, check_fn=os.path.isfile, check_msg='files')
308 for source_dir in DIRECTORIES:
309 actions += self._ActionForPath(
310 source_dir, None, check_fn=os.path.isdir,
311 check_msg='directories')
312
kjellander@webrtc.orge94f83a2014-09-18 13:47:23 +0000313 if not on_bot and self._force:
314 # When making the manual switch from legacy SVN checkouts to the new
315 # Git-based Chromium DEPS, the .gclient_entries file that contains cached
316 # URLs for all DEPS entries must be removed to avoid future sync problems.
317 entries_file = os.path.join(os.path.dirname(ROOT_DIR), '.gclient_entries')
318 if os.path.exists(entries_file):
319 actions.append(Remove(entries_file, dangerous=True))
320
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000321 actions.sort()
322
323 if self._dry_run:
324 for action in actions:
325 action.announce(planning=True)
326 logging.info('Not doing anything because dry-run was specified.')
327 sys.exit(0)
328
329 if any(a.dangerous for a in actions):
330 logging.warn('Dangerous actions:')
331 for action in (a for a in actions if a.dangerous):
332 action.announce(planning=True)
333 print
334
335 if not self._force:
336 logging.error(textwrap.dedent("""\
337 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
338 A C T I O N R E Q I R E D
339 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
340
kjellander844dd2a2016-04-05 00:13:58 -0700341 Setting up the checkout requires creating symlinks to directories in the
342 Chromium checkout inside chromium/src.
343 To avoid disrupting developers, we've chosen to not delete directories
344 forcibly, in case you have some work in progress in one of them :)
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000345
346 ACTION REQUIRED:
347 Before running `gclient sync|runhooks` again, you must run:
348 %s%s --force
349
350 Which will replace all directories which now must be symlinks, after
351 prompting with a summary of the work-to-be-done.
kjellander844dd2a2016-04-05 00:13:58 -0700352 """), 'python ' if sys.platform.startswith('win') else '', __file__)
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000353 sys.exit(1)
354 elif self._prompt:
355 if not query_yes_no('Would you like to perform the above plan?'):
356 sys.exit(1)
357
358 for action in actions:
359 action.announce(planning=False)
360 action.doit(self._links_db)
361
362 if not on_bot and self._force:
363 logging.info('Completed!\n\nNow run `gclient sync|runhooks` again to '
364 'let the remaining hooks (that probably were interrupted) '
365 'execute.')
366
367 def CleanupLinks(self):
368 logging.debug('CleanupLinks')
369 for source, link_path in self._links_db.iteritems():
370 if source == 'SCHEMA_VERSION':
371 continue
372 if os.path.islink(link_path) or sys.platform.startswith('win'):
373 # os.path.islink() always returns false on Windows
374 # See http://bugs.python.org/issue13143.
375 logging.debug('Removing link to %s at %s', source, link_path)
376 if not self._dry_run:
377 if os.path.exists(link_path):
378 if sys.platform.startswith('win') and os.path.isdir(link_path):
Henrik Kjellanderc444de62015-04-29 11:27:22 +0200379 subprocess.check_call(['rmdir', '/q', '/s', link_path],
380 shell=True)
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000381 else:
382 os.remove(link_path)
383 del self._links_db[source]
384
385 @staticmethod
386 def _ActionForPath(source_path, link_path=None, check_fn=None,
387 check_msg=None):
388 """Create zero or more Actions to link to a file or directory.
389
kjellander844dd2a2016-04-05 00:13:58 -0700390 This will be a symlink on POSIX platforms. On Windows it will result in:
391 * a junction for directories
392 * a copied file for single files.
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000393
394 Args:
395 source_path: Path relative to the Chromium checkout root.
396 For readability, the path may contain slashes, which will
397 automatically be converted to the right path delimiter on Windows.
398 link_path: The location for the link to create. If omitted it will be the
399 same path as source_path.
400 check_fn: A function returning true if the type of filesystem object is
401 correct for the attempted call. Otherwise an error message with
402 check_msg will be printed.
403 check_msg: String used to inform the user of an invalid attempt to create
404 a file.
405 Returns:
406 A list of Action objects.
407 """
408 def fix_separators(path):
409 if sys.platform.startswith('win'):
410 return path.replace(os.altsep, os.sep)
411 else:
412 return path
413
414 assert check_fn
415 assert check_msg
416 link_path = link_path or source_path
417 link_path = fix_separators(link_path)
418
419 source_path = fix_separators(source_path)
420 source_path = os.path.join(CHROMIUM_CHECKOUT, source_path)
421 if os.path.exists(source_path) and not check_fn:
kjellander844dd2a2016-04-05 00:13:58 -0700422 raise LinkError('Can only to link to %s: tried to link to: %s' %
423 (check_msg, source_path))
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000424
425 if not os.path.exists(source_path):
426 logging.debug('Silently ignoring missing source: %s. This is to avoid '
427 'errors on platform-specific dependencies.', source_path)
428 return []
429
430 actions = []
431
432 if os.path.exists(link_path) or os.path.islink(link_path):
433 if os.path.islink(link_path):
434 actions.append(Remove(link_path, dangerous=False))
435 elif os.path.isfile(link_path):
436 actions.append(Remove(link_path, dangerous=True))
437 elif os.path.isdir(link_path):
438 actions.append(Rmtree(link_path))
439 else:
440 raise LinkError('Don\'t know how to plan: %s' % link_path)
441
442 # Create parent directories to the target link if needed.
443 target_parent_dirs = os.path.dirname(link_path)
444 if (target_parent_dirs and
445 target_parent_dirs != link_path and
446 not os.path.exists(target_parent_dirs)):
447 actions.append(Makedirs(target_parent_dirs))
448
449 actions.append(Symlink(source_path, link_path))
450
451 return actions
452
453def _initialize_database(filename):
454 links_database = shelve.open(filename)
455
456 # Wipe the database if this version of the script ends up looking at a
457 # newer (future) version of the links db, just to be sure.
458 version = links_database.get('SCHEMA_VERSION')
459 if version and version != SCHEMA_VERSION:
460 logging.info('Found database with schema version %s while this script only '
461 'supports %s. Wiping previous database contents.', version,
462 SCHEMA_VERSION)
463 links_database.clear()
464 links_database['SCHEMA_VERSION'] = SCHEMA_VERSION
465 return links_database
466
467
468def main():
469 on_bot = os.environ.get('CHROME_HEADLESS') == '1'
470
471 parser = optparse.OptionParser()
472 parser.add_option('-d', '--dry-run', action='store_true', default=False,
473 help='Print what would be done, but don\'t perform any '
474 'operations. This will automatically set logging to '
475 'verbose.')
476 parser.add_option('-c', '--clean-only', action='store_true', default=False,
477 help='Only clean previously created links, don\'t create '
478 'new ones. This will automatically set logging to '
479 'verbose.')
480 parser.add_option('-f', '--force', action='store_true', default=on_bot,
481 help='Force link creation. CAUTION: This deletes existing '
482 'folders and files in the locations where links are '
483 'about to be created.')
484 parser.add_option('-n', '--no-prompt', action='store_false', dest='prompt',
485 default=(not on_bot),
486 help='Prompt if we\'re planning to do a dangerous action')
487 parser.add_option('-v', '--verbose', action='store_const',
488 const=logging.DEBUG, default=logging.INFO,
489 help='Print verbose output for debugging.')
490 options, _ = parser.parse_args()
491
492 if options.dry_run or options.force or options.clean_only:
493 options.verbose = logging.DEBUG
494 logging.basicConfig(format='%(message)s', level=options.verbose)
495
496 # Work from the root directory of the checkout.
497 script_dir = os.path.dirname(os.path.abspath(__file__))
498 os.chdir(script_dir)
499
500 if sys.platform.startswith('win'):
501 def is_admin():
502 try:
503 return os.getuid() == 0
504 except AttributeError:
505 return ctypes.windll.shell32.IsUserAnAdmin() != 0
kjellander844dd2a2016-04-05 00:13:58 -0700506 if is_admin():
507 logging.warning('WARNING: On Windows, you no longer need run as '
508 'administrator. Please run with user account privileges.')
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000509
510 if not os.path.exists(CHROMIUM_CHECKOUT):
511 logging.error('Cannot find a Chromium checkout at %s. Did you run "gclient '
512 'sync" before running this script?', CHROMIUM_CHECKOUT)
513 return 2
514
515 links_database = _initialize_database(LINKS_DB)
516 try:
517 symlink_creator = WebRTCLinkSetup(links_database, options.force,
518 options.dry_run, options.prompt)
519 symlink_creator.CleanupLinks()
520 if not options.clean_only:
521 symlink_creator.CreateLinks(on_bot)
522 except LinkError as e:
523 print >> sys.stderr, e.message
524 return 3
525 finally:
526 links_database.close()
527 return 0
528
529
530if __name__ == '__main__':
531 sys.exit(main())