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


Python path.getmtime方法代码示例

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


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

示例1: list

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getmtime [as 别名]
def list(self):
		dirs = []
		# TODO: error management
		for d in listdir(self.datapath):
			dp = path.join(self.datapath, d)
			if path.isdir(dp):
				dirs.append({
					"name": d,
					"path": dp,
					"mtime": datetime.datetime.fromtimestamp(path.getmtime(dp)).strftime('%d.%m.%Y %H:%M:%S')
					# "size": path.getsize(dp),
					# "hsize": self.human_size(self.get_size(dp))
				})
		
		dirs.sort(key=lambda dir: dir['name'], reverse=True)
		
		return {'status': 'success', 'data': dirs} 
开发者ID:SecPi,项目名称:SecPi,代码行数:19,代码来源:alarmdata.py

示例2: get_source

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getmtime [as 别名]
def get_source(self, environment, template):
        pieces = split_template_path(template)
        for searchpath in self.searchpath:
            filename = path.join(searchpath, *pieces)
            f = open_if_exists(filename)
            if f is None:
                continue
            try:
                contents = f.read().decode(self.encoding)
            finally:
                f.close()

            mtime = path.getmtime(filename)

            def uptodate():
                try:
                    return path.getmtime(filename) == mtime
                except OSError:
                    return False
            return contents, filename, uptodate
        raise TemplateNotFound(template) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:23,代码来源:loaders.py

示例3: __init__

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getmtime [as 别名]
def __init__(self, callback, files):
        """
        :files: files to be monidtored with full path
        """

        self._callback = callback
        self._files = files

        self.file_mtimes = {
            file_name: None for file_name in self._files
        }
        for k in self.file_mtimes:
            if not op.exists(k):
                continue

            try:
                if not op.exists(k):
                    continue
                self.file_mtimes[k] = op.getmtime(k)
            except OSError:
                log.logger.error("Getmtime for %s, failed: %s",
                                 k, traceback.format_exc()) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:24,代码来源:file_monitor.py

示例4: get_outdated_docs

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getmtime [as 别名]
def get_outdated_docs(self):
        for docname in self.env.found_docs:
            if docname not in self.env.all_docs:
                yield docname
                continue
            targetname = path.join(self.outdir, docname + self.out_suffix)
            try:
                targetmtime = path.getmtime(targetname)
            except Exception:
                targetmtime = 0
            try:
                srcmtime = path.getmtime(self.env.doc2path(docname))
                if srcmtime > targetmtime:
                    yield docname
            except EnvironmentError:
                pass 
开发者ID:codejamninja,项目名称:sphinx-markdown-builder,代码行数:18,代码来源:markdown_builder.py

示例5: deploy_go

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getmtime [as 别名]
def deploy_go(app, deltas={}):
    """Deploy a Go application"""

    go_path = join(ENV_ROOT, app)
    deps = join(APP_ROOT, app, 'Godeps')

    first_time = False
    if not exists(go_path):
        echo("-----> Creating GOPATH for '{}'".format(app), fg='green')
        makedirs(go_path)
        # copy across a pre-built GOPATH to save provisioning time
        call('cp -a $HOME/gopath {}'.format(app), cwd=ENV_ROOT, shell=True)
        first_time = True

    if exists(deps):
        if first_time or getmtime(deps) > getmtime(go_path):
            echo("-----> Running godep for '{}'".format(app), fg='green')
            env = {
                'GOPATH': '$HOME/gopath',
                'GOROOT': '$HOME/go',
                'PATH': '$PATH:$HOME/go/bin',
                'GO15VENDOREXPERIMENT': '1'
            }
            call('godep update ...', cwd=join(APP_ROOT, app), env=env, shell=True)
    return spawn_app(app, deltas) 
开发者ID:piku,项目名称:piku,代码行数:27,代码来源:piku.py

