From 3ed28611153f5bf6d1b040c95d427570a958acd1 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 6 Oct 2013 04:37:39 +0900 Subject: [PATCH] include platform in cv --- anki/sync.py | 5 +++-- anki/utils.py | 23 +++++++++++++++++++++++ aqt/update.py | 23 ++--------------------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/anki/sync.py b/anki/sync.py index 8fe47471e..c854ea249 100644 --- a/anki/sync.py +++ b/anki/sync.py @@ -5,7 +5,7 @@ import urllib, os, sys, httplib2, gzip from cStringIO import StringIO from anki.db import DB -from anki.utils import ids2str, intTime, json, isWin, isMac +from anki.utils import ids2str, intTime, json, isWin, isMac, platDesc from anki.consts import * from hooks import runHook import anki @@ -604,7 +604,8 @@ class RemoteServer(HttpSyncer): def meta(self): ret = self.req( - "meta", StringIO(json.dumps(dict(v=SYNC_VER, cv="ankidesktop,"+anki.version))), + "meta", StringIO(json.dumps(dict( + v=SYNC_VER, cv="ankidesktop,%s,%s"%(anki.version, platDesc())))), badAuthRaises=False) if not ret: # invalid auth diff --git a/anki/utils.py b/anki/utils.py index ad50ef79f..0eeb3dfdd 100644 --- a/anki/utils.py +++ b/anki/utils.py @@ -7,6 +7,7 @@ import re, os, random, time, math, htmlentitydefs, subprocess, \ tempfile, shutil, string, httplib2, sys, locale from hashlib import sha1 from anki.lang import _, ngettext +import platform if sys.version_info[1] < 5: def format_string(a, b): @@ -339,3 +340,25 @@ def invalidFilename(str, dirsep=True): return "/" elif (dirsep or not isWin) and "\\" in str: return "\\" + +def platDesc(): + # we may get an interrupted system call, so try this in a loop + n = 0 + theos = "unknown" + while n < 100: + n += 1 + try: + system = platform.system() + if isMac: + theos = "mac:%s" % (platform.mac_ver()[0]) + elif isWin: + theos = "win:%s" % (platform.win32_ver()[0]) + elif system == "Linux": + dist = platform.dist() + theos = "lin:%s:%s" % (dist[0], dist[1]) + else: + theos = system + break + except: + continue + return theos diff --git a/aqt/update.py b/aqt/update.py index 7593124f5..66f8fd3d6 100644 --- a/aqt/update.py +++ b/aqt/update.py @@ -6,7 +6,7 @@ import urllib, urllib2, time import aqt import platform from aqt.utils import openLink -from anki.utils import json, isWin, isMac +from anki.utils import json, isWin, isMac, platDesc from aqt.utils import showText class LatestVersionFinder(QThread): @@ -17,27 +17,8 @@ class LatestVersionFinder(QThread): self.config = main.pm.meta def _data(self): - # we may get an interrupted system call, so try this in a loop - n = 0 - theos = "unknown" - while n < 100: - n += 1 - try: - system = platform.system() - if isMac: - theos = "mac:%s" % (platform.mac_ver()[0]) - elif isWin: - theos = "win:%s" % (platform.win32_ver()[0]) - elif system == "Linux": - dist = platform.dist() - theos = "lin:%s:%s" % (dist[0], dist[1]) - else: - theos = system - break - except: - continue d = {"ver": aqt.appVersion, - "os": theos, + "os": platDesc(), "id": self.config['id'], "lm": self.config['lastMsg'], "crt": self.config['created']}