def prompt_api_key(): global SETTINGS if SETTINGS.get('api_key'): return True default_key = '' try: configs = parseConfigFile() if configs is not None: if configs.has_option('settings', 'api_key'): default_key = configs.get('settings', 'api_key') except: pass window = sublime.active_window() if window: def got_key(text): if text: SETTINGS.set('api_key', str(text)) sublime.save_settings(SETTINGS_FILE) window.show_input_panel('[WakaTime] Enter your wakatime.com api key:', default_key, got_key, None, None) return True else: log(ERROR, 'Could not prompt for api key because no window found.') return False
def prompt_api_key(): global SETTINGS create_config_file() default_key = '' try: configs = parseConfigFile() if configs is not None: if configs.has_option('settings', 'api_key'): default_key = configs.get('settings', 'api_key') except: pass if SETTINGS.get('api_key'): return True else: def got_key(text): if text: SETTINGS.set('api_key', str(text)) 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) return True else: log(ERROR, 'Could not prompt for api key because no window found.') return False