VlibrasUpdate.py
3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# -*- coding: cp1252 -*-
import json, zipfile, subprocess,urllib
from os import popen
from threading import Thread
from VlibrasUpdateInstall import*
url_download_player =''
url_download_dict =''
PATH_RESOURCE = 'C:/vlibras-libs/update/'
JSON_LOCAL_NAME = 'version/version.json'
JSON_API_NAME = 'download/versionApi.json'
PLAYER_DICT_UPDATE_PATH = PATH_RESOURCE+'bin/vlibrasPlayerDictUp.exe '
DICTIONARY_NAME = 'download/vlibras_dicionario.zip'
INSTALL_PLAYER_NAME = 'download/Vlibras_Up.exe'
URL_REQUEST_API = 'http://vlibras.lavid.ufpb.br/api/dicionario/'
DICTIONARY_EXTRACT_PATH = 'C:/vlibras-libs/Player/VLibrasPlayer_Data/Bundles'
def checkVersion():
## try:
##
## with open(PATH_RESOURCE+JSON_LOCAL_NAME) as data_file:
## json_data = json.load(data_file)
##
## my_dict_version_full = json_data['dictionaryVersion'].encode('utf-8')
## my_player_version = json_data['playerVersion'].encode('utf-8').replace(".", "")
## my_dict_version = my_dict_version_full.replace(".", "").replace("_", "")
##
## if(not downladFileApi(URL_REQUEST_API+my_dict_version_full+'?type=linux')):
## return 'erro'
##
## with open(PATH_RESOURCE+JSON_API_NAME) as data:
## json_data = json.load(data)
##
## 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_player_version) > int(my_player_version):
## return url_download_player
##
## elif int(api_dict_version) > int(my_dict_version):
##
## return url_download_dict
##
## else:
## return "atualizado"
##
## except:
return "erro"
def downladFileApi(_url):
try:
urllib.urlretrieve (_url, PATH_RESOURCE+JSON_API_NAME)
return True
except:
return False
def installPlayer():
try:
## with open(PATH_RESOURCE+JSON_API_NAME) as data:
## json_data = json.load(data)
## url_download_player = json_data['playerUrl'].encode('utf-8')
# install = CallInstall()
# install.start()
process = subprocess.Popen(["C:\\Python27\\python.exe", "c:\\vlibras-libs\\update\\py\\VlibrasUpdateInstall.pyc"])
## update_json_file()
except Exception, e:
print e
return -1
return 1
def installDict():
try:
## install = CallInstall()
## install.start()
process = subprocess.Popen(["C:\\Python27\\python.exe", "c:\\vlibras-libs\\update\\py\\VlibrasUpdateInstall.pyc"])
## with open(PATH_RESOURCE+JSON_API_NAME) as data:
## json_data = json.load(data)
## url_download_dict = json_data['dictionaryUrl'].encode('utf-8')
## process = subprocess.Popen(PLAYER_DICT_UPDATE_PATH+url_download_dict)
except Exception, e:
print e
return -1
return 1
if __name__ == '__main__':
print installPlayer()