當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。