def _init_root_path(self): if self._userInfo == None: return False toCheck = [self._userInfo.local_area, self._userInfo.log_dir] checkLayout = False for d in toCheck: if not DiskUtils.is_dir_exist(d): checkLayout = True MsgUtils.warning("%r is needed, create..." % d) if DiskUtils.create_path_rec(d) == False: MsgUtils.error("can't create %r" % d) else: MsgUtils.info("%r created" % d) #only on creation,copy if exist the defaultLayoutFile from # from the module if checkLayout: import shutil fromlayout = os.path.join(self._resource.resource_path, initDefault.DEFAULT_LAYOUT_ROOT) tolayout = os.path.join(self._userInfo.local_area, initDefault.DEFAULT_LAYOUT_ROOT) fromlayout += ".lyt" tolayout += ".lyt" if os.path.exists(fromlayout) and not os.path.exists(tolayout): shutil.copyfile(fromlayout, tolayout) MsgUtils.info("found a defaut layout file %s" % fromlayout) self.valid_to_save = self.is_persistant()
def H_loadLayout(widgetApp, editor, aDefautPathMgr, nameLayout): if nameLayout == "": log.info("not layout file specified") widgetApp.resize(500, 500) widgetApp.move(100, 100) return afile = editor.layout_file(nameLayout) if not DiskUtils.is_file_exist(afile): afile = aDefautPathMgr.getDefaultLayoutFile() if not DiskUtils.is_file_exist(afile): log.debug("cannot find the layout file %s" % afile) widgetApp.resize(500, 500) widgetApp.move(100, 100) return settings = QtT.QtCore.QSettings(afile, QtT.QtCore.QSettings.IniFormat, None) if DO_PYQT4: widgetApp.resize(settings.value('MainWindow/size').toSize()) widgetApp.move(settings.value('MainWindow/pos').toPoint()) widgets = list( map(str, settings.value('MainWindow/widgets').toStringList())) for w in widgets: className = str(settings.value('%s/className' % w).toString()) widgetApp.toolInstanciate(className, w) widgetApp.restoreState( settings.value('MainWindow/state').toByteArray()) for w in widgets: if w in widgetApp._docksWidget: widgetApp._docksWidget[w].getCustomWidget().resize( settings.value('%s/size' % w).toSize()) isFloating = settings.value('%s/floating' % w).toBool() if isFloating: widgetApp._docksWidget[w].getCustomWidget().move( settings.value('%s/pos' % w).toPoint()) else: widgetApp.resize(settings.value('MainWindow/size')) widgetApp.move(settings.value('MainWindow/pos')) widgets = settings.value('MainWindow/widgets') if widgets != None: for w in widgets: className = str(settings.value('%s/className' % w)) widgetApp.toolInstanciate(className, w) widgetApp.restoreState(settings.value('MainWindow/state')) for w in widgets: if w in widgetApp._docksWidget: widgetApp._docksWidget[w].getCustomWidget().resize( settings.value('%s/size' % w)) isFloating = settings.value('%s/floating' % w) if isFloating: widgetApp._docksWidget[w].getCustomWidget().move( settings.value('%s/pos' % w))
def checkBasicPath(): # required will exist if not found for path in DefaultPath.__REQUIRED__: if not DiskUtils.is_dir_exist(path): MsgUtils.error("%r (REQUIRED)" % path) sys.exit(1) for path in DefaultPath.__SELF_CREATED__: if not DiskUtils.is_dir_exist(path): MsgUtils.warning("%r needed, creating..." % path) if DiskUtils.create_path_rec(path) == False: MsgUtils.error("can't create %r" % path) sys.exit(1) return True
def load_preference(self): if self._prefs == None: self.make_preference() filePref = self.get_pref_file() if filePref == "": return self._prefs if DiskUtils.is_file_exist(filePref): #print "loading preferences",filePref self._prefs = self._prefs.ReadAsXml(filePref)[0] return self._prefs
def loads(self, fileName): d = {} if self.isGz(fileName) == True: f = self.OpenFileGz(fileName, "r") if f != 0: astr = f.read() d = JSON.loads(astr) f.close() return d else: if DiskUtils.is_file_exist(fileName): try: f = self.OpenFile(fileName, 'r') astr = f.read() f.close() d = JSON.loads(astr) except: return d else: return d return d return d
def getBaseInstallPath(): """ where the code py file resided """ if DiskUtils.is_dir_exist(browser_default.CODE_INSTALL): return browser_default.CODE_INSTALL return None
def getDataBasePath(): """ where the database is """ if DiskUtils.is_dir_exist(browser_default.DATABASE_PATH): return browser_default.DATABASE_PATH return None
def is_persistant(self): return DiskUtils.is_dir_exist(self.rootpath) and self.appName != ""