From d3512215ab798eee30f39f14d874ccf4c1938238 Mon Sep 17 00:00:00 2001 From: ezequiel Date: Mon, 19 Oct 2015 16:10:03 -0200 Subject: [PATCH] Versão com update funcional --- install/inno setup/user_install.iss | 2 +- update/updatePython/Util.py | 39 +++++++++++++++++++++++---------------- update/updatePython/VlibrasCheckVersion.py | 4 ++-- update/updatePython/VlibrasUpdateInstallDict.py | 25 +++++-------------------- update/updatePython/VlibrasUpdateInstallPlayer.py | 10 ++++++---- update/updatePython/writeSucessInstall.py | 13 ++++++++++--- 6 files changed, 47 insertions(+), 46 deletions(-) diff --git a/install/inno setup/user_install.iss b/install/inno setup/user_install.iss index 9e45880..c980c75 100644 --- a/install/inno setup/user_install.iss +++ b/install/inno setup/user_install.iss @@ -44,7 +44,7 @@ Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescrip [Files] -;Source: "C:\Users\ezequiel\Desktop\dotnetfx45_full_x86_x64.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; +Source: "C:\Instalacao_Vlibras\wx_3.0.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; Source: "C:\Users\ezequiel\Desktop\user_install\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs diff --git a/update/updatePython/Util.py b/update/updatePython/Util.py index 25f2e74..524a880 100644 --- a/update/updatePython/Util.py +++ b/update/updatePython/Util.py @@ -1,13 +1,15 @@ +# -*- coding: utf-8 -*- import os.path import json, zipfile, subprocess,urllib from os import popen -import sys +import sys , shutil 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' +DICTIONARY_ZIP_PATH = PATH_RESOURCE+'download/vlibras_dicionario.zip' TXT_DICT_VERSION = PATH_RESOURCE+'version/dictVersion.txt' TXT_PLAYER_VERSION = PATH_RESOURCE+'version/playerVersion.txt' +TXT_PLAYER_VERSION_DOWNLOAD = PATH_RESOURCE+'version/DownloadPlayerVersion.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' @@ -34,19 +36,21 @@ def checkDictVersion(): arquivoDictVersion.close() if not os.path.exists(DICTIONARY_EXTRACT_PATH): os.mkdir(DICTIONARY_EXTRACT_PATH) - return [versionDict,len(os.listdir(DICTIONARY_EXTRACT_PATH))] + return [versionDict] 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 + try: + if os.path.isfile(TXT_PLAYER_VERSION): + + txt_local_version = open(TXT_PLAYER_VERSION, 'w') + txt_local_version.write(version) + txt_local_version.close() + return True + else: + return False except: return False @@ -83,7 +87,7 @@ def getUrlDict(): try: my_dict_version = '000000' dictVersionList = checkDictVersion(); - if(len(dictVersionList) == 2): + if(len(dictVersionList) == 1): my_dict_version = dictVersionList[0].replace(".", "").replace("_", "") if(not downladFileApi(URL_REQUEST_API+dictVersionList[0]+'?type=json')): return ['erro'] @@ -112,7 +116,7 @@ def getUrlDictPlayer(): my_dict_version = '000000' dictVersionList = checkDictVersion() my_player_version = checkPlayerVersion().replace(".", "").replace("_", "") - if(len(dictVersionList) == 2): + if(len(dictVersionList) == 1): my_dict_version = dictVersionList[0].replace(".", "").replace("_", "") if(not downladFileApi(URL_REQUEST_API+dictVersionList[0]+'?type=json')): return ['erro'] @@ -131,16 +135,19 @@ def getUrlDictPlayer(): 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] + return [url_download_player,api_player_version_full,checkPlayerVersion()] elif int(api_dict_version) > int(my_dict_version): - return [url_download_dict,api_dict_version_full] + return [url_download_dict,api_dict_version_full,checkPlayerVersion()] else: return [] - + +def extractDictZip(): + with zipfile.ZipFile(DICTIONARY_ZIP_PATH, "r") as z: + z.extractall(DICTIONARY_EXTRACT_PATH) if __name__ == '__main__': - print checkDictVersion() + print "main" diff --git a/update/updatePython/VlibrasCheckVersion.py b/update/updatePython/VlibrasCheckVersion.py index bf8fa0c..b940879 100644 --- a/update/updatePython/VlibrasCheckVersion.py +++ b/update/updatePython/VlibrasCheckVersion.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- from os import popen import Util @@ -10,7 +10,7 @@ if __name__ == '__main__': listPlayerVersion = Util.getUrlDictPlayer() txt_local_version = open(TXT_LOCAL_VERSION, 'w') - if len(listPlayerVersion)== 2: + if len(listPlayerVersion) > 2: result = listPlayerVersion[0] if result.endswith('.exe'): diff --git a/update/updatePython/VlibrasUpdateInstallDict.py b/update/updatePython/VlibrasUpdateInstallDict.py index ca456a9..146b7e2 100644 --- a/update/updatePython/VlibrasUpdateInstallDict.py +++ b/update/updatePython/VlibrasUpdateInstallDict.py @@ -1,6 +1,6 @@  # -*- coding: utf-8 -*- - + import wx import subprocess import time @@ -8,26 +8,14 @@ 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 @@ -76,17 +64,14 @@ class UpdateView(wx.Frame): def downloadSucess(self, msg): self.percentDownload = 100.0 + self.downloadFile.stop() 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): + try: + Util.extractDictZip() self.ShowMessage('Vlibras Atualizado com sucesso!') Util.updateFileDictVersion(listUrlDictVersionFull[1]) - else: + except: self.ShowMessageError('Houve um erro ao atualizar dicionário!') - - self.downloadFile.stop() self.Destroy() diff --git a/update/updatePython/VlibrasUpdateInstallPlayer.py b/update/updatePython/VlibrasUpdateInstallPlayer.py index d044c9a..aa564e3 100644 --- a/update/updatePython/VlibrasUpdateInstallPlayer.py +++ b/update/updatePython/VlibrasUpdateInstallPlayer.py @@ -1,4 +1,4 @@ - + # -*- coding: utf-8 -*- import wx @@ -43,7 +43,7 @@ class UpdateView(wx.Frame): #inicia o download do arquivo - self.downloadFile = DownloadFile2(listPlayerVersion[0], Util.INSTALL_PLAYER_PATH) + self.downloadFile = DownloadFile2(self.listPlayerVersion[0], Util.INSTALL_PLAYER_PATH) self.downloadFile.start() self.myText.SetLabel('Baixando atualização do VLibras. Aguarde... ') @@ -71,10 +71,11 @@ class UpdateView(wx.Frame): time.sleep( 3 ) if os.path.isfile(Util.TEXT_CHECK_INSTALL): self.ShowMessage('Vlibras Atualizado com sucesso!') - Util.updateFilePlayerVersion(listPlayerVersion[1]) + Util.updateFilePlayerVersion(self.listPlayerVersion[1]) subprocess.Popen(Util.PATH_PLAYER) else: self.ShowMessageError('O Vlibras não foi atualizado!') + Util.updateFilePlayerVersion(self.listPlayerVersion[2]) subprocess.Popen(Util.PATH_PLAYER) self.downloadFile.stop() self.Destroy() @@ -111,6 +112,7 @@ class UpdateView(wx.Frame): self.downloadFile.stop() time.sleep( 0.5 ) os.remove(Util.INSTALL_PLAYER_PATH) + Util.updateFilePlayerVersion(self.listPlayerVersion[2]) self.Destroy() else: event.StopPropagation() @@ -136,7 +138,7 @@ if __name__ == '__main__': listPlayerVersion = Util.getUrlDictPlayer() if os.path.isfile(Util.TEXT_CHECK_INSTALL): os.remove(Util.TEXT_CHECK_INSTALL) - if len(listPlayerVersion)== 2: + if len(listPlayerVersion) > 2: if(listPlayerVersion[0].endswith('.exe')): frame = UpdateView(listPlayerVersion) frame.register_close_callback(lambda: True) diff --git a/update/updatePython/writeSucessInstall.py b/update/updatePython/writeSucessInstall.py index 0bc33c9..c8a1833 100644 --- a/update/updatePython/writeSucessInstall.py +++ b/update/updatePython/writeSucessInstall.py @@ -1,10 +1,17 @@ # -*- coding: utf-8 -*- -import shutil +import Util, os if __name__ == '__main__': - shutil.move('C:/vlibras-libs/update/bin/vlibrasPlayerUp.exe', "C:/vlibras-libs/update/") - + + Util.updateSuccess() + + for raiz, diretorios, arquivos in os.walk('C:/vlibras-libs/vlibras-translate/src'): + for arquivo in arquivos: + if arquivo.endswith('.py'): + os.remove(os.path.join(raiz,arquivo)) + + -- libgit2 0.21.2