-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathBrowserRefresh.py
81 lines (59 loc) · 2.16 KB
/
BrowserRefresh.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
import os
import sys
import platform
import sublime
import sublime_plugin
# Fix windows imports
__file__ = os.path.normpath(os.path.abspath(__file__))
__path__ = os.path.dirname(__file__)
if __path__ not in sys.path:
sys.path.insert(0, __path__)
_pywinauto = os.path.join(__path__ + os.path.sep + 'win')
if _pywinauto not in sys.path:
sys.path.insert(0, _pywinauto)
class BrowserRefreshCommand(sublime_plugin.TextCommand):
def run(self, args, activate=True,
browsers=['chrome'], auto_save=True, delay=None):
_os = platform.system()
# Auto-save
if auto_save and self.view and self.view.is_dirty():
self.view.run_command('save')
# Detect OS and import
if _os == 'Darwin':
from mac import MacBrowserRefresh
refresher = MacBrowserRefresh(activate)
elif _os == 'Windows':
from win import WinBrowserRefresh
refresher = WinBrowserRefresh(activate)
elif _os == 'Linux':
from linux import LinuxBrowserRefresh
refresher = LinuxBrowserRefresh(activate)
else:
sublime.error_message('Your operating system is not supported')
# Delay refresh
if delay is not None:
import time
time.sleep(delay)
# Actually refresh browsers
if 'chrome' in browsers:
refresher.chrome()
if 'canary' in browsers and _os == 'Darwin':
refresher.canary()
if 'yandex' in browsers and _os == 'Darwin':
refresher.yandex()
if 'safari' in browsers:
refresher.safari()
if 'webkit' in browsers and _os == 'Darwin':
refresher.webkit()
if 'firefox' in browsers:
refresher.firefox()
if 'firefoxdev' in browsers and _os == 'Darwin':
refresher.firefox_dev()
if 'opera' in browsers:
refresher.opera()
if 'ie' in browsers and _os == 'Windows':
refresher.ie()
if 'iron' in browsers and _os == 'Windows':
refresher.iron()
if 'palemoon' in browsers and _os == 'Windows':
refresher.palemoon()