Philipp Hörist pushed to branch master at gajim / gajim
Commits:
877b754e by Philipp Hörist at 2018-02-12T23:39:50+01:00
Simplfy writing to config file
- use `with` statement and open() instead of os.open()
- execute run() on dialog, otherwise sys.exit() is called immediatly
- - - - -
2 changed files:
- gajim/common/optparser.py
- gajim/gui_interface.py
Changes:
=====================================
gajim/common/optparser.py
=====================================
--- a/gajim/common/optparser.py
+++ b/gajim/common/optparser.py
@@ -111,24 +111,18 @@ class OptionsParser:
(base_dir, filename) = os.path.split(self.__filename)
self.__tempfile = os.path.join(base_dir, '.' + filename)
try:
- f = os.fdopen(os.open(self.__tempfile,
- os.O_CREAT|os.O_WRONLY|os.O_TRUNC, 0o600), 'w', encoding='utf-8')
+ with open(self.__tempfile, 'w', encoding='utf-8') as f:
+ app.config.foreach(self.write_line, f)
except IOError as e:
return str(e)
- try:
- app.config.foreach(self.write_line, f)
- except IOError as e:
- return str(e)
- f.flush()
- os.fsync(f.fileno())
- f.close()
+
if os.path.exists(self.__filename):
if os.name == 'nt':
# win32 needs this
try:
os.remove(self.__filename)
- except Exception:
- pass
+ except Exception as e:
+ return str(e)
try:
os.rename(self.__tempfile, self.__filename)
except IOError as e:
=====================================
gajim/gui_interface.py
=====================================
--- a/gajim/gui_interface.py
+++ b/gajim/gui_interface.py
@@ -2408,8 +2408,9 @@ class Interface:
print(err_str, file=sys.stderr)
# it is good to notify the user
# in case he or she cannot see the output of the console
- dialogs.ErrorDialog(_('Could not save your settings and '
+ error_dialog = dialogs.ErrorDialog(_('Could not save your settings and '
'preferences'), err_str)
+ error_dialog.run()
sys.exit()
@staticmethod
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/877b754ef3965d947c78e072daaf990a2a…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/877b754ef3965d947c78e072daaf990a2a…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
fb4b2624 by Philipp Hörist at 2018-02-12T21:27:55+01:00
Dont use getTimestamp()
getTimestamp() generates always a timestring with a resolution of seconds and
this means time gets always rounded down.
Because we use a resolution of .00000 precision for outgoing messages this
can lead to wrongly sorted messages.
- - - - -
1 changed file:
- gajim/common/connection_handlers_events.py
Changes:
=====================================
gajim/common/connection_handlers_events.py
=====================================
--- a/gajim/common/connection_handlers_events.py
+++ b/gajim/common/connection_handlers_events.py
@@ -99,7 +99,7 @@ class HelperEvent:
def _generate_timestamp(self, tag):
# Make sure we use only int/float Epoch time
- if not isinstance(tag, str):
+ if tag is None:
self.timestamp = time_time()
return
try:
@@ -771,7 +771,7 @@ PresenceHelperEvent):
# XEP-0203
delay_tag = self.stanza.getTag('delay', namespace=nbxmpp.NS_DELAY2)
if delay_tag:
- self._generate_timestamp(self.stanza.getTimestamp2())
+ self._generate_timestamp(self.stanza.timestamp)
# XEP-0319
self.idle_time = None
idle_tag = self.stanza.getTag('idle', namespace=nbxmpp.NS_IDLE)
@@ -791,7 +791,7 @@ PresenceHelperEvent):
self.contact_nickname = x.getTagData('nickname')
elif namespace == nbxmpp.NS_DELAY and not self.timestamp:
# XEP-0091
- self._generate_timestamp(self.stanza.getTimestamp())
+ self._generate_timestamp(self.stanza.timestamp)
elif namespace == 'http://delx.cjb.net/protocol/roster-subsync':
# see http://trac.gajim.org/ticket/326
agent = app.get_server_from_jid(self.jid)
@@ -1401,7 +1401,7 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
self.session.last_receive = time_time()
- self._generate_timestamp(self.stanza.getTimestamp())
+ self._generate_timestamp(self.stanza.timestamp)
return True
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/fb4b262477cbbe51c66b8e1de15ae42932…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/fb4b262477cbbe51c66b8e1de15ae42932…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch gajim_1.0 at gajim / gajim
Commits:
19689ac9 by Philipp Hörist at 2018-02-12T21:18:49+01:00
Dont use getTimestamp()
getTimestamp() generates always a timestring with a resolution of seconds and
this means time gets always rounded down.
Because we use a resolution of .00000 precision for outgoing messages this
can lead to wrongly sorted messages.
- - - - -
1 changed file:
- gajim/common/connection_handlers_events.py
Changes:
=====================================
gajim/common/connection_handlers_events.py
=====================================
--- a/gajim/common/connection_handlers_events.py
+++ b/gajim/common/connection_handlers_events.py
@@ -99,7 +99,7 @@ class HelperEvent:
def _generate_timestamp(self, tag):
# Make sure we use only int/float Epoch time
- if not isinstance(tag, str):
+ if tag is None:
self.timestamp = time_time()
return
try:
@@ -771,7 +771,7 @@ PresenceHelperEvent):
# XEP-0203
delay_tag = self.stanza.getTag('delay', namespace=nbxmpp.NS_DELAY2)
if delay_tag:
- self._generate_timestamp(self.stanza.getTimestamp2())
+ self._generate_timestamp(self.stanza.timestamp)
# XEP-0319
self.idle_time = None
idle_tag = self.stanza.getTag('idle', namespace=nbxmpp.NS_IDLE)
@@ -791,7 +791,7 @@ PresenceHelperEvent):
self.contact_nickname = x.getTagData('nickname')
elif namespace == nbxmpp.NS_DELAY and not self.timestamp:
# XEP-0091
- self._generate_timestamp(self.stanza.getTimestamp())
+ self._generate_timestamp(self.stanza.timestamp)
elif namespace == 'http://delx.cjb.net/protocol/roster-subsync':
# see http://trac.gajim.org/ticket/326
agent = app.get_server_from_jid(self.jid)
@@ -1401,7 +1401,7 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
self.session.last_receive = time_time()
- self._generate_timestamp(self.stanza.getTimestamp())
+ self._generate_timestamp(self.stanza.timestamp)
return True
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/19689ac9f8a4bee54197135f0f04ae20d8…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/19689ac9f8a4bee54197135f0f04ae20d8…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch gajim_1.0 at gajim / gajim
Commits:
172e7af4 by Philipp Hörist at 2018-02-12T18:52:18+01:00
Read config files with UTF-8
- - - - -
1 changed file:
- gajim/common/optparser.py
Changes:
=====================================
gajim/common/optparser.py
=====================================
--- a/gajim/common/optparser.py
+++ b/gajim/common/optparser.py
@@ -48,7 +48,7 @@ class OptionsParser:
def read(self):
try:
- fd = open(self.__filename)
+ fd = open(self.__filename, encoding='utf-8')
except Exception:
if os.path.exists(self.__filename):
#we talk about a file
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/172e7af4a5fefee68cbf8c5a1c1314618d…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/172e7af4a5fefee68cbf8c5a1c1314618d…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
c02af8f5 by Link Mauve at 2018-02-12T12:34:00+01:00
Fix data form window space usage
- - - - -
1 changed file:
- gajim/data/gui/data_form_window.ui
Changes:
=====================================
gajim/data/gui/data_form_window.ui
=====================================
--- a/gajim/data/gui/data_form_window.ui
+++ b/gajim/data/gui/data_form_window.ui
@@ -34,7 +34,7 @@
<object class="GtkScrolledWindow" id="single_form_scrolledwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="vexpand">True</property>
+ <property name="expand">True</property>
<child>
<object class="GtkViewport" id="single_form_viewport">
<property name="visible">True</property>
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/c02af8f5175812aaa441e58f3205cd18db…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/c02af8f5175812aaa441e58f3205cd18db…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
f47ea05b by Philipp Hörist at 2018-02-10T18:59:34+01:00
Read config files with UTF-8
- - - - -
1 changed file:
- gajim/common/optparser.py
Changes:
=====================================
gajim/common/optparser.py
=====================================
--- a/gajim/common/optparser.py
+++ b/gajim/common/optparser.py
@@ -48,7 +48,7 @@ class OptionsParser:
def read(self):
try:
- fd = open(self.__filename)
+ fd = open(self.__filename, encoding='utf-8')
except Exception:
if os.path.exists(self.__filename):
#we talk about a file
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/f47ea05b79ce30e27b8962cd7296a73b08…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/f47ea05b79ce30e27b8962cd7296a73b08…
You're receiving this email because of your account on dev.gajim.org.