Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1398)

Side by Side Diff: Tools/Scripts/webkitpy/common/system/user.py

Issue 633503003: [webkitpy] Remove leftover changelog editor methods from User. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Tools/Scripts/webkitpy/common/system/user_mock.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 25 matching lines...) Expand all
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.platforminfo import PlatformInfo 40 from webkitpy.common.system.platforminfo import PlatformInfo
41 41
42 42
43 _log = logging.getLogger(__name__) 43 _log = logging.getLogger(__name__)
44 44
45 45
46 try:
47 import readline
48 except ImportError:
49 if sys.platform != "win32":
50 # There is no readline module for win32, not much to do except cry.
51 _log.warn("Unable to import readline.")
52
53
54 class User(object): 46 class User(object):
55 DEFAULT_NO = 'n' 47 DEFAULT_NO = 'n'
56 DEFAULT_YES = 'y' 48 DEFAULT_YES = 'y'
57 49
58 def __init__(self, platforminfo=None): 50 def __init__(self, platforminfo=None):
59 # We cannot get the PlatformInfo object from a SystemHost because 51 # We cannot get the PlatformInfo object from a SystemHost because
60 # User is part of SystemHost itself. 52 # User is part of SystemHost itself.
61 self._platforminfo = platforminfo or PlatformInfo(sys, platform, Executi ve()) 53 self._platforminfo = platforminfo or PlatformInfo(sys, platform, Executi ve())
62 54
63 # FIXME: These are @classmethods because bugzilla.py doesn't have a Tool obj ect (thus no User instance). 55 # FIXME: These are @classmethods because bugzilla.py doesn't have a Tool obj ect (thus no User instance).
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 i += 1 113 i += 1
122 print "%2d. %s" % (i, item) 114 print "%2d. %s" % (i, item)
123 return cls._wait_on_list_response(list_items, can_choose_multiple, raw_i nput) 115 return cls._wait_on_list_response(list_items, can_choose_multiple, raw_i nput)
124 116
125 def edit(self, files): 117 def edit(self, files):
126 editor = os.environ.get("EDITOR") or "vi" 118 editor = os.environ.get("EDITOR") or "vi"
127 args = shlex.split(editor) 119 args = shlex.split(editor)
128 # Note: Not thread safe: http://bugs.python.org/issue2320 120 # Note: Not thread safe: http://bugs.python.org/issue2320
129 subprocess.call(args + files) 121 subprocess.call(args + files)
130 122
131 def _warn_if_application_is_xcode(self, edit_application):
132 if "Xcode" in edit_application:
133 print "Instead of using Xcode.app, consider using EDITOR=\"xed --wai t\"."
134
135 def edit_changelog(self, files):
136 edit_application = os.environ.get("CHANGE_LOG_EDIT_APPLICATION")
137 if edit_application and self._platforminfo.is_mac():
138 # On Mac we support editing ChangeLogs using an application.
139 args = shlex.split(edit_application)
140 print "Using editor in the CHANGE_LOG_EDIT_APPLICATION environment v ariable."
141 print "Please quit the editor application when done editing."
142 self._warn_if_application_is_xcode(edit_application)
143 subprocess.call(["open", "-W", "-n", "-a"] + args + files)
144 return
145 self.edit(files)
146
147 def page(self, message): 123 def page(self, message):
148 pager = os.environ.get("PAGER") or "less" 124 pager = os.environ.get("PAGER") or "less"
149 try: 125 try:
150 # Note: Not thread safe: http://bugs.python.org/issue2320 126 # Note: Not thread safe: http://bugs.python.org/issue2320
151 child_process = subprocess.Popen([pager], stdin=subprocess.PIPE) 127 child_process = subprocess.Popen([pager], stdin=subprocess.PIPE)
152 child_process.communicate(input=message) 128 child_process.communicate(input=message)
153 except IOError, e: 129 except IOError, e:
154 pass 130 pass
155 131
156 def confirm(self, message=None, default=DEFAULT_YES, raw_input=raw_input): 132 def confirm(self, message=None, default=DEFAULT_YES, raw_input=raw_input):
157 if not message: 133 if not message:
158 message = "Continue?" 134 message = "Continue?"
159 choice = {'y': 'Y/n', 'n': 'y/N'}[default] 135 choice = {'y': 'Y/n', 'n': 'y/N'}[default]
160 response = raw_input("%s [%s]: " % (message, choice)) 136 response = raw_input("%s [%s]: " % (message, choice))
161 if not response: 137 if not response:
162 response = default 138 response = default
163 return response.lower() == 'y' 139 return response.lower() == 'y'
164 140
165 def can_open_url(self): 141 def can_open_url(self):
166 try: 142 try:
167 webbrowser.get() 143 webbrowser.get()
168 return True 144 return True
169 except webbrowser.Error, e: 145 except webbrowser.Error, e:
170 return False 146 return False
171 147
172 def open_url(self, url): 148 def open_url(self, url):
173 if not self.can_open_url(): 149 if not self.can_open_url():
174 _log.warn("Failed to open %s" % url) 150 _log.warn("Failed to open %s" % url)
175 webbrowser.open(url) 151 webbrowser.open(url)
OLDNEW
« no previous file with comments | « no previous file | Tools/Scripts/webkitpy/common/system/user_mock.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698