示例#1
0
 def _checkKsFile(self):
     """
     Raise an exception if Kickstart file is not set
     or does not exist.
     """
     ks = self.kickstartPath
     if not isNonEmptyString(ks):
         msg = "No Kickstart file set"
         raise ObsLightErr.ObsLightMicProjectErr(msg)
     if not os.path.exists(ks):
         msg = "Kickstart file '%s' does not exist" % ks
         raise ObsLightErr.ObsLightMicProjectErr(msg)
示例#2
0
def getOpenFileCommand():
    aConfigParser = ConfigParser.ConfigParser()
    with open(CONFIGPATH, 'r') as aConfigFile:
        aConfigParser.readfp(aConfigFile)
    command = ""
    if (aConfigParser.has_section('editor') and
            aConfigParser.has_option('editor', 'openFile')):
        command = aConfigParser.get('editor', 'openFile')
    if isNonEmptyString(command):
        return command
    else:
        return None
示例#3
0
def getConsole(title=None):
    '''
    Return the name of the term
    '''
    aConfigParser = ConfigParser.ConfigParser()
    aConfigFile = open(CONFIGPATH, 'rw')

    replacements = {}
    if isNonEmptyString(title):
        replacements["title"] = "'%s'" % title
    else:
        replacements["title"] = "OBS Light console"
    aConfigParser.readfp(aConfigFile)
    if ('editor' in aConfigParser.sections()) and ('console' in aConfigParser.options('editor')):
        return aConfigParser.get('editor', 'console', vars=replacements)
    else:
        return 'xterm -e'
示例#4
0
def getLocalRepoServer():
    cmd = "/sbin/ifconfig"
    __mySubprocessCrt = SubprocessCrt()
    global HOST_IP
    localhostIp = "127.0.0.1"
    if HOST_IP is None:
        try:
            res = __mySubprocessCrt.execSubprocess(cmd, stdout=True, noOutPut=True)
            for ip in re.findall(".*inet.*?:([\d.]*)[\s]+.*", res):
                if isNonEmptyString(ip) and ip != localhostIp:
                    HOST_IP = ip
                    break
        except:
            HOST_IP = localhostIp
    if HOST_IP is None:
        HOST_IP = localhostIp
    return "http://%s:84" % HOST_IP
示例#5
0
 def checkGitUserConfig(self, workTree, gitDir):
     """
     Git complains if you don't set 'user.name' and 'user.email' config
     parameters. This method checks if they are set, and in case they
     aren't, set them.
     """
     confParams = {
         "user.email": "*****@*****.**",
         "user.name": "OBS Light"
     }
     for param, value in confParams.iteritems():
         cmd = self.prepareGitCommand(workTree, "config " + param, gitDir)
         res = self.__subprocess(cmd, stdout=True, noOutPut=True)
         self.logger.debug("Git parameter '%s': '%s'" % (param, res))
         if not isNonEmptyString(res):
             self.logger.debug(" -> Setting it to '%s'" % (value))
             cmd2 = self.prepareGitCommand(
                 workTree, 'config %s "%s"' % (param, value), gitDir)
             res2 = self.__subprocess(cmd2)
             if res2 != 0:
                 msg = 'Failed to set git parameter "%s", next git operation may fail!'
                 self.logger.warning(msg % param)