Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def atest_root(kernel32_idb):
root = idb.netnode.get_nodeid(kernel32_idb, 'Root Node')
assert idb.netnode.get_int(kernel32_idb, root, 'A', idb.netnode.ROOT_INDEX.VERSION) == 695
assert idb.netnode.get_string(kernel32_idb, root, 'S', idb.netnode.ROOT_INDEX.VERSION_STRING) == '6.95'
assert idb.netnode.get_int(kernel32_idb, root, 'A', idb.netnode.ROOT_INDEX.OPEN_COUNT) == 1
ts = idb.netnode.get_int(kernel32_idb, root, 'A', idb.netnode.ROOT_INDEX.CREATED)
ts = datetime.datetime.utcfromtimestamp(ts)
assert ts.isoformat() == '2017-06-20T22:31:34'
assert idb.netnode.get_int(kernel32_idb, root, 'A', idb.netnode.ROOT_INDEX.CRC) == 0xdf9bdf12
md5 = idb.netnode.get_bytes(kernel32_idb, root, 'S', idb.netnode.ROOT_INDEX.MD5)
md5 = binascii.hexlify(md5).decode('ascii')
assert md5 == '00bf1bf1b779ce1af41371426821e0c2'
def epochToString(D):
return datetime.datetime.utcfromtimestamp(D).strftime(
"%Y-%m-%d %H:%M:%S"
)
def _serialize(self, value, attr, obj, **kwargs):
"""
Serialize value as a timestamp, either as a Unix timestamp (in float second) or a UTC isoformat string.
"""
if value is None:
return None
if self.use_isoformat:
return datetime.utcfromtimestamp(value).isoformat()
else:
return value
def get_commit_time(self):
return datetime.utcfromtimestamp(int(self.package.repo.commit_to_time(
self.specified_revision)))
def get_target_start_date(self) -> Optional[datetime]:
return datetime.utcfromtimestamp(cast(int, self.get_state("target_start_date")))
# section a
elif format_version == 23:
latest_exec_date = content[0x0080:0x0080 + 8]
exec_count = struct.unpack("
def populate_result(self):
substrate = self.decoded_response
try:
decoded, substrate = decoder.decode(substrate, asn1Spec=Integer())
self.result['partition_id'] = int(decoded)
decoded, substrate = decoder.decode(substrate, asn1Spec=Integer())
self.result['replica_state'] = int(decoded)
decoded, substrate = decoder.decode(substrate, asn1Spec=Integer())
self.result['modification_time'] = datetime.utcfromtimestamp(int(decoded))
decoded, substrate = decoder.decode(substrate, asn1Spec=Integer())
self.result['purge_time'] = datetime.utcfromtimestamp(int(decoded))
decoded, substrate = decoder.decode(substrate, asn1Spec=Integer())
self.result['local_partition_id'] = int(decoded)
decoded, substrate = decoder.decode(substrate, asn1Spec=LDAPDN())
self.result['partition_dn'] = str(decoded)
decoded, substrate = decoder.decode(substrate, asn1Spec=Integer())
self.result['replica_type'] = int(decoded)
decoded, substrate = decoder.decode(substrate, asn1Spec=Integer())
self.result['flags'] = int(decoded)
except Exception:
raise LDAPExtensionError('unable to decode substrate')
if substrate:
raise LDAPExtensionError('unknown substrate remaining')
headers.append((x_header_name, safe_str(x_filename)))
return Response('', status=200, headers=headers,
direct_passthrough=True)
else:
request = environ.get('werkzeug.request')
if request:
range = request.range
else:
range = parse_range_header(environ.get('HTTP_RANGE'))
#when request range,only recognize "bytes" as range units
if range and range.units=="bytes":
try:
fsize = os.path.getsize(real_filename)
except OSError as e:
return Response("Not found",status=404)
mtime = datetime.utcfromtimestamp(os.path.getmtime(real_filename))
mtime_str = http_date(mtime)
if cache:
etag = _generate_etag(mtime, fsize, real_filename)
else:
etag = mtime_str
if_range = environ.get('HTTP_IF_RANGE')
if if_range:
check_if_range_ok = (if_range.strip('"')==etag)
#print "check_if_range_ok (%s) = (%s ==%s)"%(check_if_range_ok,if_range.strip('"'),etag)
else:
check_if_range_ok = True
rbegin,rend = range.ranges[0]
if check_if_range_ok and (rbegin+1)
def utc_milliseconds(timestamp=None):
if timestamp is None: timestamp = datetime.utcnow()
epoch = datetime.utcfromtimestamp(0)
return long((timestamp - epoch).total_seconds() * 1000)
def get_readable_time():
ts = int(time.time())
return str(datetime.utcfromtimestamp(ts).strftime('%Y.%m.%d')) + f"__{ts}"