[gyrus/gyrus-python] new file: src/GyrusExport.py
- From: Alejandro Valdes Jimenez <avaldes src gnome org>
- To: svn-commits-list gnome org
- Subject: [gyrus/gyrus-python] new file: src/GyrusExport.py
- Date: Tue, 14 Jul 2009 15:17:43 +0000 (UTC)
commit f7f47a9d0e67d5aea2a08513624c92c24685a6ec
Author: Alejandro Valdes jimenez <avaldes amvj in utalca cl>
Date: Tue Jul 14 11:10:32 2009 -0400
new file: src/GyrusExport.py
ChangeLog | 2 +-
gyrus.desktop | 19 +++++-------
src/GyrusExport.py | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 88 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3f9c742..8b90c96 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,6 @@
2009-07-09 Alejandro Valdes jimenez <avaldes gnome org>
- * src/GyrusReport.py: add script for export data to CSV format.
+ * src/GyrusExpport.py: add script for export data to CSV format.
* src/Makefile.am: add file.
* src/gyrus.py: add menuitem for export.
diff --git a/gyrus.desktop b/gyrus.desktop
index ab41719..be50662 100644
--- a/gyrus.desktop
+++ b/gyrus.desktop
@@ -1,17 +1,14 @@
[Desktop Entry]
+X-AppInstall-Package=gyrus
+X-AppInstall-Popcon=2
+X-AppInstall-Section=main
+
Encoding=UTF-8
-Name=GNOME Cyrus/IMAP Administrator
-Name[en_CA]=GNOME Cyrus/IMAP Administrator
-Name[en_GB]=GNOME Cyrus/IMAP Administrator
-Name[es]=GNOME Cyrus/IMAP Administrador
+Name=Gyrus
+GenericName=GNOME Cyrus/IMAP Administrator
Comment=Manager Cyrus/IMAP server
-Comment[en_CA]=Manager Cyrus/IMAP server
-Comment[en_GB]=Manager Cyrus/IMAP server
-Comment[es]=Administra servidores Cyrus/IMAP
-Exec=gyrus.py
+Icon=gyrus.png
+Exec=gyrus
Terminal=false
Type=Application
-StartupNotify=true
-MimeType=text/plain;
-Icon=/usr/share/gyrus/images/gyrus.png
Categories=GNOME;GTK;Network;
diff --git a/src/GyrusExport.py b/src/GyrusExport.py
new file mode 100644
index 0000000..cbb47ce
--- /dev/null
+++ b/src/GyrusExport.py
@@ -0,0 +1,79 @@
+import pygtk
+pygtk.require('2.0')
+import gtk.glade
+import os
+import gettext
+import config
+import gyrus_util
+
+gettext.bindtextdomain(config.PACKAGE,config.LOCALEDIR)
+gettext.textdomain(config.PACKAGE)
+_ = gettext.gettext
+
+gtk.glade.bindtextdomain(config.PACKAGE,config.LOCALEDIR)
+gtk.glade.textdomain(config.PACKAGE)
+
+LOGO = os.path.join (config.ARTDIR, "gyrus.png")
+
+
+class GyrusExport:
+ def __init__ (self):
+ self.endline = "\n"
+ self.ext = ".csv"
+ self.separator = "|"
+
+ def load_interface (self):
+ filechooser = gtk.FileChooserDialog(_("Save file as"),None,gtk.FILE_CHOOSER_ACTION_SAVE,
+ (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
+
+ filechooser.set_select_multiple(False)
+ responce = filechooser.run()
+ filename = filechooser.get_filename()
+ filechooser.destroy()
+ return filename
+
+ def save_file (self,filename,admin):
+ filename = filename + self.ext
+
+ #try:
+ FILE = open (filename,"w")
+ if (FILE):
+ model = admin.treeview_users.get_model()
+ if model:
+ iter = model.get_iter_first()
+ line = _("Mailbox") + self.separator + _("Assigned") + self.separator + _("Used") + self.separator + _("Free") + self.separator + _("Percentage") + self.endline
+ FILE.write(line)
+ while iter:
+ usr = model.get_name_mailbox(iter)
+ quota,free = model.get_quota_of_mailbox(iter)
+
+ if (quota == 0):
+ porc = str('0')
+ else:
+ used = quota - free
+ porc = str('%3.0f'%((used*1.0/quota)*100))
+
+ line = usr + self.separator + str(quota) + self.separator + str(used) + self.separator + str(free) + self.separator + porc + self.endline
+ FILE.write(line)
+
+ iter = model.iter_next(iter)
+
+ FILE.close()
+ #except:
+ #result = gyrus_util.show_message (_("Can not write to file"),gtk.MESSAGE_ERROR,gtk.BUTTONS_OK)
+
+ def get_all_data_from_view (self,gyrus,FILE):
+ print gyrus
+ #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;"
+
+ #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]