コード例 #1
0
    def getTargetFileName(self, fileInfo):
        if self.arguments["strip"]:
            # always strip time as well as date (not doing so may lead to huge headaches)
            fileName = "%s.%s" % (fileInfo["title"], fileInfo["extension"])
        elif self.arguments["time"]:
            fileName = FILE_FORMAT_DATETIME % (
                fileInfo["year"],
                fileInfo["month"],
                fileInfo["day"],
                fileInfo["hour"],
                fileInfo["minute"],
                fileInfo["title"],
                fileInfo["extension"],
            )
        else:
            fileName = FILE_FORMAT_DATE % (
                fileInfo["year"],
                fileInfo["month"],
                fileInfo["day"],
                fileInfo["title"],
                fileInfo["extension"],
            )
        return fileName


if __name__ == "__main__":
    from py_base.Job import runMockJob

    runMockJob(ImageDateStamper, arguments={"path": getTestFilePaths() + ["bad/path.JPG"]})  # 'time': True,
コード例 #2
0
#!/usr/bin/python
from image_tools.ImageScaler import ImageScaler
from image_tools_gui.ImageToolsSharedGui import ImageFileInfoToolGui

class ImageScalerGui(ImageScaler):

    def doRunSteps(self):
        imageTool = ImageFileInfoToolGui(self.out, self.system)
        super(ImageScalerGui, self).doRunSteps(imageTool)

if __name__ == "__main__":
    from py_base.Job import runMockJob
    from image_tools.ImageToolsShared import getTestFilePaths
    runMockJob(ImageScalerGui, arguments={'path':getTestFilePaths()})
コード例 #3
0
    def getAllStarsFullPaths(self, path):
        self.out.put("Looking for all stars path in %s" % (path), self.out.LOG_LEVEL_VERBOSE)
        result = []

        # list the subfolder contents of path
        # I'm using sorted() here so that there is consistency
        # in the order of preference when multiple folders exist
        for filename in sorted(listdir(path)):
            # does this name match the regex?
            if not self.isAllStarFolder(filename):
                self.out.put("- filename %s failed all star regex" % filename, self.out.LOG_LEVEL_DEBUG)
                continue

            self.out.put("- all star filename %s found! (not a confirmed directory yet)" % filename, self.out.LOG_LEVEL_DEBUG)

            # is the matching name a folder?
            allStarsFullPath = "%s/%s" % (path, filename)
            if isdir(allStarsFullPath):
                # we've found what we are looking for
                self.out.put("- full path %s is a confirmed directory! Adding to result list." % allStarsFullPath, self.out.LOG_LEVEL_DEBUG)
                result.append(allStarsFullPath)
        return result

    def isAllStarFolder(self, filename):
        return match(REGEX_ALL_STARS_FOLDER, filename)

if __name__ == "__main__":
    from py_base.Job import runMockJob
    runMockJob(AllStarCopier, arguments={'path': getTestFilePaths()})
コード例 #4
0
ファイル: ImageScaler.py プロジェクト: CronWorks/image-tools
        if self.inDebugMode():
            # if we're running in mock mode, then we shouldn't be changing anything on the filesystem.
            self.out.put("DEBUG: Not writing image file because we're in mock mode")
        else:
            self.out.put("writing image file...", self.out.LOG_LEVEL_DEBUG)
            sourceImage.save(targetFileName)

    def getTargetFileName(self, sourceFileName):
        self.out.put("Setting target filename...", self.out.LOG_LEVEL_VERBOSE)
        (base, ext) = splitext(sourceFileName)
        targetFileName = base + FILENAME_SCALED_SUFFIX + ext.lower()
        self.out.put("source path: %s" % sourceFileName, self.out.LOG_LEVEL_VERBOSE)
        self.out.put("target path: %s" % targetFileName, self.out.LOG_LEVEL_VERBOSE)
        return targetFileName

    def inDebugMode(self):
        return self.system.__class__ == PySystemMock

if __name__ == "__main__":
    from py_base.Job import runMockJob

    # clean out old runs
    from subprocess import Popen
    Popen(['rm', '-f', '%s/test/*.scaled.jpg' % dirname(__file__)])

    runMockJob(ImageScaler,
               arguments={'limit_size': 100,
                          'greyscale': True,
                          'path': getTestFilePaths()})