X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Flibsync.py;h=f8acdacbfadaa5e42653ba19640f3339f68b1010;hb=8679b5e1510e859b696e6400731b0ba957dbdf4c;hp=48bcc8683cf2101df20c1d41d1ab848cb7f4dc94;hpb=95a7f33eee9a55cafe60f739a29f4a2caf212721;p=quicknote diff --git a/src/libsync.py b/src/libsync.py index 48bcc86..f8acdac 100755 --- a/src/libsync.py +++ b/src/libsync.py @@ -38,12 +38,15 @@ except NameError: _ = lambda x: x +_moduleLogger = logging.getLogger("sync") + + class ProgressDialog(gtk.Dialog): def __init__(self, title = _("Sync process"), parent = None): gtk.Dialog.__init__(self, title, parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, ()) - logging.info("ProgressDialog, init") + _moduleLogger.info("ProgressDialog, init") label = gtk.Label(_("Sync process running...please wait")) self.vbox.pack_start(label, True, True, 0) @@ -67,7 +70,7 @@ class Sync(gtk.VBox): def __init__(self, db, parentwindow, port): gtk.VBox.__init__(self, homogeneous = False, spacing = 0) - logging.info("Sync, init") + _moduleLogger.info("Sync, init") self.db = db self.progress = None self.server = None @@ -168,13 +171,13 @@ class Sync(gtk.VBox): syncpartner, pcdatum = rows[0] else: pcdatum = -1 - logging.info("LastSyncDatum: "+str(pcdatum)+" Jetzt "+str(int(time.time()))) + _moduleLogger.info("LastSyncDatum: "+str(pcdatum)+" Jetzt "+str(int(time.time()))) return pcdatum def check4commit(self, newSQL, lastdate): - logging.info("check4commit 1") + _moduleLogger.info("check4commit 1") if self.concernedRows is None: - logging.info("check4commit Updatung concernedRows") + _moduleLogger.info("check4commit Updatung concernedRows") sql = "SELECT pcdatum, rowid FROM logtable WHERE pcdatum>? ORDER BY pcdatum DESC" self.concernedRows = self.db.ladeSQL(sql, (lastdate, )) @@ -185,7 +188,7 @@ class Sync(gtk.VBox): for x in self.concernedRows: if x[1] == rowid: if pcdatum < x[0]: - logging.info("newer sync entry, ignoring old one") + _moduleLogger.info("newer sync entry, ignoring old one") return False else: return True @@ -198,7 +201,7 @@ class Sync(gtk.VBox): self.concernedRows = None pausenzaehler = 0 - logging.info("writeSQLTupel got "+str(len(newSQLs))+" sql tupels") + _moduleLogger.info("writeSQLTupel got "+str(len(newSQLs))+" sql tupels") for newSQL in newSQLs: if newSQL[3] != "": param = newSQL[3].split(" <> ") @@ -214,7 +217,7 @@ class Sync(gtk.VBox): if (commitSQL == True): self.db.speichereSQL(newSQL[2], param, commit = False, pcdatum = newSQL[1], rowid = newSQL[5]) else: - logging.error("writeSQLTupel: Error") + _moduleLogger.error("writeSQLTupel: Error") pausenzaehler += 1 if (pausenzaehler % 10) == 0: @@ -222,9 +225,9 @@ class Sync(gtk.VBox): while gtk.events_pending(): gtk.main_iteration() - logging.info("Alle SQLs an sqlite geschickt, commiting now") + _moduleLogger.info("Alle SQLs an sqlite geschickt, commiting now") self.db.commitSQL() - logging.info("Alle SQLs commited") + _moduleLogger.info("Alle SQLs commited") def doSync(self, sync_uuid, pcdatum, newSQLs, pcdatumjetzt): self.changeSyncStatus(True, "sync process running") @@ -236,13 +239,13 @@ class Sync(gtk.VBox): if 30 < diff: return -1 - logging.info("doSync read sqls") + _moduleLogger.info("doSync read sqls") sql = "SELECT * FROM logtable WHERE pcdatum>?" rows = self.db.ladeSQL(sql, (pcdatum, )) - logging.info("doSync read sqls") + _moduleLogger.info("doSync read sqls") self.writeSQLTupel(newSQLs, pcdatum) - logging.info("doSync wrote "+str(len(newSQLs))+" sqls") - logging.info("doSync sending "+str(len(rows))+" sqls") + _moduleLogger.info("doSync wrote "+str(len(newSQLs))+" sqls") + _moduleLogger.info("doSync sending "+str(len(rows))+" sqls") return rows def getRemoteSyncUUID(self): @@ -253,7 +256,7 @@ class Sync(gtk.VBox): self.db.speichereDirekt("syncServerIP", self.comboIP.get_child().get_text()) if widget.get_active(): - logging.info("Starting Server") + _moduleLogger.info("Starting Server") try: ip = self.comboIP.get_child().get_text() @@ -274,7 +277,7 @@ class Sync(gtk.VBox): except StandardError: s = str(sys.exc_info()) - logging.error("libsync: could not start server. Error: "+s) + _moduleLogger.error("libsync: could not start server. Error: "+s) mbox = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("Could not start SyncServer. Check IP, port settings.")) #gtk.DIALOG_MODAL mbox.set_modal(False) response = mbox.run() @@ -282,7 +285,7 @@ class Sync(gtk.VBox): mbox.destroy() widget.set_active(False) else: - logging.info("Stopping Server") + _moduleLogger.info("Stopping Server") try: del self.rpcserver except StandardError: @@ -309,7 +312,7 @@ class Sync(gtk.VBox): return (self.sync_uuid, pcdatum) def syncButton(self, widget, data = None): - logging.info("Syncing") + _moduleLogger.info("Syncing") self.changeSyncStatus(True, _("sync process running")) while (gtk.events_pending()): @@ -324,11 +327,11 @@ class Sync(gtk.VBox): sql = "SELECT * FROM logtable WHERE pcdatum>?" rows = self.db.ladeSQL(sql, (lastDate, )) - logging.info("loaded concerned rows") + _moduleLogger.info("loaded concerned rows") newSQLs = self.server.doSync(self.sync_uuid, lastDate, rows, time.time()) - logging.info("did do sync, processing sqls now") + _moduleLogger.info("did do sync, processing sqls now") if newSQLs != -1: self.writeSQLTupel(newSQLs, lastDate) @@ -342,14 +345,14 @@ class Sync(gtk.VBox): mbox.hide() mbox.destroy() else: - logging.warning("Zeitdiff zu groß/oder anderer db-Fehler") + _moduleLogger.warning("Zeitdiff zu groß/oder anderer db-Fehler") self.changeSyncStatus(False, _("no sync process (at the moment)")) mbox = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, _("The clocks are not synchronized between stations")) response = mbox.run() mbox.hide() mbox.destroy() except StandardError: - logging.warning("Sync connect failed") + _moduleLogger.warning("Sync connect failed") self.changeSyncStatus(False, _("no sync process (at the moment)")) mbox = gtk.MessageDialog( None,