def checkLogDir(self): #Check if exist a log directory, if doesn't create it _lst = os.listdir(currentDir()) for i in _lst: if i == 'logs': return os.mkdir(currentDir()+'/logs')
def __init__(self): self.checkLogDir() if os.name == 'nt': _time = datetime.datetime.now() self._file = open(currentDir()+'/logs/log_{}_'.format(datetime.date.today())+str(_time.hour)+str(_time.minute)+'.txt', 'w') else: self._file = open(currentDir()+'/logs/log_{}'.format(datetime.datetime.now())+'.txt', 'w') self._file.write('{}'.format(datetime.datetime.now())+'\n') self.fileIsOpen = True
def checkForLANG(self): #check if lang dir exist #else create lang for i in os.listdir(currentDir()): if i == 'lang': return print "Couldn't find lang."
def OSession(self, e): #Open a session from a file global reliableServer, serverList, locationIsSet, lastSession _dlg = wx.FileDialog(self, self.txt.osdialogTitle, defaultDir=ini.currentDir(), defaultFile="", wildcard="*.ini", style=wx.OPEN) if _dlg.ShowModal() == wx.ID_OK: _open_path = _dlg.GetPath() _dict = ini.OpenINI(_open_path) lastSession = _open_path self.location = _dict['location'] serverList = _dict['sl'] print self.location if self.location == 'BR': self.msWindow.choice.SetSelection(0) elif self.location == 'EU': self.msWindow.choice.SetSelection(1) elif self.location == 'NA': self.msWindow.choice.SetSelection(2) locationIsSet = True global ShouldLog if ShouldLog: self.log.WriteToLog(serverList, 2) _dlg.Destroy() #update GUI and start pings self.msWindow.serverCount.SetLabel("{} servers".format(len(serverList))) self.Start() else: _dlg.Destroy()
def checkFileVersion(appV): #check if version.txt exists, otherwise create it for i in os.listdir(currentDir()): if i == "version.txt": return _file = open("version.txt", "w") _file.write('"{}"'.format(appV)) _file.close()
def getXML(self): if self.translate: self.tree = ET.parse(currentDir()+'/lang'+'/{}.xml'.format(self.translate)) self.root = self.tree.getroot() #verifing if lang matches self.translate if self.root.attrib['lang'] == self.translate: print 'match' else: print 'dont match'
def CompareVersion(github): _file = open(currentDir()+"version.txt", "r") v = _file.read() loc = github.find(":") newstr = github[loc+1:] print v, newstr if v == newstr: return False else: return True
def CreateStartup(self): _startup = os.path.expanduser('~\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\_run.bat') _file = open(_startup, 'w') _file.write(self.echo) _file.write('start "" "{}"'.format(currentDir()+'main.exe')+'\n')
def getPie(self): #Get current program location return currentDir()+'main.exe'