跳至主要内容

博文

目前显示的是 二月, 2022的博文

Workaround a jython runtime bug by interop with Java java.time

TypeError: unsupported operand type(s) for +: 'java.sql.Timestamp' and 'timedelta' I was working on a NIFI script recently. As the following code snip shows, I was trying to construct a series of timestamped string with Python’s datetime. import os.path from datetime import datetime, time, timedelta import subprocess now = datetime.now() dirs = [ (now + timedelta(milliseconds=(-100 * x))).strftime( '%Y%m%d%H/%M/%S/%f' )[0:-5] for x in range (0,100)] fullpaths = [ '/workspace/nifi_output/{}' . format (d) for d in dirs] existspaths = [fp for fp in fullpaths if os.path.exists(fp)] flowFile = session.get() if (flowFile == None ): flowFile = session.create() ep_length = len (existspaths) if ep_length > 1: session.putAttribute(flowFile, 'batch_path' , existspaths[1]) session.transfer(flowFile, REL_SUCCESS) elif ep_length == 1: session.putAttribute(flowFile, 'batch_path' , existspaths[0]) sessi