本文整理汇总了Python中vistrails.core.system.strftime函数的典型用法代码示例。如果您正苦于以下问题:Python strftime函数的具体用法?Python strftime怎么用?Python strftime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strftime函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
def save(self):
return (self.id,
self.type_id,
self.name,
self.user,
strftime(self.mod_time, self.DATE_FORMAT),
strftime(self.create_time, self.DATE_FORMAT),
self.size,
self.description,
self.url)
示例2: update
def update(self, workflow_exec):
self.workflow_exec = workflow_exec
if self.workflow_exec is not None:
self.name = "%s" % self.workflow_exec.db_ts_start
self.user = self.workflow_exec.user
self.mod_time = (
strftime(self.workflow_exec.ts_end, '%d %b %Y %H:%M:%S')
if self.workflow_exec.ts_end else '1 Jan 0000 00:00:00')
self.create_time = (
strftime(self.workflow_exec.ts_start, '%d %b %Y %H:%M:%S')
if self.workflow_exec.ts_start else '1 Jan 0000 00:00:00')
self.size = len(self.workflow_exec.item_execs)
self.description = ""
self.url = 'test'
self.was_updated = True
示例3: convertToStr
def convertToStr(self, value, type):
if value is not None:
if type == 'date':
return value.isoformat()
elif type == 'datetime':
return strftime(value, '%Y-%m-%d %H:%M:%S')
else:
return str(value)
return ''
示例4: saveToHistory
def saveToHistory(self):
""" saveToHistory() -> None
Save the current contents to the history
"""
# Generate filename
current = datetime.datetime.now()
tmpDir = tempfile.gettempdir()
fn = "hist_" + strftime(current, "%Y_%m_%d__%H_%M_%S") + "_" + str(current.microsecond) + ".png"
fn = os.path.join(tmpDir, fn)
if self.saveToPNG(fn):
self._historyImages.append(fn)
示例5: getParameterExploration
def getParameterExploration(self):
""" getParameterExploration() -> string
Generates an XML string that represents the current
parameter exploration, and which can be loaded with
setParameterExploration().
"""
# Construct xml for persisting parameter exploration
escape_dict = {"'": "'", '"': """, "\n": "
"}
timestamp = strftime(current_time(), "%Y-%m-%d %H:%M:%S")
# TODO: For now, we use the timestamp as the 'name' - Later, we should set 'name' based on a UI input field
xml = '\t<paramexp dims="%s" layout="%s" date="%s" name="%s">' % (
str(self.peWidget.table.label.getCounts()),
str(self.virtualCell.getConfiguration()[2]),
timestamp,
timestamp,
)
for i in xrange(self.peWidget.table.layout().count()):
pEditor = self.peWidget.table.layout().itemAt(i).widget()
if pEditor and isinstance(pEditor, QParameterSetEditor):
firstParam = True
for paramWidget in pEditor.paramWidgets:
paramInfo = paramWidget.param
interpolator = paramWidget.editor.stackedEditors.currentWidget()
intType = interpolator.exploration_name
# Write function tag prior to the first parameter of the function
if firstParam:
xml += '\n\t\t<function id="%s" alias="%s" name="%s">' % (
paramInfo.parent_id,
paramInfo.is_alias,
pEditor.info[0],
)
firstParam = False
# Write parameter tag
xml += '\n\t\t\t<param id="%s" dim="%s" interp="%s"' % (
paramInfo.id,
paramWidget.getDimension(),
intType,
)
if intType == "Linear Interpolation":
xml += ' min="%s" max="%s"' % (
interpolator.fromEdit.get_value(),
interpolator.toEdit.get_value(),
)
elif intType == "List":
xml += ' values="%s"' % escape(str(interpolator._str_values), escape_dict)
elif intType == "User-defined Function":
xml += ' code="%s"' % escape(interpolator.function, escape_dict)
xml += "/>"
xml += "\n\t\t</function>"
xml += "\n\t</paramexp>"
return xml
示例6: getParameterExploration
def getParameterExploration(self):
""" getParameterExploration() -> ParameterExploration
Generates a ParameterExploration object hat represents the current
parameter exploration, and which can be loaded with
setParameterExploration().
"""
# Construct xml for persisting parameter exploration
escape_dict = { "'":"'", '"':'"', '\n':'
' }
palette = self.get_palette()
id_scope = self.controller.id_scope
functions = []
for i in xrange(self.table.layout().count()):
pEditor = self.table.layout().itemAt(i).widget()
if pEditor and isinstance(pEditor, QParameterSetEditor):
function = None
firstParam = True
for paramWidget in pEditor.paramWidgets:
paramInfo = paramWidget.param
interpolator = paramWidget.editor.stackedEditors.currentWidget()
intType = interpolator.exploration_name
# Write function tag prior to the first parameter of the function
if firstParam:
function = PEFunction(id=id_scope.getNewId(PEFunction.vtType),
module_id=paramInfo.module_id,
port_name=paramInfo.name,
is_alias = 1 if paramInfo.is_alias else 0)
firstParam = False
if intType in ['Linear Interpolation', 'RGB Interpolation',
'HSV Interpolation']:
value = '["%s", "%s"]' % (interpolator.fromEdit.get_value(),
interpolator.toEdit.get_value())
elif intType == 'List':
value = '%s' % escape(str(interpolator._str_values), escape_dict)
elif intType == 'User-defined Function':
value ='%s' % escape(interpolator.function, escape_dict)
# Write parameter tag
param = PEParam(id=id_scope.getNewId(PEParam.vtType),
pos=paramInfo.pos,
interpolator=intType,
value=value,
dimension=paramWidget.getDimension())
function.addParameter(param)
functions.append(function)
pe = ParameterExploration(dims=str(self.table.label.getCounts()),
layout=repr(palette.virtual_cell.getConfiguration()[2]),
date=strftime(current_time(), '%Y-%m-%d %H:%M:%S'),
user=getuser(),
functions=functions)
return pe
示例7: saveSession
def saveSession(self):
"""saveSession() -> None
Opens a File Save dialog and passes the filename to shell's saveSession.
"""
default = 'visTrails' + '-' + strftime("%Y%m%d-%H%M.log")
default = os.path.join(vistrails.core.system.vistrails_file_directory(),default)
fileName = QtGui.QFileDialog.getSaveFileName(self,
"Save Session As..",
default,
"Log files (*.log)")
if not fileName:
return
self.shell.saveSession(str(fileName))
示例8: update
def update(self, thumbnail):
self.thumbnail = thumbnail
if self.thumbnail is not None:
# store in cache if not already there
cache = ThumbnailCache.getInstance()
cache._copy_thumbnails([thumbnail])
self.name = os.path.basename(thumbnail)
statinfo = os.stat(self.thumbnail)
self.user = statinfo[stat.ST_UID]
self.size = statinfo[stat.ST_SIZE]
time = strftime(datetime(*localtime(statinfo[stat.ST_MTIME])[:6]),
'%d %b %Y %H:%M:%S')
self.mod_time = ''
self.create_time = time
self.description = ""
self.url = 'test'
self.was_updated = True
示例9: convertToDB
def convertToDB(self, value, type, db_type):
if value is not None:
if type == 'str':
return "'" + str(value) + "'"
elif type == 'long':
return str(value)
elif type == 'float':
return str(value)
elif type == 'int':
return str(value)
elif type == 'date':
return "'" + value.isoformat() + "'"
elif type == 'datetime':
return "'" + strftime(value, '%Y-%m-%d %H:%M:%S') + "'"
else:
return str(value)
return "''"
示例10: convertToDB
def convertToDB(self, value, type, db_type):
if value is not None:
if type == "str":
# return "'" + str(value).replace("'", "''") + "'"
return str(value)
elif type == "long":
return str(value)
elif type == "float":
return str(value)
elif type == "int":
return str(value)
elif type == "date":
return value.isoformat()
elif type == "datetime":
return strftime(value, "%Y-%m-%d %H:%M:%S")
else:
return str(value)
return None
示例11: _get_date
def _get_date(self):
if self.db_date is not None:
return strftime(self.db_date, '%d %b %Y %H:%M:%S')
return strftime(datetime(1900,1,1), '%d %b %Y %H:%M:%S')
示例12: int
elif type == 'int':
# note: on 64-bit machines int:s are 64-bit
MIN_INT = -2147483648
MAX_INT = 2147483647
if db_type == 'int':
if int(value) < MIN_INT:
self.convertWarning(value, MIN_INT, type, db_type)
value = MIN_INT
if int(value) > MAX_INT:
self.convertWarning(value, MAX_INT, type, db_type)
value = MAX_INT
return str(value)
elif type == 'date':
return value.isoformat()
elif type == 'datetime':
return strftime(value, '%Y-%m-%d %H:%M:%S')
else:
return str(value)
return None
def createSQLSelect(self, table, columns, whereMap, orderBy=None,
forUpdate=False):
columnStr = ', '.join(columns)
whereStr = ''
whereClause = ''
values = []
for column, value in whereMap.iteritems():
whereStr += '%s%s = %%s' % \
(whereClause, column)
values.append(value)