-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_init_check.py
116 lines (87 loc) · 3.29 KB
/
_init_check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Copyright (c) 2014, Guillermo López-Anglada. Please see the AUTHORS file for details.
# All rights reserved. Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.)
'''
This module is intended to run first thing when ST loads modules in this package.
It should perform a basic status check so that we can catch severe
configuration errors early on and report them to the user.
'''
import os
import sublime
import sublime_plugin
from Dart.lib import ga
from Dart.lib.error import FatalConfigError
from Dart.lib.sdk import SDK
from Dart.sublime_plugin_lib.io import touch
from Dart.sublime_plugin_lib.panels import OutputPanel
HEADING = '''
Dart Package for Sublime Text
================================================================================
___ _
/ _ \ ___ ___ _ __ ___| |
| | | |/ _ \ / _ \| '_ \/ __| |
| |_| | (_) | (_) | |_) \__ \_|
\___/ \___/ \___/| .__/|___(_)
|_|
Something went wrong... :-[
This is an automatic report from the Dart package for Sublime Text.
Most likely, your settings are off. For help, check out:
* https://github.com/guillermooo/dart-sublime-bundle/wiki/Installation%20and%20Basic%20Configuration
To see a summary of your current settings, open the command palette and select
"Dart: Check Configuration".
---
If you're having trouble running this package, please open an issue in our
issue tracker[1] and paste as much information as possible from the report
below.
[1] https://github.com/dart-lang/dart-sublime-bundle/issues
'''
def check_install():
install_record = os.path.join(sublime.packages_path(),
'User/sublime-dart-plugin-installed.txt')
if os.path.exists(install_record):
return
touch(install_record)
with open(install_record, 'wt') as f:
f.write('autogenerated file. please do not delete.')
ga.Event(category='actions',
action='install',
label='Plugin installed',
value=1,
).send()
def check():
try:
SDK().check_for_critical_configuration_errors()
except FatalConfigError as e:
sublime.active_window().run_command('_dart_report_config_errors', {
'message': str(e)
})
def plugin_loaded():
check()
check_install()
class _dart_report_config_errors(sublime_plugin.WindowCommand):
'''
Shows config errors in an output panel.
'''
def run(self, message):
v = OutputPanel('dart.config.check')
text = HEADING + '\n'
text += ('=' * 80) + '\n'
text += 'MESSAGE:\n'
text += message + '\n'
text += '\n'
text += 'CONFIGURATION:\n'
text += ('-' * 80) + '\n'
text += "editor version: {} ({})".format(sublime.version(),
sublime.channel())
text += '\n'
text += ('-' * 80) + '\n'
text += "os: {} ({})".format(sublime.platform(),
sublime.arch())
text += '\n'
text += ('-' * 80) + '\n'
setts = sublime.load_settings('Dart - Plugin Settings.sublime-settings')
text += "dart_sdk_path: {}".format(setts.get('dart_sdk_path'))
text += '\n'
text += '=' * 80
v.write(text)
v.show()