dodle
May 16th, 2009, 07:25 PM
This is a section of my code. The else statement executes no matter what.
...
...
...
def onBuild(self, event):
nameVal = self.name_widg.GetValue()
verVal = self.ver_widg.GetValue()
archVal = self.arch_widg.GetValue()
execVal = self.xpath_widg.GetValue()
custVal = self.cust_widg.GetValue()
optfilesVal = self.optfiles_widg.GetValue()
destVal = self.dest_widg.GetValue()
treeVal = ("%s/%s_tmp" % (destVal,nameVal))
iconVal = self.icon_widg.GetValue()
catVal = self.m_cat_widg.GetValue()
m_nameVal = self.m_name_widg.GetValue()
if nameVal == "":
error_dia = wx.MessageDialog(self, "Under \"Info1\" tab\n\nSpecify a name for the project",
"Software Name Error", wx.OK|wx.ICON_ERROR)
error_dia.ShowModal()
error_dia.Close()
if verVal == "":
error_dia = wx.MessageDialog(self, "Under \"Info1\" tab\n\nSpecify a version for the project",
"Software Version Error", wx.OK|wx.ICON_ERROR)
error_dia.ShowModal()
error_dia.Close()
if not exists(execVal):
error_dia = wx.MessageDialog(self, "Under \"Paths\" tab\n\nExecutables folder does not exists",
"Directory Error", wx.OK|wx.ICON_ERROR)
error_dia.ShowModal()
error_dia.Close()
if self.optfiles_widg.IsEnabled() and optfilesVal == "":
error_dia = wx.MessageDialog(self, "Under \"Paths\" tab\n\nOptional Files directory cannot be blank",
"Directory Error", wx.OK|wx.ICON_ERROR)
error_dia.ShowModal()
error_dia.Close()
if not exists(destVal):
error_dia = wx.MessageDialog(self, "Under \"Build\" tab\n\nDestination folder does not exists",
"Directory Error", wx.OK|wx.ICON_ERROR)
error_dia.ShowModal()
error_dia.Close()
else:
try:
os.mkdir("%s/%s_tmp" % (destVal,nameVal))
except OSError:
pass
# --- Making the directory tree
if self.xout_bin.GetValue() == True:
if exists("%s/bin" % treeVal):
print "Executables path already exists"
else:
print "Creating directory %s/bin" % treeVal
os.mkdir("%s/bin" % treeVal)
...
...
...
I can't see where I've gone wrong. Shouldn't the else statement only execute if the other statements have not been satisfied?
...
...
...
def onBuild(self, event):
nameVal = self.name_widg.GetValue()
verVal = self.ver_widg.GetValue()
archVal = self.arch_widg.GetValue()
execVal = self.xpath_widg.GetValue()
custVal = self.cust_widg.GetValue()
optfilesVal = self.optfiles_widg.GetValue()
destVal = self.dest_widg.GetValue()
treeVal = ("%s/%s_tmp" % (destVal,nameVal))
iconVal = self.icon_widg.GetValue()
catVal = self.m_cat_widg.GetValue()
m_nameVal = self.m_name_widg.GetValue()
if nameVal == "":
error_dia = wx.MessageDialog(self, "Under \"Info1\" tab\n\nSpecify a name for the project",
"Software Name Error", wx.OK|wx.ICON_ERROR)
error_dia.ShowModal()
error_dia.Close()
if verVal == "":
error_dia = wx.MessageDialog(self, "Under \"Info1\" tab\n\nSpecify a version for the project",
"Software Version Error", wx.OK|wx.ICON_ERROR)
error_dia.ShowModal()
error_dia.Close()
if not exists(execVal):
error_dia = wx.MessageDialog(self, "Under \"Paths\" tab\n\nExecutables folder does not exists",
"Directory Error", wx.OK|wx.ICON_ERROR)
error_dia.ShowModal()
error_dia.Close()
if self.optfiles_widg.IsEnabled() and optfilesVal == "":
error_dia = wx.MessageDialog(self, "Under \"Paths\" tab\n\nOptional Files directory cannot be blank",
"Directory Error", wx.OK|wx.ICON_ERROR)
error_dia.ShowModal()
error_dia.Close()
if not exists(destVal):
error_dia = wx.MessageDialog(self, "Under \"Build\" tab\n\nDestination folder does not exists",
"Directory Error", wx.OK|wx.ICON_ERROR)
error_dia.ShowModal()
error_dia.Close()
else:
try:
os.mkdir("%s/%s_tmp" % (destVal,nameVal))
except OSError:
pass
# --- Making the directory tree
if self.xout_bin.GetValue() == True:
if exists("%s/bin" % treeVal):
print "Executables path already exists"
else:
print "Creating directory %s/bin" % treeVal
os.mkdir("%s/bin" % treeVal)
...
...
...
I can't see where I've gone wrong. Shouldn't the else statement only execute if the other statements have not been satisfied?