Commit d3512215ab798eee30f39f14d874ccf4c1938238

Authored by ezequiel
1 parent 2e0a2912
Exists in master

Versão com update funcional

install/inno setup/user_install.iss
@@ -44,7 +44,7 @@ Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescrip @@ -44,7 +44,7 @@ Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescrip
44 44
45 [Files] 45 [Files]
46 46
47 -;Source: "C:\Users\ezequiel\Desktop\dotnetfx45_full_x86_x64.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; 47 +Source: "C:\Instalacao_Vlibras\wx_3.0.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall;
48 Source: "C:\Users\ezequiel\Desktop\user_install\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs 48 Source: "C:\Users\ezequiel\Desktop\user_install\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
49 49
50 50
update/updatePython/Util.py
  1 +# -*- coding: utf-8 -*-
1 import os.path 2 import os.path
2 import json, zipfile, subprocess,urllib 3 import json, zipfile, subprocess,urllib
3 from os import popen 4 from os import popen
4 -import sys 5 +import sys , shutil
5 6
6 PATH_RESOURCE = 'c:/vlibras-libs/update/' 7 PATH_RESOURCE = 'c:/vlibras-libs/update/'
7 DICTIONARY_EXTRACT_PATH = 'C:/vlibras-libs/Player/VLibrasPlayer_Data/Bundles' 8 DICTIONARY_EXTRACT_PATH = 'C:/vlibras-libs/Player/VLibrasPlayer_Data/Bundles'
8 -DICTIONARY_ZIP_PARH = PATH_RESOURCE+'download/vlibras_dicionario.zip' 9 +DICTIONARY_ZIP_PATH = PATH_RESOURCE+'download/vlibras_dicionario.zip'
9 TXT_DICT_VERSION = PATH_RESOURCE+'version/dictVersion.txt' 10 TXT_DICT_VERSION = PATH_RESOURCE+'version/dictVersion.txt'
10 TXT_PLAYER_VERSION = PATH_RESOURCE+'version/playerVersion.txt' 11 TXT_PLAYER_VERSION = PATH_RESOURCE+'version/playerVersion.txt'
  12 +TXT_PLAYER_VERSION_DOWNLOAD = PATH_RESOURCE+'version/DownloadPlayerVersion.txt'
11 JSON_API_VERSION = PATH_RESOURCE+'download/versionApi.json' 13 JSON_API_VERSION = PATH_RESOURCE+'download/versionApi.json'
12 URL_REQUEST_API = 'http://vlibras.lavid.ufpb.br/api/dicionario/' 14 URL_REQUEST_API = 'http://vlibras.lavid.ufpb.br/api/dicionario/'
13 TEXT_CHECK_INSTALL = 'C:/vlibras-libs/installSucess.txt' 15 TEXT_CHECK_INSTALL = 'C:/vlibras-libs/installSucess.txt'
@@ -34,19 +36,21 @@ def checkDictVersion(): @@ -34,19 +36,21 @@ def checkDictVersion():
34 arquivoDictVersion.close() 36 arquivoDictVersion.close()
35 if not os.path.exists(DICTIONARY_EXTRACT_PATH): 37 if not os.path.exists(DICTIONARY_EXTRACT_PATH):
36 os.mkdir(DICTIONARY_EXTRACT_PATH) 38 os.mkdir(DICTIONARY_EXTRACT_PATH)
37 - return [versionDict,len(os.listdir(DICTIONARY_EXTRACT_PATH))] 39 + return [versionDict]
38 else: 40 else:
39 return [] 41 return []
40 42
41 -def checkDictSucess(quant):  
42 - return int(quant) < len(os.listdir(DICTIONARY_EXTRACT_PATH))  
43 43
44 def updateFilePlayerVersion(version): 44 def updateFilePlayerVersion(version):
45 - try:  
46 - txt_local_version = open(TXT_PLAYER_VERSION, 'w')  
47 - txt_local_version.write(version)  
48 - txt_local_version.close()  
49 - return True 45 + try:
  46 + if os.path.isfile(TXT_PLAYER_VERSION):
  47 +
  48 + txt_local_version = open(TXT_PLAYER_VERSION, 'w')
  49 + txt_local_version.write(version)
  50 + txt_local_version.close()
  51 + return True
  52 + else:
  53 + return False
