当前位置: 首页>>代码示例>>Python>>正文


Python FilePath.isfile方法代码示例

本文整理汇总了Python中twisted.python.filepath.FilePath.isfile方法的典型用法代码示例。如果您正苦于以下问题:Python FilePath.isfile方法的具体用法?Python FilePath.isfile怎么用?Python FilePath.isfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.python.filepath.FilePath的用法示例。


在下文中一共展示了FilePath.isfile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: inspect

# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import isfile [as 别名]
def inspect(doc):
    data = json.loads(doc)
    path = FilePath(data['path'])
    ret = {'kind': 'file', 'path': path.path, 'exists': path.exists()}
    if not ret['exists']:
        return ret
    
    if path.isdir():
        ret['filetype'] = 'dir'
    elif path.isfile():
        ret['filetype'] = 'file'
        ret['size'] = path.statinfo.st_size
        h = sha1()
        fh = open(path.path, 'r')
        while True:
            data = fh.read(4096)
            if not data:
                break
            h.update(data)
        ret['sha1'] = h.hexdigest()

    ret['owner'] = pwd.getpwuid(path.getUserID()).pw_name
    ret['group'] = grp.getgrgid(path.getGroupID()).gr_name
    ret['perms'] = permsString(path.getPermissions())
    ret['ctime'] = int(path.statinfo.st_ctime)
    ret['mtime'] = int(path.statinfo.st_mtime)
    ret['atime'] = int(path.statinfo.st_atime)
    return ret
开发者ID:hagna,项目名称:mold,代码行数:30,代码来源:file.py

示例2: handle_config

# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import isfile [as 别名]
def handle_config():
    if request.method == 'POST':    
        log.msg('Received JSON post with config')     
        jsonConfig = request.get_json(True)
        mumudvbConfig = ConfigParser.SafeConfigParser()
        for cardConfig in jsonConfig:
            card = cardConfig['_']['card']
            # Check the type, dvb-c = freq/1,000, dvb-s(2) = freq/1,000,000
            type = cardConfig['_']['type'] 
            if (type == 'DVB-C'):
                cardConfig['_']['freq'] =  int(cardConfig['_']['freq'])/1000
            else:
                cardConfig['_']['freq'] =  int(cardConfig['_']['freq'])/1000000
            # The DVB-S2 type needs an additional delivery system option
            if (type == 'DVB-S2'):
                cardConfig['_']['delivery_system'] = type
            cardConfig['_']['srate'] = int(cardConfig['_']['srate'])/1000
            cardConfig['_']['log_file'] = '/var/log/mumudvb' + card
            cardConfig['_']['log_type'] = 'syslog' 
            for section in sorted(cardConfig, reverse=True):                
                mumudvbConfig.add_section(section)
                for key in cardConfig[section]:
                    if (cardConfig[section][key] != None and key != 'type'):
                            mumudvbConfig.set(section,str(key),str(cardConfig[section][key]))                            
            cardConf = FilePath(tmpdir.path+'/dvbrc_adapter' + card + '.conf')
            with FilePath.open(cardConf, 'wb') as configfile:   
                mumudvbConfig.write(configfile)
            if FilePath.isfile(cardConf):
                mumu = startMumudvb(card)
                cmd = ["mumudvb","-d","-c", cardConf.path]
                log.msg('Starting MuMuDVB with the following flags: ' + str(cmd) + ' on card ' + card)
                process = reactor.spawnProcess(mumu, cmd[0], cmd, usePTY=True, env=None)
                log.msg(process)
    return ''
开发者ID:tijmenNL,项目名称:ip_streamer_v2,代码行数:36,代码来源:main.py

示例3: render_GET

# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import isfile [as 别名]
    def render_GET(self, request):
        """
        Create a custom or generic Login/Access to the Application.
        """
        file=FilePath('custom/unauthorized.py')
        if file.exists() and file.isfile() or file.islink():
            # Custom form is provided
            from custom.login import CustomLogin
            root=IResource(CustomLogin())
        else:
            from goliat.auth.login import Login
            from goliat.utils.config import ConfigManager
            root=IResource(Login(
                ConfigManager().get_config('Goliat')['Project']))

        request.setResponseCode(http.UNAUTHORIZED)
        return root.render(request)
开发者ID:DamnWidget,项目名称:goliat,代码行数:19,代码来源:__init__.py

示例4: main

# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import isfile [as 别名]
def main():
    address = FilePath(sys.argv[1])
    content = FilePath(sys.argv[2])

    if address.exists():
        raise SystemExit("Cannot listen on an existing path")

    if not content.isfile():
        raise SystemExit("Content file must exist")

    startLogging(sys.stdout)

    serverFactory = Factory()
    serverFactory.content = content
    serverFactory.protocol = SendFDProtocol

    port = reactor.listenUNIX(address.path, serverFactory)
    reactor.run()
开发者ID:BillAndersan,项目名称:twisted,代码行数:20,代码来源:sendfd.py

示例5: walk

# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import isfile [as 别名]
 def walk(self, path):
     containers = []
     filepath = FilePath(path)
     if filepath.isdir():
         containers.append(filepath)
     elif filepath.isfile():
         self.items.append(FilePath(path))
     while len(containers)>0:
         container = containers.pop()
         try:
             for child in container.children():
                 if child.isdir():
                     containers.append(child)
                 elif child.isfile() or child.islink():
                     mimetype,_ = mimetypes.guess_type(child.path, strict=False)
                     if mimetype and mimetype.startswith("image/"):
                         self.items.append(child)
         except UnicodeDecodeError:
             self.warning("UnicodeDecodeError - there is something wrong with a file located in %r", container.get_path())
开发者ID:BlackHole,项目名称:coherence,代码行数:21,代码来源:base.py

示例6: FilePath

# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import isfile [as 别名]
#--------------------------------------------------------------------------------
# Log handler
#--------------------------------------------------------------------------------
if (debug):
    log.startLogging(sys.stdout)
else:
    logFile = logfile.LogFile("ip_streamer.log", "/tmp")
    log.startLogging(logFile)
    
#--------------------------------------------------------------------------------
# Read config, exit if no config is found
#--------------------------------------------------------------------------------
config = ConfigParser.ConfigParser()
path = FilePath('/etc/vice/config.ini')
if(FilePath.isfile(path)):
    config.read('/etc/vice/config.ini')
    viceIp = config.get('settings','server')
    vicePort = config.get('settings','port')
    viceServer = 'http://' + viceIp + ':' + vicePort
    updatetime = config.get('settings_mumudude','updatetime')
    tmpdir = FilePath(config.get('settings_mumudude','tmpdir'))
    if not FilePath.isdir(tmpdir):
        FilePath.createDirectory(tmpdir)
    mumudvblogdir = FilePath(config.get('settings_mumudude','mumudvblogdir'))
    if not FilePath.isdir(mumudvblogdir):
        FilePath.createDirectory(mumudvblogdir)
    mumudvbbindir = FilePath(config.get('settings_mumudude','mumudvbbindir'))   
    if not FilePath.isdir(mumudvbbindir):
        FilePath.createDirectory(mumudvbbindir)
else:
开发者ID:tijmenNL,项目名称:ip_streamer_v2,代码行数:32,代码来源:main.py


注:本文中的twisted.python.filepath.FilePath.isfile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。