bug fixes
This commit is contained in:
parent
5f3de82caa
commit
b95c3f57c4
3
.gitignore
vendored
3
.gitignore
vendored
@ -112,4 +112,5 @@ addons/
|
|||||||
.pylintrc
|
.pylintrc
|
||||||
*.pyc
|
*.pyc
|
||||||
release.zip
|
release.zip
|
||||||
README.txt
|
README.txt
|
||||||
|
.fastwq.ankihub.json
|
||||||
@ -59,7 +59,7 @@ class Ui_DialogUpdates(object):
|
|||||||
QtCore.QMetaObject.connectSlotsByName(DialogUpdates)
|
QtCore.QMetaObject.connectSlotsByName(DialogUpdates)
|
||||||
|
|
||||||
def retranslateUi(self, DialogUpdates):
|
def retranslateUi(self, DialogUpdates):
|
||||||
DialogUpdates.setWindowTitle(_translate("DialogUpdates", "Update Checker", None))
|
DialogUpdates.setWindowTitle(_translate("DialogUpdates", "FastWQ - Update Checker", None))
|
||||||
self.labelUpdates.setText(_translate("DialogUpdates", "<html><head/><body><p>A new version of {0} is available for download! </p><p>Do you want to update {1}to version {2}?</p><p>Changes from your version are listed below:</p></body></html>", None))
|
self.labelUpdates.setText(_translate("DialogUpdates", "<html><head/><body><p>A new version of {0} is available for download! </p><p>Do you want to update {1}to version {2}?</p><p>Changes from your version are listed below:</p></body></html>", None))
|
||||||
#self.always.setText(_translate("DialogUpdates", "Always update", None))
|
#self.always.setText(_translate("DialogUpdates", "Always update", None))
|
||||||
self.update.setText(_translate("DialogUpdates", "Update", None))
|
self.update.setText(_translate("DialogUpdates", "Update", None))
|
||||||
|
|||||||
@ -13,10 +13,12 @@ import aqt
|
|||||||
from aqt import mw
|
from aqt import mw
|
||||||
from anki.hooks import addHook
|
from anki.hooks import addHook
|
||||||
from anki.utils import isMac, isWin
|
from anki.utils import isMac, isWin
|
||||||
|
from ..context import APP_ICON
|
||||||
|
|
||||||
|
|
||||||
'''
|
|
||||||
# taken from Anki's aqt/profiles.py
|
# taken from Anki's aqt/profiles.py
|
||||||
def defaultBase():
|
def defaultBase():
|
||||||
|
'''
|
||||||
print(mw.pm.addonFolder())
|
print(mw.pm.addonFolder())
|
||||||
if isWin:
|
if isWin:
|
||||||
loc = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.DocumentsLocation)
|
loc = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.DocumentsLocation)
|
||||||
@ -34,10 +36,13 @@ def defaultBase():
|
|||||||
return os.path.expanduser("~/Documents/Anki")
|
return os.path.expanduser("~/Documents/Anki")
|
||||||
else:
|
else:
|
||||||
return os.path.join(loc, "Anki")
|
return os.path.join(loc, "Anki")
|
||||||
'''
|
'''
|
||||||
|
path = mw.pm.addonFolder()
|
||||||
|
return path[:path.rindex(os.path.sep)]
|
||||||
|
|
||||||
|
|
||||||
headers = {"User-Agent": "AnkiHub"}
|
headers = {"User-Agent": "AnkiHub"}
|
||||||
dataPath = '.ankihub.json' #os.path.join(defaultBase(),'.ankihub.json')
|
dataPath = os.path.join(defaultBase(),'.fastwq.ankihub.json')
|
||||||
|
|
||||||
|
|
||||||
class DialogUpdates(QtGui.QDialog, Ui_DialogUpdates):
|
class DialogUpdates(QtGui.QDialog, Ui_DialogUpdates):
|
||||||
@ -48,9 +53,9 @@ class DialogUpdates(QtGui.QDialog, Ui_DialogUpdates):
|
|||||||
self.windowFlags() &
|
self.windowFlags() &
|
||||||
~QtCore.Qt.WindowContextHelpButtonHint
|
~QtCore.Qt.WindowContextHelpButtonHint
|
||||||
)
|
)
|
||||||
|
self.setWindowIcon(APP_ICON)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
totalSize = sum(map(lambda x:x['size'],data['assets']))
|
totalSize = sum(map(lambda x:x['size'],data['assets']))
|
||||||
|
|
||||||
def answer(doUpdate,answ):
|
def answer(doUpdate,answ):
|
||||||
self.update.setEnabled(False)
|
self.update.setEnabled(False)
|
||||||
#self.dont.setEnabled(False)
|
#self.dont.setEnabled(False)
|
||||||
@ -100,7 +105,9 @@ def installZipFile(data, fname):
|
|||||||
base = mw.pm.addonFolder()#os.path.join(defaultBase(),'addons')
|
base = mw.pm.addonFolder()#os.path.join(defaultBase(),'addons')
|
||||||
if fname.endswith(".py"):
|
if fname.endswith(".py"):
|
||||||
path = os.path.join(base, fname)
|
path = os.path.join(base, fname)
|
||||||
open(path, "wb").write(data)
|
with open(path, "wb") as file:
|
||||||
|
file.write(data)
|
||||||
|
file.close()
|
||||||
return True
|
return True
|
||||||
# .zip file
|
# .zip file
|
||||||
try:
|
try:
|
||||||
@ -164,6 +171,7 @@ def updateSingle(repositories,path,data):
|
|||||||
repositories[path]['update'] = answer
|
repositories[path]['update'] = answer
|
||||||
with open(dataPath,'w') as file:
|
with open(dataPath,'w') as file:
|
||||||
json.dump(repositories,file,indent=2)
|
json.dump(repositories,file,indent=2)
|
||||||
|
file.close()
|
||||||
if install:
|
if install:
|
||||||
appendHtml('Executing new scripts...<br/>')
|
appendHtml('Executing new scripts...<br/>')
|
||||||
newFiles = set(aqt.mw.addonManager.files()) - set(filesBefore)
|
newFiles = set(aqt.mw.addonManager.files()) - set(filesBefore)
|
||||||
@ -190,6 +198,7 @@ def updateSingle(repositories,path,data):
|
|||||||
repositories[path]['update'] = answer
|
repositories[path]['update'] = answer
|
||||||
with open(dataPath,'w') as file:
|
with open(dataPath,'w') as file:
|
||||||
json.dump(repositories,file,indent=2)
|
json.dump(repositories,file,indent=2)
|
||||||
|
file.close()
|
||||||
onReady()
|
onReady()
|
||||||
return callback
|
return callback
|
||||||
|
|
||||||
@ -200,6 +209,7 @@ def update(add=[],install=False, VERSION='v0.0.0'):
|
|||||||
try:
|
try:
|
||||||
with open(dataPath,'r') as file:
|
with open(dataPath,'r') as file:
|
||||||
repositories = json.load(file)
|
repositories = json.load(file)
|
||||||
|
file.close()
|
||||||
except:
|
except:
|
||||||
repositories = {}
|
repositories = {}
|
||||||
# 'dayjaby/AnkiHub': {
|
# 'dayjaby/AnkiHub': {
|
||||||
@ -288,6 +298,7 @@ def update(add=[],install=False, VERSION='v0.0.0'):
|
|||||||
|
|
||||||
with open(dataPath,'w') as file:
|
with open(dataPath,'w') as file:
|
||||||
json.dump(repositories,file,indent=2)
|
json.dump(repositories,file,indent=2)
|
||||||
|
file.close()
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
#update()
|
#update()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user