wakatime / sublime-wakatime

Sublime Text 2 & 3 plugin for automatic time tracking and metrics generated from your programming activity.
https://wakatime.com/sublime-text
BSD 3-Clause "New" or "Revised" License
526 stars 45 forks source link

Only on Windows, cmd windows open on tab change & saves #12

Closed patschi closed 10 years ago

patschi commented 11 years ago

Hello,

it's very very disturbing that on every tab change or save of any file are popping up like five python cmd windows! Sometimes when I'm programming something the windows pops up and disturbs me while I'm coding. I even sent about 2 days a tweet on your account - no response.

I installed the latest python version from the page you linked on the sublime-help page and put it with the name "Python" in the Sublime folder and in C:\Progs\ and added the python.exe to my $PATH variable.

I've Windows Ultimate x64. Please fix it. I really love the project, but the much disturbing blinking windows makes me really crazy.

Thanks.

pato commented 11 years ago

Although I don't get many cmd windows on every tab change or save, I can confirm that one python.exe is displayed on any change.

This is caused by python_binary() which checks the python version by running python.exe, which displays a CUI, before testing pythonw.exe for the version.

patschi commented 11 years ago

And how I can solve this annoying windows? :)

pato commented 11 years ago

Although this is not a proper fix, it will remove the annoying windows windows.

  1. In Sublime use Ctrl+Shift+P and select Browse Packages
  2. In the WakaTime folder edit sublime-wakatime.py
  3. Edit line 52 and change it from python = "python" to python = "pythonw"
  4. Save the file and Sublime will reload the plugin

You should no longer see the annoying windows :+1:

patschi commented 11 years ago

No sorry, didn't fixed it. Still after an restart of Sublime Text the windows continuing popping up.

pato commented 11 years ago

Mhh.. Try changing line 52 to return "pythonw" and see if that works. Because python.exe will always display a CUI but pythonw.exe wont so you want to force wakatime to always use pythonw.exe

patschi commented 11 years ago

Somehow, it still won't work. Don't know why.

def python_binary():
    return "pythonw"
    if platform.system() == 'Windows':
        try:
            Popen([python, '--version'])
        except:
            for path in glob.iglob('/python*'):
                if exists(realpath(join(path, 'python.exe'))):
                    python = realpath(join(path, 'python'))
                    break
        try:
            Popen([python+'w', '--version'])
            python = python+'w'
        except:
            pass
    return python
pato commented 11 years ago

Thats really weird because pythonw.exe should not display any windows.

Are you sure that it is WakaTime causing all the popups? Can you see what the window titles and/or content are?

patschi commented 11 years ago

No, it's popping up too fast. Immediality on every tab change or save - it's 100% from WakaTime/Python. I'm also sure, that pythonw.exe is the right executable file and it's working fine. But somehow, Wakatime/Sublime won't take over the changes to use pythonw.exe.

patschi commented 11 years ago

When I save I see a pythonw.exe and conhost.exe spawning. I see the following in my task manager: 2013-08-03_0903

I upgraded to the newest version of WakaTime - still having the popups. It seems to execute the right executable, but I still have them: 2013-08-03_0907

alanhamlett commented 11 years ago

I thought pythonw wasn't supposed to open a command window. Can you check your WakaTime version using Package Control:

press ctrl+shift+p then type list and select Package Control: List Packages. The version should be: v2013.08.02.20.00.26

patschi commented 11 years ago

It's the latest version - Checked it right now. I did some hours ago a "Upgrade/Overwrite all packages" to go sure, that I have the latest version. Like you see on the last screenshot, it's working - it is successfully executing pythonw.exe instead of python.exe, but still with a own window.

Maybe I have a wrong Python version? I did downloaded the file "Python 3.3.2 Windows X86-64 MSI Installer" from http://www.python.org/getit/

alanhamlett commented 11 years ago

bc8c1af287399f062274598aaa5f046d534d439f might fix this. It tells subprocess to not open a command window when invoking pythonw.

It is strange that it doesn't happen for me, but it's probably not something wrong with your Python version.

patschi commented 11 years ago

Very strange, yes. Sadly still the windows coming up. Does not Sublime Text have any integrated CURL-function or something like this, that pythonw.exe does't need to be used?

alanhamlett commented 11 years ago

I could use Sublime Text 3's async events to import and run the wakatime-cli script without using subprocess.

patschi commented 11 years ago

Still not working. I also currently got a other warning the 3rd time: 2013-08-07_0907

alanhamlett commented 11 years ago

The "taking too long" error from ST2 is fixed in v0.4.1 using threading.

