Skip to content

Commit

Permalink
modify for st3211
Browse files Browse the repository at this point in the history
  • Loading branch information
Haiquan-27 committed Feb 26, 2022
1 parent b83722f commit 70a4216
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
11 changes: 7 additions & 4 deletions ssh_controller.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import sublime
import sublime_plugin
import paramiko
import importlib
import util
importlib.reload(util)
# import importlib
# import util
# importlib.reload(util)
from util import *
import os
import stat
Expand Down Expand Up @@ -356,7 +356,10 @@ def get_new_channel(self):
def exec_command(self,command):
chan = self.get_new_channel()
chan.exec_command(command)
stdin = chan.makefile_stdin("wb", -1)
try:
stdin = chan.makefile_stdin("wb", -1)
except:
stdin = None
stdout = chan.makefile("r", -1)
stderr = chan.makefile_stderr("r", -1)
return {
Expand Down
42 changes: 24 additions & 18 deletions ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import sublime_plugin
import os
import json
import importlib
import re
import time
import ssh_controller
importlib.reload(ssh_controller)
# import importlib
# import ssh_controller
# importlib.reload(ssh_controller)
from ssh_controller import *
import util
importlib.reload(util)
# import util
# importlib.reload(util)
from util import *


Expand Down Expand Up @@ -64,11 +64,16 @@ def on_highlight(index):
error_parameter_list = UserSettings.check_config_error(user_config,auth_method)
self.select = (server_name,user_config,error_parameter_list)
for p_name,p_value in user_config.items():
html_ele += html_ele_tmp.format(
style='error' if p_name in error_parameter_list else
'keyword' if p_value != default_settings.get(p_name,None) else
'info',
line = "%s : %s"%(p_name,p_value))
if int(sublime.version()) >= 4000:
html_ele += html_ele_tmp.format(
style='error' if p_name in error_parameter_list else
'keyword' if p_value != default_settings.get(p_name,None) else
'info',
line = "%s : %s"%(p_name,p_value))
else:
html_ele += html_ele_tmp.format(
style='info',
line = "%s : %s"%(p_name,p_value))
self.window.run_command(
cmd="ssh_panel_output",
args={
Expand Down Expand Up @@ -454,15 +459,16 @@ def resource_info(id):
resource_path = self.path_by_resource(resource)
resource_stat = self.client.sftp_client.lstat(resource_path)
html_ele = """
<p><span class='keyword'>path:</span>{path}<p>
<p><span class='keyword'>is directory:</span>{is_dir}<p>
<p><span class='keyword'>uid:</span>{uid}<p>
<p><span class='keyword'>gid:</span>{gid}<p>
<p><span class='keyword'>mode:</span>{mode}<p>
<p><span class='keyword'>size:</span>{size}<p>
<p><span class='keyword'>access time:</span>{atime}<p>
<p><span class='keyword'>modify time:</span>{mtime}<p>
<p><span class='{style}'>path:</span>{path}<p>
<p><span class='{style}'>is directory:</span>{is_dir}<p>
<p><span class='{style}'>uid:</span>{uid}<p>
<p><span class='{style}'>gid:</span>{gid}<p>
<p><span class='{style}'>mode:</span>{mode}<p>
<p><span class='{style}'>size:</span>{size}<p>
<p><span class='{style}'>access time:</span>{atime}<p>
<p><span class='{style}'>modify time:</span>{mtime}<p>
""".format(
style = "keyword" if int(sublime.version()) >= 4000 else "info",
path = resource_path,
is_dir = resource["is_dir"],
uid = resource_stat.st_uid,
Expand Down
12 changes: 9 additions & 3 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _msg_format(self,msg_type,msg_title,msg_content):
"info":"<p class=info>Info:%s</p>"%msg_title,
"debug":"<p class=debug>Debug:%s</p>"%msg_title,
}[msg_type]
if isinstance(msg_content,dict):
if isinstance(msg_content,dict) and int(sublime.version()) >= 4000:
for k,v in msg_content.items():
console_content += "%s : %s \n"%(k,v)
html_ele += "<p style='padding-left:10px' class='keyword'><span>%s:</span>%s</p>"%(k,v)
Expand Down Expand Up @@ -145,7 +145,10 @@ def run(self,edit,
output_panel_phantomSet = sublime.PhantomSet(panel_view)
if clean:
output_panel_phantom_list=[]
output_panel_phantomSet.update([])
try: # st3 bug
output_panel_phantomSet.update([])
except:
output_panel_phantomSet = sublime.PhantomSet(panel_view)
panel_view.erase(edit,sublime.Region(0,panel_view.size()))
if new_line:
panel_view.insert(edit,panel_view.size(),"\n")
Expand All @@ -157,7 +160,10 @@ def run(self,edit,
sublime.LAYOUT_INLINE
)
)
output_panel_phantomSet.update(output_panel_phantom_list)
try: # st3 bug
output_panel_phantomSet.update(output_panel_phantom_list)
except:
output_panel_phantomSet = sublime.PhantomSet(panel_view)
panel_view.insert(edit,panel_view.size(),"\n")
else:
panel_view.insert(edit,panel_view.size(),content.rstrip())
Expand Down

0 comments on commit 70a4216

Please sign in to comment.