mirror of
https://github.com/wakatime/sublime-wakatime.git
synced 2023-08-10 21:13:02 +03:00
no need to create empty common config file
This commit is contained in:
parent
04a4630024
commit
04f8c61ebc
27
WakaTime.py
27
WakaTime.py
@ -177,27 +177,11 @@ def update_status_bar(status):
|
|||||||
set_timeout(lambda: update_status_bar(status), 0)
|
set_timeout(lambda: update_status_bar(status), 0)
|
||||||
|
|
||||||
|
|
||||||
def create_config_file():
|
|
||||||
"""Creates the .wakatime.cfg INI file in $HOME directory, if it does
|
|
||||||
not already exist.
|
|
||||||
"""
|
|
||||||
configFile = os.path.join(os.path.expanduser('~'), '.wakatime.cfg')
|
|
||||||
try:
|
|
||||||
with open(configFile) as fh:
|
|
||||||
pass
|
|
||||||
except IOError:
|
|
||||||
try:
|
|
||||||
with open(configFile, 'w') as fh:
|
|
||||||
fh.write("[settings]\n")
|
|
||||||
fh.write("debug = false\n")
|
|
||||||
except IOError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def prompt_api_key():
|
def prompt_api_key():
|
||||||
global SETTINGS
|
global SETTINGS
|
||||||
|
|
||||||
create_config_file()
|
if SETTINGS.get('api_key'):
|
||||||
|
return True
|
||||||
|
|
||||||
default_key = ''
|
default_key = ''
|
||||||
try:
|
try:
|
||||||
@ -208,15 +192,12 @@ def prompt_api_key():
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if SETTINGS.get('api_key'):
|
window = sublime.active_window()
|
||||||
return True
|
if window:
|
||||||
else:
|
|
||||||
def got_key(text):
|
def got_key(text):
|
||||||
if text:
|
if text:
|
||||||
SETTINGS.set('api_key', str(text))
|
SETTINGS.set('api_key', str(text))
|
||||||
sublime.save_settings(SETTINGS_FILE)
|
sublime.save_settings(SETTINGS_FILE)
|
||||||
window = sublime.active_window()
|
|
||||||
if window:
|
|
||||||
window.show_input_panel('[WakaTime] Enter your wakatime.com api key:', default_key, got_key, None, None)
|
window.show_input_panel('[WakaTime] Enter your wakatime.com api key:', default_key, got_key, None, None)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user