Skip to content

Commit

Permalink
Improve readability of rowcount and query duration (fixes #19).
Browse files Browse the repository at this point in the history
  • Loading branch information
Andi Albrecht committed Apr 29, 2016
1 parent 8718750 commit e961fc9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Development Version
* Use system fonts when possible.
* Change shortcuts for changing tabs to Alt+NUMBER (instead of
Control+NUMBER, #21).
* Improve readability of rowcount and query duration (#19).


Version 0.4.1 (2015-04-30)
Expand Down
3 changes: 3 additions & 0 deletions rsr/cmd.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import locale
import os
import signal
import sys
Expand All @@ -21,6 +22,8 @@
# any Oracle connection.
os.environ.setdefault('NLS_LANG', '.AL32UTF8')

locale.setlocale(locale.LC_ALL, '.'.join(locale.getlocale()))


def main():
parser.parse_args()
Expand Down
12 changes: 8 additions & 4 deletions rsr/connections/query.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import locale

from gi.repository import GObject


Expand Down Expand Up @@ -26,8 +28,10 @@ def get_result_summary(self):
if not self.finished:
return None
if self.result is not None:
return '%i rows, %.3f seconds' % (len(self.result),
self.execution_duration)
return '{} rows, {} seconds'.format(
locale.format('%d', len(self.result), grouping=True),
locale.format('%.3f', self.execution_duration, grouping=True))
else:
return '%i rows affected, %.3f seconds' % (self.rowcount,
self.execution_duration)
return '{} rows affected, {} seconds'.format(
locale.format('%d', self.rowcount, grouping=True),
locale.foramt('%.3f', self.execution_duration, grouping=True))
4 changes: 3 additions & 1 deletion rsr/connections/ui.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import locale
import time

from gi.repository import Gtk, GObject, Gio
Expand Down Expand Up @@ -341,5 +342,6 @@ def on_query_changed(self, editor):
GObject.timeout_add(10, self.on_query_changed, self._editor)
else:
duration = time.time() - query.start_time
self.lbl_query.set_text('Running for %.3f seconds' % duration)
self.lbl_query.set_text('Running for {} seconds'.format(
locale.format('%.3f', duration, grouping=True)))
GObject.timeout_add(10, self.on_query_changed, self._editor)

0 comments on commit e961fc9

Please sign in to comment.