no need to create empty common config file

This commit is contained in:
Alan Hamlett 2017-03-16 08:36:17 -07:00
parent 04a4630024
commit 04f8c61ebc
1 changed files with 9 additions and 28 deletions

View File

@ -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,20 +192,17 @@ 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() window.show_input_panel('[WakaTime] Enter your wakatime.com api key:', default_key, got_key, None, None)
if window: return True
window.show_input_panel('[WakaTime] Enter your wakatime.com api key:', default_key, got_key, None, None) else:
return True log(ERROR, 'Could not prompt for api key because no window found.')
else: return False
log(ERROR, 'Could not prompt for api key because no window found.')
return False
def python_binary(): def python_binary():