예제 #1
0
파일: sync.py 프로젝트: 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
예제 #2
0
파일: sync.py 프로젝트: xiaowenhuman/anki
 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()
예제 #3
0
 def _data(self):
     d = {"ver": versionWithBuild(),
          "os": platDesc(),
          "id": self.config['id'],
          "lm": self.config['lastMsg'],
          "crt": self.config['created']}
     return d
예제 #4
0
파일: update.py 프로젝트: AgarwalPragy/anki
 def _data(self):
     d = {"ver": aqt.appVersion,
          "os": platDesc(),
          "id": self.config['id'],
          "lm": self.config['lastMsg'],
          "crt": self.config['created']}
     return d
예제 #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
예제 #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
예제 #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
예제 #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
예제 #9
0
파일: update.py 프로젝트: v-limc/anki
 def _data(self) -> Dict[str, Any]:
     return {
         "ver": versionWithBuild(),
         "os": platDesc(),
         "id": self.config["id"],
         "lm": self.config["lastMsg"],
         "crt": self.config["created"],
     }
예제 #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
예제 #11
0
파일: sync.py 프로젝트: fenildf/libanki3
 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
예제 #12
0
파일: sync.py 프로젝트: chebee7i/anki
 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)
예제 #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)
예제 #14
0
파일: sync.py 프로젝트: Stvad/anki
 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
예제 #15
0
파일: sync.py 프로젝트: 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
예제 #16
0
파일: update.py 프로젝트: zzzdeb/anki
 def _data(self):
     d = {
         "ver": versionWithBuild(),
         "os": platDesc(),
         "id": self.config["id"],
         "lm": self.config["lastMsg"],
         "crt": self.config["created"],
     }
     return d
예제 #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
예제 #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"))
예제 #19
0
파일: sync.py 프로젝트: Stvad/anki
 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"))
예제 #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"))
예제 #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
예제 #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)
예제 #23
0
파일: sync.py 프로젝트: v-limc/anki
    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()