50 except: 54 except:
51 return False 55 return False
52 56
@@ -83,7 +87,7 @@ def getUrlDict(): @@ -83,7 +87,7 @@ def getUrlDict():
83 try: 87 try:
84 my_dict_version = '000000' 88 my_dict_version = '000000'
85 dictVersionList = checkDictVersion(); 89 dictVersionList = checkDictVersion();
86 - if(len(dictVersionList) == 2): 90 + if(len(dictVersionList) == 1):
87 my_dict_version = dictVersionList[0].replace(".", "").replace("_", "") 91 my_dict_version = dictVersionList[0].replace(".", "").replace("_", "")
88 if(not downladFileApi(URL_REQUEST_API+dictVersionList[0]+'?type=json')): 92 if(not downladFileApi(URL_REQUEST_API+dictVersionList[0]+'?type=json')):
89 return ['erro'] 93 return ['erro']
@@ -112,7 +116,7 @@ def getUrlDictPlayer(): @@ -112,7 +116,7 @@ def getUrlDictPlayer():
112 my_dict_version = '000000' 116 my_dict_version = '000000'
113 dictVersionList = checkDictVersion() 117 dictVersionList = checkDictVersion()
114 my_player_version = checkPlayerVersion().replace(".", "").replace("_", "") 118 my_player_version = checkPlayerVersion().replace(".", "").replace("_", "")
115 - if(len(dictVersionList) == 2): 119 + if(len(dictVersionList) == 1):
116 my_dict_version = dictVersionList[0].replace(".", "").replace("_", "") 120 my_dict_version = dictVersionList[0].replace(".", "").replace("_", "")
117 if(not downladFileApi(URL_REQUEST_API+dictVersionList[0]+'?type=json')): 121 if(not downladFileApi(URL_REQUEST_API+dictVersionList[0]+'?type=json')):
118 return ['erro'] 122 return ['erro']
@@ -131,16 +135,19 @@ def getUrlDictPlayer(): @@ -131,16 +135,19 @@ def getUrlDictPlayer():
131 url_download_dict = json_data['dictionaryUrl'].encode('utf-8') 135 url_download_dict = json_data['dictionaryUrl'].encode('utf-8')
132 136
133 if int(api_player_version) > int(my_player_version): 137 if int(api_player_version) > int(my_player_version):
134 - return [url_download_player,api_player_version_full] 138 + return [url_download_player,api_player_version_full,checkPlayerVersion()]
135 elif int(api_dict_version) > int(my_dict_version): 139 elif int(api_dict_version) > int(my_dict_version):
136 - return [url_download_dict,api_dict_version_full] 140 + return [url_download_dict,api_dict_version_full,checkPlayerVersion()]
137 else: 141 else:
138 return [] 142 return []
139 - 143 +
  144 +def extractDictZip():
  145 + with zipfile.ZipFile(DICTIONARY_ZIP_PATH, "r") as z:
  146 + z.extractall(DICTIONARY_EXTRACT_PATH)
