| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """PyAuto: Python Interface to Chromium's Automation Proxy. | 6 """PyAuto: Python Interface to Chromium's Automation Proxy. |
| 7 | 7 |
| 8 PyAuto uses swig to expose Automation Proxy interfaces to Python. | 8 PyAuto uses swig to expose Automation Proxy interfaces to Python. |
| 9 For complete documentation on the functionality available, | 9 For complete documentation on the functionality available, |
| 10 run pydoc on this file. | 10 run pydoc on this file. |
| (...skipping 5068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5079 | 5079 |
| 5080 Raises: | 5080 Raises: |
| 5081 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 5081 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
| 5082 """ | 5082 """ |
| 5083 cmd_dict = { | 5083 cmd_dict = { |
| 5084 'command': 'SetTimezone', | 5084 'command': 'SetTimezone', |
| 5085 'timezone': timezone, | 5085 'timezone': timezone, |
| 5086 } | 5086 } |
| 5087 self._GetResultFromJSONRequest(cmd_dict, windex=None) | 5087 self._GetResultFromJSONRequest(cmd_dict, windex=None) |
| 5088 | 5088 |
| 5089 def GetUpdateInfo(self): | |
| 5090 """Gets the status of the ChromeOS updater. | |
| 5091 | |
| 5092 Returns: | |
| 5093 a dictionary. | |
| 5094 Samples: | |
| 5095 { u'status': u'idle', | |
| 5096 u'release_track': u'beta-channel'} | |
| 5097 | |
| 5098 { u'status': u'downloading', | |
| 5099 u'release_track': u'beta-channel', | |
| 5100 u'download_progress': 0.1203236708350371, # 0.0 ~ 1.0 | |
| 5101 u'new_size': 152033593, # size of payload, in bytes | |
| 5102 u'last_checked_time': 1302055709} # seconds since UNIX epoch | |
| 5103 | |
| 5104 Raises: | |
| 5105 pyauto_errors.JSONInterfaceError if the automation call returns an error. | |
| 5106 """ | |
| 5107 cmd_dict = { 'command': 'GetUpdateInfo' } | |
| 5108 return self._GetResultFromJSONRequest(cmd_dict, windex=None) | |
| 5109 | |
| 5110 def UpdateCheck(self): | 5089 def UpdateCheck(self): |
| 5111 """Checks for a ChromeOS update. Blocks until finished updating. | 5090 """Checks for a ChromeOS update. Blocks until finished updating. |
| 5112 | 5091 |
| 5113 Raises: | 5092 Raises: |
| 5114 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 5093 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
| 5115 """ | 5094 """ |
| 5116 cmd_dict = { 'command': 'UpdateCheck' } | 5095 cmd_dict = { 'command': 'UpdateCheck' } |
| 5117 self._GetResultFromJSONRequest(cmd_dict, windex=None) | 5096 self._GetResultFromJSONRequest(cmd_dict, windex=None) |
| 5118 | 5097 |
| 5119 def SetReleaseTrack(self, track): | |
| 5120 """Sets the release track (channel) of the ChromeOS updater. | |
| 5121 | |
| 5122 Valid values for the track parameter are: | |
| 5123 'stable-channel', 'beta-channel', 'dev-channel' | |
| 5124 | |
| 5125 Raises: | |
| 5126 pyauto_errors.JSONInterfaceError if the automation call returns an error. | |
| 5127 """ | |
| 5128 assert track in ('stable-channel', 'beta-channel', 'dev-channel'), \ | |
| 5129 'Attempt to set release track to unknown release track "%s".' % track | |
| 5130 cmd_dict = { | |
| 5131 'command': 'SetReleaseTrack', | |
| 5132 'track': track, | |
| 5133 } | |
| 5134 self._GetResultFromJSONRequest(cmd_dict, windex=None) | |
| 5135 | |
| 5136 def GetVolumeInfo(self): | 5098 def GetVolumeInfo(self): |
| 5137 """Gets the volume and whether the device is muted. | 5099 """Gets the volume and whether the device is muted. |
| 5138 | 5100 |
| 5139 Returns: | 5101 Returns: |
| 5140 a tuple. | 5102 a tuple. |
| 5141 Sample: | 5103 Sample: |
| 5142 (47.763456790123456, False) | 5104 (47.763456790123456, False) |
| 5143 | 5105 |
| 5144 Raises: | 5106 Raises: |
| 5145 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 5107 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5979 successful = result.wasSuccessful() | 5941 successful = result.wasSuccessful() |
| 5980 if not successful: | 5942 if not successful: |
| 5981 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) | 5943 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) |
| 5982 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ | 5944 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ |
| 5983 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) | 5945 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) |
| 5984 sys.exit(not successful) | 5946 sys.exit(not successful) |
| 5985 | 5947 |
| 5986 | 5948 |
| 5987 if __name__ == '__main__': | 5949 if __name__ == '__main__': |
| 5988 Main() | 5950 Main() |
| OLD | NEW |