Esempio n. 1
0
 def msysDir():
     if not OsDetection.isWin():
         return craftSettings.get("Paths", "Msys", "/")
     else:
         if ("Paths", "Msys") in craftSettings:
             return craftSettings.get("Paths", "Msys")
         return os.path.join(CraftStandardDirs.craftRoot(), "msys")
Esempio n. 2
0
 def gitDir():
     if not "GITDIR" in CraftStandardDirs._pathCache():
         if CraftStandardDirs.isShortPathEnabled() and (
                 "ShortPath", "GitDrive") in craftSettings:
             CraftStandardDirs._pathCache(
             )["GITDIR"] = CraftStandardDirs.nomalizePath(
                 craftSettings.get("ShortPath", "GitDrive"))
         else:
             CraftStandardDirs._pathCache()["GITDIR"] = craftSettings.get(
                 "Paths", "KDEGITDIR",
                 os.path.join(CraftStandardDirs.downloadDir(), "git"))
     return CraftStandardDirs._pathCache()["GITDIR"]
Esempio n. 3
0
 def downloadDir():
     """ location of directory where fetched files are  stored """
     if not "DOWNLOADDIR" in CraftStandardDirs._pathCache():
         if CraftStandardDirs.isShortPathEnabled() and (
                 "ShortPath", "DownloadDrive") in craftSettings:
             CraftStandardDirs._pathCache(
             )["DOWNLOADDIR"] = CraftStandardDirs.nomalizePath(
                 craftSettings.get("ShortPath", "DownloadDrive"))
         else:
             CraftStandardDirs._pathCache(
             )["DOWNLOADDIR"] = craftSettings.get(
                 "Paths", "DOWNLOADDIR",
                 os.path.join(CraftStandardDirs.craftRoot(), "download"))
     return CraftStandardDirs._pathCache()["DOWNLOADDIR"]
Esempio n. 4
0
    def __init__(self):
        self.seenDeprecatedFunctions = set()
        self._handler = logging.StreamHandler(sys.stdout)

        self._log = logging.getLogger("craft")
        self._log.setLevel(logging.DEBUG)
        self._log.addHandler(self._handler)
        self._handler.setLevel(logging.INFO)

        logDir = craftSettings.get("CraftDebug", "LogDir", os.path.expanduser("~/.craft/"))
        if not os.path.exists(logDir):
            os.makedirs(logDir)

        cleanNameRe = re.compile(r":?\\+|/+|:|;")
        logfileName = os.path.join(logDir, "log-%s.txt" % cleanNameRe.sub("_", CraftStandardDirs._deSubstPath(
            CraftStandardDirs.craftRoot())))

        try:
            fileHandler = logging.handlers.RotatingFileHandler(logfileName, mode="at+", maxBytes=10000000,
                                                               backupCount=20)
            fileHandler.doRollover()
            fileHandler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s'))
            self._log.addHandler(fileHandler)
            fileHandler.setLevel(logging.DEBUG)
        except Exception as e:
            print(f"Failed to setup log file: {e}", file=sys.stderr)
            print(f"Right now we don't support running multiple Craft instances with the same configuration.",
                  file=sys.stderr)
        self.log.debug("#" * self.lineWidth)
        self.log.debug("New log started: %s" % " ".join(sys.argv))
        self.log.debug("Log is saved to: %s" % fileHandler.baseFilename)
        self.logEnv()
        self.setVerbose(0)
Esempio n. 5
0
 def junctionsDir(getDir=False):
     if "JunctionDir" not in CraftStandardDirs._pathCache():
         if not getDir and ("ShortPath", "JunctionDrive") in craftSettings:
             CraftStandardDirs._pathCache(
             )["JunctionDir"] = CraftStandardDirs.nomalizePath(
                 craftSettings.get("ShortPath", "JunctionDrive"))
         else:
             path = craftSettings.get(
                 "ShortPath", "JunctionDir",
                 os.path.join(CraftStandardDirs.craftRoot(), "build",
                              "shortPath"))
             if not os.path.isdir(path):
                 os.makedirs(path)
             CraftStandardDirs._pathCache()["JunctionDir"] = path
             if getDir:
                 return path
     return CraftStandardDirs.__pathCache["JunctionDir"]
Esempio n. 6
0
 def craftRoot():
     if not "EMERGEROOT" in CraftStandardDirs._pathCache():
         if CraftStandardDirs.isShortPathEnabled() and (
                 "ShortPath", "RootDrive") in craftSettings:
             CraftStandardDirs._pathCache(
             )["EMERGEROOT"] = CraftStandardDirs.nomalizePath(
                 craftSettings.get("ShortPath", "RootDrive"))
         else:
             CraftStandardDirs._pathCache(
             )["EMERGEROOT"] = craftSettings._craftRoot()
     return CraftStandardDirs._pathCache()["EMERGEROOT"]
Esempio n. 7
0
 def tmpDir():
     if not "TMPDIR" in CraftStandardDirs._pathCache():
         CraftStandardDirs._pathCache()["TMPDIR"] = craftSettings.get(
             "Paths", "TMPDIR",
             os.path.join(CraftStandardDirs.craftRoot(), "tmp"))
     return CraftStandardDirs._pathCache()["TMPDIR"]
Esempio n. 8
0
 def svnDir():
     if not "SVNDIR" in CraftStandardDirs._pathCache():
         CraftStandardDirs._pathCache()["SVNDIR"] = craftSettings.get(
             "Paths", "KDESVNDIR",
             os.path.join(CraftStandardDirs.downloadDir(), "svn"))
     return CraftStandardDirs._pathCache()["SVNDIR"]
Esempio n. 9
0
 def blueprintRoot():
     if ("Blueprints", "BlueprintRoot") in craftSettings:
         return craftSettings.get("Blueprints", "BlueprintRoot")
     return os.path.join(CraftStandardDirs.etcBlueprintDir(), "locations")
Esempio n. 10
0
    def root():
        if not CraftPackageObject.__rootPackage:
            if ("Blueprints", "Ignores") in craftSettings:
                CraftPackageObject.Ignores = re.compile("|".join([f"^{entry}$" for entry in craftSettings.get("Blueprints", "Ignores").split(";")]))

            CraftPackageObject.__rootPackage = root = CraftPackageObject()
            root.path = "/"
            for blueprintRoot in CraftPackageObject.rootDirectories():
                if not os.path.isdir(blueprintRoot):
                    craftDebug.log.warning(f"{blueprintRoot} does not exist")
                    continue
                blueprintRoot = utils.normalisePath(os.path.abspath(blueprintRoot))
                # create a dummy package to load its children
                child = root._addNode(None, blueprintRoot)
                root.children.update(child.children)
        return CraftPackageObject.__rootPackage