示例6: get_source

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getmtime [as 别名]
def get_source(self, environment, template):
        pieces = split_template_path(template)
        for searchpath in self.searchpath:
            filename = path.join(searchpath, *pieces)
            f = open_if_exists(filename)
            if f is None:
                continue
            try:
                contents = f.read().decode(self.encoding)
            finally:
                f.close()

            mtime = path.getmtime(filename)

            def uptodate():
                try:
                    return path.getmtime(filename) == mtime
                except OSError:
                    return False

            return contents, filename, uptodate
        raise TemplateNotFound(template) 
开发者ID:pypa,项目名称:pipenv,代码行数:24,代码来源:loaders.py

示例7: test_is_cached_without_cachefile

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getmtime [as 别名]
def test_is_cached_without_cachefile(proc_factory, tmp_path):
    infile = tmp_path / 'test_is_cached_without_cachefile.txt'
    infile.write_text('')
    outfile = tmp_path / 'test_is_cached_without_cachefile_out.txt'
    outfile.write_text('')

    proc = proc_factory(
        'pIsCachedWithoutCacheFile',
        input={'infile:file': [infile]},
        output=
        'outfile:file:{{i.infile | __import__("pathlib").Path | .stem}}.txt')
    job = Job(0, proc)
    job.rc = 0
    job.input
    Path(job.output['outfile'][1]).write_text('')
    assert job._is_cached_without_cachefile()
    #print(job.signature)
    job.signature = ''
    utime(infile, (path.getmtime(infile) + 100, ) * 2)
    #print(job.signature)
    assert not job._is_cached_without_cachefile() 
开发者ID:pwwang,项目名称:PyPPL,代码行数:23,代码来源:test_job.py

示例8: try_download

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getmtime [as 别名]
def try_download(_path, _file, _url, _stale,):
    now = time()
    url = URLopener()
    file_exists = isfile(_path+_file) == True
    if file_exists:
        file_old = (getmtime(_path+_file) + _stale) < now
    if not file_exists or (file_exists and file_old):
        try:
            url.retrieve(_url, _path+_file)
            result = 'ID ALIAS MAPPER: \'{}\' successfully downloaded'.format(_file)
        except IOError:
            result = 'ID ALIAS MAPPER: \'{}\' could not be downloaded'.format(_file)
    else:
        result = 'ID ALIAS MAPPER: \'{}\' is current, not downloaded'.format(_file)
    url.close()
    return result

# SHORT VERSION - MAKES A SIMPLE {INTEGER ID: 'CALLSIGN'} DICTIONARY 
开发者ID:n0mjs710,项目名称:dmr_utils,代码行数:20,代码来源:utils.py

示例9: __init__

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getmtime [as 别名]
def __init__(self, filename, target_dir):
        self.filename = filename
        self.target_dir = target_dir
        self.thumbloc = .5, .5
        self.extract_docstring()
        with open(filename, "r") as fid:
            self.filetext = fid.read()

        outfilename = op.join(target_dir, self.rstfilename)

        # Only actually run it if the output RST file doesn't
        # exist or it was modified less recently than the example
        if (not op.exists(outfilename)
            or (op.getmtime(outfilename) < op.getmtime(filename))):

            self.exec_file()
        else:

            print("skipping {0}".format(self.filename)) 
开发者ID:matplotlib,项目名称:mpl-probscale,代码行数:21,代码来源:plot_generator.py

示例10: __init__

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getmtime [as 别名]
def __init__(self, filename, target_dir):
        self.filename = filename
        self.target_dir = target_dir
        self.thumbloc = .5, .5
        self.extract_docstring()
        with open(filename, "r") as fid:
            self.filetext = fid.read()

        outfilename = op.join(target_dir, self.rstfilename)

        # Only actually run it if the output RST file doesn't
        # exist or it was modified less recently than the example
        if (not op.exists(outfilename) \
            or (op.getmtime(outfilename) < op.getmtime(filename))):
            self.exec_file()
        else:
            print("skipping {0}".format(self.filename)) 
开发者ID:dhhagan,项目名称:py-openaq,代码行数:19,代码来源:plot_generator.py


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