Skip to content

Commit 39a69be

Browse files
committed
Update grammar bundles To circumvent subl path blunder
the documentation up to now was missing a critical step for installation namely putting the directory 'C:\\Program Files\\Sublime Text 3' Where the executable subl was located, in the path. With this commit, if subl is not in the path, then we fall back to the classical install directory!
1 parent 45c62c4 commit 39a69be

File tree

3 files changed

+78
-6
lines changed

3 files changed

+78
-6
lines changed

bundles/Caster/python_voice_coding_plugin_caster_v0-5-11.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
#########################################################################################
3939

40-
GRAMMAR_VERSION = (0,1,1)
40+
GRAMMAR_VERSION = (0,1,2)
4141

4242
#########################################################################################
4343

@@ -49,10 +49,34 @@ def create_arguments(command,format,**kwargs):
4949
return {"arg":p}
5050

5151

52+
53+
def validate_subl():
54+
if platform.system() != 'Windows':
55+
return "subl"
56+
try:
57+
subprocess.check_call(["subl", "-h"],stdout=subprocess.PIPE,stderr=subprocess.PIPE) # For testing purposes you can invalidate to trigger failure
58+
return "subl"
59+
except Exception as e:
60+
try :
61+
subprocess.check_call(["C:\\Program Files\\Sublime Text 3\\subl", "-h"],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
62+
print("Resorting to C:\\Program Files\\Sublime Text 3\\subl.exe")
63+
return "C:\\Program Files\\Sublime Text 3\\subl"
64+
except :
65+
print("Sublime Text 3 `subl` executable was not in the Windows path")
66+
if not os.path.isdir(r'C:\\Program Files\\Sublime Text 3'):
67+
print("And there is no C:\\Program Files\\Sublime Text 3 directory to fall back to!")
68+
else:
69+
print("And it was not found under C:\\Program Files\\Sublime Text 3")
70+
print("Please add `subl` to the path manually")
71+
return "subl"
72+
73+
subl = validate_subl()
74+
75+
5276
def send_sublime(c,data):
5377
if local_settings["show_command"]:
5478
print(c + " " + json.dumps(data))
55-
subprocess.Popen(["subl","-b", "--command",c + " " + json.dumps(data)],creationflags = 0x08000000)
79+
RunCommand([subl,"-b", "--command",c + " " + json.dumps(data)],synchronous = True).execute()
5680

5781
def noob_send(command,format,**kwargs):
5882
data = create_arguments(command,format,**kwargs)

bundles/Caster/python_voice_coding_plugin_caster_v0-6-11.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
#########################################################################################
3939

40-
GRAMMAR_VERSION = (0,1,1)
40+
GRAMMAR_VERSION = (0,1,2)
4141

4242
#########################################################################################
4343

@@ -49,10 +49,34 @@ def create_arguments(command,format,**kwargs):
4949
return {"arg":p}
5050

5151

52+
53+
def validate_subl():
54+
if platform.system() != 'Windows':
55+
return "subl"
56+
try:
57+
subprocess.check_call(["subl", "-h"],stdout=subprocess.PIPE,stderr=subprocess.PIPE) # For testing purposes you can invalidate to trigger failure
58+
return "subl"
59+
except Exception as e:
60+
try :
61+
subprocess.check_call(["C:\\Program Files\\Sublime Text 3\\subl", "-h"],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
62+
print("Resorting to C:\\Program Files\\Sublime Text 3\\subl.exe")
63+
return "C:\\Program Files\\Sublime Text 3\\subl"
64+
except :
65+
print("Sublime Text 3 `subl` executable was not in the Windows path")
66+
if not os.path.isdir(r'C:\\Program Files\\Sublime Text 3'):
67+
print("And there is no C:\\Program Files\\Sublime Text 3 directory to fall back to!")
68+
else:
69+
print("And it was not found under C:\\Program Files\\Sublime Text 3")
70+
print("Please add `subl` to the path manually")
71+
return "subl"
72+
73+
subl = validate_subl()
74+
75+
5276
def send_sublime(c,data):
5377
if local_settings["show_command"]:
5478
print(c + " " + json.dumps(data))
55-
RunCommand(["subl","-b", "--command",c + " " + json.dumps(data)],synchronous = True).execute()
79+
RunCommand([subl,"-b", "--command",c + " " + json.dumps(data)],synchronous = True).execute()
5680

5781
def noob_send(command,format,**kwargs):
5882
data = create_arguments(command,format,**kwargs)

bundles/Caster/python_voice_coding_plugin_caster_v1-0-0.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
#########################################################################################
3838

39-
GRAMMAR_VERSION = (0,1,1)
39+
GRAMMAR_VERSION = (0,1,2)
4040

4141
#########################################################################################
4242

@@ -48,10 +48,34 @@ def create_arguments(command,format,**kwargs):
4848
return {"arg":p}
4949

5050

51+
52+
def validate_subl():
53+
if platform.system() != 'Windows':
54+
return "subl"
55+
try:
56+
subprocess.check_call(["subl", "-h"],stdout=subprocess.PIPE,stderr=subprocess.PIPE) # For testing purposes you can invalidate to trigger failure
57+
return "subl"
58+
except Exception as e:
59+
try :
60+
subprocess.check_call(["C:\\Program Files\\Sublime Text 3\\subl", "-h"],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
61+
print("Resorting to C:\\Program Files\\Sublime Text 3\\subl.exe")
62+
return "C:\\Program Files\\Sublime Text 3\\subl"
63+
except :
64+
print("Sublime Text 3 `subl` executable was not in the Windows path")
65+
if not os.path.isdir(r'C:\\Program Files\\Sublime Text 3'):
66+
print("And there is no C:\\Program Files\\Sublime Text 3 directory to fall back to!")
67+
else:
68+
print("And it was not found under C:\\Program Files\\Sublime Text 3")
69+
print("Please add `subl` to the path manually")
70+
return "subl"
71+
72+
subl = validate_subl()
73+
74+
5175
def send_sublime(c,data):
5276
if local_settings["show_command"]:
5377
print(c + " " + json.dumps(data))
54-
RunCommand(["subl","-b", "--command",c + " " + json.dumps(data)],synchronous = True).execute()
78+
RunCommand([subl,"-b", "--command",c + " " + json.dumps(data)],synchronous = True).execute()
5579

5680

5781
def noob_send(command,format,**kwargs):

0 commit comments

Comments
 (0)