gnutrition-commits
[Top][All Lists]
Advanced

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

[GNUtrition-commits] /srv/bzr/gnutrition/trunk r20: Committing patch fro


From: Jason Self
Subject: [GNUtrition-commits] /srv/bzr/gnutrition/trunk r20: Committing patch from Adam Rakowski
Date: Wed, 27 Mar 2013 08:04:25 -0700
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 20
committer: Jason Self <address@hidden>
branch nick: trunk
timestamp: Wed 2013-03-27 08:04:25 -0700
message:
  Committing patch from Adam Rakowski
modified:
  ChangeLog
  src/config.py
  src/druid.py
  src/run_app.py
=== modified file 'ChangeLog'
--- a/ChangeLog 2013-03-27 15:00:11 +0000
+++ b/ChangeLog 2013-03-27 15:04:25 +0000
@@ -1,4 +1,20 @@
-2013-03-07  Adam Rakowski <address@hidden>
+2013-03-27  Adam Rakowski <address@hidden>
+
+        * src/config.py
+       * src/druid.py
+       * src/run_app.py 
+
+       Gnutrition homedir is in.gnutrition/version_number.
+
+       Fixing a problem with empty db and empty config when first-run 
+       druid has been canceled.
+
+       If druid was canceled on first screen, then empty sqlite file was
+       created and next time gnutrition tried to load data from this file.
+       Similiar, the empty configuration file wasn't deleted when user cancels
+       config-druid.
+
+2013-03-27  Adam Rakowski <address@hidden>
 
        * Makefile.in
        * configure (removed from repository, no need to be downloaded)

=== modified file 'src/config.py'
--- a/src/config.py     2013-01-13 07:35:25 +0000
+++ b/src/config.py     2013-03-27 15:04:25 +0000
@@ -1,6 +1,7 @@
 #  GNUtrition - a nutrition and diet analysis program.
 #  Copyright(C) 2000 - 2002 Edgar Denny (address@hidden)
 #  Copyright (C) 2012 Free Software Foundation, Inc.
+#  Copyright (C) 2013 Adam 'foo-script' Rakowski (fooscript att o2 dott pl)
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-import shelve
+import shelve, install
 from os import environ, path, access, F_OK, mkdir, name
 
 if name == 'nt':
@@ -25,7 +26,7 @@
        home = environ['HOME']
 
 user = path.basename(home)
-udir = path.join(home, '.gnutrition')
+udir = path.join(home, '.gnutrition', install.gnutr_version())
 fn = path.join(udir, 'config')
 if not access(udir, F_OK):
     mkdir(udir)

=== modified file 'src/druid.py'
--- a/src/druid.py      2012-11-18 23:26:59 +0000
+++ b/src/druid.py      2013-03-27 15:04:25 +0000
@@ -1,6 +1,7 @@
 #  GNUtrition - a nutrition and diet analysis program.
 #  Copyright(C) 2000-2002 Edgar Denny (address@hidden)
 #  Copryight (C) 2010 2012 Free Software Foundation, Inc.
+#  Copyright (C) 2013 Adam 'foo-script' Rakowski (fooscript att o2 dott pl)
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -22,6 +23,7 @@
 import druid_ui
 import config
 import person
+import os
 import calc_rdi
 import database
 import nutr_goal_dlg
@@ -37,6 +39,7 @@
         self.ui.cancel_button.connect('clicked', self.on_cancel)
         self.ui.next_button.connect('clicked', self.on_next)
         self.ui.back_button.connect('clicked', self.on_back)
+        self.ui.dialog.connect('destroy', self.on_cancel)
 
     def show(self):
         self.ui.dialog.show_all()
@@ -44,6 +47,8 @@
     def on_cancel(self, w, d=None):
         self.ui.dialog.hide()
         gtk.main_quit()
+        for user_file in os.listdir(self.app.user_dir):
+            os.unlink(os.path.join(self.app.user_dir, user_file))
         return 0
 
     def on_next(self, w, d=None):

=== modified file 'src/run_app.py'
--- a/src/run_app.py    2012-11-18 23:26:59 +0000
+++ b/src/run_app.py    2013-03-27 15:04:25 +0000
@@ -1,6 +1,7 @@
 #  GNUtrition - a nutrition and diet analysis program.
 #  Copyright(C) 2000-2002 Edgar Denny (address@hidden)
 #  Copyright (C) 2010 2012 Free Software Foundation, Inc.
+#  Copyright (C) 2013 Adam 'foo-script' Rakowski (fooscript att o2 dott pl)
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,6 +26,7 @@
         logfile = path.join(config.udir, 'log')
         init_logging(logfile, logto='both', level='info')
         if not config.get_value('sqlite3'):
+            self.first_run = True
             # First run, program default values can be added here
             import druid
             # Set default version check information
@@ -34,6 +36,7 @@
             config.set_key_value('check_version', gnutr_consts.CHECK_VERSION)
             config.set_key_value('check_interval', gnutr_consts.CHECK_INTERVAL)
             config.set_key_value('last_check', 0)
+            self.user_dir = config.udir
             self.druid = druid.Druid(self)
             self.druid.show()
         else:
@@ -58,9 +61,10 @@
         self.base_win.show()
 
     def shutdown(self):
-        import database 
-        db = database.Database()
-        db.close()
+        if not self.first_run:          #otherwise, after first run empty db 
would be created. Smells like program crash in future
+            import database 
+            db = database.Database()    #foo-script: Do we really need it at 
all?
+            db.close()
         
 def run_app():
     app = RunApp()


reply via email to

[Prev in Thread] Current Thread [Next in Thread]