Ejemplo n.º 1
0
 def wrapper(*args, **kwds):
     try:
         return function_in_this_module(*args, **kwds)
     except fs.errors.CreateFailed:
         message = "Failed to open %s" % args[0]
         LOG.debug(message)
         raise exceptions.FileNotFound(args[0])
     except fs.opener.errors.UnsupportedProtocol as e:
         LOG.exception(e)
         raise exceptions.UnsupportedPyFS2Protocol(e)
def file_permissions(url):
    if not exists(url):
        raise exceptions.FileNotFound(url)
    if sys.platform == "win32":
        return 0
    elif is_zip_alike_url(url):
        return 755
    else:
        unix_path = system_path(url)
        return stat.S_IMODE(os.stat(unix_path).st_mode)
Ejemplo n.º 3
0
def file_permissions(url):
    if not exists(url):
        raise exceptions.FileNotFound(url)
    if sys.platform == "win32":
        raise exceptions.NoPermissionsNeeded()
    elif is_zip_alike_url(url):
        raise exceptions.NoPermissionsNeeded()
    else:
        try:
            unix_path = system_path(url)
            return stat.S_IMODE(os.stat(unix_path).st_mode)
        except fs.errors.NoSysPath:
            raise exceptions.NoPermissionsNeeded()
Ejemplo n.º 4
0
    def get_template(self, template_file):
        """
        :param str template_file: the template file name that appeared in moban
                                  file. It could be a file name, or a relative
                                  file path with reference to template
                                  directories.
        :return: a jinja2 template

        For example:

        suppose your current working directory is: /User/moban-pro/ and your
        template folder list is: ['./my-template'], and the given template
        file equals to: 'templates/myfile.jj2', they as a group tells the
        template file exists at:
            '/User/moban-pro/my-template/templates/myfile.jj2'
        """
        try:
            template = self.jj2_environment.get_template(template_file)
        except TemplateNotFound:
            raise exceptions.FileNotFound("%s does not exist" % template_file)
        return template
Ejemplo n.º 5
0
def file_permissions(afile):
    if not os.path.exists(afile):
        raise exceptions.FileNotFound(afile)
    if sys.platform == "win32":
        return 0
    return stat.S_IMODE(os.stat(afile).st_mode)
Ejemplo n.º 6
0
def file_permissions(afile):
    if not os.path.exists(afile):
        raise exceptions.FileNotFound(afile)
    return stat.S_IMODE(os.stat(afile).st_mode)