| OLD | NEW |
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 command() | 103 command() |
| 104 | 104 |
| 105 def _update(self, force_clean=False): | 105 def _update(self, force_clean=False): |
| 106 if not self.git.is_cleanly_tracking_remote_master(): | 106 if not self.git.is_cleanly_tracking_remote_master(): |
| 107 if not force_clean: | 107 if not force_clean: |
| 108 confirm = raw_input('This repository has local changes, continue
? (uncommitted changes will be lost) y/n: ') | 108 confirm = raw_input('This repository has local changes, continue
? (uncommitted changes will be lost) y/n: ') |
| 109 if not confirm.lower() == 'y': | 109 if not confirm.lower() == 'y': |
| 110 return False | 110 return False |
| 111 try: | 111 try: |
| 112 self.git.ensure_cleanly_tracking_remote_master() | 112 self.git.ensure_cleanly_tracking_remote_master() |
| 113 except ScriptError, e: | 113 except ScriptError as e: |
| 114 _log.error('Failed to clean repository: %s' % e) | 114 _log.error('Failed to clean repository: %s' % e) |
| 115 return False | 115 return False |
| 116 | 116 |
| 117 attempts = 1 | 117 attempts = 1 |
| 118 while attempts <= retry_attempts: | 118 while attempts <= retry_attempts: |
| 119 if attempts > 1: | 119 if attempts > 1: |
| 120 # User may have sent a keyboard interrupt during the wait. | 120 # User may have sent a keyboard interrupt during the wait. |
| 121 if not self.connection.is_connected(): | 121 if not self.connection.is_connected(): |
| 122 return False | 122 return False |
| 123 wait = int(update_wait_seconds) << (attempts - 1) | 123 wait = int(update_wait_seconds) << (attempts - 1) |
| 124 if wait < 120: | 124 if wait < 120: |
| 125 _log.info('Waiting %s seconds' % wait) | 125 _log.info('Waiting %s seconds' % wait) |
| 126 else: | 126 else: |
| 127 _log.info('Waiting %s minutes' % (wait / 60)) | 127 _log.info('Waiting %s minutes' % (wait / 60)) |
| 128 time.sleep(wait) | 128 time.sleep(wait) |
| 129 _log.info('Pull attempt %s out of %s' % (attempts, retry_attempt
s)) | 129 _log.info('Pull attempt %s out of %s' % (attempts, retry_attempt
s)) |
| 130 try: | 130 try: |
| 131 self.git.pull() | 131 self.git.pull() |
| 132 return True | 132 return True |
| 133 except ScriptError, e: | 133 except ScriptError as e: |
| 134 _log.error('Error pulling from server: %s' % e) | 134 _log.error('Error pulling from server: %s' % e) |
| 135 _log.error('Output: %s' % e.output) | 135 _log.error('Output: %s' % e.output) |
| 136 attempts += 1 | 136 attempts += 1 |
| 137 _log.error('Exceeded pull attempts') | 137 _log.error('Exceeded pull attempts') |
| 138 _log.error('Aborting at time: %s' % self._time()) | 138 _log.error('Aborting at time: %s' % self._time()) |
| 139 return False | 139 return False |
| 140 | 140 |
| 141 def _time(self): | 141 def _time(self): |
| 142 return time.strftime('[%x %X %Z]', time.localtime()) | 142 return time.strftime('[%x %X %Z]', time.localtime()) |
| 143 | 143 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 def __init__(self, tool, announce_path, irc_password): | 191 def __init__(self, tool, announce_path, irc_password): |
| 192 threading.Thread.__init__(self) | 192 threading.Thread.__init__(self) |
| 193 self.bot = CommitAnnouncer(tool, announce_path, irc_password) | 193 self.bot = CommitAnnouncer(tool, announce_path, irc_password) |
| 194 | 194 |
| 195 def run(self): | 195 def run(self): |
| 196 self.bot.start() | 196 self.bot.start() |
| 197 | 197 |
| 198 def stop(self): | 198 def stop(self): |
| 199 self.bot.stop() | 199 self.bot.stop() |
| 200 self.join() | 200 self.join() |
| OLD | NEW |