本文整理汇总了Python中Time.timetostring方法的典型用法代码示例。如果您正苦于以下问题:Python Time.timetostring方法的具体用法?Python Time.timetostring怎么用?Python Time.timetostring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Time
的用法示例。
在下文中一共展示了Time.timetostring方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _writer_helper
# 需要导入模块: import Time [as 别名]
# 或者: from Time import timetostring [as 别名]
def _writer_helper(self, prefix, flatfileclass, typestr, time):
"""Used in the get_xx_writer functions, returns a writer class"""
if time is None: timestr = Time.curtimestr
else: timestr = Time.timetostring(time)
filename = '%s.%s.%s' % (prefix, timestr, typestr)
rp = Globals.rbdir.append(filename)
assert not rp.lstat(), "File %s already exists!" % (rp.path,)
assert rp.isincfile()
return flatfileclass(rp, 'w', callback = self.add_incrp)
示例2: get_inc
# 需要导入模块: import Time [as 别名]
# 或者: from Time import timetostring [as 别名]
def get_inc(rp, typestr, time = None):
"""Return increment like rp but with time and typestr suffixes
To avoid any quoting, the returned rpath has empty index, and the
whole filename is in the base (which is not quoted).
"""
if time is None: time = Time.prevtime
addtostr = lambda s: "%s.%s.%s" % (s, Time.timetostring(time), typestr)
if rp.index:
incrp = rp.__class__(rp.conn, rp.base, rp.index[:-1] +
(addtostr(rp.index[-1]),))
else:
dirname, basename = rp.dirsplit()
incrp = rp.__class__(rp.conn, dirname, (addtostr(basename),))
assert not incrp.lstat(), incrp
return incrp
示例3: recreate_meta
# 需要导入模块: import Time [as 别名]
# 或者: from Time import timetostring [as 别名]
def recreate_meta(meta_manager):
"""Make regress_time mirror_metadata snapshot by patching
We write to a tempfile first. Otherwise, in case of a crash, it
would seem we would have an intact snapshot and partial diff, not
the reverse.
"""
temprp = [TempFile.new_in_dir(Globals.rbdir)]
def callback(rp): temprp[0] = rp
writer = metadata.MetadataFile(temprp[0], 'w', check_path = 0, callback = callback)
for rorp in meta_manager.get_meta_at_time(regress_time, None):
writer.write_object(rorp)
writer.close()
finalrp = Globals.rbdir.append("mirror_metadata.%s.snapshot.gz" %
Time.timetostring(regress_time))
assert not finalrp.lstat(), finalrp
rpath.rename(temprp[0], finalrp)
if Globals.fsync_directories: Globals.rbdir.fsync()