本文整理汇总了Python中sublime.error_message函数的典型用法代码示例。如果您正苦于以下问题:Python error_message函数的具体用法?Python error_message怎么用?Python error_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了error_message函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: add_done
def add_done(self, message, result):
if result.strip():
sublime.error_message("Error adding file:\n" + result)
return
self.run_command(['git', 'commit', '-m', message],
callback=self.update_status)
开发者ID:Eun,项目名称:sublime-text-git-autocommit,代码行数:7,代码来源:git-autocommit.py
示例2: run
def run(self, edit):
fname = self.view.file_name()
if not fname:
sublime.error_message("Save the file!")
return
cmd = "source(\"" + escape_dq(fname) + "\")"
sendtext(cmd)
开发者ID:vnijs,项目名称:R-Box,代码行数:7,代码来源:sendtext.py
示例3: copy_linter
def copy_linter(self, name):
"""Copy the template linter to a new linter with the given name."""
self.name = name
self.fullname = 'SublimeLinter-contrib-{}'.format(name)
self.dest = os.path.join(sublime.packages_path(), self.fullname)
if os.path.exists(self.dest):
sublime.error_message('The plugin “{}” already exists.'.format(self.fullname))
return
src = os.path.join(sublime.packages_path(), persist.PLUGIN_DIRECTORY, 'linter-plugin-template')
self.temp_dir = None
try:
self.temp_dir = tempfile.mkdtemp()
self.temp_dest = os.path.join(self.temp_dir, self.fullname)
shutil.copytree(src, self.temp_dest)
self.get_linter_language(name, self.configure_linter)
except Exception as ex:
if self.temp_dir and os.path.exists(self.temp_dir):
shutil.rmtree(self.temp_dir)
sublime.error_message('An error occurred while copying the template plugin: {}'.format(str(ex)))
开发者ID:1901,项目名称:sublime_sync,代码行数:26,代码来源:commands.py
示例4: run
def run(self, edit):
template_filename = self.view.file_name()
self.dissect_filename(template_filename)
if not template_filename:
return sublime.error_message("You have to provide a template path.")
if not self.action.startswith("eton"):
return sublime.error_message("Invalid eton template %s" % template_filename)
if not os.path.exists(template_filename):
return sublime.error_message("File does not exist")
self.url = get_url(self.settings) + self.COMMAND_URL+self.partner+'/'+self.action.replace('eton_','')
# get file names
file_names = json.dumps(self.generate_file_list())
use_cache = self.settings.get('use_cache', DEFAULT_USE_CACHE_SETTING)
print("Attempting to render %s for %s" % (self.action, self.partner))
print("url is %s" % self.url)
params = dict(partner=self.partner,
action=self.action,
templates= json.dumps(self.generate_file_map()))
try:
response = urlopen(self.url, urllib.parse.urlencode(params).encode("utf-8"))
except urllib.error.URLError as e:
print(e)
return str(e)
temp = tempfile.NamedTemporaryFile(delete=False, suffix=".html")
temp.write(response.read())
temp.close()
webbrowser.open("file://"+temp.name)
开发者ID:TriggerMail,项目名称:triggermail_sublimetext_plugin,代码行数:31,代码来源:triggermail_templates.py
示例5: protocol
def protocol(self, req):
self.buf += req
while True:
before, sep, after = self.buf.partition(NEWLINE)
if not sep:
break
try:
# Node.js sends invalid utf8 even though we're calling write(string, "utf8")
# Python 2 can figure it out, but python 3 hates it and will die here with some byte sequences
# Instead of crashing the plugin, we drop the data. Yes, this is horrible.
before = before.decode('utf-8', 'ignore')
data = json.loads(before)
except Exception as e:
msg.error('Unable to parse json: %s' % str(e))
msg.error('Data: %s' % before)
# XXXX: THIS LOSES DATA
self.buf = after
continue
name = data.get('name')
try:
if name == 'error':
message = 'Floobits: Error! Message: %s' % str(data.get('msg'))
msg.error(message)
if data.get('flash'):
sublime.error_message('Floobits: %s' % str(data.get('msg')))
elif name == 'disconnect':
message = 'Floobits: Disconnected! Reason: %s' % str(data.get('reason'))
msg.error(message)
sublime.error_message(message)
self.stop()
else:
self.handler(name, data)
except Exception as e:
msg.error('Error handling %s event with data %s: %s' % (name, data, e))
self.buf = after
开发者ID:chenkaigithub,项目名称:floobits-sublime,代码行数:35,代码来源:agent_connection.py
示例6: __createArchiveFilename
def __createArchiveFilename(self):
# Create our archive filename, from the mask in our settings.
# Split filename int dir, base, and extension, then apply our mask
path_base, extension = os.path.splitext(self.view.file_name())
dir = os.path.dirname(path_base)
base = os.path.basename(path_base)
sep = os.sep
# Now build our new filename
try:
# This could fail, if someone messed up the mask in the
# settings. So, if it did fail, use our default.
archive_filename = self.archive_org_filemask.format(
dir=dir, base=base, ext=extension, sep=sep)
except:
# Use our default mask
archive_filename = self.archive_org_default_filemask.format(
dir=dir, base=base, ext=extension, sep=sep)
# Display error, letting the user know
sublime.error_message(u"Error:\n\nInvalid filemask:{0}\nUsing default: {1}".format(
self.archive_org_filemask, self.archive_org_default_filemask))
return archive_filename
开发者ID:chenmo1996,项目名称:sublimeBackups,代码行数:25,代码来源:PlainTasks.py
示例7: run
def run(self, edit, **args):
DEFAULT_FORMAT = '%Y-%m-%d'
view = self.view
date_format = get_setting(view, 'jekyll_date_format', '%Y-%m-%d')
datetime_format = get_setting(view, 'jekyll_datetime_format', '%Y-%m-%d %H:%M:%S')
try:
d = datetime.today()
if args['format'] and args['format'] == 'date':
text = d.strftime(date_format)
elif args['format'] and args['format'] == 'datetime':
text = d.strftime(datetime_format)
else:
text = d.strftime(DEFAULT_FORMAT)
except Exception as e:
sublime.error_message('Jekyll: {0}: {1}'.format(type(e).__name__, e))
return
# Don't bother replacing selections if no text exists
if text == '' or text.isspace():
return
# Do replacements
for r in self.view.sel():
# Insert when sel is empty to not select the contents
if r.empty():
self.view.insert(edit, r.a, text)
else:
self.view.replace(edit, r, text)
开发者ID:nighthawk,项目名称:sublime-jekyll,代码行数:35,代码来源:jekyll.py
示例8: update_build_settings
def update_build_settings(self, settings):
val = settings.get("ANSI_process_trigger", "on_finish")
if val in ["on_finish", "on_data"]:
self.process_trigger = val
else:
self.process_trigger = None
sublime.error_message("ANSIescape settings warning:\n\nThe setting ANSI_process_trigger has been set to an invalid value; must be one of 'on_finish' or 'on_data'.")
开发者ID:UNIVERSAL-IT-SYSTEMS,项目名称:SublimeANSI,代码行数:7,代码来源:ansi.py
示例9: run
def run(self, edit):
selections = self.get_selections()
CompilerCall = self.get_minifier()
if CompilerCall is None:
sublime.error_message('Please focus on the file you wish to minify.')
else:
threads = []
for sel in selections:
selbody = self.view.substr(sel)
thread = CompilerCall(
sel,
selbody,
timeout=self.settings.get('timeout', 5),
level=self.settings.get('optimization_level', 'WHITESPACE_ONLY'),
rm_new_lines=self.settings.get('remove_new_lines', False))
threads.append(thread)
thread.start()
# Wait for threads
for thread in threads:
thread.join()
selections.clear()
self.handle_threads(edit, threads, selections, offset=0, i=0, dir=1)
开发者ID:Mirovinger,项目名称:Sublime-Minifier,代码行数:28,代码来源:Minify.py
示例10: curl_convert
def curl_convert(self, data):
try:
import subprocess
# It looks like the text does NOT need to be escaped and
# surrounded with double quotes.
# Tested in ubuntu 13.10, python 2.7.5+
shell_safe_json = data.decode("utf-8")
curl_args = [
"curl",
"-H",
"Content-Type: application/json",
"-d",
shell_safe_json,
"https://api.github.com/markdown",
]
github_oauth_token = self.settings.get("github_oauth_token")
if github_oauth_token:
curl_args[1:1] = ["-u", github_oauth_token]
markdown_html = subprocess.Popen(curl_args, stdout=subprocess.PIPE).communicate()[0].decode("utf-8")
return markdown_html
except subprocess.CalledProcessError:
sublime.error_message(
"cannot use github API to convert markdown. SSL is not included in your Python installation. And using curl didn't work either"
)
return None
开发者ID:kinjo1506,项目名称:sublimetext-markdown-preview,代码行数:28,代码来源:MarkdownPreview.py
示例11: parser_specific_convert
def parser_specific_convert(self, markdown_text):
import subprocess
binary = self.settings.get("multimarkdown_binary", "")
if os.path.exists(binary):
cmd = [binary]
critic_mode = self.settings.get("strip_critic_marks", "accept")
if critic_mode in ("accept", "reject"):
cmd.append("-a" if critic_mode == "accept" else "-r")
sublime.status_message("converting markdown with multimarkdown...")
if sublime.platform() == "windows":
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
p = subprocess.Popen(
cmd, startupinfo=startupinfo, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
else:
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for line in markdown_text.split("\n"):
p.stdin.write((line + "\n").encode("utf-8"))
markdown_html = p.communicate()[0].decode("utf-8")
if p.returncode:
# Log info to console
sublime.error_message("Could not convert file! See console for more info.")
print(markdown_html)
markdown_html = _CANNOT_CONVERT
else:
sublime.error_message("Cannot find multimarkdown binary!")
markdown_html = _CANNOT_CONVERT
return markdown_html
开发者ID:kinjo1506,项目名称:sublimetext-markdown-preview,代码行数:30,代码来源:MarkdownPreview.py
示例12: open_in_browser
def open_in_browser(cls, path, browser="default"):
if browser == "default":
if sys.platform == "darwin":
# To open HTML files, Mac OS the open command uses the file
# associated with .html. For many developers this is Sublime,
# not the default browser. Getting the right value is
# embarrassingly difficult.
import shlex
import subprocess
env = {"VERSIONER_PERL_PREFER_32_BIT": "true"}
raw = """perl -MMac::InternetConfig -le 'print +(GetICHelper "http")[1]'"""
process = subprocess.Popen(shlex.split(raw), env=env, stdout=subprocess.PIPE)
out, err = process.communicate()
default_browser = out.strip().decode("utf-8")
cmd = "open -a '%s' %s" % (default_browser, path)
os.system(cmd)
else:
desktop.open(path)
sublime.status_message("Markdown preview launched in default browser")
else:
cmd = '"%s" %s' % (browser, path)
if sys.platform == "darwin":
cmd = "open -a %s" % cmd
elif sys.platform == "linux2":
cmd += " &"
elif sys.platform == "win32":
cmd = 'start "" %s' % cmd
result = os.system(cmd)
if result != 0:
sublime.error_message('cannot execute "%s" Please check your Markdown Preview settings' % browser)
else:
sublime.status_message("Markdown preview launched in %s" % browser)
开发者ID:kinjo1506,项目名称:sublimetext-markdown-preview,代码行数:33,代码来源:MarkdownPreview.py
示例13: SearchFor
def SearchFor(view, text, searchurl):
if not searchurl:
# see if we have an extension match first, then use default
settings = sublime.load_settings(__name__ + '.sublime-settings')
filename, ext = os.path.splitext(view.file_name())
typesettings = settings.get('searchanywhere_type_searchengine', [])
foundsetting = False
for typesetting in typesettings:
if typesetting['extension'] == ext:
foundsetting = True
searchurl = typesetting['searchurl']
if not foundsetting:
if settings.has('searchanywhere_searchurl'):
searchurl = settings.get('searchanywhere_searchurl')
else:
sublime.error_message(__name__ + ': No Search Engine selected')
return
else:
# search url is provided by the caller
pass
url = searchurl.replace('{0}', text.replace(' ','%20'))
webbrowser.open_new_tab(url)
开发者ID:sevensky,项目名称:MyST3Data,代码行数:26,代码来源:searchanywhere.py
示例14: handle_cwd
def handle_cwd(self, new_dir):
try:
if new_dir[0] == "~":
new_dir = os.getenv(self.home) + new_dir[1:]
os.chdir(new_dir)
except:
sublime.error_message(new_dir + " does not exist")
开发者ID:Jedius,项目名称:sublime-jed,代码行数:7,代码来源:sublime_files.py
示例15: process_status
def process_status(self, vcs, path):
global file_status_cache
settings = sublime.load_settings('Tortoise.sublime-settings')
if path in file_status_cache and file_status_cache[path]['time'] > \
time.time() - settings.get('cache_length'):
if settings.get('debug'):
print 'Fetching cached status for %s' % path
return file_status_cache[path]['status']
if settings.get('debug'):
start_time = time.time()
try:
status = vcs.check_status(path)
except (Exception) as (exception):
sublime.error_message(str(exception))
file_status_cache[path] = {
'time': time.time() + settings.get('cache_length'),
'status': status
}
if settings.get('debug'):
print 'Fetching status for %s in %s seconds' % (path,
str(time.time() - start_time))
return status
开发者ID:mesozoic,项目名称:sublime_tortoise,代码行数:27,代码来源:Tortoise.py
示例16: get_lint_version
def get_lint_version(cls):
""" Return the Pylint version as a (x, y, z) tuple """
pylint_path = cls.get_or('pylint_path', None)
python_bin = cls.get_or('python_bin', 'python')
found = None
regex = re.compile(b"[lint.py|pylint] ([0-9]+).([0-9]+).([0-9]+)")
if pylint_path:
command = [python_bin, pylint_path]
else:
command = list(DEFAULT_PYLINT_COMMAND)
command.append("--version")
try:
p = subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
startupinfo=STARTUPINFO)
output, _ = p.communicate()
found = regex.search(output)
except OSError:
msg = "Pylinter could not find '%s'" % command[-2]
sublime.error_message(msg)
if found:
found = found.groups()
if len(found) == 3:
version = tuple(int(v) for v in found)
speak("Pylint version %s found" % str(version))
return version
speak("Could not determine Pylint version")
return (1, 0, 0)
开发者ID:Mondego,项目名称:pyreco,代码行数:35,代码来源:allPythonContent.py
示例17: show_panel_or_open
def show_panel_or_open(self, fn, sym, line, col, text):
win = sublime.active_window()
self._current_res = list()
if sym:
for name, _, pos in win.lookup_symbol_in_index(sym):
if name.endswith(fn):
line, col = pos
self._current_res.append((name, line, col, "f"))
else:
fn = fn.replace('/', os.sep)
all_folders = win.folders() + [os.path.dirname(v.file_name()) for v in win.views() if v.file_name()]
for folder in set(all_folders):
for root, _, _ in os.walk(folder):
name = os.path.abspath(os.path.join(root, fn))
if os.path.isfile(name):
self._current_res.append((name, line or 0, col or 0, "f"))
if os.path.isdir(name):
self._current_res.append((name, 0, 0, "d"))
if os.path.isfile(fn): # check for full path
self._current_res.append((fn, line or 0, col or 0, "f"))
elif os.path.isdir(fn):
self._current_res.append((fn, 0, 0, "d"))
self._current_res = list(set(self._current_res))
if not self._current_res:
sublime.error_message('File was not found\n\n\t%s' % fn)
if len(self._current_res) == 1:
self._on_panel_selection(0)
else:
entries = [self._format_res(res) for res in self._current_res]
win.show_quick_panel(entries, self._on_panel_selection)
开发者ID:chenmo1996,项目名称:sublimeBackups,代码行数:30,代码来源:PlainTasks.py
示例18: process_errors
def process_errors(self, lines, errlines):
""" Process the error found """
view_id = self.view.id()
PYLINTER_ERRORS[view_id] = {"visible": True}
# if pylint raised any exceptions, propogate those to the user, for
# instance, trying to disable a messaage id that does not exist
if len(errlines) > 1:
err = errlines[-2]
if not err.startswith("No config file found"):
sublime.error_message("Fatal pylint error:\n%s" % (errlines[-2]))
for line in lines:
mdic = re.match(P_PYLINT_ERROR, line)
if mdic:
m = mdic.groupdict()
line_num = int(m['line']) - 1
if m['type'].lower() not in self.ignore:
PYLINTER_ERRORS[view_id][line_num] = \
"%s%s: %s " % (m['type'], m['errno'],
m['msg'].strip())
speak(PYLINTER_ERRORS[view_id][line_num])
if len(PYLINTER_ERRORS[view_id]) <= 1:
speak("No errors found")
PylinterCommand.show_errors(self.view)
开发者ID:Mondego,项目名称:pyreco,代码行数:27,代码来源:allPythonContent.py
示例19: transformations
def transformations(self):
'''Generates a ranked list of available transformations.'''
view = self.window.active_view()
# hash of transformation ranks
ranked = {}
for label, settings in _s('transformations').items():
for scope in settings['scope'].keys():
score = view.score_selector(0, scope)
if not score:
continue
if label not in ranked or ranked[label] < score:
ranked[label] = score
if not len(ranked):
sublime.error_message(
'No transformations configured for the syntax '
+ view.settings().get('syntax'))
return
# reverse sort
self.options = list(OrderedDict(sorted(
ranked.items(), key=lambda t: t[1])).keys())
self.options.reverse()
return self.options
开发者ID:akaiwolf,项目名称:sublimetext-Pandoc,代码行数:26,代码来源:Pandoc.py
示例20: on_input
def on_input(self, input):
if not input:
sublime.error_message("Please input job ids that is separated by ','")
return
job_ids = input.split(",")
processor.handle_close_jobs_thread(job_ids)
开发者ID:openPlugin,项目名称:SublimeApex,代码行数:7,代码来源:bulk.py
注:本文中的sublime.error_message函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论