def writeFile(self): if self.checkActive(): try: with open(self.path, 'w') as f: f.write('#mGeo settings file\n') for i in self.data.items(): f.write(str(i[0]) + '=' + str(i[1]) + '\n') except: cmds.warning('Cant open options file 1')
def readFile(self): if self.checkActive(): lines = [] if os.path.exists(self.path): try: with open(self.path, 'r') as f: lines = f.readlines() except: cmds.warning('Cant open options file') if lines: lines.pop(0) return lines else: return [] else: return []
def readFile(self): if self.checkActive(): lines = [] if os.path.exists(self.path): try: with open(self.path, 'r') as f: lines = f.readlines() except: cmds.warning('Cant open options file 2') if lines: lines.pop(0) return lines else: return [] else: return []
def getConfigFolder(self): home = os.path.dirname(__file__) optDir = os.path.join(home, 'config') try: if not os.path.exists(optDir): os.makedirs(optDir, 0777) return optDir except: home = os.path.expanduser('~') optDir = os.path.join(home, 'config') try: if not os.path.exists(optDir): os.makedirs(optDir, 0777) cmds.warning('Access denied. Options saved in user folder') return optDir except: cmds.warning('Cant create options file 3')
def getConfigFolder(self): #home = os.path.dirname(__file__) home = os.getenv('APPDATA') return home optDir = os.path.join(home, 'config') try: if not os.path.exists(optDir): os.makedirs(optDir, 0777) return optDir except: home = os.path.expanduser('~') optDir = os.path.join(home, 'config') try: if not os.path.exists(optDir): os.makedirs(optDir, 0777) cmds.warning('Access denied. Options saved in user folder') return optDir except: cmds.warning('Cant create options file 3')
def checkActive(self): if not self.active: cmds.warning('Options not active') return False else: return True