Use requests instead of urllib in getListOfPublicServers and checkForUpdate
This commit is contained in:
parent
5e6cc80efb
commit
477dc37535
@ -29,6 +29,7 @@ before_install:
|
|||||||
|
|
||||||
install:
|
install:
|
||||||
- pip install twisted appnope
|
- pip install twisted appnope
|
||||||
|
- pip install -U https://github.com/requests/requests/zipball/master
|
||||||
#- git clone -b qtpy-pyside2 https://github.com/alby128/syncplay.git syncplay-qtpy-PySide2
|
#- git clone -b qtpy-pyside2 https://github.com/alby128/syncplay.git syncplay-qtpy-PySide2
|
||||||
#- cd syncplay-qtpy-PySide2
|
#- cd syncplay-qtpy-PySide2
|
||||||
#- git checkout qtpy-pyside2
|
#- git checkout qtpy-pyside2
|
||||||
|
|||||||
@ -15,7 +15,7 @@ DATA_FILES = [
|
|||||||
]
|
]
|
||||||
OPTIONS = {
|
OPTIONS = {
|
||||||
'iconfile':'resources/icon.icns',
|
'iconfile':'resources/icon.icns',
|
||||||
'includes': {'PySide2.QtCore', 'PySide2.QtUiTools', 'PySide2.QtGui','PySide2.QtWidgets'},
|
'includes': {'PySide2.QtCore', 'PySide2.QtUiTools', 'PySide2.QtGui','PySide2.QtWidgets', 'certifi'},
|
||||||
'excludes': {'PySide', 'PySide.QtCore', 'PySide.QtUiTools', 'PySide.QtGui'},
|
'excludes': {'PySide', 'PySide.QtCore', 'PySide.QtUiTools', 'PySide.QtGui'},
|
||||||
'qt_plugins': ['platforms/libqcocoa.dylib', 'platforms/libqminimal.dylib','platforms/libqoffscreen.dylib'],
|
'qt_plugins': ['platforms/libqcocoa.dylib', 'platforms/libqminimal.dylib','platforms/libqoffscreen.dylib'],
|
||||||
'plist': {
|
'plist': {
|
||||||
|
|||||||
@ -721,8 +721,8 @@ info = dict(
|
|||||||
options={'py2exe': {
|
options={'py2exe': {
|
||||||
'dist_dir': OUT_DIR,
|
'dist_dir': OUT_DIR,
|
||||||
'packages': 'PySide2.QtUiTools',
|
'packages': 'PySide2.QtUiTools',
|
||||||
'includes': 'twisted, sys, encodings, datetime, os, time, math, PySide2, liburl, ast, unicodedata',
|
'includes': 'twisted, sys, encodings, datetime, os, time, math, PySide2, liburl, ast, unicodedata, _ssl',
|
||||||
'excludes': 'venv, _ssl, doctest, pdb, unittest, win32clipboard, win32file, win32pdh, win32security, win32trace, win32ui, winxpgui, win32pipe, win32process, Tkinter',
|
'excludes': 'venv, doctest, pdb, unittest, win32clipboard, win32file, win32pdh, win32security, win32trace, win32ui, winxpgui, win32pipe, win32process, Tkinter',
|
||||||
'dll_excludes': 'msvcr71.dll, MSVCP90.dll, POWRPROF.dll',
|
'dll_excludes': 'msvcr71.dll, MSVCP90.dll, POWRPROF.dll',
|
||||||
'optimize': 2,
|
'optimize': 2,
|
||||||
'compressed': 1
|
'compressed': 1
|
||||||
|
|||||||
@ -208,4 +208,18 @@ furnished to do so, subject to the following conditions:\
|
|||||||
The above copyright notice and this permission notice shall be included in\
|
The above copyright notice and this permission notice shall be included in\
|
||||||
all copies or substantial portions of the Software.\
|
all copies or substantial portions of the Software.\
|
||||||
\
|
\
|
||||||
}
|
|
||||||
|
\b Requests\
|
||||||
|
\
|
||||||
|
|
||||||
|
\b0 Copyright 2018 Kenneth Reitz\
|
||||||
|
\
|
||||||
|
Licensed under the Apache License, Version 2.0 (the \'93License\'94); you may not use this file\
|
||||||
|
except in compliance with the License. You may obtain a copy of the License at\
|
||||||
|
\
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0\
|
||||||
|
\
|
||||||
|
Unless required by applicable law or agreed to in writing, software distributed under the \
|
||||||
|
License is distributed on an \'93AS IS\'94 BASIS, WITHOUT WARRANTIES OR CONDI-\
|
||||||
|
TIONS OF ANY KIND, either express or implied. See the License for the specific lang-\
|
||||||
|
uage governing permissions and limitations under the License.}
|
||||||
@ -11,7 +11,8 @@ from twisted.internet import reactor, task, defer, threads
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from syncplay.protocols import SyncClientProtocol
|
from syncplay.protocols import SyncClientProtocol
|
||||||
from syncplay import utils, constants
|
from syncplay import utils, constants, version
|
||||||
|
from syncplay.utils import isMacOS
|
||||||
from syncplay.messages import getMissingStrings, getMessage
|
from syncplay.messages import getMissingStrings, getMessage
|
||||||
from syncplay.constants import PRIVACY_SENDHASHED_MODE, PRIVACY_DONTSEND_MODE, \
|
from syncplay.constants import PRIVACY_SENDHASHED_MODE, PRIVACY_DONTSEND_MODE, \
|
||||||
PRIVACY_HIDDENFILENAME
|
PRIVACY_HIDDENFILENAME
|
||||||
@ -910,10 +911,13 @@ class SyncplayClient(object):
|
|||||||
|
|
||||||
def checkForUpdate(self, userInitiated):
|
def checkForUpdate(self, userInitiated):
|
||||||
try:
|
try:
|
||||||
import urllib, syncplay, sys, messages, json
|
import syncplay, sys, messages, urllib, json
|
||||||
params = urllib.urlencode({'version': syncplay.version, 'milestone': syncplay.milestone, 'release_number': syncplay.release_number,
|
params = urllib.urlencode({'version': syncplay.version, 'milestone': syncplay.milestone, 'release_number': syncplay.release_number, 'language': messages.messages["CURRENT"], 'platform': sys.platform, 'userInitiated': userInitiated})
|
||||||
'language': messages.messages["CURRENT"], 'platform': sys.platform, 'userInitiated': userInitiated})
|
if isMacOS():
|
||||||
|
import requests
|
||||||
|
response = requests.get(constants.SYNCPLAY_UPDATE_URL.format(params))
|
||||||
|
response = response.text
|
||||||
|
else:
|
||||||
f = urllib.urlopen(constants.SYNCPLAY_UPDATE_URL.format(params))
|
f = urllib.urlopen(constants.SYNCPLAY_UPDATE_URL.format(params))
|
||||||
response = f.read()
|
response = f.read()
|
||||||
response = response.replace("<p>","").replace("</p>","").replace("<br />","").replace("“","\"").replace("”","\"") # Fix Wordpress
|
response = response.replace("<p>","").replace("</p>","").replace("<br />","").replace("“","\"").replace("”","\"") # Fix Wordpress
|
||||||
@ -926,7 +930,7 @@ class SyncplayClient(object):
|
|||||||
return response["version-status"], response["version-message"] if response.has_key("version-message")\
|
return response["version-status"], response["version-message"] if response.has_key("version-message")\
|
||||||
else None, response["version-url"] if response.has_key("version-url") else None, publicServers
|
else None, response["version-url"] if response.has_key("version-url") else None, publicServers
|
||||||
except:
|
except:
|
||||||
return "failed", getMessage("update-check-failed-notification").format(syncplay.version), constants.SYNCPLAY_DOWNLOAD_URL, None
|
return "failed", getMessage("update-check-failed-notification").format(version), constants.SYNCPLAY_DOWNLOAD_URL, None
|
||||||
|
|
||||||
class _WarningManager(object):
|
class _WarningManager(object):
|
||||||
def __init__(self, player, userlist, ui, client):
|
def __init__(self, player, userlist, ui, client):
|
||||||
|
|||||||
@ -374,9 +374,13 @@ def open_system_file_browser(path):
|
|||||||
|
|
||||||
def getListOfPublicServers():
|
def getListOfPublicServers():
|
||||||
try:
|
try:
|
||||||
import urllib, syncplay, sys, messages, json
|
import syncplay, sys, messages, urllib
|
||||||
params = urllib.urlencode({'version': syncplay.version, 'milestone': syncplay.milestone, 'release_number': syncplay.release_number,
|
params = urllib.urlencode({'version': syncplay.version, 'milestone': syncplay.milestone, 'release_number': syncplay.release_number, 'language': messages.messages["CURRENT"]})
|
||||||
'language': messages.messages["CURRENT"]})
|
if isMacOS():
|
||||||
|
import requests
|
||||||
|
response = requests.get(constants.SYNCPLAY_PUBLIC_SERVER_LIST_URL.format(params))
|
||||||
|
response = response.text
|
||||||
|
else:
|
||||||
f = urllib.urlopen(constants.SYNCPLAY_PUBLIC_SERVER_LIST_URL.format(params))
|
f = urllib.urlopen(constants.SYNCPLAY_PUBLIC_SERVER_LIST_URL.format(params))
|
||||||
response = f.read()
|
response = f.read()
|
||||||
response = response.replace("<p>","").replace("</p>","").replace("<br />","").replace("“","'").replace("”","'").replace(":’","'").replace("’","'").replace("′","'").replace("\n","").replace("\r","") # Fix Wordpress
|
response = response.replace("<p>","").replace("</p>","").replace("<br />","").replace("“","'").replace("”","'").replace(":’","'").replace("’","'").replace("′","'").replace("\n","").replace("\r","") # Fix Wordpress
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user