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 44  
45 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 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 2 import os.path
2 3 import json, zipfile, subprocess,urllib
3 4 from os import popen
4   -import sys
  5 +import sys , shutil
5 6  
6 7 PATH_RESOURCE = 'c:/vlibras-libs/update/'
7 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 10 TXT_DICT_VERSION = PATH_RESOURCE+'version/dictVersion.txt'
10 11 TXT_PLAYER_VERSION = PATH_RESOURCE+'version/playerVersion.txt'
  12 +TXT_PLAYER_VERSION_DOWNLOAD = PATH_RESOURCE+'version/DownloadPlayerVersion.txt'
11 13 JSON_API_VERSION = PATH_RESOURCE+'download/versionApi.json'
12 14 URL_REQUEST_API = 'http://vlibras.lavid.ufpb.br/api/dicionario/'
13 15 TEXT_CHECK_INSTALL = 'C:/vlibras-libs/installSucess.txt'
... ... @@ -34,19 +36,21 @@ def checkDictVersion():
34 36 arquivoDictVersion.close()
35 37 if not os.path.exists(DICTIONARY_EXTRACT_PATH):
36 38 os.mkdir(DICTIONARY_EXTRACT_PATH)
37   - return [versionDict,len(os.listdir(DICTIONARY_EXTRACT_PATH))]
  39 + return [versionDict]
38 40 else:
39 41 return []
40 42  
41   -def checkDictSucess(quant):
42   - return int(quant) < len(os.listdir(DICTIONARY_EXTRACT_PATH))
43 43  
44 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 54 except:
51 55 return False
52 56  
... ... @@ -83,7 +87,7 @@ def getUrlDict():
83 87 try:
84 88 my_dict_version = '000000'
85 89 dictVersionList = checkDictVersion();
86   - if(len(dictVersionList) == 2):
  90 + if(len(dictVersionList) == 1):
87 91 my_dict_version = dictVersionList[0].replace(".", "").replace("_", "")
88 92 if(not downladFileApi(URL_REQUEST_API+dictVersionList[0]+'?type=json')):
89 93 return ['erro']
... ... @@ -112,7 +116,7 @@ def getUrlDictPlayer():
112 116 my_dict_version = '000000'
113 117 dictVersionList = checkDictVersion()
114 118 my_player_version = checkPlayerVersion().replace(".", "").replace("_", "")
115   - if(len(dictVersionList) == 2):
  119 + if(len(dictVersionList) == 1):
116 120 my_dict_version = dictVersionList[0].replace(".", "").replace("_", "")
117 121 if(not downladFileApi(URL_REQUEST_API+dictVersionList[0]+'?type=json')):
118 122 return ['erro']
... ... @@ -131,16 +135,19 @@ def getUrlDictPlayer():
131 135 url_download_dict = json_data['dictionaryUrl'].encode('utf-8')
132 136  
133 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 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 141 else:
138 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 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 2 from os import popen
3 3 import Util
4 4  
... ... @@ -10,7 +10,7 @@ if __name__ == &#39;__main__&#39;:
10 10  
11 11 listPlayerVersion = Util.getUrlDictPlayer()
12 12 txt_local_version = open(TXT_LOCAL_VERSION, 'w')
13   - if len(listPlayerVersion)== 2:
  13 + if len(listPlayerVersion) > 2:
14 14  
15 15 result = listPlayerVersion[0]
16 16 if result.endswith('.exe'):
... ...
update/updatePython/VlibrasUpdateInstallDict.py
1 1 
2 2 # -*- coding: utf-8 -*-
3   -
  3 +
4 4 import wx
5 5 import subprocess
6 6 import time
... ... @@ -8,26 +8,14 @@ import os.path
8 8 from wx.lib.pubsub import pub
9 9 from DownloadFile import *
10 10 from VlibrasCheckVersion import *
11   -import zipfile
12 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 15 class UpdateView(wx.Frame):
24 16  
25 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 20 self.listUrlDictVersionFull = _listUrlDictVersionFull
33 21  
... ... @@ -76,17 +64,14 @@ class UpdateView(wx.Frame):
76 64  
77 65 def downloadSucess(self, msg):
78 66 self.percentDownload = 100.0
  67 + self.downloadFile.stop()
79 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 71 self.ShowMessage('Vlibras Atualizado com sucesso!')
85 72 Util.updateFileDictVersion(listUrlDictVersionFull[1])
86   - else:
  73 + except:
87 74 self.ShowMessageError('Houve um erro ao atualizar dicionário!')
88   -
89   - self.downloadFile.stop()
90 75 self.Destroy()
91 76  
92 77  
... ...
update/updatePython/VlibrasUpdateInstallPlayer.py
1   -
  1 +
2 2 # -*- coding: utf-8 -*-
3 3  
4 4 import wx
... ... @@ -43,7 +43,7 @@ class UpdateView(wx.Frame):
43 43  
44 44  
45 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 47 self.downloadFile.start()
48 48 self.myText.SetLabel('Baixando atualização do VLibras. Aguarde... ')
49 49  
... ... @@ -71,10 +71,11 @@ class UpdateView(wx.Frame):
71 71 time.sleep( 3 )
72 72 if os.path.isfile(Util.TEXT_CHECK_INSTALL):
73 73 self.ShowMessage('Vlibras Atualizado com sucesso!')
74   - Util.updateFilePlayerVersion(listPlayerVersion[1])
  74 + Util.updateFilePlayerVersion(self.listPlayerVersion[1])
75 75 subprocess.Popen(Util.PATH_PLAYER)
76 76 else:
77 77 self.ShowMessageError('O Vlibras não foi atualizado!')
  78 + Util.updateFilePlayerVersion(self.listPlayerVersion[2])
78 79 subprocess.Popen(Util.PATH_PLAYER)
79 80 self.downloadFile.stop()
80 81 self.Destroy()
... ... @@ -111,6 +112,7 @@ class UpdateView(wx.Frame):
111 112 self.downloadFile.stop()
112 113 time.sleep( 0.5 )
113 114 os.remove(Util.INSTALL_PLAYER_PATH)
  115 + Util.updateFilePlayerVersion(self.listPlayerVersion[2])
114 116 self.Destroy()
115 117 else:
116 118 event.StopPropagation()
... ... @@ -136,7 +138,7 @@ if __name__ == &#39;__main__&#39;:
136 138 listPlayerVersion = Util.getUrlDictPlayer()
137 139 if os.path.isfile(Util.TEXT_CHECK_INSTALL):
138 140 os.remove(Util.TEXT_CHECK_INSTALL)
139   - if len(listPlayerVersion)== 2:
  141 + if len(listPlayerVersion) > 2:
140 142 if(listPlayerVersion[0].endswith('.exe')):
141 143 frame = UpdateView(listPlayerVersion)
142 144 frame.register_close_callback(lambda: True)
... ...
update/updatePython/writeSucessInstall.py
1 1 # -*- coding: utf-8 -*-
2   -import shutil
  2 +import Util, os
3 3  
4 4  
5 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  
... ...