140 147
141 148
142 149
143 150
144 if __name__ == '__main__': 151 if __name__ == '__main__':
145 - print checkDictVersion() 152 + print "main"
146 153
update/updatePython/VlibrasCheckVersion.py
1 -# -*- coding: utf-8 -*- 1 +# -*- coding: utf-8 -*-
2 from os import popen 2 from os import popen
3 import Util 3 import Util
4 4
@@ -10,7 +10,7 @@ if __name__ == &#39;__main__&#39;: @@ -10,7 +10,7 @@ if __name__ == &#39;__main__&#39;:
10 10
11 listPlayerVersion = Util.getUrlDictPlayer() 11 listPlayerVersion = Util.getUrlDictPlayer()
12 txt_local_version = open(TXT_LOCAL_VERSION, 'w') 12 txt_local_version = open(TXT_LOCAL_VERSION, 'w')
13 - if len(listPlayerVersion)== 2: 13 + if len(listPlayerVersion) > 2:
14 14
15 result = listPlayerVersion[0] 15 result = listPlayerVersion[0]
16 if result.endswith('.exe'): 16 if result.endswith('.exe'):
update/updatePython/VlibrasUpdateInstallDict.py
1  1 
2 # -*- coding: utf-8 -*- 2 # -*- coding: utf-8 -*-
3 - 3 +
4 import wx 4 import wx
5 import subprocess 5 import subprocess
6 import time 6 import time
@@ -8,26 +8,14 @@ import os.path @@ -8,26 +8,14 @@ import os.path
8 from wx.lib.pubsub import pub 8 from wx.lib.pubsub import pub
9 from DownloadFile import * 9 from DownloadFile import *
10 from VlibrasCheckVersion import * 10 from VlibrasCheckVersion import *
11 -import zipfile  
12 import Util 11 import Util
13 12
14 13
15 14
16 -##PATH_RESOURCE = 'C:/vlibras-libs/update/'  
17 -##DICTIONARY_NAME = 'download/vlibras_dicionario.zip'  
18 -##INSTALL_PLAYER_NAME = 'download/Vlibras_Up.exe'  
19 -##DICTIONARY_EXTRACT_PATH = 'C:/vlibras-libs/Player/VLibrasPlayer_Data/Bundles'  
20 -##JSON_LOCAL_NAME = PATH_RESOURCE+'version/version.json'  
21 -##JSON_API_NAME = PATH_RESOURCE+'download/versionApi.json'  
22 -  
23 class UpdateView(wx.Frame): 15 class UpdateView(wx.Frame):
24 16
25 def __init__(self,_listUrlDictVersionFull): 17 def __init__(self,_listUrlDictVersionFull):
26 18
27 - self.length_dict = 0;  
28 - self.listDictVersionDictLength = Util.checkDictVersion()  
29 - if self.listDictVersionDictLength == 2:  
30 - self.length_dict =listDictVersionDictLength[1]  
31 19
32 self.listUrlDictVersionFull = _listUrlDictVersionFull 20 self.listUrlDictVersionFull = _listUrlDictVersionFull
33 21
@@ -76,17 +64,14 @@ class UpdateView(wx.Frame): @@ -76,17 +64,14 @@ class UpdateView(wx.Frame):
76 64
77 def downloadSucess(self, msg): 65 def downloadSucess(self, msg):
78 self.percentDownload = 100.0 66 self.percentDownload = 100.0
  67 + self.downloadFile.stop()
79 time.sleep( 2 ) 68 time.sleep( 2 )
80 -  
81 - with zipfile.ZipFile(Util.DICTIONARY_ZIP_PATH, "r") as z:  
82 - z.extractall(Util.DICTIONARY_EXTRACT_PATH)  
83 - if Util.checkDictSucess(self.lenght_dict): 69 + try:
  70 + Util.extractDictZip()
