Code Duplication    Length = 24-24 lines in 2 locations

mine/models/status.py 2 locations

@@ 176-199 (lines=24) @@
173
        else:
174
            status.computers.append(state)
175
176
    @log_stopping
177
    def stop(self, application, computer):
178
        """Record an application as no longer running on a computer."""
179
        for status in self.applications:
180
            if status.application == application.name:
181
                for state in status.computers:
182
                    if state.computer == computer.name:
183
                        self.counter += 1
184
                        state.timestamp.stopped = self.counter
185
                        return
186
                break
187
        else:
188
            status = None
189
190
        # Status not found, add the application/computer as stopped
191
        self.counter += 1
192
        state = State(computer.name)
193
        state.timestamp.stopped = self.counter
194
        if status is None:
195
            status = Status(application.name)
196
            status.computers.append(state)
197
            self.applications.append(status)
198
        else:
199
            status.computers.append(state)
200
@@ 151-174 (lines=24) @@
148
        status = self.find(application)
149
        status.next = computer.name
150
151
    @log_starting
152
    def start(self, application, computer):
153
        """Record an application as running on a computer."""
154
        for status in self.applications:
155
            if status.application == application.name:
156
                for state in status.computers:
157
                    if state.computer == computer.name:
158
                        self.counter += 1
159
                        state.timestamp.started = self.counter
160
                        return
161
                break
162
        else:
163
            status = None
164
165
        # Status not found, add the application/computer as started
166
        self.counter += 1
167
        state = State(computer.name)
168
        state.timestamp.started = self.counter
169
        if status is None:
170
            status = Status(application.name)
171
            status.computers.append(state)
172
            self.applications.append(status)
173
        else:
174
            status.computers.append(state)
175
176
    @log_stopping
177
    def stop(self, application, computer):