1a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)# Copyright (c) 2013 The Chromium Authors. All rights reserved. 2a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)# Use of this source code is governed by a BSD-style license that can be 3a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)# found in the LICENSE file. 4a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 5a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)import os 6a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)import sys 7a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 8a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 9a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)def IsAvailable(): 10a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) _winreg = None 11a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if sys.platform == 'win32': 12a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) import _winreg 13a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) elif sys.platform == 'cygwin': 14a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) try: 15a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) import cygwinreg as _winreg 16a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) except ImportError: 17a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) pass # If not available, be safe and write 0. 18a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 19a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if not _winreg: 20a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return False 21a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 22a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) try: 23a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) val = _winreg.QueryValue(_winreg.HKEY_CURRENT_USER, 24a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 'Software\\Chromium\\split_link_installed') 25a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return os.path.exists(val) 26a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) except WindowsError: 27a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) pass 28a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 29a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return False 30a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 31a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 32a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)def main(): 33a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) # Can be called from gyp to set variable. 34a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) if IsAvailable(): 35a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) sys.stdout.write('1') 36a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) else: 37a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) print >> sys.stderr, "Couldn't find split_link installation." 38a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) print >> sys.stderr, ('Run python tools\\win\\split_link\\' 39a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 'install_split_link.py from an elevated Visual ' 40a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 'Studio Command Prompt to install.') 41a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) sys.stdout.write('0') 42a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return 1 43a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 44a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 45a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)if __name__ == '__main__': 46a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) sys.exit(main()) 47