From 42f83e3df5f7f86de86dac7a2f6e14af44638ed0 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Sun, 30 Sep 2018 21:49:26 -0700 Subject: [PATCH] upgrade wakatime-cli to v10.3.0 --- packages/wakatime/__about__.py | 2 +- packages/wakatime/compat.py | 18 ++++++++++++++++++ packages/wakatime/projects/subversion.py | 6 ++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/wakatime/__about__.py b/packages/wakatime/__about__.py index 9fdad25..29babca 100644 --- a/packages/wakatime/__about__.py +++ b/packages/wakatime/__about__.py @@ -1,7 +1,7 @@ __title__ = 'wakatime' __description__ = 'Common interface to the WakaTime api.' __url__ = 'https://github.com/wakatime/wakatime' -__version_info__ = ('10', '2', '4') +__version_info__ = ('10', '3', '0') __version__ = '.'.join(__version_info__) __author__ = 'Alan Hamlett' __author_email__ = 'alan@wakatime.com' diff --git a/packages/wakatime/compat.py b/packages/wakatime/compat.py index 097854e..744f3ee 100644 --- a/packages/wakatime/compat.py +++ b/packages/wakatime/compat.py @@ -11,11 +11,14 @@ import codecs +import platform +import subprocess import sys is_py2 = (sys.version_info[0] == 2) is_py3 = (sys.version_info[0] == 3) +is_win = platform.system() == 'Windows' if is_py2: # pragma: nocover @@ -98,3 +101,18 @@ try: from .packages import simplejson as json except (ImportError, SyntaxError): # pragma: nocover import json + + +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) diff --git a/packages/wakatime/projects/subversion.py b/packages/wakatime/projects/subversion.py index f5a6f38..d4f9572 100644 --- a/packages/wakatime/projects/subversion.py +++ b/packages/wakatime/projects/subversion.py @@ -12,10 +12,10 @@ import logging import os import platform -from subprocess import Popen, PIPE +from subprocess import PIPE from .base import BaseProject -from ..compat import u, open +from ..compat import u, open, Popen try: from collections import OrderedDict except ImportError: # pragma: nocover @@ -86,8 +86,6 @@ class Subversion(BaseProject): return info def _find_project_base(self, path, found=False): - if platform.system() == 'Windows': - return False # pragma: nocover path = os.path.realpath(path) if os.path.isfile(path): path = os.path.split(path)[0]