[gevice] enable export option
- From: Alejandro Valdes Jimenez <avaldes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gevice] enable export option
- Date: Fri, 14 Dec 2012 20:19:19 +0000 (UTC)
commit 3de75898860041aa747e3b40efdffd7015a3babb
Author: Alejandro ValdÃs Jimenez <avaldes gnome org>
Date: Fri Dec 14 17:14:28 2012 -0300
enable export option
ChangeLog | 4 ++++
src/gevice.py | 10 +++++++---
src/geviceexport.py | 14 +++++---------
3 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 221ddfa..dac5197 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
2012-12-14 Alejandro ValdéJimenez <avaldes gnome org>
+ * src/gevice.py: enable export option.
+ * src/geviceexport.py: clean code.
+
+2012-12-14 Alejandro ValdéJimenez <avaldes gnome org>
* data/ui/diagram.xml: change to modal window.
* src/gevice.py: enable diagram option.
* src/gevicediagram.py: clean code.
diff --git a/src/gevice.py b/src/gevice.py
index 16f6977..ff71733 100755
--- a/src/gevice.py
+++ b/src/gevice.py
@@ -30,7 +30,7 @@ import gevicevte
import gevicedevice
import gevicemodel
import gevicedatabase
-###import geviceexport
+import geviceexport
import gettext
gettext.bindtextdomain(config.PACKAGE,config.LOCALEDIR)
@@ -126,7 +126,6 @@ class Gevice:
# load preferences
self.gpref = geviceprefer.GevicePrefer(self)
- ###self.gpref.load_interface (self)
# show all
self.window_main.show_all()
@@ -163,7 +162,7 @@ class Gevice:
self.actiongroup_model.add_actions([
('Find', Gtk.STOCK_FIND, _('Find'),None, _('Search a device'), self.passing),
('Save', Gtk.STOCK_SAVE, _('Save'), None, _('Save model'), self.on_action_save),
- ('Export', Gtk.STOCK_SELECT_ALL, _('Export all to CSV'), None, _('Export all to CSV'), self.passing),
+ ('Export', Gtk.STOCK_SELECT_ALL, _('Export all to CSV'), None, _('Export all to CSV'), self.on_action_export),
('AddDevice', Gtk.STOCK_ADD, _('Add'),None, _('Add a device'), self.on_action_adddevice),
])
@@ -489,6 +488,11 @@ class Gevice:
(Gtk.STOCK_OK, Gtk.ResponseType.OK),
self.window_main)
+ def on_action_export (self,action):
+ dialogexport = geviceexport.GeviceExport ()
+ dialogexport.load_interface (self)
+ dialogexport.save_file (self)
+
if __name__ == "__main__":
gevice = Gevice()
gevice.main()
diff --git a/src/geviceexport.py b/src/geviceexport.py
index 5b43297..348edf7 100644
--- a/src/geviceexport.py
+++ b/src/geviceexport.py
@@ -40,7 +40,6 @@ class GeviceExport:
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT))
filechooser.set_select_multiple(False)
-
response = filechooser.run()
if response == Gtk.ResponseType.ACCEPT:
@@ -51,21 +50,18 @@ class GeviceExport:
def save_file (self,gevice):
if self.filename:
self.filename = self.filename + self.ext
- print self.filename
try:
FILE = open (self.filename,"w")
if (FILE):
- self.get_all_data_from_view (gevice,FILE)
+ self.get_all_data_from_dbase (gevice,FILE)
FILE.close()
+ result = gevice.show_infobar_message (_("Model exported"), Gtk.MessageType.INFO)
except:
result = gevice.show_infobar_message (_("Can not write to file"), Gtk.MessageType.ERROR)
- def get_all_data_from_view (self,gevice,FILE):
- #sql = "select nom_tipo_disp,nom_marca,nom_modelo,nom_tipo_disp || ' ' || nom_marca || ' ' || nom_modelo,count(nom_tipo_disp) "
- #sql = sql + "from todoslosdispositivos group by nom_tipo_disp,nom_marca,nom_modelo;"
-
- sql = "select nom_disp,nom_tipo_disp || ' ' || nom_marca || ' ' || nom_modelo,ip_disp from todoslosdispositivos order by 2;"
+ def get_all_data_from_dbase (self,gevice,FILE):
+ sql = "select id_dev, ip_dev from device order by 1;"
cur = gevice.gdbase.conn.cursor()
cur.execute(sql)
@@ -74,6 +70,6 @@ class GeviceExport:
for reg in rows:
line = ""
for col in reg:
- line = line + str(col) + gevice.gpref.settings.get_string("csvseparator")
+ line = line + str(col) + gevice.gpref.gsettings.get_string("csvseparator")
FILE.write (line + self.endline)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]