static public void DownloadCli() { Logger.Debug("Downloading wakatime cli..."); var tempDir = Path.GetTempPath(); var localZipFile = Path.Combine(tempDir, "wakatime-cli.zip"); var client = new WebClient { Proxy = WakaTimeConfigFile.GetProxy() // Check for proxy setting }; // Download wakatime cli DownloadProgress.Show(CliUrl); client.DownloadProgressChanged += (s, e) => { DownloadProgress.Report(e); }; client.DownloadFileCompleted += (s, e) => { try { DownloadProgress.Complete(e); Logger.Debug("Finished downloading wakatime cli."); // Extract wakatime cli zip file #if NET35 || NET40 using (var zipFile = new ZipFile(localZipFile)) { zipFile.ExtractAll(ConfigDir, ExtractExistingFileAction.OverwriteSilently); } #else ZipFile.ExtractToDirectory(localZipFile, ConfigDir); #endif Logger.Debug(string.Format("Finished extracting wakatime cli: {0}", GetCliPath())); // Delete downloaded file File.Delete(localZipFile); } catch (Exception ex) { Logger.Error("Failed to download and/or extract WakaTime Cli", ex); } finally { OnInitialized(); } }; Logger.Warning("DownloadProgress.Show"); try { client.DownloadFileAsync(new Uri(CliUrl), localZipFile); } catch (Exception ex) { Logger.Error("Failed to download WakaTime Cli", ex); } }
static public void DownloadPython() { Logger.Debug("Downloading python..."); var tempDir = Path.GetTempPath(); var localFile = Path.Combine(tempDir, "python.zip"); var client = new WebClient { Proxy = WakaTimeConfigFile.GetProxy() // Check for proxy setting }; // Download embeddable python DownloadProgress.Show(PythonDownloadUrl); client.DownloadProgressChanged += (s, e) => { DownloadProgress.Report(e); }; client.DownloadFileCompleted += (s, e) => { try { DownloadProgress.Complete(e); Logger.Debug("Finished downloading python."); // Extract wakatime cli zip file var appDataPath = GetAppDataDirectory(); // Extract wakatime cli zip file #if NET35 || NET40 using (var zipFile = new ZipFile(localFile)) { zipFile.ExtractAll(Path.Combine(appDataPath, "python"), ExtractExistingFileAction.OverwriteSilently); } #else ZipFile.ExtractToDirectory(localFile, Path.Combine(appDataPath, "python")); #endif Logger.Debug(string.Format("Finished extracting python: {0}", Path.Combine(appDataPath, "python"))); // Delete downloaded file File.Delete(localFile); } finally { OnInitialized(); } }; client.DownloadFileAsync(new Uri(PythonDownloadUrl), localFile); }