Beispiel #1
0
Datei: sync.py Projekt: dper/anki
 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
Beispiel #2
0
 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()
Beispiel #3
0
 def _data(self):
     d = {"ver": versionWithBuild(),
          "os": platDesc(),
          "id": self.config['id'],
          "lm": self.config['lastMsg'],
          "crt": self.config['created']}
     return d
Beispiel #4
0
 def _data(self):
     d = {"ver": aqt.appVersion,
          "os": platDesc(),
          "id": self.config['id'],
          "lm": self.config['lastMsg'],
          "crt": self.config['created']}
     return d
Beispiel #5
0
 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
Beispiel #6
0
 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
Beispiel #7
0
 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
Beispiel #8
0
 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
Beispiel #9
0
 def _data(self) -> Dict[str, Any]:
     return {
         "ver": versionWithBuild(),
         "os": platDesc(),
         "id": self.config["id"],
         "lm": self.config["lastMsg"],
         "crt": self.config["created"],
     }
Beispiel #10
0
 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
Beispiel #11
0
 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
Beispiel #12
0
 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)
Beispiel #13
0
 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)
Beispiel #14
0
 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
Beispiel #15
0
Datei: sync.py Projekt: dper/anki
 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
Beispiel #16
0
 def _data(self):
     d = {
         "ver": versionWithBuild(),
         "os": platDesc(),
         "id": self.config["id"],
         "lm": self.config["lastMsg"],
         "crt": self.config["created"],
     }
     return d
Beispiel #17
0
 def _data(self):
     d = {
         "ver": aqt.appVersion,
         "os": platDesc(),
         "id": self.config['id'],
         "lm": self.config['lastMsg'],
         "crt": self.config['created']
     }
     return d
Beispiel #18
0
 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"))
Beispiel #19
0
 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"))
Beispiel #20
0
    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"))
Beispiel #21
0
    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
Beispiel #22
0
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)
Beispiel #23
0
    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()