Beispiel #1
0
 def deserialize(byts, protocol_version):
     timestamp = int64_unpack(byts) / 1000.0
     if timestamp >= 0:
         dt = datetime.utcfromtimestamp(timestamp)
     else:
         # PYTHON-119: workaround for Windows
         dt = datetime(1970, 1, 1) + timedelta(seconds=timestamp)
     return dt
Beispiel #2
0
 def deserialize(byts, protocol_version):
     timestamp = int64_unpack(byts) / 1000.0
     if timestamp >= 0:
         dt = datetime.utcfromtimestamp(timestamp)
     else:
         # PYTHON-119: workaround for Windows
         dt = datetime(1970, 1, 1) + timedelta(seconds=timestamp)
     return dt
Beispiel #3
0
    def deserialize(cls, byts, protocol_version):
        # <type>[<time0><precision0>[<time1><precision1>]]
        type_ = int8_unpack(byts[0:1])

        if type_ in (BoundKind.to_int(BoundKind.BOTH_OPEN_RANGE),
                     BoundKind.to_int(BoundKind.SINGLE_DATE_OPEN)):
            time0 = precision0 = None
        else:
            time0 = int64_unpack(byts[1:9])
            precision0 = int8_unpack(byts[9:10])

        if type_ == BoundKind.to_int(BoundKind.CLOSED_RANGE):
            time1 = int64_unpack(byts[10:18])
            precision1 = int8_unpack(byts[18:19])
        else:
            time1 = precision1 = None

        if time0 is not None:
            date_range_bound0 = util.DateRangeBound(
                time0, cls._decode_precision(precision0))
        if time1 is not None:
            date_range_bound1 = util.DateRangeBound(
                time1, cls._decode_precision(precision1))

        if type_ == BoundKind.to_int(BoundKind.SINGLE_DATE):
            return util.DateRange(value=date_range_bound0)
        if type_ == BoundKind.to_int(BoundKind.CLOSED_RANGE):
            return util.DateRange(lower_bound=date_range_bound0,
                                  upper_bound=date_range_bound1)
        if type_ == BoundKind.to_int(BoundKind.OPEN_RANGE_HIGH):
            return util.DateRange(lower_bound=date_range_bound0,
                                  upper_bound=util.OPEN_BOUND)
        if type_ == BoundKind.to_int(BoundKind.OPEN_RANGE_LOW):
            return util.DateRange(lower_bound=util.OPEN_BOUND,
                                  upper_bound=date_range_bound0)
        if type_ == BoundKind.to_int(BoundKind.BOTH_OPEN_RANGE):
            return util.DateRange(lower_bound=util.OPEN_BOUND,
                                  upper_bound=util.OPEN_BOUND)
        if type_ == BoundKind.to_int(BoundKind.SINGLE_DATE_OPEN):
            return util.DateRange(value=util.OPEN_BOUND)
        raise ValueError('Could not deserialize %r' % (byts, ))
 def run(self):
     date_begin, date_end = self.get_start_end_times()
     params = dict(orgid=self.orgid,
                   date_begin=date_begin.isoformat(),
                   date_end=date_end.isoformat(),
                   group=self.group)
     cluster = Cluster([self.host], self.port)
     session = cluster.connect()
     session.set_keyspace(self.keyspace)
     ret = session.execute(self.query, params)
     
     with self.output().open('w') as out:
         for row in ret:
             db_date = datetime.utcfromtimestamp(int64_unpack(row[0]) / 1000)
             print >> out, db_date.isoformat(), int(row[1])
     session.shutdown()
     cluster.shutdown()
Beispiel #5
0
 def deserialize(byts):
     return datetime.utcfromtimestamp(int64_unpack(byts) / 1000.0)
Beispiel #6
0
 def deserialize(byts):
     return datetime.utcfromtimestamp(int64_unpack(byts) / 1000.0)
Beispiel #7
0
 def deserialize(byts, protocol_version):
     return util.Time(int64_unpack(byts))
Beispiel #8
0
 def deserialize(byts, protocol_version):
     timestamp = int64_unpack(byts) / 1000.0
     return util.datetime_from_timestamp(timestamp)
Beispiel #9
0
 def deserialize(byts, protocol_version):
     return int64_unpack(byts)
Beispiel #10
0
 def deserialize(byts, protocol_version):
     return util.Time(int64_unpack(byts))
Beispiel #11
0
 def deserialize(byts, protocol_version):
     timestamp = int64_unpack(byts) / 1000.0
     return util.datetime_from_timestamp(timestamp)
Beispiel #12
0
 def deserialize(byts, protocol_version):
     return int64_unpack(byts)
 def deserialize(byts, protocol_version):
     return datetime.utcfromtimestamp(int64_unpack(byts) / 1000.0)
Beispiel #14
0
 def deserialize(byts, protocol_version):
     return datetime.utcfromtimestamp(int64_unpack(byts) / 1000.0)
 def deserialize(byts, protocol_version):
     timestamp = int64_unpack(byts) / 1000.0
     dt = datetime(1970, 1, 1) + timedelta(seconds=timestamp)
     return dt
Beispiel #16
0
 def deserialize(byts, protocol_version):
     timestamp = int64_unpack(byts) / 1000.0
     dt = datetime(1970, 1, 1) + timedelta(seconds=timestamp)
     return dt