예제 #1
0
파일: file.py 프로젝트: interpretive/crab
    def _make_output_path(self, finishid, host, user, id_, crabid):
        """Determine the full path to use to store output
        (excluding file extensions).

        This uses a directory heirarchy:

            * host
            * user
            * crabid (name) or ID (number)
            * finish ID

        Where the finish ID is broken into blocks of a few characters,
        the first of which is zero-padded to ensure all blocks are the
        same length.  This prevents an excessive number of entries
        being placed in a single directory, while the path is easily
        determined without needing to read the directory structure.
        So breaking on the default number of digits (3) finish ID 1 would
        yield 001 whereas 2005 would yield 002/005."""

        if crabid is None or crabid == '':
            job = str(id_)
        else:
            job = alphanum(crabid)

        finish = str(finishid)
        finishpath = []

        lead = len(finish) % self.breakdigits
        if lead:
            finishpath.append('0' * (self.breakdigits - lead) + finish[:lead])
            finish = finish[lead:]

        finishpath.extend([
            finish[x:x + self.breakdigits]
            for x in range(0, len(finish), self.breakdigits)
        ])

        return os.path.join(self.outputdir, alphanum(host), alphanum(user),
                            job, *finishpath)
예제 #2
0
파일: file.py 프로젝트: namely/crab
    def _make_output_path(self, finishid, host, user, id_, crabid):
        """Determine the full path to use to store output
        (excluding file extensions).

        This uses a directory heirarchy:

            * host
            * user
            * crabid (name) or ID (number)
            * finish ID

        Where the finish ID is broken into blocks of a few characters,
        the first of which is zero-padded to ensure all blocks are the
        same length.  This prevents an excessive number of entries
        being placed in a single directory, while the path is easily
        determined without needing to read the directory structure.
        So breaking on the default number of digits (3) finish ID 1 would
        yield 001 whereas 2005 would yield 002/005."""

        if crabid is None or crabid == '':
            job = str(id_)
        else:
            job = alphanum(crabid)

        finish = str(finishid)
        finishpath = []

        lead = len(finish) % self.breakdigits
        if lead:
            finishpath.append('0' * (self.breakdigits - lead) + finish[:lead])
            finish = finish[lead:]

        finishpath.extend([finish[x:x + self.breakdigits]
                           for x in range(0, len(finish), self.breakdigits)])

        return os.path.join(self.outputdir, alphanum(host), alphanum(user),
                            job, *finishpath)
예제 #3
0
파일: file.py 프로젝트: interpretive/crab
    def _make_crontab_path(self, host, user):
        """Determine the full path to be used to store a crontab."""

        return (os.path.join(self.tabdir, alphanum(host), alphanum(user)) +
                '.' + self.tabext)
예제 #4
0
파일: file.py 프로젝트: namely/crab
    def _make_crontab_path(self, host, user):
        """Determine the full path to be used to store a crontab."""

        return (os.path.join(self.tabdir, alphanum(host), alphanum(user)) +
                '.' + self.tabext)