def createDictFromConfig(): """ Read the configuration from scipion/config/scipionbox.conf. A dictionary will be created where each key will be a section starting by MICROSCOPE:, all variables that are in the GLOBAL section will be inherited by default. """ # Read from users' config file. confGlobalDict = OrderedDict() confDict = OrderedDict() cp = ConfigParser() cp.optionxform = str # keep case (stackoverflow.com/questions/1611799) confFile = pw.getConfigPath("scipionbox.conf") print "Reading conf file: ", confFile cp.read(confFile) GLOBAL = "GLOBAL" MICROSCOPE = "MICROSCOPE:" if not GLOBAL in cp.sections(): raise Exception("Missing section %s in %s" % (GLOBAL, confFile)) else: for opt in cp.options(GLOBAL): confGlobalDict[opt] = cp.get(GLOBAL, opt) for section in cp.sections(): if section != GLOBAL and section.startswith(MICROSCOPE): sectionDict = OrderedDict(confGlobalDict) for opt in cp.options(section): sectionDict[opt] = cp.get(section, opt) confDict[section.replace(MICROSCOPE, '')] = sectionDict return confDict
def _getHTMLTemplatePath(self): """ Returns the path of the customized template at config/execution.summary.html or the standard scipion HTML template""" # Try if there is a customized template template = getConfigPath('execution.summary.html') if not os.path.exists(template): template = getTemplatePath('execution.summary.template.html') else: print("Customized HTML template found at %s." % template) return template
def _openConfigFile(self, configFile, userOnly=False): """ Open an Scipion configuration file, if the user have one defined, also open that one with the defined text editor. """ if not userOnly: _open_cmd(pw.getConfigPath(configFile)) userHostConf = os.path.join(pwutils.getHomePath(), '.config', 'scipion', configFile) if os.path.exists(userHostConf): _open_cmd(userHostConf)
def onGeneral(self): # Config -> General _open_cmd(pw.getConfigPath('scipion.conf'))
def getWorkflow(workflow): """ Return the full workflow path from the Scipion folder + config/workflows/ """ return pw.getConfigPath('workflows', workflow)