Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The LUCI Authors. All rights reserved. | 1 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """OS specific utility functions. | 5 """OS specific utility functions. |
| 6 | 6 |
| 7 Includes code: | 7 Includes code: |
| 8 - to declare the current system this code is running under. | 8 - to declare the current system this code is running under. |
| 9 - to run a command on user login. | 9 - to run a command on user login. |
| 10 - to reboot the host. | 10 - to reboot the host. |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 return None | 405 return None |
| 406 | 406 |
| 407 | 407 |
| 408 @tools.cached | 408 @tools.cached |
| 409 def get_cost_hour(): | 409 def get_cost_hour(): |
| 410 """Returns the cost in $USD/h as a floating point value if applicable.""" | 410 """Returns the cost in $USD/h as a floating point value if applicable.""" |
| 411 # Machine. | 411 # Machine. |
| 412 machine_type = get_machine_type() | 412 machine_type = get_machine_type() |
| 413 if platforms.is_gce(): | 413 if platforms.is_gce(): |
| 414 if platforms.gce.get_zone().startswith('us-'): | 414 if platforms.gce.get_zone().startswith('us-'): |
| 415 machine_cost = GCE_MACHINE_COST_HOUR_US[machine_type] | 415 machine_cost = GCE_MACHINE_COST_HOUR_US.get(machine_type, 0.) |
|
borenet
2017/04/07 12:19:25
I suspect we'll want a default, eg. GCE_MACHINE_CO
M-A Ruel
2017/04/07 12:20:16
Bah, I prefer 0 than something really wrong. I don
| |
| 416 else: | 416 else: |
| 417 machine_cost = GCE_MACHINE_COST_HOUR_EUROPE_ASIA[machine_type] | 417 machine_cost = GCE_MACHINE_COST_HOUR_EUROPE_ASIA.get(machine_type, 0.) |
| 418 else: | 418 else: |
| 419 # Guess an equivalent machine_type. | 419 # Guess an equivalent machine_type. |
| 420 machine_cost = GCE_MACHINE_COST_HOUR_US.get(machine_type, 0.) | 420 machine_cost = GCE_MACHINE_COST_HOUR_US.get(machine_type, 0.) |
| 421 | 421 |
| 422 # OS. | 422 # OS. |
| 423 os_cost = 0. | 423 os_cost = 0. |
| 424 if sys.platform == 'darwin': | 424 if sys.platform == 'darwin': |
| 425 # Apple tax. It's 50% better, right? | 425 # Apple tax. It's 50% better, right? |
| 426 os_cost = GCE_WINDOWS_COST_CORE_HOUR * 1.5 * get_num_processors() | 426 os_cost = GCE_WINDOWS_COST_CORE_HOUR * 1.5 * get_num_processors() |
| 427 elif sys.platform == 'win32': | 427 elif sys.platform == 'win32': |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1204 | 1204 |
| 1205 | 1205 |
| 1206 def trim_rolled_log(name): | 1206 def trim_rolled_log(name): |
| 1207 try: | 1207 try: |
| 1208 for item in glob.iglob('%s.??' % name): | 1208 for item in glob.iglob('%s.??' % name): |
| 1209 os.remove(item) | 1209 os.remove(item) |
| 1210 for item in glob.iglob('%s.???' % name): | 1210 for item in glob.iglob('%s.???' % name): |
| 1211 os.remove(item) | 1211 os.remove(item) |
| 1212 except Exception as e: | 1212 except Exception as e: |
| 1213 logging.exception('trim_rolled_log(%s) failed: %s', name, e) | 1213 logging.exception('trim_rolled_log(%s) failed: %s', name, e) |
| OLD | NEW |