cdd-dev team mailing list archive
-
cdd-dev team
-
Mailing list archive
-
Message #00359
[Branch ~cdd-dev/cdd/trunk] Rev 202: Proper way of testing directory and config file existence.
------------------------------------------------------------
revno: 202
committer: Eduardo C. P. Ribeiro <eduardo.cesar@xxxxxxx>
branch nick: cdd
timestamp: Sun 2012-07-29 21:51:05 -0300
message:
Proper way of testing directory and config file existence.
modified:
src/cdd.py
src/cdg_main.py
--
lp:cdd
https://code.launchpad.net/~cdd-dev/cdd/trunk
Your team CDD Developers is subscribed to branch lp:cdd.
To unsubscribe from this branch go to https://code.launchpad.net/~cdd-dev/cdd/trunk/+edit-subscription
=== modified file 'src/cdd.py'
--- src/cdd.py 2012-07-27 23:27:36 +0000
+++ src/cdd.py 2012-07-30 00:51:05 +0000
@@ -335,13 +335,6 @@
cdg_main.popup_message(self, '%s.xsd' % info.ccd_id, _('Generated the file'), wx.OK | wx.ICON_INFORMATION)
- #TODO: Eduardo to add the generator portion here.
- # msg = "File->Generate Not Yet Implemented."
- # dlg = wx.MessageDialog(self, msg,
- # 'Menu Msg.',
- # wx.OK | wx.ICON_INFORMATION)
- # dlg.ShowModal()
- # dlg.Destroy()
def onQuit(self, e):
dlg = wx.MessageDialog(self,
@@ -397,6 +390,7 @@
def show_config(self, event):
result = self.config_dialog.ShowModal()
if result == wx.ID_OK:
+ self.config_dialog.get_panel_configs()
self.config_dialog.save_config()
# end of class MainFrame
=== modified file 'src/cdg_main.py'
--- src/cdg_main.py 2012-07-28 18:15:53 +0000
+++ src/cdg_main.py 2012-07-30 00:51:05 +0000
@@ -171,26 +171,25 @@
'choice_definition' : '0',
})
+ if not os.path.isdir(self.configdir):
+ try:
+ os.mkdir(self.configdir)
+ except:
+ popup_message(None, 'Config directory NOT created.', 'Error creating config dir', wx.ICON_EXCLAMATION)
+
+
def read_config(self):
- try:
- if not self.config.read(self.configname):
- self.make_config_dir()
- except:
- self.save_config()
+ self.config.read(self.configname)
self.set_panel_configs()
-
- def make_config_dir(self):
- if not os.path.exists(self.configdir):
- os.mkdir(self.configdir)
- # with open(self.configname, 'wb') as configfile:
- # self.config.write(configfile)
-
def save_config(self):
self.get_panel_configs()
- with open(self.configname, 'wb') as configfile:
- configfile.write('# Concept Definition Designer Configuration\n# Do not edit the text to the left of the equal symbol (=)\n\n')
- self.config.write(configfile)
+ try:
+ with open(self.configname, 'wb') as configfile:
+ configfile.write('# Concept Definition Designer Configuration\n# Do not edit the text to the left of the equal symbol (=)\n\n')
+ self.config.write(configfile)
+ except IOError:
+ popup_message(None, 'Config could not be saved.', 'Error saving config', wx.ICON_EXCLAMATION)
def get_panel_configs(self):
@@ -298,27 +297,26 @@
'workspace' : home + '/' + 'MLHIM2'
})
+ if not os.path.isdir(self.configdir):
+ try:
+ os.mkdir(self.configdir)
+ except:
+ popup_message(None, 'Config directory NOT created.', 'Error creating config dir', wx.ICON_EXCLAMATION)
+
+
def read_config(self):
- try:
- if not self.config.read(self.configname):
- self.make_config_dir()
- except:
- self.save_config()
+ self.config.read(self.configname)
self.set_panel_configs()
-
- def make_config_dir(self):
- if not os.path.exists(self.configdir):
- os.mkdir(self.configdir)
- # with open(self.configname, 'wb') as configfile:
- # self.config.write(configfile)
-
def save_config(self):
- self.get_panel_configs()
- with open(self.configname, 'wb') as configfile:
- configfile.write('# Concept Definition Designer Configuration\n# Do not edit the text to the left of the equal symbol (=)\n\n')
- self.config.write(configfile)
-
+ #self.get_panel_configs()
+ try:
+ with open(self.configname, 'wb') as configfile:
+ configfile.write('# Concept Definition Designer Configuration\n# Do not edit the text to the left of the equal symbol (=)\n\n')
+ self.config.write(configfile)
+ except IOError:
+ popup_message(None, 'Config could not be saved.', 'Error saving config', wx.ICON_EXCLAMATION)
+
def get_panel_configs(self):
self.config.set('DEFAULT', 'autosave', self.text_ctrl_autosave.GetValue().encode('utf8'))