forked from wakatime/visualstudio-wakatime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDownloader.cs
64 lines (50 loc) · 1.63 KB
/
Downloader.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Net;
namespace WakaTime
{
class Downloader
{
static public void DownloadCli(string url, string dir)
{
Logger.Debug("Downloading wakatime cli...");
var client = new WebClient();
var localZipFile = dir + "\\wakatime-cli.zip";
// Download wakatime cli
client.DownloadFile(url, localZipFile);
Logger.Debug("Finished downloading wakatime cli.");
// Extract wakatime cli zip file
ZipFile.ExtractToDirectory(localZipFile, dir);
try
{
File.Delete(localZipFile);
}
catch { /* ignored */ }
}
static public void DownloadPython(string url, string dir)
{
Logger.Debug("Downloading python...");
var localFile = dir + "\\python.msi";
var client = new WebClient();
client.DownloadFile(url, localFile);
Logger.Debug("Finished downloading python.");
var arguments = "/i \"" + localFile + "\"";
arguments = arguments + " /norestart /qb!";
var procInfo = new ProcessStartInfo
{
UseShellExecute = false,
RedirectStandardError = true,
FileName = "msiexec",
CreateNoWindow = true,
Arguments = arguments
};
Process.Start(procInfo);
try
{
File.Delete(localFile);
}
catch { /* ignored */ }
}
}
}