Esempio n. 1
0
 def set_timeout(self, seconds):
     """
     Operation timeout, see http://msdn.microsoft.com/en-us/library/ee916629(v=PROT.13).aspx
     @param int seconds: the number of seconds to set the timeout to. It will be converted to an ISO8601 format.
     """
     # in original library there is an alias - op_timeout method
     return duration_isoformat(timedelta(seconds))
Esempio n. 2
0
 def set_timeout(self, seconds):
     """
     Operation timeout, see http://msdn.microsoft.com/en-us/library/ee916629(v=PROT.13).aspx
     @param int seconds: the number of seconds to set the timeout to. It will be converted to an ISO8601 format.
     """
     # in original library there is an alias - op_timeout method
     return duration_isoformat(timedelta(seconds))
Esempio n. 3
0
    def build_event_signal(site_event):
        event_start = site_event.dr_event.start
        event_end = site_event.dr_event.end
        event_duration = event_end - event_start

        seconds = event_duration.seconds

        # datetime.timedelta only has a seconds property, so pass in seconds to duration
        duration = isoduration.Duration(seconds=seconds)

        iso_duration = isoduration.duration_isoformat(
            duration)  # duration in iso format
        duration = oadr_20b.DurationPropType(duration=iso_duration)
        dtstart = oadr_20b.dtstart(date_time=event_start)
        properties = oadr_20b.properties(dtstart=dtstart, duration=duration)
        report_interval = [
            oadr_20b.WsCalendarIntervalType(properties=properties)
        ]
        interval = [oadr_20b.IntervalType(dtstart=dtstart, duration=duration)]
        intervals = oadr_20b.intervals(interval=interval)
        return [
            oadr_20b.eiEventSignalType(intervals=intervals,
                                       signalName='simple',
                                       signalType='level')
        ]
Esempio n. 4
0
 def __str__(self):
     ret = ""
     if self.repeat:
         ret += "R%d/" % self.repeat
     if self.start and self.end:
         ret += "%s/%s" % (datetime_isoformat(
             self.start), datetime_isoformat(self.end))
     elif self.start and self.duration:
         ret += "%s/%s" % (datetime_isoformat(
             self.start), duration_isoformat(self.duration))
     elif self.duration and self.end:
         ret += "%s/%s" % (duration_isoformat(
             self.duration), datetime_isoformat(self.end))
     else:
         raise ISO8601Error(
             "Could not produce a valid ISO8601 interval string")
     return ret
Esempio n. 5
0
def seconds_to_isoduration(secs):
    #================================
    """
  Convert a duration to an ISO 8601 representation.

  :param secs: The duration in seconds.
  :type secs: float
  :return: A string representation of the duration formatted as ISO 8601.
  """
    return isoduration.duration_isoformat(
        timedelta(seconds=int(secs),
                  microseconds=int(1000000 * (float(secs) - int(secs))))
    ) if secs != 0.0 else "PT0S"  ## More meaningful than "P0D"
Esempio n. 6
0
def seconds_to_isoduration(secs):
    # ================================
    """
  Convert a duration to an ISO 8601 representation.

  :param secs: The duration in seconds.
  :type secs: float
  :return: A string representation of the duration formatted as ISO 8601.
  """
    return (
        isoduration.duration_isoformat(
            timedelta(seconds=int(secs), microseconds=int(1000000 * (float(secs) - int(secs))))
        )
        if secs != 0.0
        else "PT0S"
    )  ## More meaningful than "P0D"
Esempio n. 7
0
    def build_event_signal(site_event):
        event_start = site_event.dr_event.start
        event_end = site_event.dr_event.end
        event_duration = event_end - event_start

        seconds = event_duration.seconds

        # datetime.timedelta only has a seconds property, so pass in seconds to duration
        duration = isoduration.Duration(seconds=seconds)

        iso_duration = isoduration.duration_isoformat(duration)  # duration in iso format
        duration = oadr_20b.DurationPropType(duration=iso_duration)
        dtstart = oadr_20b.dtstart(date_time=event_start)
        properties = oadr_20b.properties(dtstart=dtstart, duration=duration)
        report_interval = [oadr_20b.WsCalendarIntervalType(properties=properties)]
        interval = [oadr_20b.IntervalType(dtstart=dtstart, duration=duration)]
        intervals = oadr_20b.intervals(interval=interval)
        return [oadr_20b.eiEventSignalType(intervals=intervals, signalName='simple',
                                           signalType='level')]
Esempio n. 8
0
    def build_active_period_properties(site_event):
        # Calculate duration
        event_start = site_event.dr_event.start
        event_end = site_event.dr_event.end
        event_duration = event_end - event_start
        seconds = event_duration.seconds
        # datetime.timedelta only has a seconds property, so pass in seconds to duration
        duration = isoduration.Duration(seconds=seconds)
        iso_duration = isoduration.duration_isoformat(duration)  # duration in iso format
        duration = oadr_20b.DurationPropType(duration=iso_duration)

        x_ei_notification = oadr_20b.DurationPropType(duration=iso_duration)
        dtstart = oadr_20b.dtstart(date_time=event_start)
        properties = oadr_20b.properties(dtstart=dtstart,
                                         duration=duration,
                                         x_eiNotification=x_ei_notification,
                                         x_eiRampUp=None, x_eiRecovery=None)

        return properties
Esempio n. 9
0
    def build_active_period_properties(site_event):
        # Calculate duration
        event_start = site_event.dr_event.start
        event_end = site_event.dr_event.end
        event_duration = event_end - event_start
        seconds = event_duration.seconds
        # datetime.timedelta only has a seconds property, so pass in seconds to duration
        duration = isoduration.Duration(seconds=seconds)
        iso_duration = isoduration.duration_isoformat(
            duration)  # duration in iso format
        duration = oadr_20b.DurationPropType(duration=iso_duration)

        x_ei_notification = oadr_20b.DurationPropType(duration=iso_duration)
        dtstart = oadr_20b.dtstart(date_time=event_start)
        properties = oadr_20b.properties(dtstart=dtstart,
                                         duration=duration,
                                         x_eiNotification=x_ei_notification,
                                         x_eiRampUp=None,
                                         x_eiRecovery=None)

        return properties
Esempio n. 10
0
 def convert_iso8601_timeout(self, timeout):
     #convert timeout to ISO8601 format
     return duration_isoformat(timedelta(int(timeout)))
Esempio n. 11
0
 def convert_iso8601_timeout(self, timeout):
     # convert timeout to ISO8601 format
     return duration_isoformat(timedelta(int(timeout)))