Commit b8e528c15176102b012e8fff7bc63bf68ea1773f
1 parent
15994223
Exists in
Au-ghub/master
Versão lançada 18102016
Showing
4 changed files
with
492 additions
and
120 deletions
Show diff stats
AU.csproj
| @@ -7,8 +7,8 @@ | @@ -7,8 +7,8 @@ | ||
| 7 | <ProjectGuid>{6EB1FB18-7A1B-46E0-9991-A18B3AA32E5C}</ProjectGuid> | 7 | <ProjectGuid>{6EB1FB18-7A1B-46E0-9991-A18B3AA32E5C}</ProjectGuid> |
| 8 | <OutputType>Exe</OutputType> | 8 | <OutputType>Exe</OutputType> |
| 9 | <AppDesignerFolder>Properties</AppDesignerFolder> | 9 | <AppDesignerFolder>Properties</AppDesignerFolder> |
| 10 | - <RootNamespace>VLIBRAS_II</RootNamespace> | ||
| 11 | - <AssemblyName>VLIBRAS_II</AssemblyName> | 10 | + <RootNamespace>AtualizadorVLibras</RootNamespace> |
| 11 | + <AssemblyName>AtualizadorVLibras</AssemblyName> | ||
| 12 | <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | 12 | <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
| 13 | <FileAlignment>512</FileAlignment> | 13 | <FileAlignment>512</FileAlignment> |
| 14 | <IsWebBootstrapper>true</IsWebBootstrapper> | 14 | <IsWebBootstrapper>true</IsWebBootstrapper> |
| @@ -22,14 +22,15 @@ | @@ -22,14 +22,15 @@ | ||
| 22 | <UpdatePeriodically>false</UpdatePeriodically> | 22 | <UpdatePeriodically>false</UpdatePeriodically> |
| 23 | <UpdateRequired>true</UpdateRequired> | 23 | <UpdateRequired>true</UpdateRequired> |
| 24 | <MapFileExtensions>false</MapFileExtensions> | 24 | <MapFileExtensions>false</MapFileExtensions> |
| 25 | - <InstallUrl>http://150.165.205.137:8080/</InstallUrl> | ||
| 26 | - <UpdateUrl>http://150.165.205.137:8080/</UpdateUrl> | ||
| 27 | - <ProductName>VLIBRAS</ProductName> | 25 | + <InstallUrl>http://atualizacao.vlibras.lavid.ufpb.br/windows/</InstallUrl> |
| 26 | + <UpdateUrl>http://atualizacao.vlibras.lavid.ufpb.br/windows/</UpdateUrl> | ||
| 27 | + <ProductName>Atualizador VLibras</ProductName> | ||
| 28 | <PublisherName>LAVID-UFPB</PublisherName> | 28 | <PublisherName>LAVID-UFPB</PublisherName> |
| 29 | - <MinimumRequiredVersion>1.0.0.82</MinimumRequiredVersion> | 29 | + <MinimumRequiredVersion>5.0.0.0</MinimumRequiredVersion> |
| 30 | <OpenBrowserOnPublish>false</OpenBrowserOnPublish> | 30 | <OpenBrowserOnPublish>false</OpenBrowserOnPublish> |
| 31 | - <ApplicationRevision>94</ApplicationRevision> | ||
| 32 | - <ApplicationVersion>1.0.0.%2a</ApplicationVersion> | 31 | + <TrustUrlParameters>true</TrustUrlParameters> |
| 32 | + <ApplicationRevision>2</ApplicationRevision> | ||
| 33 | + <ApplicationVersion>5.0.0.%2a</ApplicationVersion> | ||
| 33 | <UseApplicationTrust>true</UseApplicationTrust> | 34 | <UseApplicationTrust>true</UseApplicationTrust> |
| 34 | <CreateDesktopShortcut>true</CreateDesktopShortcut> | 35 | <CreateDesktopShortcut>true</CreateDesktopShortcut> |
| 35 | <PublishWizardCompleted>true</PublishWizardCompleted> | 36 | <PublishWizardCompleted>true</PublishWizardCompleted> |
| @@ -44,6 +45,7 @@ | @@ -44,6 +45,7 @@ | ||
| 44 | <DefineConstants>DEBUG;TRACE</DefineConstants> | 45 | <DefineConstants>DEBUG;TRACE</DefineConstants> |
| 45 | <ErrorReport>prompt</ErrorReport> | 46 | <ErrorReport>prompt</ErrorReport> |
| 46 | <WarningLevel>4</WarningLevel> | 47 | <WarningLevel>4</WarningLevel> |
| 48 | + <Prefer32Bit>false</Prefer32Bit> | ||
| 47 | </PropertyGroup> | 49 | </PropertyGroup> |
| 48 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | 50 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
| 49 | <PlatformTarget>AnyCPU</PlatformTarget> | 51 | <PlatformTarget>AnyCPU</PlatformTarget> |
| @@ -64,7 +66,7 @@ | @@ -64,7 +66,7 @@ | ||
| 64 | <ApplicationManifest>Properties\app.manifest</ApplicationManifest> | 66 | <ApplicationManifest>Properties\app.manifest</ApplicationManifest> |
| 65 | </PropertyGroup> | 67 | </PropertyGroup> |
| 66 | <PropertyGroup> | 68 | <PropertyGroup> |
| 67 | - <SignManifests>true</SignManifests> | 69 | + <SignManifests>false</SignManifests> |
| 68 | </PropertyGroup> | 70 | </PropertyGroup> |
| 69 | <PropertyGroup> | 71 | <PropertyGroup> |
| 70 | <ManifestCertificateThumbprint>2811720AF50392C2792C67C4DEBCB1D40662604A</ManifestCertificateThumbprint> | 72 | <ManifestCertificateThumbprint>2811720AF50392C2792C67C4DEBCB1D40662604A</ManifestCertificateThumbprint> |
| @@ -97,7 +99,9 @@ | @@ -97,7 +99,9 @@ | ||
| 97 | <Reference Include="System.Xml" /> | 99 | <Reference Include="System.Xml" /> |
| 98 | </ItemGroup> | 100 | </ItemGroup> |
| 99 | <ItemGroup> | 101 | <ItemGroup> |
| 100 | - <Compile Include="BundlesManager.cs" /> | 102 | + <Compile Include="BundlesManager.cs"> |
| 103 | + <SubType>Component</SubType> | ||
| 104 | + </Compile> | ||
| 101 | <Compile Include="Form1.cs"> | 105 | <Compile Include="Form1.cs"> |
| 102 | <SubType>Form</SubType> | 106 | <SubType>Form</SubType> |
| 103 | </Compile> | 107 | </Compile> |
BundlesManager.cs
| @@ -3,10 +3,21 @@ using System.Net; | @@ -3,10 +3,21 @@ using System.Net; | ||
| 3 | using System.IO; | 3 | using System.IO; |
| 4 | using System.IO.Compression; | 4 | using System.IO.Compression; |
| 5 | 5 | ||
| 6 | -namespace VLIBRAS_II | 6 | +namespace AtualizadorVLibras |
| 7 | { | 7 | { |
| 8 | + | ||
| 9 | + public class TimeoutWebClient : WebClient{ | ||
| 10 | + protected override WebRequest GetWebRequest(Uri address){ | ||
| 11 | + HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address); | ||
| 12 | + request.Timeout = 3600000; //1 hour timeout | ||
| 13 | + return request; | ||
| 14 | + } | ||
| 15 | + } | ||
| 16 | + | ||
| 8 | static class BundlesManager | 17 | static class BundlesManager |
| 9 | { | 18 | { |
| 19 | + //timeout para verificação de existência e data de última verificação dos pacotes | ||
| 20 | + static int timeout = 2000; | ||
| 10 | 21 | ||
| 11 | public static void ExtractToDirectory(this ZipArchive archive, string destinationDirectoryName, bool overwrite){ | 22 | public static void ExtractToDirectory(this ZipArchive archive, string destinationDirectoryName, bool overwrite){ |
| 12 | if (!overwrite){ | 23 | if (!overwrite){ |
| @@ -14,59 +25,73 @@ namespace VLIBRAS_II | @@ -14,59 +25,73 @@ namespace VLIBRAS_II | ||
| 14 | return; | 25 | return; |
| 15 | } | 26 | } |
| 16 | foreach (ZipArchiveEntry file in archive.Entries){ | 27 | foreach (ZipArchiveEntry file in archive.Entries){ |
| 17 | - string completeFileName = Path.Combine(destinationDirectoryName, file.FullName); | ||
| 18 | - string directory = Path.GetDirectoryName(completeFileName); | ||
| 19 | - Console.WriteLine("Extraindo "+file.FullName+"."); | ||
| 20 | - if (!Directory.Exists(directory)){ | ||
| 21 | - Directory.CreateDirectory(directory); | ||
| 22 | - } | 28 | + try{ |
| 29 | + string completeFileName = Path.Combine(destinationDirectoryName, file.FullName); | ||
| 30 | + string directory = Path.GetDirectoryName(completeFileName); | ||
| 31 | + Console.WriteLine("Extraindo "+file.FullName+"."); | ||
| 32 | + if (!Directory.Exists(directory)){ | ||
| 33 | + Directory.CreateDirectory(directory); | ||
| 34 | + } | ||
| 23 | 35 | ||
| 24 | - if (file.Name != ""){ | ||
| 25 | - file.ExtractToFile(completeFileName, true); | 36 | + if (file.Name != ""){ |
| 37 | + file.ExtractToFile(completeFileName, true); | ||
| 38 | + } | ||
| 39 | + }catch(Exception e){ | ||
| 40 | + Console.WriteLine("Erro na extração: {0}",e); | ||
| 41 | + continue; | ||
| 26 | } | 42 | } |
| 27 | } | 43 | } |
| 28 | } | 44 | } |
| 29 | 45 | ||
| 30 | - private static bool RemoteFileExists(string url){ | 46 | + //File.Exists(path); |
| 47 | + | ||
| 48 | + private static bool RemoteFileExists(string url){ | ||
| 49 | + bool result = false; | ||
| 50 | + var request = (HttpWebRequest)WebRequest.Create(url); | ||
| 51 | + request.Method = "HEAD"; | ||
| 52 | + request.Timeout = timeout; | ||
| 53 | + HttpWebResponse response = null; | ||
| 31 | try{ | 54 | try{ |
| 32 | - //Creating the HttpWebRequest | ||
| 33 | - HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; | ||
| 34 | - //Setting the Request method HEAD | ||
| 35 | - request.Method = "HEAD"; | ||
| 36 | - request.Timeout = 2000; | ||
| 37 | - //Getting the Web Response. | ||
| 38 | - HttpWebResponse response = request.GetResponse() as HttpWebResponse; | ||
| 39 | - //Returns TURE if the Status code == 200 | ||
| 40 | - return (response.StatusCode == HttpStatusCode.OK); | ||
| 41 | - } | ||
| 42 | - catch{ | ||
| 43 | - //Any exception will returns false. | ||
| 44 | - return false; | 55 | + response = (HttpWebResponse)request.GetResponse(); |
| 56 | + result = (response.StatusCode == HttpStatusCode.OK); | ||
| 57 | + }catch(Exception e){ | ||
| 58 | + //Console.WriteLine("Arquivo não existe no servidor: {0}",e); | ||
| 59 | + }finally{ | ||
| 60 | + if(response != null){ | ||
| 61 | + response.Close(); | ||
| 62 | + } | ||
| 45 | } | 63 | } |
| 64 | + return result; | ||
| 46 | } | 65 | } |
| 47 | 66 | ||
| 48 | - //File.Exists(path); | ||
| 49 | - | ||
| 50 | private static bool RemoteIsNewerThanLocal(string url, string path){ | 67 | private static bool RemoteIsNewerThanLocal(string url, string path){ |
| 68 | + bool result = false;//resultado padrão | ||
| 69 | + //informações do arquivo | ||
| 51 | FileInfo sourceFile = new FileInfo(path); | 70 | FileInfo sourceFile = new FileInfo(path); |
| 71 | + //solicitação do arquivo remoto | ||
| 52 | var request = (HttpWebRequest)WebRequest.Create(url); | 72 | var request = (HttpWebRequest)WebRequest.Create(url); |
| 53 | request.Method = "HEAD"; | 73 | request.Method = "HEAD"; |
| 54 | - var response = (HttpWebResponse)request.GetResponse(); | ||
| 55 | - //Console.WriteLine("response.LastModified: "+response.LastModified); | ||
| 56 | - //Console.WriteLine("sourceFile.LastWriteTime: "+sourceFile.LastWriteTime); | ||
| 57 | - if(response.LastModified > sourceFile.LastWriteTime){ | ||
| 58 | - return true; | ||
| 59 | - }else{ | ||
| 60 | - return false; | 74 | + request.Timeout = timeout; |
| 75 | + HttpWebResponse response = null; | ||
| 76 | + try{ | ||
| 77 | + response = (HttpWebResponse)request.GetResponse(); | ||
| 78 | + result = (response.LastModified > sourceFile.LastWriteTime); | ||
| 79 | + }catch(Exception e){ | ||
| 80 | + //Console.WriteLine("Erro: {0}",e); | ||
| 81 | + }finally{ | ||
| 82 | + if(response != null){ | ||
| 83 | + response.Close(); | ||
| 84 | + } | ||
| 61 | } | 85 | } |
| 86 | + return result; | ||
| 62 | } | 87 | } |
| 63 | 88 | ||
| 64 | private static void DownloadFileToPath(string site, string path){ | 89 | private static void DownloadFileToPath(string site, string path){ |
| 65 | try{ | 90 | try{ |
| 66 | - WebClient webClient = new WebClient(); | 91 | + TimeoutWebClient webClient = new TimeoutWebClient(); |
| 67 | webClient.DownloadFile(site, path); | 92 | webClient.DownloadFile(site, path); |
| 68 | }catch(Exception e){ | 93 | }catch(Exception e){ |
| 69 | - Console.WriteLine("Erro: {0}", e); | 94 | + Console.WriteLine("Erro: {0}\nAperte alguma tecla para continuar.", e); |
| 70 | } | 95 | } |
| 71 | } | 96 | } |
| 72 | 97 | ||
| @@ -79,6 +104,7 @@ namespace VLIBRAS_II | @@ -79,6 +104,7 @@ namespace VLIBRAS_II | ||
| 79 | string remote; | 104 | string remote; |
| 80 | string local; | 105 | string local; |
| 81 | while(true){ | 106 | while(true){ |
| 107 | + Console.WriteLine("Verificando arquivo "+i+"zip dos pacotes de sinais."); | ||
| 82 | remote = url+i.ToString()+ext; | 108 | remote = url+i.ToString()+ext; |
| 83 | local = rootPath+i.ToString()+ext; | 109 | local = rootPath+i.ToString()+ext; |
| 84 | if(!RemoteFileExists(remote)){ | 110 | if(!RemoteFileExists(remote)){ |
| @@ -87,9 +113,11 @@ namespace VLIBRAS_II | @@ -87,9 +113,11 @@ namespace VLIBRAS_II | ||
| 87 | break; | 113 | break; |
| 88 | }else{ | 114 | }else{ |
| 89 | if(!File.Exists(local)){ | 115 | if(!File.Exists(local)){ |
| 116 | + Console.WriteLine("Baixando o "+i+"o pacote de sinais."); | ||
| 90 | DownloadFileToPath(remote, local); | 117 | DownloadFileToPath(remote, local); |
| 91 | }else{ | 118 | }else{ |
| 92 | if(RemoteIsNewerThanLocal(remote, local)){ | 119 | if(RemoteIsNewerThanLocal(remote, local)){ |
| 120 | + Console.WriteLine("Houve um patch nesse pacote: baixando o "+i+"o pacote de sinais."); | ||
| 93 | DownloadFileToPath(remote, local); | 121 | DownloadFileToPath(remote, local); |
| 94 | //DELETA ARQUIVO DE VERIFICAÇÃO PARA QUE HAJA NOVA EXTRAÇÃO | 122 | //DELETA ARQUIVO DE VERIFICAÇÃO PARA QUE HAJA NOVA EXTRAÇÃO |
| 95 | File.Delete(extractPath + i); | 123 | File.Delete(extractPath + i); |
| @@ -101,7 +129,7 @@ namespace VLIBRAS_II | @@ -101,7 +129,7 @@ namespace VLIBRAS_II | ||
| 101 | return i; | 129 | return i; |
| 102 | } | 130 | } |
| 103 | 131 | ||
| 104 | - public static void ExtractBundlesPackages(string rootPath, string extractPath, int qtd){ | 132 | + /*public static void ExtractBundlesPackages(string rootPath, string extractPath, int qtd){ |
| 105 | string ext = @".zip"; | 133 | string ext = @".zip"; |
| 106 | bool exists = System.IO.Directory.Exists(extractPath); | 134 | bool exists = System.IO.Directory.Exists(extractPath); |
| 107 | if(!exists){ | 135 | if(!exists){ |
| @@ -120,9 +148,10 @@ namespace VLIBRAS_II | @@ -120,9 +148,10 @@ namespace VLIBRAS_II | ||
| 120 | } | 148 | } |
| 121 | qtd--; | 149 | qtd--; |
| 122 | } | 150 | } |
| 123 | - } | 151 | + }*/ |
| 152 | + | ||
| 124 | //ZipArchive archive = ZipFile.Open(fileAbsolute, ZipArchiveMode.Read, System.Text.Encoding.GetEncoding(System.Globalization.CultureInfo.CurrentCulture.TextInfo.OEMCodePage)); | 153 | //ZipArchive archive = ZipFile.Open(fileAbsolute, ZipArchiveMode.Read, System.Text.Encoding.GetEncoding(System.Globalization.CultureInfo.CurrentCulture.TextInfo.OEMCodePage)); |
| 125 | - public static void ExtractBundlesPackagesOverWrite(string rootPath, string extractPath, int qtd){ | 154 | + public static void ExtractBundlesPackagesOverWrite(string rootPath, string extractPath, int qtd, string url){ |
| 126 | string ext = @".zip"; | 155 | string ext = @".zip"; |
| 127 | bool exists = System.IO.Directory.Exists(extractPath); | 156 | bool exists = System.IO.Directory.Exists(extractPath); |
| 128 | if(!exists){ | 157 | if(!exists){ |
| @@ -130,18 +159,25 @@ namespace VLIBRAS_II | @@ -130,18 +159,25 @@ namespace VLIBRAS_II | ||
| 130 | } | 159 | } |
| 131 | 160 | ||
| 132 | while(qtd > 0){ | 161 | while(qtd > 0){ |
| 133 | - if(!File.Exists(extractPath+qtd.ToString())){ | ||
| 134 | - string fileAbsolute = rootPath+qtd.ToString()+ext; | ||
| 135 | - ZipArchive zip = ZipFile.Open(fileAbsolute, ZipArchiveMode.Read, System.Text.Encoding.GetEncoding(System.Globalization.CultureInfo.CurrentCulture.TextInfo.OEMCodePage)); | ||
| 136 | - Console.WriteLine("Extraindo o arquivo: "+zip); | ||
| 137 | - //ZipFile.ExtractToDirectory(zip, extractPath); | ||
| 138 | - ExtractToDirectory(zip, extractPath, true); | ||
| 139 | - //CRIA UM ARQUIVO 1(SEM EXTENSÃO), 2, 3... NA PASTA BUNDLES PARA VERIFICAÇÃO DE EXTRAÇÃO PRÉVIA | ||
| 140 | - //SÓ É CRIADO APÓS EXTRAÇÃO DE TODOS OS ARQUIVOS DE CADA ZIP | ||
| 141 | - Console.WriteLine("Extração do arquivo "+zip+" concluída."); | ||
| 142 | - File.Create(extractPath+qtd).Close(); | ||
| 143 | - } | 162 | + try{ |
| 163 | + if(!File.Exists(extractPath+qtd.ToString())){ | ||
| 164 | + string fileAbsolute = rootPath+qtd.ToString()+ext; | ||
| 165 | + ZipArchive zip = ZipFile.Open(fileAbsolute, ZipArchiveMode.Read, System.Text.Encoding.GetEncoding(System.Globalization.CultureInfo.CurrentCulture.TextInfo.OEMCodePage)); | ||
| 166 | + Console.WriteLine("Extraindo o arquivo: "+zip); | ||
| 167 | + //ZipFile.ExtractToDirectory(zip, extractPath); | ||
| 168 | + ExtractToDirectory(zip, extractPath, true); | ||
| 169 | + //CRIA UM ARQUIVO 1(SEM EXTENSÃO), 2, 3... NA PASTA BUNDLES PARA VERIFICAÇÃO DE EXTRAÇÃO PRÉVIA | ||
| 170 | + //SÓ É CRIADO APÓS EXTRAÇÃO DE TODOS OS ARQUIVOS DE CADA ZIP | ||
| 171 | + Console.WriteLine("Extração do arquivo "+zip+" concluída."); | ||
| 172 | + File.Create(extractPath+qtd).Close(); | ||
| 173 | + } | ||
| 144 | qtd--; | 174 | qtd--; |
| 175 | + }catch(Exception e){ | ||
| 176 | + Console.WriteLine("Erro na extração do "+qtd.ToString()+ext+"\nErro: {0}",e); | ||
| 177 | + Console.WriteLine("Tentando baixar novamente o arquivo: "+qtd.ToString()+ext); | ||
| 178 | + DownloadFileToPath(url+qtd.ToString()+ext, rootPath+qtd.ToString()+ext); | ||
| 179 | + continue; | ||
| 180 | + } | ||
| 145 | } | 181 | } |
| 146 | } | 182 | } |
| 147 | } | 183 | } |
Program.cs
| @@ -5,12 +5,12 @@ using Microsoft.Win32; | @@ -5,12 +5,12 @@ using Microsoft.Win32; | ||
| 5 | using System.IO; | 5 | using System.IO; |
| 6 | using System.IO.Compression; | 6 | using System.IO.Compression; |
| 7 | 7 | ||
| 8 | -namespace VLIBRAS_II | 8 | +namespace AtualizadorVLibras |
| 9 | { | 9 | { |
| 10 | static class Program | 10 | static class Program |
| 11 | { | 11 | { |
| 12 | static void ResetEnvVar(){ | 12 | static void ResetEnvVar(){ |
| 13 | - string vLibrasAtual = Environment.GetEnvironmentVariable("PATH_VLIBRAS",EnvironmentVariableTarget.Machine); | 13 | + string vLibrasAtual = Environment.GetEnvironmentVariable("PATH_VLIBRAS",EnvironmentVariableTarget.User); |
| 14 | string vLibrasNovo = Directory.GetCurrentDirectory(); | 14 | string vLibrasNovo = Directory.GetCurrentDirectory(); |
| 15 | 15 | ||
| 16 | if(!vLibrasNovo.Equals(vLibrasAtual)){ | 16 | if(!vLibrasNovo.Equals(vLibrasAtual)){ |
| @@ -36,66 +36,111 @@ namespace VLIBRAS_II | @@ -36,66 +36,111 @@ namespace VLIBRAS_II | ||
| 36 | static void Main() | 36 | static void Main() |
| 37 | { | 37 | { |
| 38 | //ENDEREÇO DE ONDE SERÃO BAIXADOS OS PACOTES (.ZIP) DE SINAIS (1.ZIP, 2.ZIP E ETC...) | 38 | //ENDEREÇO DE ONDE SERÃO BAIXADOS OS PACOTES (.ZIP) DE SINAIS (1.ZIP, 2.ZIP E ETC...) |
| 39 | - string url = @"http://150.165.205.137:8080/"; | 39 | + string url = @"http://atualizacao.vlibras.lavid.ufpb.br/windows/"; |
| 40 | + //string url = @"http://179.185.184.75:8080/"; | ||
| 41 | + | ||
| 40 | string dirAtual = Directory.GetCurrentDirectory(); | 42 | string dirAtual = Directory.GetCurrentDirectory(); |
| 41 | string[] buscaDeArquivo; | 43 | string[] buscaDeArquivo; |
| 44 | + bool instalouPython = false; | ||
| 42 | //Variáveis para verificar se há instalação no registro em lm64 e 32 (local machine x64 e x86) | 45 | //Variáveis para verificar se há instalação no registro em lm64 e 32 (local machine x64 e x86) |
| 43 | var lm64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); | 46 | var lm64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); |
| 44 | var lm32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32); | 47 | var lm32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32); |
| 48 | + var cu64 = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64); | ||
| 49 | + var cu32 = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32); | ||
| 45 | 50 | ||
| 46 | 51 | ||
| 47 | //EXTRAÇÃO DO VLIBRAS | 52 | //EXTRAÇÃO DO VLIBRAS |
| 48 | - string vlibrasZip = @"VLIBRAS.zip"; | ||
| 49 | - string vlibrasZipAbsolute = dirAtual+@"\"+vlibrasZip; | ||
| 50 | - ZipArchive archive = ZipFile.Open(vlibrasZipAbsolute, ZipArchiveMode.Read, System.Text.Encoding.GetEncoding(System.Globalization.CultureInfo.CurrentCulture.TextInfo.OEMCodePage)); | ||
| 51 | - if(!File.Exists(dirAtual+@"\"+@"extraido")){ | ||
| 52 | - Console.WriteLine("Extraindo do arquivo: "+vlibrasZip); | ||
| 53 | - BundlesManager.ExtractToDirectory(archive, dirAtual, true); | ||
| 54 | - Console.WriteLine("Extração do arquivo "+vlibrasZip+" concluída."); | ||
| 55 | - File.Create(dirAtual+@"\"+@"extraido").Close(); | 53 | + Console.WriteLine("Extração do vlibras"); |
| 54 | + try{ | ||
| 55 | + string vlibrasZip = @"VLIBRAS.zip"; | ||
| 56 | + string vlibrasZipAbsolute = dirAtual+@"\"+vlibrasZip; | ||
| 57 | + ZipArchive archive = ZipFile.Open(vlibrasZipAbsolute, ZipArchiveMode.Read, System.Text.Encoding.GetEncoding(System.Globalization.CultureInfo.CurrentCulture.TextInfo.OEMCodePage)); | ||
| 58 | + if(!File.Exists(dirAtual+@"\"+@"extraido")){ | ||
| 59 | + Console.WriteLine("Extraindo do arquivo: "+vlibrasZip); | ||
| 60 | + BundlesManager.ExtractToDirectory(archive, dirAtual, true); | ||
| 61 | + Console.WriteLine("Extração do arquivo "+vlibrasZip+" concluída."); | ||
| 62 | + File.Create(dirAtual+@"\"+@"extraido").Close(); | ||
| 63 | + } | ||
| 64 | + }catch(Exception e){ | ||
| 65 | + Console.WriteLine("Erro: {0}\nAperte alguma tecla para continuar.", e); | ||
| 66 | + Console.ReadKey(); | ||
| 56 | } | 67 | } |
| 57 | 68 | ||
| 58 | 69 | ||
| 59 | //EXTRAÇÃO DOS REQUISITOS | 70 | //EXTRAÇÃO DOS REQUISITOS |
| 60 | - string reqZip = @"requisitos.zip"; | ||
| 61 | - string reqZipAbsolute = dirAtual+@"\"+reqZip; | ||
| 62 | - archive = ZipFile.Open(reqZipAbsolute, ZipArchiveMode.Read, System.Text.Encoding.GetEncoding(System.Globalization.CultureInfo.CurrentCulture.TextInfo.OEMCodePage)); | ||
| 63 | - if(!File.Exists(dirAtual+@"\"+@"extraidoReq")){ | ||
| 64 | - Console.WriteLine("Extraindo do arquivo: "+reqZip); | ||
| 65 | - BundlesManager.ExtractToDirectory(archive, dirAtual, true); | ||
| 66 | - Console.WriteLine("Extração do arquivo "+reqZip+" concluída."); | ||
| 67 | - File.Create(dirAtual+@"\"+@"extraidoReq").Close(); | 71 | + Console.WriteLine("Extração de Requisitos"); |
| 72 | + try{ | ||
| 73 | + string reqZip = @"requisitos.zip"; | ||
| 74 | + string reqZipAbsolute = dirAtual+@"\"+reqZip; | ||
| 75 | + ZipArchive archive = ZipFile.Open(reqZipAbsolute, ZipArchiveMode.Read, System.Text.Encoding.GetEncoding(System.Globalization.CultureInfo.CurrentCulture.TextInfo.OEMCodePage)); | ||
| 76 | + if(!File.Exists(dirAtual+@"\"+@"extraidoReq")){ | ||
| 77 | + Console.WriteLine("Extraindo do arquivo: "+reqZip); | ||
| 78 | + BundlesManager.ExtractToDirectory(archive, dirAtual, true); | ||
| 79 | + Console.WriteLine("Extração do arquivo "+reqZip+" concluída."); | ||
| 80 | + File.Create(dirAtual+@"\"+@"extraidoReq").Close(); | ||
| 81 | + } | ||
| 82 | + }catch(Exception e){ | ||
| 83 | + Console.WriteLine("Erro: {0}\nAperte alguma tecla para continuar.", e); | ||
| 84 | + Console.ReadKey(); | ||
| 68 | } | 85 | } |
| 69 | 86 | ||
| 70 | 87 | ||
| 71 | - | ||
| 72 | //VERIFICAÇÃO E DESINSTALAÇÃO DO VLIBRAS DESCONTINUADO | 88 | //VERIFICAÇÃO E DESINSTALAÇÃO DO VLIBRAS DESCONTINUADO |
| 73 | Console.WriteLine("Verificação se há versões descontinuadas do VLibras."); | 89 | Console.WriteLine("Verificação se há versões descontinuadas do VLibras."); |
| 74 | - //x64 | ||
| 75 | - RegistryKey[] regVLibrasOld = new RegistryKey[2]; | ||
| 76 | - regVLibrasOld[0] = lm64.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{84B73167-EF7F-42BB-9CCD-E1A8E2C53659-vlibras}_is1"); | ||
| 77 | - regVLibrasOld[1] = lm32.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{84B73167-EF7F-42BB-9CCD-E1A8E2C53659-vlibras}_is1"); | ||
| 78 | - Requirements.Uninstall(regVLibrasOld); | 90 | + try{ |
| 91 | + RegistryKey[] regVLibrasOld = new RegistryKey[2]; | ||
| 92 | + regVLibrasOld[0] = lm64.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{84B73167-EF7F-42BB-9CCD-E1A8E2C53659-vlibras}_is1"); | ||
| 93 | + regVLibrasOld[1] = lm32.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{84B73167-EF7F-42BB-9CCD-E1A8E2C53659-vlibras}_is1"); | ||
| 94 | + Requirements.Uninstall(regVLibrasOld); | ||
| 95 | + }catch(Exception e){ | ||
| 96 | + Console.WriteLine("Erro: {0}\nAperte alguma tecla para continuar.", e); | ||
| 97 | + Console.ReadKey(); | ||
| 98 | + } | ||
| 79 | 99 | ||
| 80 | 100 | ||
| 81 | - //REGISTROS DO PYTHON | ||
| 82 | - RegistryKey[] regPython = new RegistryKey[4]; | ||
| 83 | - regPython[0] = lm64.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{79F081BF-7454-43DB-BD8F-9EE596813232}"); | ||
| 84 | - regPython[1] = lm64.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{79F081BF-7454-43DB-BD8F-9EE596813233}"); | ||
| 85 | - regPython[2] = lm32.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{79F081BF-7454-43DB-BD8F-9EE596813232}"); | ||
| 86 | - regPython[3] = lm32.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{79F081BF-7454-43DB-BD8F-9EE596813233}"); | 101 | + //INSTALAÇÃO DO LAUNCHER DO PYTHON |
| 102 | + //é para ser instalado antes mesmo!!!!!!! | ||
| 103 | + /*Console.WriteLine("Verificação do launcher"); | ||
| 104 | + try{ | ||
| 105 | + RegistryKey[] regPyLauncher = new RegistryKey[2]; | ||
| 106 | + regPyLauncher[0] = cu64.OpenSubKey(@"Software\Microsoft\Installer\Products\B24C6BC17885FC74FA128928650F54B5"); | ||
| 107 | + regPyLauncher[1] = cu64.OpenSubKey(@"Software\Microsoft\Installer\Products\26D5B8927821F7248B9D4BD406F5F8B6"); | ||
| 108 | + if(!Requirements.IsInstalled(regPyLauncher)){ | ||
| 109 | + buscaDeArquivo = Directory.GetFiles(dirAtual, "launchwin-1.0.1.6.amd64.msi", SearchOption.AllDirectories); | ||
| 110 | + string pyLauncherPath64 = (buscaDeArquivo.Length > 0)? buscaDeArquivo[0]: @""; | ||
| 111 | + buscaDeArquivo = Directory.GetFiles(dirAtual, "launchwin-1.0.1.6.msi", SearchOption.AllDirectories); | ||
| 112 | + string pyLauncherPath86 = (buscaDeArquivo.Length > 0)? buscaDeArquivo[0]: @""; //O VALOR É 0 MESMO, POIS REALIZOU UMA NOVA BUSCA | ||
| 113 | + Requirements.InstallAndWait(pyLauncherPath64, pyLauncherPath86);//, @"/passive"); //instalação passiva | ||
| 114 | + } | ||
| 115 | + }catch(Exception e){ | ||
| 116 | + Console.WriteLine("Erro: {0}\nAperte alguma tecla para continuar.", e); | ||
| 117 | + Console.ReadKey(); | ||
| 118 | + }*/ | ||
| 119 | + | ||
| 87 | //VERIFICAÇÃO E INSTALAÇÃO DO PYTHON | 120 | //VERIFICAÇÃO E INSTALAÇÃO DO PYTHON |
| 88 | - Console.WriteLine("Verificando se o Python 2.7.9 está instalado"); | ||
| 89 | - if(!Requirements.IsInstalled(regPython)){ | ||
| 90 | - //PATHS DE INSTALAÇÃO DO PYTHON | ||
| 91 | - buscaDeArquivo = Directory.GetFiles(dirAtual, "python-2.7.9.amd64.msi", SearchOption.AllDirectories); | ||
| 92 | - string pythonPath64 = (buscaDeArquivo.Length > 0)? buscaDeArquivo[0]: @""; | ||
| 93 | - buscaDeArquivo = Directory.GetFiles(dirAtual, "python-2.7.9.msi", SearchOption.AllDirectories); | ||
| 94 | - string pythonPath86 = (buscaDeArquivo.Length > 0)? buscaDeArquivo[0]: @""; //O VALOR É 0 MESMO, POIS REALIZOU UMA NOVA BUSCA | ||
| 95 | - Requirements.InstallAndWait(pythonPath64, pythonPath86); | 121 | + //REGISTROS DO PYTHON |
| 122 | + try{ | ||
| 123 | + RegistryKey[] regPython = new RegistryKey[4]; | ||
| 124 | + regPython[0] = lm64.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9DA28CE5-0AA5-429E-86D8-686ED898C665}"); | ||
| 125 | + regPython[1] = lm32.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9DA28CE5-0AA5-429E-86D8-686ED898C665}"); | ||
| 126 | + regPython[2] = lm32.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{9DA28CE5-0AA5-429E-86D8-686ED898C665}"); | ||
| 127 | + regPython[3] = lm64.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{9DA28CE5-0AA5-429E-86D8-686ED898C665}"); | ||
| 128 | + | ||
| 129 | + Console.WriteLine("Verificando se o Python 2.7.12(32) está instalado"); | ||
| 130 | + if(!Requirements.IsInstalled(regPython)){//ChecarVersaoPython()){ | ||
| 131 | + //PATHS DE INSTALAÇÃO DO PYTHON | ||
| 132 | + buscaDeArquivo = Directory.GetFiles(dirAtual, "python-2.7.12.msi", SearchOption.AllDirectories); | ||
| 133 | + string pythonPath86 = (buscaDeArquivo.Length > 0)? buscaDeArquivo[0]: @""; //O VALOR É 0 MESMO, POIS REALIZOU UMA NOVA BUSCA | ||
| 134 | + Requirements.InstallAndWait(pythonPath86, pythonPath86);//, @"/qn"); //instalação silenciosa | ||
| 135 | + instalouPython = true; | ||
| 136 | + } | ||
| 137 | + }catch(Exception e){ | ||
| 138 | + Console.WriteLine("Erro: {0}\nAperte alguma tecla para continuar.", e); | ||
| 139 | + Console.ReadKey(); | ||
| 96 | } | 140 | } |
| 97 | 141 | ||
| 98 | 142 | ||
| 143 | + /* | ||
| 99 | //VERIFICAÇÃO E INSTALAÇÃO DE PYWIN32 | 144 | //VERIFICAÇÃO E INSTALAÇÃO DE PYWIN32 |
| 100 | //usa esse arquivo para verificação de instalação do pywin32 | 145 | //usa esse arquivo para verificação de instalação do pywin32 |
| 101 | Console.WriteLine("Verificando instalação do Pywin32."); | 146 | Console.WriteLine("Verificando instalação do Pywin32."); |
| @@ -111,9 +156,11 @@ namespace VLIBRAS_II | @@ -111,9 +156,11 @@ namespace VLIBRAS_II | ||
| 111 | Requirements.Install(pywin32Pathx64, pywin32Pathx86); | 156 | Requirements.Install(pywin32Pathx64, pywin32Pathx86); |
| 112 | //File.Create(pywin32File).Close(); | 157 | //File.Create(pywin32File).Close(); |
| 113 | } | 158 | } |
| 159 | + */ | ||
| 114 | 160 | ||
| 115 | 161 | ||
| 116 | //VERIFICAÇÃO DA INSTALAÇÃO DO NVDA | 162 | //VERIFICAÇÃO DA INSTALAÇÃO DO NVDA |
| 163 | + /* | ||
| 117 | Console.WriteLine("Verificando instalação do NVDA."); | 164 | Console.WriteLine("Verificando instalação do NVDA."); |
| 118 | //REGISTROS DO NDVA | 165 | //REGISTROS DO NDVA |
| 119 | RegistryKey[] regNVDA = new RegistryKey[3]; | 166 | RegistryKey[] regNVDA = new RegistryKey[3]; |
| @@ -125,6 +172,7 @@ namespace VLIBRAS_II | @@ -125,6 +172,7 @@ namespace VLIBRAS_II | ||
| 125 | string NVDApath = (buscaDeArquivo.Length > 0)? buscaDeArquivo[0] : @""; | 172 | string NVDApath = (buscaDeArquivo.Length > 0)? buscaDeArquivo[0] : @""; |
| 126 | Requirements.Install(NVDApath, NVDApath); | 173 | Requirements.Install(NVDApath, NVDApath); |
| 127 | } | 174 | } |
| 175 | + */ | ||
| 128 | 176 | ||
| 129 | 177 | ||
| 130 | //CONFIGURAÇÃO DAS VARIÁVEIS DE AMBIENTE | 178 | //CONFIGURAÇÃO DAS VARIÁVEIS DE AMBIENTE |
| @@ -132,7 +180,34 @@ namespace VLIBRAS_II | @@ -132,7 +180,34 @@ namespace VLIBRAS_II | ||
| 132 | try{ | 180 | try{ |
| 133 | ResetEnvVar(); | 181 | ResetEnvVar(); |
| 134 | }catch(Exception e){ | 182 | }catch(Exception e){ |
| 135 | - Console.WriteLine("Erro Var Env: {0}", e); | 183 | + Console.WriteLine("Erro Var Env: {0}\nAperte alguma tecla para continuar.", e); |
| 184 | + Console.ReadKey(); | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + | ||
| 188 | + | ||
| 189 | + //INSTALAÇÃO DOS MÓDULOS DO PYTHON | ||
| 190 | + //Tem que ser depois da configuração das variáveis de ambiente | ||
| 191 | + Console.WriteLine("Instalando os módulos de python."); | ||
| 192 | + try{ | ||
| 193 | + if(instalouPython){ | ||
| 194 | + //instalação forçada de módulos | ||
| 195 | + Requirements.InstallWheels(true); | ||
| 196 | + }else{ | ||
| 197 | + Requirements.InstallWheels(false); | ||
| 198 | + } | ||
| 199 | + }catch(Exception e){ | ||
| 200 | + Console.WriteLine("Erro na instalação de módulos do python {0}\nAperte alguma tecla para continuar.", e); | ||
| 201 | + Console.ReadKey(); | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + //CRIAÇÃO DO ATALHO DO VLIBRAS | ||
| 205 | + Console.WriteLine("Criação do atalho do vlibras."); | ||
| 206 | + try{ | ||
| 207 | + Requirements.criaAtalho(); | ||
| 208 | + }catch(Exception e){ | ||
| 209 | + Console.WriteLine("Erro na instalação de módulos do python {0}\nAperte alguma tecla para continuar.", e); | ||
| 210 | + Console.ReadKey(); | ||
| 136 | } | 211 | } |
| 137 | 212 | ||
| 138 | 213 | ||
| @@ -145,7 +220,8 @@ namespace VLIBRAS_II | @@ -145,7 +220,8 @@ namespace VLIBRAS_II | ||
| 145 | try{ | 220 | try{ |
| 146 | qtdDeBundles = BundlesManager.DownloadBundlesPackages(url, rootPath, extractPath); | 221 | qtdDeBundles = BundlesManager.DownloadBundlesPackages(url, rootPath, extractPath); |
| 147 | }catch(Exception e){ | 222 | }catch(Exception e){ |
| 148 | - Console.WriteLine("Erro no download do pacote de sinais."); | 223 | + Console.WriteLine("Erro no download do pacote de sinais.\n{0}\nAperte alguma tecla para continuar.",e); |
| 224 | + Console.ReadKey(); | ||
| 149 | } | 225 | } |
| 150 | 226 | ||
| 151 | 227 | ||
| @@ -153,11 +229,12 @@ namespace VLIBRAS_II | @@ -153,11 +229,12 @@ namespace VLIBRAS_II | ||
| 153 | //EXTRAI APENAS SE NÃO TIVER O ARQUIVO HOMÔNIMO SEM EXTENSÃO NA PASTA SINAIS | 229 | //EXTRAI APENAS SE NÃO TIVER O ARQUIVO HOMÔNIMO SEM EXTENSÃO NA PASTA SINAIS |
| 154 | //SE O CAMINHO DE EXTRAÇÃO NÃO EXISTE, ELE SERÁ CRIADO | 230 | //SE O CAMINHO DE EXTRAÇÃO NÃO EXISTE, ELE SERÁ CRIADO |
| 155 | Console.WriteLine("Extraindo pacote de sinais."); | 231 | Console.WriteLine("Extraindo pacote de sinais."); |
| 156 | - try{ | ||
| 157 | - BundlesManager.ExtractBundlesPackagesOverWrite(rootPath, extractPath, qtdDeBundles); | ||
| 158 | - }catch(Exception e){ | ||
| 159 | - Console.WriteLine("Erro na extração"); | ||
| 160 | - } | 232 | + //try{ |
| 233 | + BundlesManager.ExtractBundlesPackagesOverWrite(rootPath, extractPath, qtdDeBundles, url); | ||
| 234 | + /*}catch(Exception e){ | ||
| 235 | + Console.WriteLine("Erro na extração: {0}", e); | ||
| 236 | + Console.ReadKey(); | ||
| 237 | + }*/ | ||
| 161 | 238 | ||
| 162 | 239 | ||
| 163 | //CONCLUSÃO | 240 | //CONCLUSÃO |
| @@ -165,6 +242,8 @@ namespace VLIBRAS_II | @@ -165,6 +242,8 @@ namespace VLIBRAS_II | ||
| 165 | 242 | ||
| 166 | 243 | ||
| 167 | //RODA O VLIBRAS | 244 | //RODA O VLIBRAS |
| 245 | + | ||
| 246 | + /*Console.WriteLine("Abrindo player."); | ||
| 168 | try{ | 247 | try{ |
| 169 | Process playerProc = new Process(); | 248 | Process playerProc = new Process(); |
| 170 | string[] buscaPlayer = Directory.GetFiles(dirAtual, "vlibrasPlayer.exe", SearchOption.AllDirectories); | 249 | string[] buscaPlayer = Directory.GetFiles(dirAtual, "vlibrasPlayer.exe", SearchOption.AllDirectories); |
| @@ -174,8 +253,9 @@ namespace VLIBRAS_II | @@ -174,8 +253,9 @@ namespace VLIBRAS_II | ||
| 174 | playerProc.Start(); | 253 | playerProc.Start(); |
| 175 | //playerProc.WaitForExit(); | 254 | //playerProc.WaitForExit(); |
| 176 | }catch(Exception e){ | 255 | }catch(Exception e){ |
| 177 | - Console.WriteLine("Erro: {0}", e); | ||
| 178 | - } | 256 | + Console.WriteLine("Erro: {0}\nAperte alguma tecla para continuar.", e); |
| 257 | + Console.ReadKey(); | ||
| 258 | + }*/ | ||
| 179 | 259 | ||
| 180 | /* | 260 | /* |
| 181 | Application.EnableVisualStyles(); | 261 | Application.EnableVisualStyles(); |
Requirements.cs
| 1 | using System; | 1 | using System; |
| 2 | +using System.IO; | ||
| 3 | +using System.Diagnostics; | ||
| 2 | using Microsoft.Win32; | 4 | using Microsoft.Win32; |
| 3 | 5 | ||
| 4 | -namespace VLIBRAS_II | 6 | +namespace AtualizadorVLibras |
| 5 | { | 7 | { |
| 6 | class Requirements | 8 | class Requirements |
| 7 | { | 9 | { |
| @@ -26,9 +28,9 @@ namespace VLIBRAS_II | @@ -26,9 +28,9 @@ namespace VLIBRAS_II | ||
| 26 | foreach(RegistryKey reg in regs){ | 28 | foreach(RegistryKey reg in regs){ |
| 27 | if(IsInstalled(reg)){ | 29 | if(IsInstalled(reg)){ |
| 28 | try{ | 30 | try{ |
| 29 | - System.Diagnostics.Process uninsProc = new System.Diagnostics.Process(); | ||
| 30 | - System.Diagnostics.ProcessStartInfo uninsProcInfo = new System.Diagnostics.ProcessStartInfo(); | ||
| 31 | - uninsProcInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; | 31 | + Process uninsProc = new Process(); |
| 32 | + ProcessStartInfo uninsProcInfo = new ProcessStartInfo(); | ||
| 33 | + uninsProcInfo.WindowStyle = ProcessWindowStyle.Hidden; | ||
| 32 | uninsProcInfo.FileName = "cmd.exe"; | 34 | uninsProcInfo.FileName = "cmd.exe"; |
| 33 | string comandoUnins; | 35 | string comandoUnins; |
| 34 | comandoUnins = "/C" + reg.GetValue("QuietUninstallString").ToString().Replace("\"", ""); | 36 | comandoUnins = "/C" + reg.GetValue("QuietUninstallString").ToString().Replace("\"", ""); |
| @@ -36,13 +38,208 @@ namespace VLIBRAS_II | @@ -36,13 +38,208 @@ namespace VLIBRAS_II | ||
| 36 | uninsProc.StartInfo = uninsProcInfo; | 38 | uninsProc.StartInfo = uninsProcInfo; |
| 37 | uninsProc.Start(); | 39 | uninsProc.Start(); |
| 38 | //uninsProc.WaitForExit(); | 40 | //uninsProc.WaitForExit(); |
| 39 | - }catch(Exception e){ | 41 | + }catch(Exception){ |
| 40 | //NOTHING | 42 | //NOTHING |
| 41 | } | 43 | } |
| 42 | } | 44 | } |
| 43 | } | 45 | } |
| 44 | } | 46 | } |
| 45 | 47 | ||
| 48 | + //CRIA ATALHO | ||
| 49 | + public static void criaAtalho(){ | ||
| 50 | + //string driveAtual = @"%HOMEPATH%\..\.."; | ||
| 51 | + //string pathPython2 = driveAtual+@"Python27\python.exe"; | ||
| 52 | + //string pathPython2 = Environment.GetEnvironmentVariable("PYTHONPATH", EnvironmentVariableTarget.Machine); | ||
| 53 | + string pathPython2 = GetRegistroPythonPath(); | ||
| 54 | + int idx = pathPython2.IndexOf(@";"); | ||
| 55 | + //pathPython2 = pathPython2.Remove(idx, pathPython2.Length - idx); | ||
| 56 | + //pathPython2 = "\""+pathPython2 + "\\python.exe\""; | ||
| 57 | + | ||
| 58 | + //Console.WriteLine("VERIFICAÇÃO DA LINHA criaAtalho: "+pathPython2); | ||
| 59 | + //Console.ReadKey(); | ||
| 60 | + | ||
| 61 | + ProcessStartInfo procInfo = new ProcessStartInfo(); | ||
| 62 | + procInfo.FileName = pathPython2;//"cmd.exe"; | ||
| 63 | + //procInfo.Arguments = "/C py -2 "+Directory.GetCurrentDirectory()+@"\criaLnk.py"; | ||
| 64 | + //procInfo.Arguments = "/C "+pathPython2+" -m "+Directory.GetCurrentDirectory()+@"\criaLnk.py"; | ||
| 65 | + //procInfo.Arguments = "/C "+pathPython2+" \""+Directory.GetCurrentDirectory()+"\\criaLnk.py\""; | ||
| 66 | + procInfo.Arguments = "\""+Directory.GetCurrentDirectory()+@"\criaLnk.py"; | ||
| 67 | + procInfo.UseShellExecute = false; | ||
| 68 | + procInfo.RedirectStandardOutput = true; | ||
| 69 | + procInfo.WindowStyle = ProcessWindowStyle.Hidden; | ||
| 70 | + | ||
| 71 | + //Process process = new Process(); | ||
| 72 | + //process.StartInfo = procInfo; | ||
| 73 | + //process.Start(); | ||
| 74 | + using(Process process = Process.Start(procInfo)){ | ||
| 75 | + using(StreamReader reader = process.StandardOutput){ | ||
| 76 | + string result = reader.ReadToEnd(); | ||
| 77 | + Console.Write(result); | ||
| 78 | + } | ||
| 79 | + process.WaitForExit(); | ||
| 80 | + } | ||
| 81 | + //Console.WriteLine("pausa: {0}",procInfo.Arguments); | ||
| 82 | + //Console.ReadKey(); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public static string GetRegistroPythonPath(){ | ||
| 86 | + var lm64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); | ||
| 87 | + var lm32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32); | ||
| 88 | + var cr64 = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry64); | ||
| 89 | + var cr32 = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry32); | ||
| 90 | + var cu64 = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64); | ||
| 91 | + var cu32 = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32); | ||
| 92 | + | ||
| 93 | + RegistryKey pythonReg = null; | ||
| 94 | + if(lm64.OpenSubKey(@"SOFTWARE\Python\PythonCore\2.7\InstallPath") != null){ | ||
| 95 | + pythonReg = lm64.OpenSubKey(@"SOFTWARE\Python\PythonCore\2.7\InstallPath"); | ||
| 96 | + } | ||
| 97 | + if(lm32.OpenSubKey(@"SOFTWARE\Python\PythonCore\2.7\InstallPath") != null){ | ||
| 98 | + pythonReg = lm32.OpenSubKey(@"SOFTWARE\Python\PythonCore\2.7\InstallPath"); | ||
| 99 | + } | ||
| 100 | + if(cu64.OpenSubKey(@"SOFTWARE\Python\PythonCore\2.7\InstallPath") != null){ | ||
| 101 | + pythonReg = cu64.OpenSubKey(@"SOFTWARE\Python\PythonCore\2.7\InstallPath"); | ||
| 102 | + } | ||
| 103 | + if(cu32.OpenSubKey(@"SOFTWARE\Python\PythonCore\2.7\InstallPath") != null){ | ||
| 104 | + pythonReg = cu32.OpenSubKey(@"SOFTWARE\Python\PythonCore\2.7\InstallPath"); | ||
| 105 | + } | ||
| 106 | + if(lm64.OpenSubKey(@"SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath") != null){ | ||
| 107 | + pythonReg = lm64.OpenSubKey(@"SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath"); | ||
| 108 | + } | ||
| 109 | + if(lm32.OpenSubKey(@"SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath") != null){ | ||
| 110 | + pythonReg = lm32.OpenSubKey(@"SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath"); | ||
| 111 | + } | ||
| 112 | + if(cu64.OpenSubKey(@"SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath") != null){ | ||
| 113 | + pythonReg = cu64.OpenSubKey(@"SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath"); | ||
| 114 | + } | ||
| 115 | + if(cu32.OpenSubKey(@"SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath") != null){ | ||
| 116 | + pythonReg = cu32.OpenSubKey(@"SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath"); | ||
| 117 | + } | ||
| 118 | + if(pythonReg != null){ | ||
| 119 | + //CONIFGURAÇÃO DA VARIÁVEL PYTHONPATH | ||
| 120 | + string python = pythonReg.GetValue(null).ToString(); | ||
| 121 | + //python = python.Remove(python.Length - 1).ToString(); | ||
| 122 | + return "\""+python+@"python.exe"+"\""; | ||
| 123 | + }else{ | ||
| 124 | + return ""; | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + //INSTALA, SE NECESSÁRIO, OS MÓDULOS DO PYTHON | ||
| 129 | + public static void InstallWheels(bool force){ | ||
| 130 | + /*var cr64 = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry64); | ||
| 131 | + var cr32 = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry32); | ||
| 132 | + RegistryKey pythonShell = cr64.OpenSubKey(@"Python.File\Shell\open\command"); | ||
| 133 | + if(pythonShell == null){ | ||
| 134 | + pythonShell = cr32.OpenSubKey(@"Python.File\Shell\open\command"); | ||
| 135 | + } | ||
| 136 | + path do python na máquina | ||
| 137 | + string pythonCMD = pythonShell.GetValue(null).ToString(); | ||
| 138 | + pythonCMD = pythonCMD.Remove(pythonCMD.Length - 9).Replace("\"", ""); | ||
| 139 | + procInfo.FileName = pythonCMD;*/ | ||
| 140 | + | ||
| 141 | + //INFORMAÇÕES SOBRE O PROCESSO QUE VAI SER INICIADO | ||
| 142 | + //string driveAtual = @"%HOMEPATH%\..\.."; | ||
| 143 | + //string pathPython2 = driveAtual+@"Python27\python.exe"; | ||
| 144 | + | ||
| 145 | + //string pathPython2 = Environment.GetEnvironmentVariable("PYTHONPATH", EnvironmentVariableTarget.Machine); | ||
| 146 | + string pathPython2 = GetRegistroPythonPath(); | ||
| 147 | + int idx = pathPython2.IndexOf(@";"); | ||
| 148 | + //pathPython2 = pathPython2.Remove(idx, pathPython2.Length - idx); | ||
| 149 | + //pathPython2 = "\""+pathPython2 + "\\python.exe\""; | ||
| 150 | + | ||
| 151 | + //Console.WriteLine("VERIFICAÇÃO DA LINHA insWhls: "+pathPython2); | ||
| 152 | + //Console.ReadKey(); | ||
| 153 | + //ATUALIZAÇÃO DO PIP | ||
| 154 | + ProcessStartInfo procInfo = new ProcessStartInfo(); | ||
| 155 | + //procInfo.FileName = "py"; | ||
| 156 | + //procInfo.Arguments = "-2 -m pip install --upgrade pip"; | ||
| 157 | + procInfo.FileName = pathPython2; | ||
| 158 | + procInfo.Arguments = "-m pip install --upgrade pip"; | ||
| 159 | + procInfo.UseShellExecute = false; | ||
| 160 | + procInfo.RedirectStandardOutput = true; | ||
| 161 | + procInfo.WindowStyle = ProcessWindowStyle.Hidden; | ||
| 162 | + | ||
| 163 | + //Process process = new Process(); | ||
| 164 | + //process.StartInfo = procInfo; | ||
| 165 | + //process.Start(); | ||
| 166 | + //process.WaitForExit(); | ||
| 167 | + using(Process process = Process.Start(procInfo)){ | ||
| 168 | + using(StreamReader reader = process.StandardOutput){ | ||
| 169 | + string result = reader.ReadToEnd(); | ||
| 170 | + Console.Write(result); | ||
| 171 | + } | ||
| 172 | + process.WaitForExit(); | ||
| 173 | + } | ||
| 174 | + Console.WriteLine("Pip atualizado."); | ||
| 175 | + Console.WriteLine("Instalando os módulos. Isso pode levar alguns minutos. Por favor, aguarde."); | ||
| 176 | + //INSTALAÇÃO DOS MÓDULOS | ||
| 177 | + if(force){ | ||
| 178 | + //instalação forçada | ||
| 179 | + //procInfo.Arguments = "-2 "+Directory.GetCurrentDirectory()+@"\checkwheels.py --force"; | ||
| 180 | + //procInfo.Arguments = "-m "+Directory.GetCurrentDirectory()+@"\checkwheels.py --force"; | ||
| 181 | + procInfo.Arguments = "\""+Directory.GetCurrentDirectory()+@"\checkwheels.py"+"\""+" --force"; | ||
| 182 | + }else{ | ||
| 183 | + //procInfo.Arguments = "-2 "+Directory.GetCurrentDirectory()+@"\checkwheels.py"; | ||
| 184 | + //procInfo.Arguments = "-m "+Directory.GetCurrentDirectory()+@"\checkwheels.py"; | ||
| 185 | + procInfo.Arguments = "\""+Directory.GetCurrentDirectory()+@"\checkwheels.py"+"\""; | ||
| 186 | + } | ||
| 187 | + //Console.WriteLine("VERIFICAÇÃO DA LINHA insWhls2: "+procInfo.Arguments); | ||
| 188 | + //Console.ReadKey(); | ||
| 189 | + //process = new Process(); | ||
| 190 | + //process.StartInfo = procInfo; | ||
| 191 | + //process.Start(); | ||
| 192 | + //process.WaitForExit(); | ||
| 193 | + using(Process process = Process.Start(procInfo)){ | ||
| 194 | + using(StreamReader reader = process.StandardOutput){ | ||
| 195 | + string result = reader.ReadToEnd(); | ||
| 196 | + Console.Write(result); | ||
| 197 | + } | ||
| 198 | + process.WaitForExit(); | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + | ||
| 203 | + //SE FOR USAR BOTAR PYTHONPATH2 ENTRE ASPAS!!!!!!!!!! | ||
| 204 | + /*public static bool ChecarVersaoPython(){ | ||
| 205 | + string driveAtual = @"%HOMEPATH%\..\.."; | ||
| 206 | + string pathPython2 = driveAtual+@"Python27\python.exe"; | ||
| 207 | + | ||
| 208 | + //string comandoIns = "/C py -2 --version"; | ||
| 209 | + string comandoIns = @"/C "+"\""pathPython2+"\""+" --version"; | ||
| 210 | + //Process e Process Information | ||
| 211 | + ProcessStartInfo insProcInfo = new ProcessStartInfo(); | ||
| 212 | + Process insProc = new Process(); | ||
| 213 | + | ||
| 214 | + insProcInfo.WindowStyle = ProcessWindowStyle.Hidden; | ||
| 215 | + insProcInfo.FileName = "cmd.exe"; | ||
| 216 | + insProcInfo.Arguments = comandoIns; | ||
| 217 | + insProcInfo.UseShellExecute = false; | ||
| 218 | + insProcInfo.CreateNoWindow = true; | ||
| 219 | + insProcInfo.RedirectStandardError = true; | ||
| 220 | + //insProcInfo.Verb = "runas"; //ADM | ||
| 221 | + | ||
| 222 | + insProc.StartInfo = insProcInfo; | ||
| 223 | + insProc.Start(); | ||
| 224 | + string output = insProc.StandardError.ReadToEnd(); | ||
| 225 | + insProc.WaitForExit(); | ||
| 226 | + if(output == null || output == ""){ | ||
| 227 | + return false; | ||
| 228 | + } | ||
| 229 | + output = output.Remove(output.Length-2); | ||
| 230 | + string version = output.Replace("Python ", ""); | ||
| 231 | + string majorMinorVersion = version.Remove(3); | ||
| 232 | + if(majorMinorVersion.Equals("2.7")){ | ||
| 233 | + string patchVersion = version.Replace("2.7.",""); | ||
| 234 | + int x = -1; | ||
| 235 | + int.TryParse(patchVersion, out x); | ||
| 236 | + if(x >= 9){ | ||
| 237 | + return true; | ||
| 238 | + } | ||
| 239 | + } | ||
| 240 | + return false; | ||
| 241 | + }*/ | ||
| 242 | + | ||
| 46 | public static void Install(string pathInstaller64, string pathInstaller86){ | 243 | public static void Install(string pathInstaller64, string pathInstaller86){ |
| 47 | string pathInstaller; | 244 | string pathInstaller; |
| 48 | if(Environment.Is64BitOperatingSystem){ | 245 | if(Environment.Is64BitOperatingSystem){ |
| @@ -53,12 +250,13 @@ namespace VLIBRAS_II | @@ -53,12 +250,13 @@ namespace VLIBRAS_II | ||
| 53 | if(pathInstaller == ""){ | 250 | if(pathInstaller == ""){ |
| 54 | return; | 251 | return; |
| 55 | } | 252 | } |
| 56 | - string comandoIns = "/C" + pathInstaller; | 253 | + //string comandoIns = "/C" + pathInstaller + " -s -v -qn"; |
| 254 | + string comandoIns = @"msiexec /i "+"\""+pathInstaller+"\""+@" /quiet /qn /norestart"; | ||
| 57 | //Process e Process Information | 255 | //Process e Process Information |
| 58 | - System.Diagnostics.ProcessStartInfo insProcInfo = new System.Diagnostics.ProcessStartInfo(); | ||
| 59 | - insProcInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; | ||
| 60 | - System.Diagnostics.Process insProc = new System.Diagnostics.Process(); | 256 | + ProcessStartInfo insProcInfo = new ProcessStartInfo(); |
| 257 | + Process insProc = new Process(); | ||
| 61 | 258 | ||
| 259 | + insProcInfo.WindowStyle = ProcessWindowStyle.Hidden; | ||
| 62 | insProcInfo.FileName = "cmd.exe"; | 260 | insProcInfo.FileName = "cmd.exe"; |
| 63 | insProcInfo.Arguments = comandoIns; | 261 | insProcInfo.Arguments = comandoIns; |
| 64 | //insProcInfo.Verb = "runas"; //ADM | 262 | //insProcInfo.Verb = "runas"; //ADM |
| @@ -68,7 +266,7 @@ namespace VLIBRAS_II | @@ -68,7 +266,7 @@ namespace VLIBRAS_II | ||
| 68 | //insProc.WaitForExit(); | 266 | //insProc.WaitForExit(); |
| 69 | } | 267 | } |
| 70 | 268 | ||
| 71 | - public static void InstallAndWait(string pathInstaller64, string pathInstaller86){ | 269 | + public static void Install(string pathInstaller64, string pathInstaller86, string args){ |
| 72 | string pathInstaller; | 270 | string pathInstaller; |
| 73 | if(Environment.Is64BitOperatingSystem){ | 271 | if(Environment.Is64BitOperatingSystem){ |
| 74 | pathInstaller = pathInstaller64; | 272 | pathInstaller = pathInstaller64; |
| @@ -78,18 +276,72 @@ namespace VLIBRAS_II | @@ -78,18 +276,72 @@ namespace VLIBRAS_II | ||
| 78 | if(pathInstaller == ""){ | 276 | if(pathInstaller == ""){ |
| 79 | return; | 277 | return; |
| 80 | } | 278 | } |
| 81 | - string comandoIns = "/C" + pathInstaller; | 279 | + //string comandoIns = "/C" + pathInstaller + " -s -v -qn"; |
| 280 | + string comandoIns = @"msiexec /i "+"\""+pathInstaller+"\" "+args; | ||
| 82 | //Process e Process Information | 281 | //Process e Process Information |
| 83 | - System.Diagnostics.ProcessStartInfo insProcInfo = new System.Diagnostics.ProcessStartInfo(); | ||
| 84 | - insProcInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; | ||
| 85 | - System.Diagnostics.Process insProc = new System.Diagnostics.Process(); | 282 | + ProcessStartInfo insProcInfo = new ProcessStartInfo(); |
| 283 | + Process insProc = new Process(); | ||
| 86 | 284 | ||
| 285 | + insProcInfo.WindowStyle = ProcessWindowStyle.Hidden; | ||
| 87 | insProcInfo.FileName = "cmd.exe"; | 286 | insProcInfo.FileName = "cmd.exe"; |
| 88 | insProcInfo.Arguments = comandoIns; | 287 | insProcInfo.Arguments = comandoIns; |
| 89 | //insProcInfo.Verb = "runas"; //ADM | 288 | //insProcInfo.Verb = "runas"; //ADM |
| 90 | 289 | ||
| 91 | insProc.StartInfo = insProcInfo; | 290 | insProc.StartInfo = insProcInfo; |
| 92 | insProc.Start(); | 291 | insProc.Start(); |
| 292 | + //insProc.WaitForExit(); | ||
| 293 | + } | ||
| 294 | + | ||
| 295 | + public static void InstallAndWait(string pathInstaller64, string pathInstaller86){ | ||
| 296 | + string pathInstaller; | ||
| 297 | + if(Environment.Is64BitOperatingSystem){ | ||
| 298 | + pathInstaller = pathInstaller64; | ||
| 299 | + }else{ | ||
| 300 | + pathInstaller = pathInstaller86; | ||
| 301 | + } | ||
| 302 | + if(pathInstaller == ""){ | ||
| 303 | + return; | ||
| 304 | + } | ||
| 305 | + //string comandoIns = "/C" + pathInstaller + " -s -v -qn"; | ||
| 306 | + string comandoIns = @"/i "+"\""+pathInstaller+"\""; | ||
| 307 | + //Process e Process Information | ||
| 308 | + ProcessStartInfo insProcInfo = new ProcessStartInfo(); | ||
| 309 | + //insProcInfo.WindowStyle = ProcessWindowStyle.Hidden; | ||
| 310 | + Process insProc = new Process(); | ||
| 311 | + | ||
| 312 | + insProcInfo.FileName = "msiexec"; | ||
| 313 | + insProcInfo.Arguments = comandoIns; | ||
| 314 | + //insProcInfo.Verb = "runas"; //ADM | ||
| 315 | + //Console.WriteLine("VERIFICAÇÃO DE LINHA insWait: "+ insProcInfo.Arguments); | ||
| 316 | + //Console.ReadKey(); | ||
| 317 | + insProc.StartInfo = insProcInfo; | ||
| 318 | + insProc.Start(); | ||
| 319 | + insProc.WaitForExit(); | ||
| 320 | + } | ||
| 321 | + //qn - instalação sem interface, passive instalação passiva | ||
| 322 | + public static void InstallAndWait(string pathInstaller64, string pathInstaller86, string args){ | ||
| 323 | + string pathInstaller; | ||
| 324 | + if(Environment.Is64BitOperatingSystem){ | ||
| 325 | + pathInstaller = pathInstaller64; | ||
| 326 | + }else{ | ||
| 327 | + pathInstaller = pathInstaller86; | ||
| 328 | + } | ||
| 329 | + if(pathInstaller == ""){ | ||
| 330 | + return; | ||
| 331 | + } | ||
| 332 | + //string comandoIns = "/C" + pathInstaller + " -s -v -qn"; | ||
| 333 | + string comandoIns = @"/i "+"\""+pathInstaller+"\" "+args; | ||
| 334 | + //Process e Process Information | ||
| 335 | + ProcessStartInfo insProcInfo = new ProcessStartInfo(); | ||
| 336 | + //insProcInfo.WindowStyle = ProcessWindowStyle.Hidden; | ||
| 337 | + Process insProc = new Process(); | ||
| 338 | + | ||
| 339 | + insProcInfo.FileName = "msiexec"; | ||
| 340 | + insProcInfo.Arguments = comandoIns; | ||
| 341 | + //insProcInfo.Verb = "runas"; //ADM | ||
| 342 | + | ||
| 343 | + insProc.StartInfo = insProcInfo; | ||
| 344 | + insProc.Start(); | ||
| 93 | insProc.WaitForExit(); | 345 | insProc.WaitForExit(); |
| 94 | } | 346 | } |
| 95 | 347 |