When using Sublime Text 3 for Windows, the cmd windows won't open because wakatime-cli.py is no longer called in a new process. Instead, the wakatime package is imported directly in a non-blocking thread.

Unfortunately, Sublime Text 2 doesn't have support for SSL in the embedded Python so a child process is still used and could cause command windows to open on the Windows platform. I'm not sure how to get around this right now.

patschi commented 11 years ago

The windows only coming up with SSL? Could change to plugin to HTTP to avoid these windows?

alanhamlett commented 11 years ago

The api doesn't accept HTTP requests to prevent someone intercepting a user's api key.

patschi commented 11 years ago

mhh, than I will make a workaround somehow. I could change the site in the plugin and call a HTTP-site in my local network on my NAS, which is forwarding the request to the site with SSL :D

I really want to use this plugin, but the windows are really annoying.

alanhamlett commented 11 years ago

I'll fix it eventually with a local/offline version of WakaTime, but it would be great to find out why pythonw opens cmd windows when it shouldn't: http://docs.python.org/2/using/windows.html#executing-scripts

If only I could reproduce the issue in my environment.

alanhamlett commented 11 years ago

I've switched to using kennethreitz/requests instead of urllib2 and haven't noticed any SSL errors in my ST2 testing on Windows.

fnkr commented 10 years ago

I just installed Wakatime on ST2 and I haveing this windows. I have Python 2.7 and Python 3.3 (and 3.3 is in path).

Screenshot

It looks like git is the problem.

mtfd commented 10 years ago

EDIT: seems that it's as @fnkr says - git is the problem. After removing cygwin bin from my path, i installed latest git version and added it to my path - cmds started popping up again.

Removing any folder from path that contains git.exe seems to be the fix.

patschi commented 10 years ago

Good to know what the issue is, but I strongly need git in the command line, so I don't want to remove it from the PATH variable. Someone knows any other workaround? :)

alanhamlett commented 10 years ago

That's why I wasn't ever able to reproduce it! Now that I know the problem I can fix it in the plugin by checking for pythonw.exe first in the default location C:\python33\ before using the system path.

Thanks for figuring this out @mtfd!

fnkr commented 10 years ago

Is there already an ETA for the bugfix?

alanhamlett commented 10 years ago

Fixed with e812e9fe15ea6966683ed7490c0ecf701cc0994e.

Just released a new plugin version 1.4.4 that doesn't run git command line, so no more popup window.

patschi commented 10 years ago

Sadly some popups are still coming up on my PC :( Seems to be a other issue... I already updated to version v1.4.4

FichteFoll commented 10 years ago

Cool, that fixed it for me :+1:

alanhamlett commented 10 years ago

@patschi can you try restarting Sublime and see if the popup windows still open?

patschi commented 10 years ago

Doesn't help. Still the popups are coming up - it's also not easily possible to remove the plugin again, because on every selecting of "Packages: remove package" the popup of any process is pushing me out of the selection.

But I lukely I could catch an screenshot (which isn't very good to read, but it's possible) of the fast windows and it's possible to read, that an svn.exe will be called: svn

alanhamlett commented 10 years ago

@patschi ok makes sense. when a git repo isn't found, WakaTime looks for a subversion project to set the project's name. I'll fix this for you tonight!

patschi commented 10 years ago

Nice to hear - Thanks! :) Would be nice, if it would be possible to manually set the project name for files or folders.

alanhamlett commented 10 years ago

The project name gets set from the name of your git directory, so changing the name of your top git directory will change your project's name.

You also don't have to actually use git to have WakaTime recognize the project's name. Just initialize a git repo inside your project folder using git init and then WakaTime recognizes the project's name even if you don't use git anytime after.

alanhamlett commented 10 years ago

Fixed with fe641d01d4d0741a0b8dcddcfe3ba4e795952f6d by removing support for Subverison projects on Windows platform.

Upgrading to v1.4.5 should prevent any popup windows from opening.

@patschi Can you please let me know if this is fixed for you?

patschi commented 10 years ago

It seems to work - Great! :)

alanhamlett commented 10 years ago

Awesome!

patschi commented 10 years ago

Would be nice if WakaTime can read the project name from subversion local repo :)

alanhamlett commented 10 years ago

For now, you can use a .wakatime-project file in your project directory to set the project's name:

https://www.wakati.me/help/faq/general#set-project-name

StephenKoller commented 8 years ago

I'm seeing this same problem now on Windows 10 (x64) and with Sublime WakaTime 7.0.2

Is this the right place to address this or should I open a new issue?

alanhamlett commented 8 years ago

A new issue would be better, with a ton of info to help us find the cause :)