Beispiel #1
0
def test_format_time_diff():
    assert_equal(
        "1h:0m:0s", format_time_diff(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(60 * 60 * 1))
    )
    assert_equal("0s", format_time_diff(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(0)))
    assert_equal(
        "1d:12h:24m:32s", format_time_diff(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(131072))
    )
Beispiel #2
0
def test_format_time_diff():
    assert_equal(
        "1h:0m:0s",
        format_time_diff(datetime.datetime.fromtimestamp(0),
                         datetime.datetime.fromtimestamp(60 * 60 * 1)))
    assert_equal(
        "0s",
        format_time_diff(datetime.datetime.fromtimestamp(0),
                         datetime.datetime.fromtimestamp(0)))
    assert_equal(
        "1d:12h:24m:32s",
        format_time_diff(datetime.datetime.fromtimestamp(0),
                         datetime.datetime.fromtimestamp(131072)))
Beispiel #3
0
    def _init_attributes(self):
        self.queueName = self.job.profile.queueName
        self.jobName = self.job.profile.name
        self.user = self.job.profile.user
        self.mapProgress = self.job.status.mapProgress
        self.reduceProgress = self.job.status.reduceProgress
        self.setupProgress = self.job.status.setupProgress
        self.cleanupProgress = self.job.status.cleanupProgress

        if self.job.desiredMaps == 0:
            maps_percent_complete = 0
        else:
            maps_percent_complete = int(
                round(
                    float(self.job.finishedMaps) / self.job.desiredMaps * 100))

        self.desiredMaps = self.job.desiredMaps

        if self.job.desiredReduces == 0:
            reduces_percent_complete = 0
        else:
            reduces_percent_complete = int(
                round(
                    float(self.job.finishedReduces) / self.job.desiredReduces *
                    100))

        self.desiredReduces = self.job.desiredReduces
        self.maps_percent_complete = maps_percent_complete
        self.finishedMaps = self.job.finishedMaps
        self.finishedReduces = self.job.finishedReduces
        self.reduces_percent_complete = reduces_percent_complete
        self.startTimeMs = self.job.startTime
        self.startTimeFormatted = format_unixtime_ms(self.job.startTime)
        self.launchTimeMs = self.job.launchTime
        self.launchTimeFormatted = format_unixtime_ms(self.job.launchTime)

        self.finishTimeMs = self.job.finishTime
        self.finishTimeFormatted = format_unixtime_ms(self.job.finishTime)
        self.status = self.job.status.runStateAsString
        self.priority = self.job.priorityAsString
        self.jobFile = self.job.profile.jobFile

        finishTime = self.job.finishTime
        if finishTime == 0:
            finishTime = datetime.datetime.now()
        else:
            finishTime = datetime.datetime.fromtimestamp(finishTime / 1000)
        self.duration = finishTime - datetime.datetime.fromtimestamp(
            self.job.startTime / 1000)
        self.durationFormatted = format_time_diff(
            datetime.datetime.fromtimestamp(self.job.startTime / 1000),
            finishTime)
Beispiel #4
0
    def _init_attributes(self):
        self.queueName = i18n.smart_unicode(self.job.profile.queueName)
        self.jobName = i18n.smart_unicode(self.job.profile.name)
        self.user = i18n.smart_unicode(self.job.profile.user)
        self.mapProgress = self.job.status.mapProgress
        self.reduceProgress = self.job.status.reduceProgress
        self.setupProgress = self.job.status.setupProgress
        self.cleanupProgress = self.job.status.cleanupProgress

        if self.job.desiredMaps == 0:
            maps_percent_complete = 0
        else:
            maps_percent_complete = int(round(float(self.job.finishedMaps) / self.job.desiredMaps * 100))

        self.desiredMaps = self.job.desiredMaps

        if self.job.desiredReduces == 0:
            reduces_percent_complete = 0
        else:
            reduces_percent_complete = int(round(float(self.job.finishedReduces) / self.job.desiredReduces * 100))

        self.desiredReduces = self.job.desiredReduces
        self.maps_percent_complete = maps_percent_complete
        self.finishedMaps = self.job.finishedMaps
        self.finishedReduces = self.job.finishedReduces
        self.reduces_percent_complete = reduces_percent_complete
        self.startTimeMs = self.job.startTime
        self.startTimeFormatted = format_unixtime_ms(self.job.startTime)
        self.launchTimeMs = self.job.launchTime
        self.launchTimeFormatted = format_unixtime_ms(self.job.launchTime)

        self.finishTimeMs = self.job.finishTime
        self.finishTimeFormatted = format_unixtime_ms(self.job.finishTime)
        self.status = self.job.status.runStateAsString
        self.priority = self.job.priorityAsString
        self.jobFile = self.job.profile.jobFile

        finishTime = self.job.finishTime
        if finishTime == 0:
            finishTime = datetime.datetime.now()
        else:
            finishTime = datetime.datetime.fromtimestamp(finishTime / 1000)
        self.duration = finishTime - datetime.datetime.fromtimestamp(self.job.startTime / 1000)
        self.durationFormatted = format_time_diff(
            datetime.datetime.fromtimestamp(self.job.startTime / 1000), finishTime
        )