mirror of
https://github.com/wakatime/sublime-wakatime.git
synced 2023-08-10 21:13:02 +03:00
cross-platform Popen with hidden window
This commit is contained in:
parent
bbf5761e26
commit
b39eefb4f5
20
WakaTime.py
20
WakaTime.py
@ -18,6 +18,7 @@ import json
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import threading
|
||||
@ -25,7 +26,7 @@ import traceback
|
||||
import urllib
|
||||
import webbrowser
|
||||
from datetime import datetime
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
from subprocess import STDOUT, PIPE
|
||||
from zipfile import ZipFile
|
||||
try:
|
||||
import _winreg as winreg # py2
|
||||
@ -42,6 +43,8 @@ except ImportError:
|
||||
|
||||
is_py2 = (sys.version_info[0] == 2)
|
||||
is_py3 = (sys.version_info[0] == 3)
|
||||
is_win = platform.system() == 'Windows'
|
||||
|
||||
|
||||
if is_py2:
|
||||
def u(text):
|
||||
@ -91,6 +94,21 @@ else:
|
||||
))
|
||||
|
||||
|
||||
class Popen(subprocess.Popen):
|
||||
"""Patched Popen to prevent opening cmd window on Windows platform."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
startupinfo = kwargs.get('startupinfo')
|
||||
if is_win or True:
|
||||
try:
|
||||
startupinfo = startupinfo or subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
except AttributeError:
|
||||
pass
|
||||
kwargs['startupinfo'] = startupinfo
|
||||
super(Popen, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
# globals
|
||||
HEARTBEAT_FREQUENCY = 2
|
||||
ST_VERSION = int(sublime.version())
|
||||
|
Loading…
Reference in New Issue
Block a user