84 self.ShowMessage('Vlibras Atualizado com sucesso!') 71 self.ShowMessage('Vlibras Atualizado com sucesso!')
85 Util.updateFileDictVersion(listUrlDictVersionFull[1]) 72 Util.updateFileDictVersion(listUrlDictVersionFull[1])
86 - else: 73 + except:
87 self.ShowMessageError('Houve um erro ao atualizar dicionário!') 74 self.ShowMessageError('Houve um erro ao atualizar dicionário!')
88 -  
89 - self.downloadFile.stop()  
90 self.Destroy() 75 self.Destroy()
91 76
92 77
update/updatePython/VlibrasUpdateInstallPlayer.py
1 - 1 +
2 # -*- coding: utf-8 -*- 2 # -*- coding: utf-8 -*-
3 3
4 import wx 4 import wx
@@ -43,7 +43,7 @@ class UpdateView(wx.Frame): @@ -43,7 +43,7 @@ class UpdateView(wx.Frame):
43 43
44 44
45 #inicia o download do arquivo 45 #inicia o download do arquivo
46 - self.downloadFile = DownloadFile2(listPlayerVersion[0], Util.INSTALL_PLAYER_PATH) 46 + self.downloadFile = DownloadFile2(self.listPlayerVersion[0], Util.INSTALL_PLAYER_PATH)
47 self.downloadFile.start() 47 self.downloadFile.start()
48 self.myText.SetLabel('Baixando atualização do VLibras. Aguarde... ') 48 self.myText.SetLabel('Baixando atualização do VLibras. Aguarde... ')
49 49
@@ -71,10 +71,11 @@ class UpdateView(wx.Frame): @@ -71,10 +71,11 @@ class UpdateView(wx.Frame):
71 time.sleep( 3 ) 71 time.sleep( 3 )
72 if os.path.isfile(Util.TEXT_CHECK_INSTALL): 72 if os.path.isfile(Util.TEXT_CHECK_INSTALL):
73 self.ShowMessage('Vlibras Atualizado com sucesso!') 73 self.ShowMessage('Vlibras Atualizado com sucesso!')
74 - Util.updateFilePlayerVersion(listPlayerVersion[1]) 74 + Util.updateFilePlayerVersion(self.listPlayerVersion[1])
75 subprocess.Popen(Util.PATH_PLAYER) 75 subprocess.Popen(Util.PATH_PLAYER)
76 else: 76 else:
77 self.ShowMessageError('O Vlibras não foi atualizado!') 77 self.ShowMessageError('O Vlibras não foi atualizado!')
  78 + Util.updateFilePlayerVersion(self.listPlayerVersion[2])
78 subprocess.Popen(Util.PATH_PLAYER) 79 subprocess.Popen(Util.PATH_PLAYER)
79 self.downloadFile.stop() 80 self.downloadFile.stop()
80 self.Destroy() 81 self.Destroy()
@@ -111,6 +112,7 @@ class UpdateView(wx.Frame): @@ -111,6 +112,7 @@ class UpdateView(wx.Frame):
111 self.downloadFile.stop() 112 self.downloadFile.stop()
112 time.sleep( 0.5 ) 113 time.sleep( 0.5 )
113 os.remove(Util.INSTALL_PLAYER_PATH) 114 os.remove(Util.INSTALL_PLAYER_PATH)
  115 + Util.updateFilePlayerVersion(self.listPlayerVersion[2])
114 self.Destroy() 116 self.Destroy()
115 else: 117 else:
116 event.StopPropagation() 118 event.StopPropagation()
@@ -136,7 +138,7 @@ if __name__ == &#39;__main__&#39;: @@ -136,7 +138,7 @@ if __name__ == &#39;__main__&#39;:
136 listPlayerVersion = Util.getUrlDictPlayer() 138 listPlayerVersion = Util.getUrlDictPlayer()
137 if os.path.isfile(Util.TEXT_CHECK_INSTALL): 139 if os.path.isfile(Util.TEXT_CHECK_INSTALL):
138 os.remove(Util.TEXT_CHECK_INSTALL) 140 os.remove(Util.TEXT_CHECK_INSTALL)
139 - if len(listPlayerVersion)== 2: 141 + if len(listPlayerVersion) > 2:
140 if(listPlayerVersion[0].endswith('.exe')): 142 if(listPlayerVersion[0].endswith('.exe')):
141 frame = UpdateView(listPlayerVersion) 143 frame = UpdateView(listPlayerVersion)
142 frame.register_close_callback(lambda: True) 144 frame.register_close_callback(lambda: True)
update/updatePython/writeSucessInstall.py
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 -import shutil 2 +import Util, os
3 3
4 4
5 if __name__ == '__main__': 5 if __name__ == '__main__':
6 - shutil.move('C:/vlibras-libs/update/bin/vlibrasPlayerUp.exe', "C:/vlibras-libs/update/")  
7 - 6 +
  7 + Util.updateSuccess()
  8 +
  9 + for raiz, diretorios, arquivos in os.walk('C:/vlibras-libs/vlibras-translate/src'):
  10 + for arquivo in arquivos:
  11 + if arquivo.endswith('.py'):
  12 + os.remove(os.path.join(raiz,arquivo))
  13 +
  14 +
8 15
9 16
10 17