diff options
author | flavio <fdanesse@gmail.com> | 2013-08-16 00:11:34 (GMT) |
---|---|---|
committer | flavio <fdanesse@gmail.com> | 2013-08-16 00:11:34 (GMT) |
commit | 4c154eb7b3e3a702731e8dad62003a61a8fa2dbf (patch) | |
tree | 206d855488e6958581e98443e38717a9b955ef60 /CeibalEncuesta | |
parent | 0c529cf4384aa01aca027a173444012b91c705c9 (diff) |
issue 4426 - Improvements in performance 1
Diffstat (limited to 'CeibalEncuesta')
-rw-r--r-- | CeibalEncuesta/gtk2/CeibalEncuesta/CeibalEncuesta.py | 58 | ||||
-rw-r--r-- | CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py | 13 |
2 files changed, 40 insertions, 31 deletions
diff --git a/CeibalEncuesta/gtk2/CeibalEncuesta/CeibalEncuesta.py b/CeibalEncuesta/gtk2/CeibalEncuesta/CeibalEncuesta.py index babd151..e12803a 100644 --- a/CeibalEncuesta/gtk2/CeibalEncuesta/CeibalEncuesta.py +++ b/CeibalEncuesta/gtk2/CeibalEncuesta/CeibalEncuesta.py @@ -45,16 +45,15 @@ PATH = os.path.dirname(__file__) home = site.getuserbase() HOME = home.replace(".local", "") WORKPATH = os.path.join(HOME, "CeibalEncuesta") -TEMPPATH = os.path.join("/tmp", "temp.encuesta") -BACKUP_PATH = os.path.join(HOME, "Documentos") +TEMPPATH = os.path.join("/dev/shm", "temp.encuesta") +#BACKUP_PATH = "/dev/shm" #os.path.join(HOME, "Documentos") if not os.path.exists(WORKPATH): os.mkdir(WORKPATH) os.chmod(WORKPATH, 0755) - -if not os.path.exists(BACKUP_PATH): - BACKUP_PATH = WORKPATH +#if not os.path.exists(BACKUP_PATH): +# BACKUP_PATH = WORKPATH archivo = open(TEMPPATH, "w") archivo.close() @@ -70,7 +69,7 @@ class CeibalEncuesta(gtk.Window): } def __init__(self): - self.backup_path = BACKUP_PATH + #self.backup_path = BACKUP_PATH gtk.Window.__init__(self) @@ -117,14 +116,14 @@ class CeibalEncuesta(gtk.Window): self.connect("key-press-event", self.__key_press_event) self.connect("destroy", self.__salir) self.connect("expose-event", self.__do_draw) - + self.__init() - + ''' if getattr(self, "poll_id", None): if str(self.poll_id) not in self.backup_path: self.backup_path = self.backup_path + "/%s.encuesta" % self.poll_id if not os.path.exists(self.backup_path): - self.__save_json(path=self.backup_path) + self.__save_json(path=self.backup_path)''' self.connect("destroy", gtk.main_quit) self.show_all() @@ -318,7 +317,7 @@ class CeibalEncuesta(gtk.Window): Recibe los cambios en la encuesta y almacena los datos. """ - + user = "" for item in encuestado: user += " %s" % item @@ -340,7 +339,7 @@ class CeibalEncuesta(gtk.Window): self.out_dict[encuestado][indice_grupo]["name"] = grupo_name self.out_dict[encuestado][indice_grupo]["fields"][indice_pregunta] = dict_pregunta - + self.__save_json(path = self.path) def __new_selection(self, widget, encuestado): @@ -449,6 +448,7 @@ class CeibalEncuesta(gtk.Window): """ ### Asegurandose de que se haya guardado toda la informaciĆ³n. + self.__save_json() import json @@ -592,8 +592,8 @@ class CeibalEncuesta(gtk.Window): if os.path.exists(TEMPPATH): os.remove(TEMPPATH) - - self.path = archivo + + #self.path = archivo extension = os.path.splitext(os.path.split(archivo)[1])[1] @@ -618,7 +618,7 @@ class CeibalEncuesta(gtk.Window): "pollster_id": pollster_id, "pollster_username": pollster_username} - self.backup_path = self.backup_path + "/%s.encuesta" % poll_id + #self.backup_path = self.backup_path + "/%s.encuesta" % poll_id self.infowidget.set_info(dict) @@ -637,11 +637,8 @@ class CeibalEncuesta(gtk.Window): self.path = TEMPPATH - arch = open(self.path, "w") - arch.close() - self.out_dict = {} - + self.__save_json(path = self.path) encuestados = G.cargar_encuestados(os.path.join(archivo)) @@ -661,9 +658,6 @@ class CeibalEncuesta(gtk.Window): self.path = TEMPPATH - arch = open(self.path, "w") - arch.close() - # Mantiene la lista de encuestados cargada actualmente. encuestados = self.out_dict.keys() @@ -712,7 +706,7 @@ class CeibalEncuesta(gtk.Window): archivo.close() self.poll_id = poll_id - + ''' bck_path = self.backup_path + "/%s.encuesta" % self.poll_id if os.path.exists(bck_path): msg = u""" @@ -728,7 +722,7 @@ class CeibalEncuesta(gtk.Window): ) dialog.run() dialog.destroy() - return False + return False''' self.panel.load_encuesta(encuesta) @@ -742,7 +736,7 @@ class CeibalEncuesta(gtk.Window): while gtk.events_pending(): gtk.main_iteration() - + self.__save_json(path = self.path) self.__check_sensitive() @@ -762,8 +756,8 @@ class CeibalEncuesta(gtk.Window): Guarda encuesta en formato json. """ - self.path = path - + #self.path = path + encuestados = [] encuesta = {} poll_name = "" @@ -800,6 +794,18 @@ class CeibalEncuesta(gtk.Window): if TEMPPATH != path: os.remove(TEMPPATH) + def copy_to_Documents(self): + + path = os.path.join(HOME, "Documentos") + + if not os.path.exists(path): + path = WORKPATH + + final_path = os.path.join(path, os.path.basename(self.path)) + + import shutil + shutil.copyfile(self.path, final_path) + def __salir(self, widget = None, senial = None): sys.exit(0) diff --git a/CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py b/CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py index 762483e..79d128e 100644 --- a/CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py +++ b/CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py @@ -215,6 +215,7 @@ class Panel(gtk.Paned): for question in self.visible_questions(): texto = None active_options = None + if question.pregunta.get("widget_type", None) == "TextInput": texto = question.widget_obtions.get_text().strip() else: @@ -248,13 +249,16 @@ class Panel(gtk.Paned): self._window.get_vadjustment().set_value(0) elif accion == "Siguiente" and self.toolbar_encuesta.siguiente.active: - + + ceibal_encuesta = self.get_toplevel() + if index_visible < len(grupos) - 1: map(self.__hide_groups, grupos) map(self.__show_groups, [grupos[index_visible + 1]]) self.box_encuesta.queue_draw() self._window.get_vadjustment().set_value(0) - + ceibal_encuesta.copy_to_Documents() + if index_visible == len(grupos) - 2: self.toolbar_encuesta.encuesta_actual.finalizar() @@ -264,17 +268,16 @@ class Panel(gtk.Paned): for item in encuestado: user += " %s" % item encuestado = user.strip() - ceibal_encuesta = self.get_toplevel() + if encuestado in ceibal_encuesta.out_dict.keys(): ceibal_encuesta.out_dict[encuestado].update( {"finalizada": True}) ceibal_encuesta._CeibalEncuesta__save_json( path=ceibal_encuesta.path) - self.toolbar_encuesta.siguiente.hide() self.toolbar_encuesta.anterior.show() return - + self.__check_sensibility_butons() def load_encuestados(self, encuestados): |