[gevice/gevice-2-0] Fixed bug #663014



commit 54d806b0602b8560513b712cff92b1fc1bf560d3
Author: Alejandro Valdes Jimenez <avaldes gnome org>
Date:   Thu Nov 3 15:01:57 2011 -0300

    Fixed bug #663014

 ChangeLog                      |    5 ++
 configure.ac                   |    1 +
 data/Makefile.am               |    2 +-
 data/other/Makefile.am         |   10 ++++
 data/{ => other}/db_gevice.sql |    0
 src/Makefile.am                |    1 +
 src/config.py.in               |    2 +
 src/gevice.py                  |   26 ++++++++++-
 src/geviceexport.py            |   98 ++++++++++++++++++++--------------------
 9 files changed, 93 insertions(+), 52 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index eb10a40..c310854 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
 2011-11-03  Alejandro Valdes Jimenez  <avaldes gnome org>
+	* data/other/Makefile.am: add db_gevice.sql:
+	* data/other/db_gevice.sql: script to create database.
+	* Fixed bug #663014
+
+2011-11-03  Alejandro Valdes Jimenez  <avaldes gnome org>
 	* data/ui/menu.xml: remove Action "Refresh"
 	* src/gevice.py: remove Action "Refresh"
 
diff --git a/configure.ac b/configure.ac
index 164776d..2620fd7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,7 @@ AC_CONFIG_FILES([
 	Makefile
 	data/Makefile
 	data/ui/Makefile
+	data/other/Makefile
 	data/images/Makefile
 	po/Makefile.in
 	src/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index 50ee26e..1dd6721 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1 +1 @@
-SUBDIRS = ui images
+SUBDIRS = ui images other
diff --git a/data/other/Makefile.am b/data/other/Makefile.am
new file mode 100644
index 0000000..a82880a
--- /dev/null
+++ b/data/other/Makefile.am
@@ -0,0 +1,10 @@
+#
+# Other files
+#
+
+otherdir   = $(pkgdatadir)/other
+
+other_DATA = \
+	db_gevice.sql
+
+EXTRA_DIST = $(other_DATA)
diff --git a/data/db_gevice.sql b/data/other/db_gevice.sql
similarity index 100%
rename from data/db_gevice.sql
rename to data/other/db_gevice.sql
diff --git a/src/Makefile.am b/src/Makefile.am
index 1198e26..4f680ff 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -34,6 +34,7 @@ config.py: config.py.in Makefile
 		-e s!\ PKGDATADIR\@!$(pkgdatadir)! \
 		-e s!\ UIDIR\@!$(pkgdatadir)/ui! \
 		-e s!\ ARTDIR\@!$(pkgdatadir)/images! \
+		-e s!\ OTHERDIR\@!$(pkgdatadir)/other! \
 		-e s!\ XMLDIR\@!$(pkgdatadir)/xml! \
 		-e s!\ SAMPLEDIR\@!$(pkgdatadir)/samples! \
 		-e s!\ PACKAGE_NAME\@!$(PACKAGE_NAME)! \
diff --git a/src/config.py.in b/src/config.py.in
index daee9de..9de4eb4 100644
--- a/src/config.py.in
+++ b/src/config.py.in
@@ -38,12 +38,14 @@ if exists(join(dirname(__file__), '../gevice.in')):
     PKGDATADIR  = source_datadir
     UIDIR    = join (source_datadir, "ui")
     ARTDIR	= join (source_datadir, "images")
+    OTHERDIR	= join (source_datadir, "other")
 # Normal situation: use installation paths from ./configure
 else:
     DATADIR     = "@DATADIR@"
     PKGDATADIR  = "@PKGDATADIR@"
     UIDIR    = "@UIDIR@"
     ARTDIR	= "@ARTDIR@"
+    OTHERDIR	= "@OTHERDIR@"
 
 # struct main treestore
 COLUMN_NAME_DEV = 0
diff --git a/src/gevice.py b/src/gevice.py
index 65a8bb4..e5e7d3f 100755
--- a/src/gevice.py
+++ b/src/gevice.py
@@ -395,8 +395,30 @@ class Gevice:
     return button
 
   def on_action_ndbase(gevice,action,data):
-    pass
-    
+    filechooser = Gtk.FileChooserDialog(title=_("New Database"), 
+      parent=gevice.window_main, 
+      action=Gtk.FileChooserAction.SAVE, 
+      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:
+      dbsqlite = filechooser.get_filename()
+
+      try:
+        FILE = open (dbsqlite,"w")
+        if (FILE):
+          FILE.close()
+          file_database = os.path.join (config.OTHERDIR,"db_gevice.sql")
+          id = os.popen('sqlite3 ' + dbsqlite + ' <' + file_database)
+      except:
+        result = gevice.show_infobar_message (_("Can not write to file"), 
+          Gtk.MessageType.ERROR)
+
+    filechooser.destroy()
+
   def on_action_model (gevice,action,data):
     sql_select = "select modelo.id_modelo,tipo_disp.nom_tipo_disp || ' ' || marca.nom_marca,modelo.nom_modelo "
     sql_select = sql_select + "from modelo inner join marca on modelo.id_marca = marca.id_marca inner join tipo_disp "
diff --git a/src/geviceexport.py b/src/geviceexport.py
index 7177796..331d21a 100644
--- a/src/geviceexport.py
+++ b/src/geviceexport.py
@@ -10,52 +10,52 @@ gettext.bind_textdomain_codeset (config.PACKAGE, "UTF-8");
 from gettext import gettext as _
 
 class GeviceExport:
-    def __init__ (self):
-        self.endline = "\n"
-        self.ext = ".csv"
-        self.filename = ""
-    
-    def load_interface (self,gevice):
-	filechooser = Gtk.FileChooserDialog(title=_("Save file as"), 
-	  parent=gevice.window_main, 
-	  action=Gtk.FileChooserAction.SAVE,
-	  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:
-	  self.filename = filechooser.get_filename()
-
-	filechooser.destroy()
-
-    def save_file (self,gevice):
-        if self.filename:
-            self.filename = self.filename + self.ext
-            
-            try:
-            	FILE = open (self.filename,"w")
-            	if (FILE):
-                	print self.filename
-                	self.get_all_data_from_view (gevice,FILE)
-                	FILE.close()
-            except:
-		result = gevice.show_message (_("Can not write to file"),None,(Gtk.STOCK_OK, Gtk.ResponseType.OK),self.window_database)
-
-    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;"
-        
-        cur = gevice.gdbase.conn.cursor()
-        cur.execute(sql)
-        rows = cur.fetchall()
-        
-        for reg in rows:
-            line = ""
-            for col in reg:
-                line = line + str(col) + gevice.gpref.csvseparator
-            
-            FILE.write (line + self.endline)
+  def __init__ (self):
+      self.endline = "\n"
+      self.ext = ".csv"
+      self.filename = ""
+
+  def load_interface (self,gevice):
+    filechooser = Gtk.FileChooserDialog(title=_("Save file as"), 
+      parent=gevice.window_main, 
+      action=Gtk.FileChooserAction.SAVE,
+      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:
+      self.filename = filechooser.get_filename()
+
+    filechooser.destroy()
+
+  def save_file (self,gevice):
+    if self.filename:
+      self.filename = self.filename + self.ext
+
+      try:
+        FILE = open (self.filename,"w")
+        if (FILE):
+          self.get_all_data_from_view (gevice,FILE)
+          FILE.close()
+      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;"
+
+    cur = gevice.gdbase.conn.cursor()
+    cur.execute(sql)
+    rows = cur.fetchall()
+
+    for reg in rows:
+      line = ""
+      for col in reg:
+        line = line + str(col) + gevice.gpref.csvseparator
+
+      FILE.write (line + self.endline)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]