OLD | NEW |
1 # Copyright (c) 2009, Google Inc. All rights reserved. | 1 # Copyright (c) 2009, 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 19 matching lines...) Expand all Loading... |
30 import logging | 30 import logging |
31 import os | 31 import os |
32 import platform | 32 import platform |
33 import re | 33 import re |
34 import shlex | 34 import shlex |
35 import subprocess | 35 import subprocess |
36 import sys | 36 import sys |
37 import webbrowser | 37 import webbrowser |
38 | 38 |
39 from webkitpy.common.system.executive import Executive | 39 from webkitpy.common.system.executive import Executive |
| 40 from webkitpy.common.system.filesystem import FileSystem |
40 from webkitpy.common.system.platforminfo import PlatformInfo | 41 from webkitpy.common.system.platforminfo import PlatformInfo |
41 | 42 |
42 | 43 |
43 _log = logging.getLogger(__name__) | 44 _log = logging.getLogger(__name__) |
44 | 45 |
45 | 46 |
46 class User(object): | 47 class User(object): |
47 DEFAULT_NO = 'n' | 48 DEFAULT_NO = 'n' |
48 DEFAULT_YES = 'y' | 49 DEFAULT_YES = 'y' |
49 | 50 |
50 def __init__(self, platforminfo=None): | 51 def __init__(self, platforminfo=None): |
51 # We cannot get the PlatformInfo object from a SystemHost because | 52 # We cannot get the PlatformInfo object from a SystemHost because |
52 # User is part of SystemHost itself. | 53 # User is part of SystemHost itself. |
53 self._platforminfo = platforminfo or PlatformInfo(sys, platform, Executi
ve()) | 54 self._platforminfo = platforminfo or PlatformInfo(sys, platform, FileSys
tem(), Executive()) |
54 | 55 |
55 # FIXME: These are @classmethods because bugzilla.py doesn't have a Tool obj
ect (thus no User instance). | 56 # FIXME: These are @classmethods because bugzilla.py doesn't have a Tool obj
ect (thus no User instance). |
56 @classmethod | 57 @classmethod |
57 def prompt(cls, message, repeat=1, raw_input=raw_input): | 58 def prompt(cls, message, repeat=1, raw_input=raw_input): |
58 response = None | 59 response = None |
59 while (repeat and not response): | 60 while (repeat and not response): |
60 repeat -= 1 | 61 repeat -= 1 |
61 response = raw_input(message) | 62 response = raw_input(message) |
62 return response | 63 return response |
63 | 64 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 try: | 143 try: |
143 webbrowser.get() | 144 webbrowser.get() |
144 return True | 145 return True |
145 except webbrowser.Error, e: | 146 except webbrowser.Error, e: |
146 return False | 147 return False |
147 | 148 |
148 def open_url(self, url): | 149 def open_url(self, url): |
149 if not self.can_open_url(): | 150 if not self.can_open_url(): |
150 _log.warn("Failed to open %s" % url) | 151 _log.warn("Failed to open %s" % url) |
151 webbrowser.open(url) | 152 webbrowser.open(url) |
OLD | NEW |