Beispiel #1
0
def copyfile(src, dst):
    logging.debug("Copy from " + "'{0}'".format(src) + " to " +
                  "'{0}'".format(dst))
    try:
        shutil.copy2(src, dst)
    except IOError as e:
        die("ERROR: failed to copy file from {0} to {1}. ".format(src, dst) +
            str(e))
Beispiel #2
0
def adddir(path_to_dir):
    logging.debug("Creating directory {0}".format(path_to_dir))
    if exists(path_to_dir):
        logging.debug("Directory exists {0}".format(path_to_dir))
        return
    try:
        logging.debug("Creating directory {0}".format(path_to_dir))
        makedirs(fixpath(path_to_dir), 0o755)
    except IOError as e:
        die("cannot make directory {0} . {1}".format(path_to_dir, str(e)))
Beispiel #3
0
def copydir(src, dst):
    """
    :param src:
    :param dst: destination directory. It shouldn't exists.
    :return:
    """
    logging.debug("Copy from " + "'{0}'".format(src) + " to " +
                  "'{0}'".format(dst))
    try:
        shutil.copytree(src, dst, symlinks=True, ignore=None)
    except IOError as e:
        die("ERROR: failed to copy directory from {0} to {1}. ".format(
            src, dst) + str(e))
Beispiel #4
0
def getfilelist(dir_path):
    """
    Returns list of files in relative path from directory.
    :param dir_path: Directory path.
    :return:
    """
    rez_list = []
    try:
        for root, dirs, files in walk(dir_path, topdown=False):
            for name in files:
                rez_list.append(path.join(root.replace(dir_path, ""), name))
    except IOError as e:
        die("ERROR: Can not open directory for reading: {0}".format(dir_path))

    return rez_list
Beispiel #5
0
 def _process(self):
     confdir = fixpath(self.area.config())
     conf = join(confdir, "toolbox", environ["SCRAM_ARCH"])
     toolbox = self.toolbox
     logging.debug("confdir: {0},\n conf: {1}, \n toolbox: {2}".format(
         confdir, conf, toolbox))
     if isdir(toolbox):
         if isdir(toolbox + "/tools"):
             adddir(conf + "/tools")
             copydir(toolbox + "/tools/selected", conf + "/tools/selected")
             copydir(toolbox + "/tools/available",
                     conf + "/tools/available")
         else:
             die("Project creating error. Missing directory \"{toolbox}/tools\" in the toolbox."
                 " Please fix file \"{boot}\" and set a valid toolbox directory."
                 .format(toolbox=toolbox, boot=self.file_to_parse))
     else:
         die("Project creating error. Missing directory \"{toolbox}/\". Please fix file \"{boot}\" "
             "and set a valid toolbox directory.".format(
                 toolbox=toolbox, boot=self.file_to_parse))
     self.area.configchksum(self.area.calchksum())
     if not isfile(confdir + "/scram_version"):
         try:
             with open(confdir + "/scram_version", 'w+') as f:
                 f.write(environ["SCRAM_VERSION"] + "\n")
         except IOError:
             die("ERROR: Can not open {confdir}/scram_version file for writing."
                 .format(confdir=confdir))
     self.area.save()