Code Duplication    Length = 24-24 lines in 2 locations

mine/status.py 2 locations

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