diff --git a/update/Makefile b/update/Makefile new file mode 100644 index 0000000..2fee5fe --- /dev/null +++ b/update/Makefile @@ -0,0 +1,35 @@ +############################## MAKEFILE VLIBRAS ############################ +# # +# Ezequiel Silva # +# ezequielsilva@lavid.ufpb.br # # +# # +############################################################################ + + +# Compilador Nativo +CC = cl + +OUTPLAYER = vlibrasPlayerUp +OUTDICT = vlibrasDictUp +OUTWRITE = writeSucess + + + +CLEAN_OBJ = del -q *.obj + + +#Gera executável +all: + + $(CC) -Fe$(OUTPLAYER) -EHsc vlibrasPlayerInstall.cpp + $(CC) -Fe$(OUTDICT) -EHsc vlibrasDictInstall.cpp + $(CC) -Fe$(OUTWRITE) -EHsc writeSucessInstall.cpp + $(CLEAN_OBJ) + + +#Limpa arquivos objetos e executáveis criados +clean: + del -q *.exe *.obj + rm -rf doc + + diff --git a/update/include/pyVlibrasUpdate.h b/update/include/pyVlibrasUpdate.h new file mode 100644 index 0000000..69465aa --- /dev/null +++ b/update/include/pyVlibrasUpdate.h @@ -0,0 +1,31 @@ +//***************************************************************** +/* + +Copyright (c) 2015 Ezequiel Silva +VLibras-Core group at LAViD, Federal University of Paraiba +*/ +//***************************************************************** + +/** +* \file pyVlibrasUpdate.h +* \authors Ezequiel Silva +* \date Setembro 2015 +*/ +#ifndef _PHVLIBRASUPDATE_H +#define _PHVLIBRASUPDATE_H + +#include + +/** \brief Classe para execução do Vlibras Update. +* +*/ +class PyVlibrasUpdate +{ + + public: + int install(char* strFunct, char* strstrParams); + void checkExe(char* strFunct, char* strstrParams); + +}; + +#endif \ No newline at end of file diff --git a/update/src/pyVlibrasUpdate.cpp b/update/src/pyVlibrasUpdate.cpp new file mode 100644 index 0000000..0a8c0c7 --- /dev/null +++ b/update/src/pyVlibrasUpdate.cpp @@ -0,0 +1,103 @@ + +/** +* \file pyVlibrasUpdate.cpp +* \authors Ezequiel Silva +* \date outubro 2015 +*/ + +#include "pyVlibrasUpdate.h" + + +void PyVlibrasUpdate::checkExe(char* strFunct, char* strstrParams) +{ + + STARTUPINFO StartupInfo; + PROCESS_INFORMATION ProcessInfo; + char Args[4096]; + char *pEnvCMD = NULL; + char *pDefaultCMD = "CMD.EXE"; + ULONG rc; + + memset(&StartupInfo, 0, sizeof(StartupInfo)); + StartupInfo.cb = sizeof(STARTUPINFO); + StartupInfo.dwFlags = STARTF_USESHOWWINDOW; + StartupInfo.wShowWindow = SW_HIDE; + + Args[0] = 0; + + pEnvCMD = getenv("COMSPEC"); + + if(pEnvCMD){ + + strcpy(Args, pEnvCMD); + } + else{ + strcpy(Args, pDefaultCMD); + } + + // "/c" option - Do the command then terminate the command window + strcat(Args, " /c "); + //the application you would like to run from the command window + strcat(Args, strFunct); + strcat(Args, " "); + //the parameters passed to the application being run from the command window. + strcat(Args, strstrParams); + + if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo)) + { + return; + } + + WaitForSingleObject(ProcessInfo.hProcess, INFINITE); + if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc)) + rc = 0; + + CloseHandle(ProcessInfo.hThread); + CloseHandle(ProcessInfo.hProcess); + + +} + +int PyVlibrasUpdate::install(char* strFunct, char* strstrParams) +{ + + STARTUPINFO StartupInfo; + PROCESS_INFORMATION ProcessInfo; + char Args[4096]; + char *pEnvCMD = NULL; + char *pDefaultCMD = "CMD.EXE"; + + memset(&StartupInfo, 0, sizeof(StartupInfo)); + StartupInfo.cb = sizeof(STARTUPINFO); + StartupInfo.dwFlags = STARTF_USESHOWWINDOW; + StartupInfo.wShowWindow = SW_HIDE; + + Args[0] = 0; + + pEnvCMD = getenv("COMSPEC"); + + if(pEnvCMD){ + + strcpy(Args, pEnvCMD); + } + else{ + strcpy(Args, pDefaultCMD); + } + + // "/c" option - Do the command then terminate the command window + strcat(Args, " /c "); + //the application you would like to run from the command window + strcat(Args, strFunct); + strcat(Args, " "); + //the parameters passed to the application being run from the command window. + strcat(Args, strstrParams); + + if (!CreateProcess( NULL, Args, NULL, NULL, FALSE,CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo)) + { + return -1; + } + + return -1; + +} + diff --git a/update/updatePython/DownloadFile.py b/update/updatePython/DownloadFile.py new file mode 100644 index 0000000..6b75b67 --- /dev/null +++ b/update/updatePython/DownloadFile.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import wx +from urllib2 import URLError +from urllib2 import HTTPError +import urllib2,os +import random +import time +from wx.lib.pubsub import pub +from threading import Thread + + + +class DownloadFile(): + + def __init__(self,url,nameFile): + self.url = url + self.nameFile = nameFile + self.downloading = True + + def start(self): + + file_name = self.nameFile + try: + u = urllib2.urlopen(self.url) + f = open(file_name, 'wb') + meta = u.info() + file_size = int(meta.getheaders("Content-Length")[0]) + + except: + + return False + + block_sz = 8192 + while self.downloading: + buffer = u.read(block_sz) + if not buffer: + self.downloading = False + f.write(buffer) + + return True + + + +class DownloadFile2(Thread): + + def __init__(self,url,nameFile): + self.url = url + self.nameFile = nameFile + self.downloading = True + Thread.__init__(self) + + + def stop(self): + self.downloading = False + + + def run(self): + + file_name = self.nameFile + try: + u = urllib2.urlopen(self.url) + f = open(file_name, 'wb') + meta = u.info() + file_size = int(meta.getheaders("Content-Length")[0]) + + except : + wx.CallAfter(pub.sendMessage, "erroDeConexao", msg="Falha na conexao") + self.downloading = False; + return False + + + file_size_dl = 0 + block_sz = 8192 + while self.downloading: + buffer = u.read(block_sz) + if not buffer: + break + + file_size_dl += len(buffer) + f.write(buffer) + status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size) + status = status + chr(8)*(len(status)+1) + + wx.CallAfter(pub.sendMessage, "updateProgress", msg=(file_size_dl * 100. / file_size)) + if (file_size_dl * 100. / file_size) >=100: + wx.CallAfter(pub.sendMessage, "downloadSucess", msg="Download realizado") diff --git a/update/updatePython/Util.py b/update/updatePython/Util.py new file mode 100644 index 0000000..25f2e74 --- /dev/null +++ b/update/updatePython/Util.py @@ -0,0 +1,146 @@ +import os.path +import json, zipfile, subprocess,urllib +from os import popen +import sys + +PATH_RESOURCE = 'c:/vlibras-libs/update/' +DICTIONARY_EXTRACT_PATH = 'C:/vlibras-libs/Player/VLibrasPlayer_Data/Bundles' +DICTIONARY_ZIP_PARH = PATH_RESOURCE+'download/vlibras_dicionario.zip' +TXT_DICT_VERSION = PATH_RESOURCE+'version/dictVersion.txt' +TXT_PLAYER_VERSION = PATH_RESOURCE+'version/playerVersion.txt' +JSON_API_VERSION = PATH_RESOURCE+'download/versionApi.json' +URL_REQUEST_API = 'http://vlibras.lavid.ufpb.br/api/dicionario/' +TEXT_CHECK_INSTALL = 'C:/vlibras-libs/installSucess.txt' +INSTALL_PLAYER_PATH = PATH_RESOURCE+'download/Vlibras_Up.exe' +##JSON_API_NAME = PATH_RESOURCE+'download/versionApi.json' +##TEXT_CHECK_INSTALL = 'C:/vlibras-libs/installSucess.txt' +PATH_PLAYER = PATH_RESOURCE+'Player/VlibrasPlayer.exe' + + + +def updateFileDictVersion(version): + try: + txt_local_version = open(TXT_DICT_VERSION, 'w') + txt_local_version.write(version) + txt_local_version.close() + return True + except: + return False + +def checkDictVersion(): + if os.path.isfile(TXT_DICT_VERSION): + arquivoDictVersion = open(TXT_DICT_VERSION,'r') + versionDict = arquivoDictVersion.readline() + arquivoDictVersion.close() + if not os.path.exists(DICTIONARY_EXTRACT_PATH): + os.mkdir(DICTIONARY_EXTRACT_PATH) + return [versionDict,len(os.listdir(DICTIONARY_EXTRACT_PATH))] + else: + return [] + +def checkDictSucess(quant): + return int(quant) < len(os.listdir(DICTIONARY_EXTRACT_PATH)) + +def updateFilePlayerVersion(version): + try: + txt_local_version = open(TXT_PLAYER_VERSION, 'w') + txt_local_version.write(version) + txt_local_version.close() + return True + except: + return False + + +def checkPlayerVersion(): + if os.path.isfile(TXT_PLAYER_VERSION): + arquivoDictPlayer = open(TXT_PLAYER_VERSION,'r') + version = arquivoDictPlayer.readline() + arquivoDictPlayer.close() + return version + else: + return '000' + + +def updateSuccess(): + txt_local_version = open(TEXT_CHECK_INSTALL, 'w') + txt_local_version.write('sucess') + txt_local_version.close() + shutil.move('C:/vlibras-libs/update/bin/vlibrasPlayerUp.exe', "C:/vlibras-libs/update/") + + +def downladFileApi(_url): + try: + + urllib.urlretrieve (_url, JSON_API_VERSION) + + return True + except Exception, e: + print e + return False + +def getUrlDict(): + + try: + my_dict_version = '000000' + dictVersionList = checkDictVersion(); + if(len(dictVersionList) == 2): + my_dict_version = dictVersionList[0].replace(".", "").replace("_", "") + if(not downladFileApi(URL_REQUEST_API+dictVersionList[0]+'?type=json')): + return ['erro'] + else: + if(not downladFileApi(URL_REQUEST_API+'0.0.0_0.0.0?type=json')): + return ['erro'] + + with open(JSON_API_VERSION) as data: + json_data = json.load(data) + + api_dict_version_full = json_data['dictionaryVersion'].encode('utf-8') + api_dict_version = json_data['dictionaryVersion'].encode('utf-8').replace(".", "").replace("_", "") + api_player_version = json_data['playerVersion'].encode('utf-8').replace(".", "") + url_download_player = json_data['playerUrl'].encode('utf-8') + url_download_dict = json_data['dictionaryUrl'].encode('utf-8') + + + if int(api_dict_version) > int(my_dict_version): + return [url_download_dict,api_dict_version_full] + else: + return [] + except: + return ['erro'] + +def getUrlDictPlayer(): + my_dict_version = '000000' + dictVersionList = checkDictVersion() + my_player_version = checkPlayerVersion().replace(".", "").replace("_", "") + if(len(dictVersionList) == 2): + my_dict_version = dictVersionList[0].replace(".", "").replace("_", "") + if(not downladFileApi(URL_REQUEST_API+dictVersionList[0]+'?type=json')): + return ['erro'] + else: + if(not downladFileApi(URL_REQUEST_API+'0.0.0_0.0.0?type=json')): + return ['erro'] + + with open(JSON_API_VERSION) as data: + json_data = json.load(data) + + api_dict_version_full = json_data['dictionaryVersion'].encode('utf-8') + api_dict_version = json_data['dictionaryVersion'].encode('utf-8').replace(".", "").replace("_", "") + api_player_version = json_data['playerVersion'].encode('utf-8').replace(".", "") + api_player_version_full = json_data['playerVersion'].encode('utf-8') + url_download_player = json_data['playerUrl'].encode('utf-8') + url_download_dict = json_data['dictionaryUrl'].encode('utf-8') + + if int(api_player_version) > int(my_player_version): + return [url_download_player,api_player_version_full] + elif int(api_dict_version) > int(my_dict_version): + return [url_download_dict,api_dict_version_full] + else: + return [] + + + + + +if __name__ == '__main__': + print checkDictVersion() + diff --git a/update/updatePython/VlibrasCheckVersion.py b/update/updatePython/VlibrasCheckVersion.py new file mode 100644 index 0000000..bf8fa0c --- /dev/null +++ b/update/updatePython/VlibrasCheckVersion.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +from os import popen +import Util + +PATH_RESOURCE = 'c:/vlibras-libs/update/' +TXT_LOCAL_VERSION = PATH_RESOURCE+'version/version.txt' + + +if __name__ == '__main__': + + listPlayerVersion = Util.getUrlDictPlayer() + txt_local_version = open(TXT_LOCAL_VERSION, 'w') + if len(listPlayerVersion)== 2: + + result = listPlayerVersion[0] + if result.endswith('.exe'): + txt_local_version.write('1') + elif result.endswith('.zip'): + txt_local_version.write('2') + + elif len(listPlayerVersion) == 0: + txt_local_version.write('0') + else: + txt_local_version.write('-1') + + txt_local_version.close() + + print listPlayerVersion + + + + + + + + + + + + + diff --git a/update/updatePython/VlibrasUpdateInstallDict.py b/update/updatePython/VlibrasUpdateInstallDict.py new file mode 100644 index 0000000..ca456a9 --- /dev/null +++ b/update/updatePython/VlibrasUpdateInstallDict.py @@ -0,0 +1,138 @@ + +# -*- coding: utf-8 -*- + +import wx +import subprocess +import time +import os.path +from wx.lib.pubsub import pub +from DownloadFile import * +from VlibrasCheckVersion import * +import zipfile +import Util + + + +##PATH_RESOURCE = 'C:/vlibras-libs/update/' +##DICTIONARY_NAME = 'download/vlibras_dicionario.zip' +##INSTALL_PLAYER_NAME = 'download/Vlibras_Up.exe' +##DICTIONARY_EXTRACT_PATH = 'C:/vlibras-libs/Player/VLibrasPlayer_Data/Bundles' +##JSON_LOCAL_NAME = PATH_RESOURCE+'version/version.json' +##JSON_API_NAME = PATH_RESOURCE+'download/versionApi.json' + +class UpdateView(wx.Frame): + + def __init__(self,_listUrlDictVersionFull): + + self.length_dict = 0; + self.listDictVersionDictLength = Util.checkDictVersion() + if self.listDictVersionDictLength == 2: + self.length_dict =listDictVersionDictLength[1] + + self.listUrlDictVersionFull = _listUrlDictVersionFull + + style = wx.SYSTEM_MENU | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX + wx.Frame.__init__(self, None, title='Atualização do VLibras', style=style,size=(480,250)) + self.SetIcon(wx.Icon("c:/vlibras-libs/icons/icon_vlibras.ico", wx.BITMAP_TYPE_ICO)) + self.myPanel = wx.Panel(self, -1) + self.myPanel.SetBackgroundColour('#F5F5F5') + btnCancel = wx.Button(self.myPanel, label="Cancelar",pos=(365, 180), size=(80, 25)) + self.myText = wx.StaticText(self.myPanel, -1, pos=(5,105)) + self.myText.SetForegroundColour('#000000') + self.progress = wx.Gauge(self.myPanel, range=100,pos=(5,80),size=(463,25)) + self.Center() + + # Anexa um evento ao botão + self.Bind(wx.EVT_BUTTON, self.onBtnCancelClick, btnCancel) + self.__close_callback = None + self.Bind(wx.EVT_CLOSE, self._when_closed) + + #registra listeners na classe DownloadFile + pub.subscribe(self.downloadSucess, "downloadSucess") + pub.subscribe(self.erroDeConexao, "erroDeConexao") + pub.subscribe(self.updateProgress, "updateProgress") + self.percentDownload = 0; + + + #inicia o download do arquivo + self.downloadFile = DownloadFile2(listUrlDictVersionFull[0], Util.DICTIONARY_ZIP_PATH) + self.downloadFile.start() + self.myText.SetLabel('Baixando dicionário') + + def erroDeConexao(self, msg): + wx.MessageBox('Ocorreu um erro ao tentar fazer atualização. \n Por favor tente mais tarde.', 'Informação',wx.OK | wx.ICON_INFORMATION) + self.Destroy() + + def register_close_callback(self, callback): + self.__close_callback = callback + + def _when_closed(self, event): + self.OnCloseFrame(event); + + + def onBtnCancelClick(self, event): + self.OnCloseFrame(event); + + + def downloadSucess(self, msg): + self.percentDownload = 100.0 + time.sleep( 2 ) + + with zipfile.ZipFile(Util.DICTIONARY_ZIP_PATH, "r") as z: + z.extractall(Util.DICTIONARY_EXTRACT_PATH) + if Util.checkDictSucess(self.lenght_dict): + self.ShowMessage('Vlibras Atualizado com sucesso!') + Util.updateFileDictVersion(listUrlDictVersionFull[1]) + else: + self.ShowMessageError('Houve um erro ao atualizar dicionário!') + + self.downloadFile.stop() + self.Destroy() + + + def updateProgress(self, msg): + value = msg + self.percentDownload = value + self.progress.SetValue(value) + + def ShowMessage(self, mesagem): + wx.MessageBox(mesagem, 'Informação', + wx.OK | wx.ICON_INFORMATION) + def ShowMessageError(self, mesagem): + wx.MessageBox(mesagem, 'Informação', + wx.OK | wx.ICON_ERROR) + self.downloadFile.stop() + self.Destroy() + + + + + + # monitora a interação do usuário no botão de fechar + def OnCloseFrame(self, event): + if(self.percentDownload>= 100): + self.downloadFile.stop() + self.Destroy() + dialog = wx.MessageDialog(self, message = "Tem certeza que deseja cancelar a atualização?", caption = "Cancelar Atualização", + style = wx.YES_NO | wx.ICON_QUESTION) + response = dialog.ShowModal() + + if (response == wx.ID_YES): + self.downloadFile.stop() + + self.Destroy() + else: + event.StopPropagation() + + + +if __name__ == '__main__': + + listUrlDictVersionFull = Util.getUrlDict() + if len(listUrlDictVersionFull)== 2: + app = wx.App(False) + frame = UpdateView(listUrlDictVersionFull) + frame.register_close_callback(lambda: True) + frame.Show() + app.MainLoop() + diff --git a/update/updatePython/VlibrasUpdateInstallPlayer.py b/update/updatePython/VlibrasUpdateInstallPlayer.py new file mode 100644 index 0000000..d044c9a --- /dev/null +++ b/update/updatePython/VlibrasUpdateInstallPlayer.py @@ -0,0 +1,152 @@ + +# -*- coding: utf-8 -*- + +import wx +import subprocess +import time +import os +from wx.lib.pubsub import pub +from DownloadFile import * +from VlibrasCheckVersion import * +import zipfile +import Util + + +class UpdateView(wx.Frame): + + def __init__(self,_listPlayerVersion): + + self.listPlayerVersion = _listPlayerVersion + + style = wx.SYSTEM_MENU | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX + wx.Frame.__init__(self, None, title='Atualização do VLibras', style=style,size=(480,250)) + # Define o ícone para a janela + self.SetIcon(wx.Icon("c:/vlibras-libs/icons/icon_vlibras.ico", wx.BITMAP_TYPE_ICO)) + self.myPanel = wx.Panel(self, -1) + self.myPanel.SetBackgroundColour('#F5F5F5') + btnCancel = wx.Button(self.myPanel, label="Cancelar",pos=(365, 180), size=(80, 25)) + self.myText = wx.StaticText(self.myPanel, -1, pos=(5,105)) + self.myText.SetForegroundColour('#000000') + self.progress = wx.Gauge(self.myPanel, range=100,pos=(5,80),size=(463,25)) + self.Center() + + # Anexa um evento ao botão + self.Bind(wx.EVT_BUTTON, self.onBtnCancelClick, btnCancel) + self.__close_callback = None + self.Bind(wx.EVT_CLOSE, self._when_closed) + + #registra listeners na classe DownloadFile + pub.subscribe(self.downloadSucess, "downloadSucess") + pub.subscribe(self.erroDeConexao, "erroDeConexao") + pub.subscribe(self.updateProgress, "updateProgress") + self.percentDownload = 0; + + + #inicia o download do arquivo + self.downloadFile = DownloadFile2(listPlayerVersion[0], Util.INSTALL_PLAYER_PATH) + self.downloadFile.start() + self.myText.SetLabel('Baixando atualização do VLibras. Aguarde... ') + + def erroDeConexao(self, msg): + wx.MessageBox('Ocorreu um erro ao tentar baixar atualização. \n Por favor verifique sua conexão e tente novamente.', 'Informação',wx.OK | wx.ICON_INFORMATION) + self.Destroy() + + def register_close_callback(self, callback): + self.__close_callback = callback + + def _when_closed(self, event): + self.OnCloseFrame(event); + + + def onBtnCancelClick(self, event): + self.OnCloseFrame(event); + + + def downloadSucess(self, msg): + self.percentDownload = 100.0 + time.sleep( 5 ) + + self.Hide() + process = subprocess.call(Util.INSTALL_PLAYER_PATH) + time.sleep( 3 ) + if os.path.isfile(Util.TEXT_CHECK_INSTALL): + self.ShowMessage('Vlibras Atualizado com sucesso!') + Util.updateFilePlayerVersion(listPlayerVersion[1]) + subprocess.Popen(Util.PATH_PLAYER) + else: + self.ShowMessageError('O Vlibras não foi atualizado!') + subprocess.Popen(Util.PATH_PLAYER) + self.downloadFile.stop() + self.Destroy() + + + def updateProgress(self, msg): + value = msg + self.percentDownload = value + self.progress.SetValue(value) + + def ShowMessage(self, mesagem): + wx.MessageBox(mesagem, 'Informação', + wx.OK | wx.ICON_INFORMATION) + def ShowMessageError(self, mesagem): + wx.MessageBox(mesagem, 'Informação', + wx.OK | wx.ICON_ERROR) + self.downloadFile.stop() + self.Destroy() + + + + + + # monitora a interação do usuário no botão de fechar + def OnCloseFrame(self, event): + if(self.percentDownload>= 100): + self.downloadFile.stop() + self.Destroy() + dialog = wx.MessageDialog(self, message = "Tem certeza que deseja cancelar a atualização?", caption = "Cancelar Atualização", + style = wx.YES_NO | wx.ICON_INFORMATION) + response = dialog.ShowModal() + + if (response == wx.ID_YES): + self.downloadFile.stop() + time.sleep( 0.5 ) + os.remove(Util.INSTALL_PLAYER_PATH) + self.Destroy() + else: + event.StopPropagation() + + +class ShowInfo(wx.Frame): + + def __init__(self,_mesagem): + self.mesagem = _mesagem + style = wx.SYSTEM_MENU | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX + wx.Frame.__init__(self, None, title='Atualização do VLibras', style=style,size=(480,250)) + def ShowMessage(self): + wx.MessageBox(self.mesagem, 'Informação', + wx.OK | wx.ICON_INFORMATION) + def ShowMessageError(self): + wx.MessageBox(self.mesagem, 'Informação', + wx.OK | wx.ICON_ERROR) + + + +if __name__ == '__main__': + app = wx.App(False) + listPlayerVersion = Util.getUrlDictPlayer() + if os.path.isfile(Util.TEXT_CHECK_INSTALL): + os.remove(Util.TEXT_CHECK_INSTALL) + if len(listPlayerVersion)== 2: + if(listPlayerVersion[0].endswith('.exe')): + frame = UpdateView(listPlayerVersion) + frame.register_close_callback(lambda: True) + frame.Show() + app.MainLoop() + else: + ShowInfo('Ocorreu um erro ao tentar atualizar o VLibras!').ShowMessageError() + + else: + ShowInfo('Atualização não disponível!').ShowMessageError() + + + diff --git a/update/updatePython/writeSucessInstall.py b/update/updatePython/writeSucessInstall.py new file mode 100644 index 0000000..0bc33c9 --- /dev/null +++ b/update/updatePython/writeSucessInstall.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +import shutil + + +if __name__ == '__main__': + shutil.move('C:/vlibras-libs/update/bin/vlibrasPlayerUp.exe', "C:/vlibras-libs/update/") + + + + + + + + + + + + + diff --git a/update/vlibrasDictInstall.cpp b/update/vlibrasDictInstall.cpp new file mode 100644 index 0000000..e65105c --- /dev/null +++ b/update/vlibrasDictInstall.cpp @@ -0,0 +1,61 @@ + + +#include //include all the basics + //string and other mapping macros + + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + LPSTR lpCmdLine, int nShowCmd) +{ + + STARTUPINFO StartupInfo; + PROCESS_INFORMATION ProcessInfo; + char Args[4096]; + char *pEnvCMD = NULL; + char *pDefaultCMD = "CMD.EXE"; + ULONG rc; + + memset(&StartupInfo, 0, sizeof(StartupInfo)); + StartupInfo.cb = sizeof(STARTUPINFO); + StartupInfo.dwFlags = STARTF_USESHOWWINDOW; + StartupInfo.wShowWindow = SW_HIDE; + + Args[0] = 0; + + pEnvCMD = getenv("COMSPEC"); + + if(pEnvCMD){ + + strcpy(Args, pEnvCMD); + } + else{ + strcpy(Args, pDefaultCMD); + } + + // "/c" option - Do the command then terminate the command window + strcat(Args, " /c "); + //the application you would like to run from the command window + strcat(Args, "c:\\Python27\\python.exe"); + strcat(Args, " "); + //the parameters passed to the application being run from the command window. + strcat(Args, "c:\\vlibras-libs\\update\\py\\VlibrasUpdateInstallDict.pyc"); + + if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, + CREATE_NEW_CONSOLE, + NULL, + NULL, + &StartupInfo, + &ProcessInfo)) + { + return GetLastError(); + } + + WaitForSingleObject(ProcessInfo.hProcess, INFINITE); + if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc)) + rc = 0; + + CloseHandle(ProcessInfo.hThread); + CloseHandle(ProcessInfo.hProcess); + + return 0; +} \ No newline at end of file diff --git a/update/vlibrasPlayerInstall.cpp b/update/vlibrasPlayerInstall.cpp new file mode 100644 index 0000000..eba2ca3 --- /dev/null +++ b/update/vlibrasPlayerInstall.cpp @@ -0,0 +1,61 @@ + + +#include //include all the basics + //string and other mapping macros + + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + LPSTR lpCmdLine, int nShowCmd) +{ + + STARTUPINFO StartupInfo; + PROCESS_INFORMATION ProcessInfo; + char Args[4096]; + char *pEnvCMD = NULL; + char *pDefaultCMD = "CMD.EXE"; + ULONG rc; + + memset(&StartupInfo, 0, sizeof(StartupInfo)); + StartupInfo.cb = sizeof(STARTUPINFO); + StartupInfo.dwFlags = STARTF_USESHOWWINDOW; + StartupInfo.wShowWindow = SW_HIDE; + + Args[0] = 0; + + pEnvCMD = getenv("COMSPEC"); + + if(pEnvCMD){ + + strcpy(Args, pEnvCMD); + } + else{ + strcpy(Args, pDefaultCMD); + } + + // "/c" option - Do the command then terminate the command window + strcat(Args, " /c "); + //the application you would like to run from the command window + strcat(Args, "c:\\Python27\\python.exe"); + strcat(Args, " "); + //the parameters passed to the application being run from the command window. + strcat(Args, "c:\\vlibras-libs\\update\\py\\VlibrasUpdateInstallPlayer.pyc"); + + if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, + CREATE_NEW_CONSOLE, + NULL, + NULL, + &StartupInfo, + &ProcessInfo)) + { + return GetLastError(); + } + + WaitForSingleObject(ProcessInfo.hProcess, INFINITE); + if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc)) + rc = 0; + + CloseHandle(ProcessInfo.hThread); + CloseHandle(ProcessInfo.hProcess); + + return 0; +} \ No newline at end of file diff --git a/update/writeSucessInstall.cpp b/update/writeSucessInstall.cpp new file mode 100644 index 0000000..eb23558 --- /dev/null +++ b/update/writeSucessInstall.cpp @@ -0,0 +1,61 @@ + + +#include //include all the basics + //string and other mapping macros + + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + LPSTR lpCmdLine, int nShowCmd) +{ + + STARTUPINFO StartupInfo; + PROCESS_INFORMATION ProcessInfo; + char Args[4096]; + char *pEnvCMD = NULL; + char *pDefaultCMD = "CMD.EXE"; + ULONG rc; + + memset(&StartupInfo, 0, sizeof(StartupInfo)); + StartupInfo.cb = sizeof(STARTUPINFO); + StartupInfo.dwFlags = STARTF_USESHOWWINDOW; + StartupInfo.wShowWindow = SW_HIDE; + + Args[0] = 0; + + pEnvCMD = getenv("COMSPEC"); + + if(pEnvCMD){ + + strcpy(Args, pEnvCMD); + } + else{ + strcpy(Args, pDefaultCMD); + } + + // "/c" option - Do the command then terminate the command window + strcat(Args, " /c "); + //the application you would like to run from the command window + strcat(Args, "c:\\Python27\\python.exe"); + strcat(Args, " "); + //the parameters passed to the application being run from the command window. + strcat(Args, "c:\\vlibras-libs\\update\\py\\writeSucessInstall.pyc"); + + if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, + CREATE_NEW_CONSOLE, + NULL, + NULL, + &StartupInfo, + &ProcessInfo)) + { + return GetLastError(); + } + + WaitForSingleObject(ProcessInfo.hProcess, INFINITE); + if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc)) + rc = 0; + + CloseHandle(ProcessInfo.hThread); + CloseHandle(ProcessInfo.hProcess); + + return 0; +} \ No newline at end of file -- libgit2 0.21.2