tsudoko / anki-sync-server

Self-hosted Anki sync server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installation guide for Anki 2.1 (desktop) unclear

dreamflasher opened this issue · comments

The readme.md sounds like one only needs to place the displayed __init__.py in one folder. The code apparently has a bug anki.sync.SYNC_BASE = "%s" + addr %s will be the string %s and not formatted.
But then why does the "anki-sync-server/addon/" folder exist? Are there supposed to be two folders? Why are they not integrated in one addon?

@dreamflasher - search the upstream Anki code for why anki.sync.SYNC_BASE = "%s" + addr is necessary. All will become clear when you spend some time looking at the upstream code.

The readme is clearly not up-to-date for the addon. I have enquired whether it might be time to publish the addon to Ankiweb's 2.1 addons directory, as it is now generic enough for that (+ see my PR for even more flexibility). Let's wait for @tsudoko 's feelings on that.

"search the upstream code" is IMHO neither an appropriate comment, nor helpful. If you have a solution, why don't you post it or even better provide a PR to fix the documentation? Please realize that with this kinds of comments you destroy a healthy atmosphere in a community that has an interest to improve code.

anki.sync.SYNC_BASE is clearly part of the upstream code base, and in anki.sync you have:

def syncURL(self):
    if devMode:
        url = "https://l1sync.ankiweb.net/"
    else:
        url = SYNC_BASE % (self.hostNum or "")
    return url + self.prefix

The string interpolation occurs in this function, not in the ankisyncd addon. Without hostNum set, an empty string is interpolated into the address (i.e., nothing is changed). If the %s were not somewhere in the SYNC_BASE string, you would get a TypeError exception when the function is called. For example:

>>> "hello, world%s" % "!"
'hello, world!'
>>> "hello, world" % "!"
  File "<stdin>", line 1, in <module>
TypeError: not all arguments converted during string formatting

This is also mentioned in PR #10.

I think most people are going to fall into one of two categories:

  1. they just copy-paste the code without stressing over what it means
  2. they understand the code well enough to search upstream for the answer

I don't think Anton was trying to be unhelpful. I think he just thought you were in category 2 and was pointing you in the right direction.

But then why does the "anki-sync-server/addon/" folder exist?

This directory contains a completely different addon. It wasn't mentioned in the README because I didn't consider it stable enough, while the version in the README was well tested. I might add it some time in the future, since it's been working fine so far.