Exemplo n.º 1
0
 def filecheck(self, filepath, filename):
     """
     Check image file and create symbolic link.
     
     Generated file pattern: DESTINATION/FILENAME_[BASE16].EXT
     Note: the same file into N different subdirectory has N symbolic links.
     """        
     try:
         # get approx size in MB
         # @see http://stackoverflow.com/a/6080504/892951
         filesize = path.getsize(filepath) >> 20
         assert filesize < self.skip_limit_mb
         with Image(filename=filepath) as img:
             assert img.format != "TXT"
             filenamenoext, ext = path.splitext(filename)
             fto = "%s%s_[%s]%s" % (self.dirs['destination'] + path.sep, filenamenoext, b16encode(md5(filepath).digest()), ext)
             try:
                 CreateSymbolicLink(fto, filepath, 0)
                 self.nice_images += 1
             except:
                 self.already_exists += 1
                 pass
     # @see http://dahlia.kr/wand/wand/exceptions.html#wand.exceptions.CorruptImageError
     except (CorruptImageError, CorruptImageWarning, CorruptImageFatalError):
         self.corrupt_errors += 1
     except (MissingDelegateError, AssertionError):
         # skip non image file / big files
         self.skip += 1
         pass
     except:
         # BlobError (cannot read/access) and more
         self.other_errors += 1
Exemplo n.º 2
0
def symlink(name, target):
    if not os.path.islink(name):
        try:
            os.symlink(target, name)
        except AttributeError:
            from win32file import CreateSymbolicLink
            CreateSymbolicLink(name, target)
        except ImportError:
            logger.error("platform does not contain support for symlinks.")
            logger.info("Windows users need pywin32.")
Exemplo n.º 3
0
def symlink(name, target):
    if not os.path.islink(name):
        try:
            os.symlink(target, name)
        except AttributeError:
            from win32file import CreateSymbolicLink
            CreateSymbolicLink(name, target)
        except ImportError:
            exit(
                'ERROR: platform does not contain support for symlinks. Windows users need to pywin32.'
            )
Exemplo n.º 4
0
	def symlink(sourcePath, targetPath):
		r"""
		Creates a soft link for the given paths.
		"""
		CreateSymbolicLink(targetPath, sourcePath, isdir(sourcePath))
Exemplo n.º 5
0
 def symlink(src, dst):
     try:
         CreateSymbolicLink(dst, src)
     except pywintypes.error, e:
         raise ReposeerException(errmsg.format(src, e[2]))