@@ -35,6 +35,7 @@ def getConnections():
3535
3636 return connections
3737
38+ @staticmethod
3839 def userFolder ():
3940 return '{0}/User' .format (sublime .packages_path ())
4041
@@ -44,20 +45,24 @@ class Storage:
4445 savedQueries = None
4546 selectedQuery = ''
4647
48+ @staticmethod
4749 def getSavedQueries ():
4850 Storage .savedQueries = sublime .load_settings (Const .USER_QUERIES_FILENAME )
4951 return Storage .savedQueries
5052
53+ @staticmethod
5154 def flushSavedQueries ():
5255 if not Storage .savedQueries :
5356 Storage .getSavedQueries ()
5457
5558 return sublime .save_settings (Const .USER_QUERIES_FILENAME )
5659
60+ @staticmethod
5761 def promptQueryAlias ():
5862 Storage .selectedQuery = Selection .get ()
5963 Window ().show_input_panel ('Query alias' , '' , Storage .saveQuery , None , None )
6064
65+ @staticmethod
6166 def saveQuery (alias ):
6267 if len (alias ) <= 0 :
6368 return
@@ -67,6 +72,7 @@ def saveQuery(alias):
6772 Storage .flushSavedQueries ()
6873
6974
75+ @staticmethod
7076 def getSavedQuery (alias ):
7177 if len (alias ) <= 0 :
7278 return
@@ -102,6 +108,7 @@ def _info(self):
102108 def _quickPanel (self ):
103109 return [self .name , self ._info ()]
104110
111+ @staticmethod
105112 def killCommandAfterTimeout (command ):
106113 timeout = sublime .load_settings (Const .SETTINGS_FILENAME ).get ('thread_timeout' , 5000 )
107114 sublime .set_timeout (command .stop , timeout )
@@ -181,6 +188,7 @@ def getOptionsForSgdbCli(self):
181188
182189
183190class Selection :
191+ @staticmethod
184192 def get ():
185193 text = []
186194 if View ().sel ():
@@ -191,6 +199,7 @@ def get():
191199 text .append (View ().substr (region ))
192200 return text
193201
202+ @staticmethod
194203 def formatSql (edit ):
195204 for region in View ().sel ():
196205 if region .empty ():
@@ -219,9 +228,10 @@ def run(self):
219228 self .tmp .write (self .query )
220229 self .tmp .close ()
221230
231+ self .args = map (str , self .args )
222232 self .process = subprocess .Popen (self .args , stdout = subprocess .PIPE ,stderr = subprocess .PIPE , stdin = open (self .tmp .name ))
223233
224- results , errors = self .process .communicate (input = self . query . encode ( 'utf-8' ) )
234+ results , errors = self .process .communicate ()
225235
226236 if errors :
227237 self .callback (errors .decode ('utf-8' , 'replace' ).replace ('\r ' , '' ))
@@ -244,6 +254,7 @@ def stop(self):
244254 os .unlink (self .tmp .name )
245255
246256class Utils :
257+ @staticmethod
247258 def getResultAsList (results , callback = None ):
248259 resultList = []
249260 for result in results .splitlines ():
@@ -257,6 +268,7 @@ def getResultAsList(results, callback=None):
257268
258269 return resultList
259270
271+ @staticmethod
260272 def formatSql (raw ):
261273 settings = sublime .load_settings (Const .SETTINGS_FILENAME ).get ("format" )
262274 try :
@@ -279,11 +291,13 @@ def formatSql(raw):
279291class History :
280292 queries = []
281293
294+ @staticmethod
282295 def add (query ):
283296 if len (History .queries ) >= sublime .load_settings (Const .SETTINGS_FILENAME ).get ('history_size' , 100 ):
284297 History .queries .pop (0 )
285298 History .queries .append (query )
286299
300+ @staticmethod
287301 def get (index ):
288302 if index < 0 or index > (len (History .queries ) - 1 ):
289303 raise "No query selected"
0 commit comments