How to use the arrow.Arrow.fromtimestamp function in arrow

To help you get started, we’ve selected a few arrow examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 1token-trade / onetoken-py-sdk / onetoken / model.py View on Github external
def from_short_list(lst):
        if isinstance(lst[0], str):
            # convert string to contract
            # lst[0] = ContractApi.get_by_symbol(lst[0])
            lst[0] = lst[0]
        bids, asks = lst[4], lst[5]
        bids = [{'price': float(p), 'volume': float(v)} for p, v in zip(bids.split(',')[::2], bids.split(',')[1::2])]
        asks = [{'price': float(p), 'volume': float(v)} for p, v in zip(asks.split(',')[::2], asks.split(',')[1::2])]

        time = arrow.Arrow.fromtimestamp(lst[1]).datetime
        return Tick(contract=lst[0], time=time, price=lst[2], volume=lst[3], bids=bids, asks=asks)
github google / rekall / rekall-agent / rekall_agent / ui / flows.py View on Github external
break

            ticket = flow.FlowStatus.from_json(
                row["ticket_data"], session=self.session)

            last_active = row["last_active"]
            if last_active:
                last_active = arrow.Arrow.fromtimestamp(last_active)

            collections = [x.location.get_canonical().to_path()
                           for x in ticket.collections]

            yield dict(state=row["status"],
                       flow_id=row["flow_id"],
                       type=row["type"],
                       created=arrow.Arrow.fromtimestamp(row["created"]),
                       last_active=last_active,
                       collections=collections)
github anl-cyberscience / LQMToolset / lqmt / tools / to_mattermost / tool.py View on Github external
def __build_post_message(self, fname, meta=None):
        """
        Generic function to build a string to accompany a MM upload of a file.
        Uses context from the file meta-data to add usage guidance (if available).

        :param fname: String filename to be added to the MM post text.
        :param meta: Meta data for file to extract context for MM post text.
        :return message: Finally built string for MM post.
        """
        # default message if no meta data to build larger message
        message = fname + ' uploaded from LQMT'

        if meta:
            t = arrow.Arrow.fromtimestamp(meta['SentTimestamp'])
            m = t.format('MMM D, hh:mm:ss A ZZ')
            message = meta['SendingSite'] + ' posted ' + fname + ' on ' + m + '\n'
            message += 'Sensitivity: ' + meta['DataSensitivity'] + '\n' + \
                       'Restrictions: ' + meta['SharingRestrictions'] + '\n' + \
                       'Recon Policy: ' + meta['ReconPolicy']

        return message
github google / rekall / rekall-core / rekall / plugins / response / common.py View on Github external
def atime(self):
        return arrow.Arrow.fromtimestamp(self.st_atime)
github google / rekall / rekall-agent / rekall_agent / ui / flows.py View on Github external
total_clients = 0
        base = None
        data_x = []
        data_y = []
        for row in collection.query(order_by="executed"):
            total_clients += 1
            if base is None:
                base = row["executed"]
            data_x.append(row["executed"] - base)
            data_y.append(total_clients)

        fig = pyplot.figure()
        ax = fig.add_subplot(111)
        ax.plot(data_x, data_y)
        start_time = arrow.Arrow.fromtimestamp(base)
        ax.set_title("Clients in Hunt %s" % self.plugin_args.flow_id)
        ax.set_xlabel("Seconds after %s (%s)" % (
            start_time.ctime(), start_time.humanize()))
        ax.set_ylabel("Total Client Count")
        pyplot.show()
github google / rekall / rekall-agent / rekall_agent / ui / flows.py View on Github external
def collect_db(self, collection):
        # Now show all the flows.
        for i, row in enumerate(collection.query(order_by="created desc")):
            if i > self.plugin_args.limit:
                break

            ticket = flow.FlowStatus.from_json(
                row["ticket_data"], session=self.session)

            last_active = row["last_active"]
            if last_active:
                last_active = arrow.Arrow.fromtimestamp(last_active)

            collections = [x.location.get_canonical().to_path()
                           for x in ticket.collections]

            yield dict(state=row["status"],
                       flow_id=row["flow_id"],
                       type=row["type"],
                       created=arrow.Arrow.fromtimestamp(row["created"]),
                       last_active=last_active,
                       collections=collections)
github Astalaseven / twitter-rss / twitter_rss.py View on Github external
def clean_timestamp(self,timestamp):
        return arrow.Arrow.fromtimestamp(float(timestamp))
github google / rekall / rekall-core / rekall / plugins / renderers / json_storage.py View on Github external
def DecodeFromJsonSafe(self, state, options):
        return arrow.Arrow.fromtimestamp(state["epoch"])
github google / rekall / rekall-lib / rekall_lib / serializer.py View on Github external
def validate(self, value, session=None):
        if isinstance(value, (float, int)):
            value = arrow.Arrow.fromtimestamp(value)

        elif not isinstance(value, arrow.Arrow):
            raise ValueError("Value must be timestamp or arrow.Arrow instance.")

        return value