Permalink
Browse files

verify dir existance when saving users, remove areas

  • Loading branch information...
1 parent 55365ee commit 330517102529dc931b2985982b430490a1b70d8f @bogolt committed Jul 5, 2012
Showing with 20 additions and 7 deletions.
  1. +10 −4 src/config.py
  2. +2 −2 src/main_frame.py
  3. +7 −0 src/map.py
  4. +1 −1 src/version.py
View
14 src/config.py
@@ -58,6 +58,7 @@ def getOptionsDir():
}
config_file_name = 'dclord.cfg'
+users_file_name = 'users.cfg'
def loadOptions():
config = ConfigParser.ConfigParser()
config.read(os.path.join(getOptionsDir(), config_file_name))
@@ -85,7 +86,7 @@ def saveOptions():
def loadAccounts():
config = ConfigParser.ConfigParser()
- config.read(os.path.join(getOptionsDir(), 'users.cfg'))
+ config.read(os.path.join(getOptionsDir(), users_file_name))
global users
global user_id_dict
for u in config.sections():
@@ -104,9 +105,14 @@ def saveUsers():
conf.add_section(u)
for k,v in p.items():
conf.set(u, k, v)
-
- with open(os.path.join(getOptionsDir(), 'users.cfg'), 'wt') as configfile:
- conf.write(configfile)
+
+ path = os.path.join(getOptionsDir(), users_file_name)
+ util.assureDirExist(getOptionsDir())
+ try:
+ with open(os.path.join(getOptionsDir(), users_file_name), 'wt') as configfile:
+ conf.write(configfile)
+ except IOError, err:
+ log.error("unable to save users file: %s"%(err,))
def loadAll():
global options
View
4 src/main_frame.py
@@ -36,7 +36,7 @@ def __init__(self, parent):
self.object_filter = object_filter.FilterPanel(self)
self.unit_list = unit_list.UnitPrototypeListWindow(self, 0)
- self.area_list = area_panel.AreaListWindow(self)
+ #self.area_list = area_panel.AreaListWindow(self)
self._mgr = wx.aui.AuiManager(self)
@@ -50,7 +50,7 @@ def __init__(self, parent):
self._mgr.AddPane(self.map, info)
self._mgr.AddPane(self.object_filter, wx.LEFT, "Filter")
self._mgr.AddPane(self.unit_list, wx.RIGHT, "Units")
- self._mgr.AddPane(self.area_list, wx.RIGHT, "Areas")
+ #self._mgr.AddPane(self.area_list, wx.RIGHT, "Areas")
self._mgr.Update()
View
7 src/map.py
@@ -38,6 +38,7 @@ def __init__(self, parent):
self.cell_size = int(config.options['map']['cell_size'])
self.screen_size = 1,1
self.filterDrawFleets = bool(config.options['filter']['fleets'])
+ #self.filterDrawAreas = bool(config.options['filter']['areas'])
self.planet_filter = []#['owner_id <> 0', 's>30', 't>20', 't<40']
@@ -213,6 +214,12 @@ def paint(self, dc, rect=None):
self.drawPlanets(dc, rect)
if self.filterDrawFleets:
self.drawFleets(dc, rect)
+
+ #if self.filterDrawAreas:
+ # self.drawAreas(dc, rect)
+
+ def drawAreas(self, dc, rect):
+ ar = [(200,200), (200,300), (300,300), (300, 200)]
def centerAt(self, logicPos):
self.offset_pos = util.sub(logicPos, util.div(self.screen_size, 2))
View
2 src/version.py
@@ -1,2 +1,2 @@
def getVersion():
- return '0.2.0'
+ return '0.2.1'

0 comments on commit 3305171

Please sign in to comment.