mirror of
https://github.com/ankitects/anki.git
synced 2025-11-09 14:17:13 -05:00
Merge branch 'master' of https://github.com/dae/anki
This commit is contained in:
commit
aef9fa630f
7 changed files with 26 additions and 14 deletions
4
Makefile
4
Makefile
|
|
@ -11,6 +11,7 @@ install:
|
||||||
cp -av * ${DESTDIR}${PREFIX}/share/anki/
|
cp -av * ${DESTDIR}${PREFIX}/share/anki/
|
||||||
cd ${DESTDIR}${PREFIX}/share/anki && (\
|
cd ${DESTDIR}${PREFIX}/share/anki && (\
|
||||||
mv runanki ${DESTDIR}${PREFIX}/local/bin/anki;\
|
mv runanki ${DESTDIR}${PREFIX}/local/bin/anki;\
|
||||||
|
test -d ${DESTDIR}${PREFIX}/share/pixmaps &&\
|
||||||
mv anki.xpm anki.png ${DESTDIR}${PREFIX}/share/pixmaps/;\
|
mv anki.xpm anki.png ${DESTDIR}${PREFIX}/share/pixmaps/;\
|
||||||
mv anki.desktop ${DESTDIR}${PREFIX}/share/applications;\
|
mv anki.desktop ${DESTDIR}${PREFIX}/share/applications;\
|
||||||
mv anki.1 ${DESTDIR}${PREFIX}/share/man/man1/)
|
mv anki.1 ${DESTDIR}${PREFIX}/share/man/man1/)
|
||||||
|
|
@ -23,7 +24,8 @@ install:
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -rf ${DESTDIR}${PREFIX}/share/anki
|
rm -rf ${DESTDIR}${PREFIX}/share/anki
|
||||||
rm -rf ${DESTDIR}${PREFIX}/local/bin/anki
|
rm -rf ${DESTDIR}${PREFIX}/local/bin/anki
|
||||||
rm -rf ${DESTDIR}${PREFIX}/share/pixmaps/anki.{xpm,png}
|
rm -rf ${DESTDIR}${PREFIX}/share/pixmaps/anki.xpm
|
||||||
|
rm -rf ${DESTDIR}${PREFIX}/share/pixmaps/anki.png
|
||||||
rm -rf ${DESTDIR}${PREFIX}/share/applications/anki.desktop
|
rm -rf ${DESTDIR}${PREFIX}/share/applications/anki.desktop
|
||||||
rm -rf ${DESTDIR}${PREFIX}/share/man/man1/anki.1
|
rm -rf ${DESTDIR}${PREFIX}/share/man/man1/anki.1
|
||||||
-xdg-mime uninstall ${DESTDIR}${PREFIX}/share/mime/packages/anki.xml
|
-xdg-mime uninstall ${DESTDIR}${PREFIX}/share/mime/packages/anki.xml
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,6 @@ if arch[1] == "ELF":
|
||||||
sys.path.insert(0, os.path.join(ext, "py2.%d-%s" % (
|
sys.path.insert(0, os.path.join(ext, "py2.%d-%s" % (
|
||||||
sys.version_info[1], arch[0][0:2])))
|
sys.version_info[1], arch[0][0:2])))
|
||||||
|
|
||||||
version="2.0.18" # build scripts grep this line, so preserve formatting
|
version="2.0.19" # build scripts grep this line, so preserve formatting
|
||||||
from anki.storage import Collection
|
from anki.storage import Collection
|
||||||
__all__ = ["Collection"]
|
__all__ = ["Collection"]
|
||||||
|
|
|
||||||
|
|
@ -373,7 +373,7 @@ class MediaManager(object):
|
||||||
z.write(fname, str(cnt))
|
z.write(fname, str(cnt))
|
||||||
files[str(cnt)] = unicodedata.normalize("NFC", fname)
|
files[str(cnt)] = unicodedata.normalize("NFC", fname)
|
||||||
sz += os.path.getsize(fname)
|
sz += os.path.getsize(fname)
|
||||||
if sz > SYNC_ZIP_SIZE or cnt > SYNC_ZIP_COUNT:
|
if sz >= SYNC_ZIP_SIZE or cnt >= SYNC_ZIP_COUNT:
|
||||||
break
|
break
|
||||||
cnt += 1
|
cnt += 1
|
||||||
z.writestr("_meta", json.dumps(files))
|
z.writestr("_meta", json.dumps(files))
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import gzip
|
import gzip
|
||||||
import random
|
import random
|
||||||
|
|
@ -16,6 +15,7 @@ from anki.consts import *
|
||||||
from hooks import runHook
|
from hooks import runHook
|
||||||
import anki
|
import anki
|
||||||
|
|
||||||
|
|
||||||
# syncing vars
|
# syncing vars
|
||||||
HTTP_TIMEOUT = 90
|
HTTP_TIMEOUT = 90
|
||||||
HTTP_PROXY = None
|
HTTP_PROXY = None
|
||||||
|
|
@ -750,8 +750,8 @@ class MediaSyncer(object):
|
||||||
# step 5: sanity check during beta testing
|
# step 5: sanity check during beta testing
|
||||||
# NOTE: when removing this, need to move server tidyup
|
# NOTE: when removing this, need to move server tidyup
|
||||||
# back from sanity check to addFiles
|
# back from sanity check to addFiles
|
||||||
s = self.server.mediaSanity()
|
|
||||||
c = self.mediaSanity()
|
c = self.mediaSanity()
|
||||||
|
s = self.server.mediaSanity(client=c)
|
||||||
self.col.log("mediaSanity", c, s)
|
self.col.log("mediaSanity", c, s)
|
||||||
if c != s:
|
if c != s:
|
||||||
# if the sanity check failed, force a resync
|
# if the sanity check failed, force a resync
|
||||||
|
|
@ -797,9 +797,9 @@ class RemoteMediaServer(HttpSyncer):
|
||||||
return json.loads(
|
return json.loads(
|
||||||
self.req("addFiles", StringIO(zip), comp=0))
|
self.req("addFiles", StringIO(zip), comp=0))
|
||||||
|
|
||||||
def mediaSanity(self):
|
def mediaSanity(self, **kw):
|
||||||
return json.loads(
|
return json.loads(
|
||||||
self.req("mediaSanity"))
|
self.req("mediaSanity", StringIO(json.dumps(kw))))
|
||||||
|
|
||||||
def mediaList(self):
|
def mediaList(self):
|
||||||
return json.loads(
|
return json.loads(
|
||||||
|
|
|
||||||
13
aqt/main.py
13
aqt/main.py
|
|
@ -2,10 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import re
|
import re
|
||||||
import traceback
|
|
||||||
import signal
|
import signal
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
|
|
@ -13,7 +10,6 @@ from send2trash import send2trash
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from anki import Collection
|
from anki import Collection
|
||||||
from anki.utils import isWin, isMac, intTime, splitFields, ids2str
|
from anki.utils import isWin, isMac, intTime, splitFields, ids2str
|
||||||
|
|
||||||
from anki.hooks import runHook, addHook
|
from anki.hooks import runHook, addHook
|
||||||
import aqt
|
import aqt
|
||||||
import aqt.progress
|
import aqt.progress
|
||||||
|
|
@ -25,6 +21,7 @@ from aqt.utils import restoreGeom, showInfo, showWarning,\
|
||||||
openHelp, openLink, checkInvalidFilename
|
openHelp, openLink, checkInvalidFilename
|
||||||
import anki.db
|
import anki.db
|
||||||
|
|
||||||
|
|
||||||
class AnkiQt(QMainWindow):
|
class AnkiQt(QMainWindow):
|
||||||
def __init__(self, app, profileManager, args):
|
def __init__(self, app, profileManager, args):
|
||||||
QMainWindow.__init__(self)
|
QMainWindow.__init__(self)
|
||||||
|
|
@ -325,6 +322,10 @@ the manual for information on how to restore from an automatic backup."))
|
||||||
|
|
||||||
def backup(self):
|
def backup(self):
|
||||||
nbacks = self.pm.profile['numBackups']
|
nbacks = self.pm.profile['numBackups']
|
||||||
|
if self.pm.profile.get('compressBackups', True):
|
||||||
|
zipStorage = zipfile.ZIP_DEFLATED
|
||||||
|
else:
|
||||||
|
zipStorage = zipfile.ZIP_STORED
|
||||||
if not nbacks or os.getenv("ANKIDEV", 0):
|
if not nbacks or os.getenv("ANKIDEV", 0):
|
||||||
return
|
return
|
||||||
dir = self.pm.backupFolder()
|
dir = self.pm.backupFolder()
|
||||||
|
|
@ -345,7 +346,7 @@ the manual for information on how to restore from an automatic backup."))
|
||||||
n = backups[-1][0] + 1
|
n = backups[-1][0] + 1
|
||||||
# do backup
|
# do backup
|
||||||
newpath = os.path.join(dir, "backup-%d.apkg" % n)
|
newpath = os.path.join(dir, "backup-%d.apkg" % n)
|
||||||
z = zipfile.ZipFile(newpath, "w", zipfile.ZIP_DEFLATED)
|
z = zipfile.ZipFile(newpath, "w", zipStorage)
|
||||||
z.write(path, "collection.anki2")
|
z.write(path, "collection.anki2")
|
||||||
z.writestr("media", "{}")
|
z.writestr("media", "{}")
|
||||||
z.close()
|
z.close()
|
||||||
|
|
@ -825,7 +826,7 @@ title="%s">%s</button>''' % (
|
||||||
aqt.update.showMessages(self, data)
|
aqt.update.showMessages(self, data)
|
||||||
|
|
||||||
def clockIsOff(self, diff):
|
def clockIsOff(self, diff):
|
||||||
diffText = ngettext("%s second", "%s seconds", diff)
|
diffText = ngettext("%s second", "%s seconds", diff) % diff
|
||||||
warn = _("""\
|
warn = _("""\
|
||||||
In order to ensure your collection works correctly when moved between \
|
In order to ensure your collection works correctly when moved between \
|
||||||
devices, Anki requires your computer's internal clock to be set correctly. \
|
devices, Anki requires your computer's internal clock to be set correctly. \
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ Not currently enabled; click the sync button in the main window to enable."""))
|
||||||
|
|
||||||
def setupBackup(self):
|
def setupBackup(self):
|
||||||
self.form.numBackups.setValue(self.prof['numBackups'])
|
self.form.numBackups.setValue(self.prof['numBackups'])
|
||||||
|
self.form.compressBackups.setChecked(self.prof.get("compressBackups", True))
|
||||||
self.connect(self.form.openBackupFolder,
|
self.connect(self.form.openBackupFolder,
|
||||||
SIGNAL("linkActivated(QString)"),
|
SIGNAL("linkActivated(QString)"),
|
||||||
self.onOpenBackup)
|
self.onOpenBackup)
|
||||||
|
|
@ -121,6 +122,7 @@ Not currently enabled; click the sync button in the main window to enable."""))
|
||||||
|
|
||||||
def updateBackup(self):
|
def updateBackup(self):
|
||||||
self.prof['numBackups'] = self.form.numBackups.value()
|
self.prof['numBackups'] = self.form.numBackups.value()
|
||||||
|
self.prof['compressBackups'] = self.form.compressBackups.isChecked()
|
||||||
|
|
||||||
# Basic & Advanced Options
|
# Basic & Advanced Options
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
|
||||||
|
|
@ -349,6 +349,13 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="compressBackups">
|
||||||
|
<property name="text">
|
||||||
|
<string>Compress backups (slower)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="openBackupFolder">
|
<widget class="QLabel" name="openBackupFolder">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue