From a4655276fe65c1baf256b7b3409c3d136424a94c Mon Sep 17 00:00:00 2001 From: junglecow <junglecow@no-mail.com> Date: Wed, 20 Dec 2006 20:40:08 +0000 Subject: [PATCH] =?UTF-8?q?[Trunk]=20=20-=20In=20verbose=20mode,=20print?= =?UTF-8?q?=20encodings.=20(Especially=20for=20Windows=20users=20who=20don?= =?UTF-8?q?'t=20have=20Python)=20(gajim.py)=20=20-=20Attempt=20at=20fixing?= =?UTF-8?q?=20traceback=20when=20getting=20user's=20home=20directory=20in?= =?UTF-8?q?=20Windows.=20See=20#2812.=20(c/configpaths.py)=20=20-=20Show?= =?UTF-8?q?=20'error'=20icon=20next=20to=20account=20while=20waiting=20for?= =?UTF-8?q?=20reconnect.=20Fixes=20#2786.=20(c/connection=5Fhandlers.py,?= =?UTF-8?q?=20c/gajim.py,=20c/connection.py)=20[PyOpenSSL]=20=20-=20Fix=20?= =?UTF-8?q?100%=20CPU=20usage=20and=20hanging=20connection=20when=20server?= =?UTF-8?q?=20closes=20connection=20on=20us.=20(c/x/transports=5Fnb.py)=20?= =?UTF-8?q?=20-=20Fix=20'hanging'=20connection=20when=20server=20closes=20?= =?UTF-8?q?the=20connection=20on=20us=20before=20we=20can=20open=20the=20X?= =?UTF-8?q?ML=20stream.=20(Disconnect=20handler=20didn't=20get=20called.)?= =?UTF-8?q?=20(c/x/client=5Fnb.py)=20=20-=20Change=20prints=20to=20logger?= =?UTF-8?q?=20calls,=20various=20enhancements=20to=20debug=20printing,=20r?= =?UTF-8?q?educe=20spam=20(c/x/transports=5Fnb.py)=20=20-=20this=20?= =?UTF-8?q?=E2=86=92=20self=20(c/x/transports=5Fnb.py)=20=20-=20Call=20=5F?= =?UTF-8?q?do=5Freceive()=20once=20to=20collect=20error=20message=20from?= =?UTF-8?q?=20socket,=20when=20error=20flag=20is=20raised=20in=20scheduler?= =?UTF-8?q?.=20(c/x/transports=5Fnb.py)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/other/servers.xml | 8 +++++++- src/common/configpaths.py | 2 +- src/common/connection.py | 10 +++++++--- src/common/connection_handlers.py | 2 +- src/common/gajim.py | 2 +- src/gajim.py | 4 ++++ 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/data/other/servers.xml b/data/other/servers.xml index 0a044c1c27..19a00c2366 100644 --- a/data/other/servers.xml +++ b/data/other/servers.xml @@ -369,4 +369,10 @@ <item jid="xmpp.us" name=""> <active port="5222"/> </item> -</query> \ No newline at end of file + <item jid="zloygod.serveftp.com" name="Rituko's server"> + <active port="5222"/> + </item> + <item jid="localhost" name="Localhost"> + <active port="5222"/> + </item> +</query> diff --git a/src/common/configpaths.py b/src/common/configpaths.py index d3c1886072..daead7794e 100644 --- a/src/common/configpaths.py +++ b/src/common/configpaths.py @@ -87,7 +87,7 @@ def init(): paths.add_from_root(n, p) paths.add('DATA', os.path.join(u'..', windowsify(u'data'))) - paths.add('HOME', os.path.expanduser(u'~')) + paths.add('HOME', fse(os.path.expanduser('~'))) paths.add('TMP', fse(tempfile.gettempdir())) try: diff --git a/src/common/connection.py b/src/common/connection.py index 42d405c9f3..606725a6bb 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -109,6 +109,8 @@ class Connection(ConnectionHandlers): self.time_to_reconnect = None if self.connected < 2: #connection failed gajim.log.debug('reconnect') + self.connected = 1 + self.dispatch('STATUS', 'connecting') self.retrycount += 1 signed = self.get_signed_msg(self.status) self.on_connect_auth = self._init_roster @@ -143,8 +145,8 @@ class Connection(ConnectionHandlers): if not self.on_purpose: self.disconnect() if gajim.config.get_per('accounts', self.name, 'autoreconnect'): - self.connected = 1 - self.dispatch('STATUS', 'connecting') + self.connected = -1 + self.dispatch('STATUS', 'error') # this check has moved from _reconnect method # do exponential backoff until 15 minutes, # then small linear increase @@ -154,7 +156,7 @@ class Connection(ConnectionHandlers): self.last_time_to_reconnect *= 1.5 self.last_time_to_reconnect += randomsource.randint(0, 5) self.time_to_reconnect = int(self.last_time_to_reconnect) - gajim.log.debug("Reconnect to %s in %ss", self.name, self.time_to_reconnect) + gajim.log.info("Reconnect to %s in %ss", self.name, self.time_to_reconnect) gajim.idlequeue.set_alarm(self._reconnect_alarm, self.time_to_reconnect) elif self.on_connect_failure: @@ -379,11 +381,13 @@ class Connection(ConnectionHandlers): if self.on_connect_success == self._on_new_account: con.RegisterDisconnectHandler(self._on_new_account) + gajim.log.info("Connecting to %s: [%s:%d]", self.name, host['host'], host['port']) con.connect((host['host'], host['port']), proxy = self._proxy, secure = self._secure) return else: if not retry and self.retrycount == 0: + gajim.log.error("Out of hosts, giving up connecting to %s", self.name) self.time_to_reconnect = None if self.on_connect_failure: self.on_connect_failure() diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 20a875fd8e..9d7b08af1c 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -38,7 +38,7 @@ from common.commands import ConnectionCommands from common.pubsub import ConnectionPubSub STATUS_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd', - 'invisible'] + 'invisible', 'error'] # kind of events we can wait for an answer VCARD_PUBLISHED = 'vcard_published' VCARD_ARRIVED = 'vcard_arrived' diff --git a/src/common/gajim.py b/src/common/gajim.py index 91e6eab8ec..78354108df 100644 --- a/src/common/gajim.py +++ b/src/common/gajim.py @@ -121,7 +121,7 @@ sleeper_state = {} # whether we pass auto away / xa or not status_before_autoaway = {} SHOW_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd', - 'invisible'] + 'invisible', 'error'] # zeroconf account name ZEROCONF_ACC_NAME = 'Local' diff --git a/src/gajim.py b/src/gajim.py index 2209623e94..fcc0d1f769 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -2157,6 +2157,10 @@ if __name__ == '__main__': # ^C exits the application normally to delete pid file signal.signal(signal.SIGINT, sigint_cb) + if gajim.verbose: + print >> sys.stderr, "Encodings: d:%s, fs:%s, p:%s" % \ + (sys.getdefaultencoding(), sys.getfilesystemencoding(), locale.getpreferredencoding()) + if os.name != 'nt': # Session Management support try: -- GitLab