def __init__(self, col, hkey, con): HttpSyncer.__init__(self, hkey, con) self.postVars = dict( k=self.hkey, v="ankidesktop,%s,%s"%(anki.version, platDesc()), ) self.col = col
def __init__(self, col, hkey, client, hostNum) -> None: HttpSyncer.__init__(self, hkey, client, hostNum=hostNum) self.postVars = dict( k=self.hkey, v="ankidesktop,%s,%s" % (anki.version, platDesc()), ) self.col = col.weakref()
def _data(self): d = {"ver": versionWithBuild(), "os": platDesc(), "id": self.config['id'], "lm": self.config['lastMsg'], "crt": self.config['created']} return d
def _data(self): d = {"ver": aqt.appVersion, "os": platDesc(), "id": self.config['id'], "lm": self.config['lastMsg'], "crt": self.config['created']} return d
def __init__(self, col, hkey, client): HttpSyncer.__init__(self, hkey, client) self.postVars = dict( k=self.hkey, v="ankidesktop,%s,%s" % (anki.version, platDesc()), ) self.col = col
def __init__(self, col, hkey, client, hostNum): HttpSyncer.__init__(self, hkey, client, hostNum=hostNum) self.postVars = dict( k=self.hkey, v="ankidesktop,%s,%s" % (ANKI_VERSION, platDesc()), ) self.col = col
def __init__(self, col, hkey, client, hostNum): super().__init__(self, hkey, client, hostNum=hostNum) self.postVars = dict( k=self.hkey, v="ankidesktop,%s,%s" % (anki.version, platDesc()), ) self.col = col
def begin(self) -> Any: self.postVars = dict(k=self.hkey, v="ankidesktop,%s,%s" % (anki.version, platDesc())) ret = self._dataOnly( self.req("begin", io.BytesIO(json.dumps(dict()).encode("utf8")))) self.skey = ret["sk"] return ret
def _data(self) -> Dict[str, Any]: return { "ver": versionWithBuild(), "os": platDesc(), "id": self.config["id"], "lm": self.config["lastMsg"], "crt": self.config["created"], }
def begin(self): self.postVars = dict(k=self.hkey, v="ankidesktop,%s,%s" % (ANKI_VERSION, platDesc())) ret = self._dataOnly( self.req("begin", io.BytesIO(json.dumps(dict()).encode("utf8")))) self.skey = ret['sk'] return ret
def begin(self): self.postVars = dict(k=self.hkey, v="ankidesktop,%s,%s" % (anki.version, platDesc())) ret = self._dataOnly( json.loads(self.req("begin", StringIO(json.dumps(dict()))))) self.skey = ret['sk'] return ret
def meta(self): ret = self.req( "meta", StringIO(json.dumps(dict( v=SYNC_VER, cv="ankidesktop,%s,%s"%(anki.version, platDesc())))), badAuthRaises=False) if not ret: # invalid auth return return json.loads(ret)
def begin(self): self.postVars = dict( k=self.hkey, v="ankidesktop,%s,%s"%(anki.version, platDesc()) ) ret = self._dataOnly(self.req( "begin", io.BytesIO(json.dumps(dict()).encode("utf8")))) self.skey = ret['sk'] return ret
def begin(self): self.postVars = dict( k=self.hkey, v="ankidesktop,%s,%s"%(anki.version, platDesc()) ) ret = self._dataOnly(json.loads(self.req( "begin", StringIO(json.dumps(dict()))))) self.skey = ret['sk'] return ret
def _data(self): d = { "ver": versionWithBuild(), "os": platDesc(), "id": self.config["id"], "lm": self.config["lastMsg"], "crt": self.config["created"], } return d
def _data(self): d = { "ver": aqt.appVersion, "os": platDesc(), "id": self.config['id'], "lm": self.config['lastMsg'], "crt": self.config['created'] } return d
def meta(self): self.postVars = dict( k=self.hkey, s=self.skey, ) ret = self.req( "meta", io.BytesIO(json.dumps(dict( v=SYNC_VER, cv="ankidesktop,%s,%s"%(anki.version, platDesc()))).encode("utf8")), badAuthRaises=False) if not ret: # invalid auth return return json.loads(ret.decode("utf8"))
def meta(self): """ Ask the server for an object which should contain """ self.postVars = dict( k=self.hkey, s=self.skey, ) d = dict(v=SYNC_VER, cv="ankidesktop,%s,%s"%(versionWithBuild(), platDesc())) ret = self.req( "meta", io.BytesIO(json.dumps(d).encode("utf8")), badAuthRaises=False) if not ret: # invalid auth return return json.loads(ret.decode("utf8"))
def begin(self): """Send a request to initialize the communication. It contains: * 'k': the hostkey (a number sent during synchronization of data, to identify the user) * 'v': "ankidesktop,{anki's version number},{platform}:{platform's version}", with platform being either win, lin, mac or unknown. In the last case, there are no version sent. Set the identification number as provided by the server. This number is used for this communication only. Raise an exception if the response contains an error field or is not json. """ self.postVars = dict( k=self.hkey, v="ankidesktop,%s,%s"%(anki.version, platDesc()) ) ret = self._dataOnly(self.req( "begin", io.BytesIO(json.dumps(dict()).encode("utf8")))) self.skey = ret['sk'] return ret
def debugInfo(): """Return verbose info on add-ons and Anki installation""" info = [ "{name} version {version}".format(name=ADDON.NAME, version=ADDON.VERSION) ] if ANKI20: from aqt.qt import QT_VERSION_STR, PYQT_VERSION_STR from aqt import appVersion from anki.utils import platDesc info.append("Anki {version} (Qt {qt} PyQt {pyqt})".format( version=appVersion, qt=QT_VERSION_STR, pyqt=PYQT_VERSION_STR)) info.append(platDesc()) files = [f for f in os.listdir(PATH_ADDONS) if f.endswith(".py")] info.append("Add-ons:\n\n" + repr(files)) else: from aqt.utils import supportText info.append(supportText()) addmgr = mw.addonManager info.append("Add-ons:\n\n" + "\n".join( addmgr.annotatedName(d) for d in addmgr.allAddons())) return "\n\n".join(info)
g = QGridLayout() l1 = QLabel(tr.sync_ankiweb_id_label()) g.addWidget(l1, 0, 0) user = QLineEdit() user.setText(username) g.addWidget(user, 0, 1) l2 = QLabel(tr.sync_password_label()) g.addWidget(l2, 1, 0) passwd = QLineEdit() passwd.setText(password) passwd.setEchoMode(QLineEdit.Password) g.addWidget(passwd, 1, 1) vbox.addLayout(g) bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) # type: ignore bb.button(QDialogButtonBox.Ok).setAutoDefault(True) qconnect(bb.accepted, diag.accept) qconnect(bb.rejected, diag.reject) vbox.addWidget(bb) diag.setLayout(vbox) diag.show() accepted = diag.exec_() if not accepted: return ("", "") return (user.text().strip(), passwd.text()) # export platform version to syncing code os.environ["PLATFORM"] = platDesc()