Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
fix ADBLogWatch instance
Browse files Browse the repository at this point in the history
  • Loading branch information
maticrivo committed Jun 21, 2015
1 parent 0da431c commit 22f9c68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions magneto/utils/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ def __init__(self):
self._watchers = {}
self.asked_to_stop = False

if self.__class__.instance is not None:
raise RuntimeError('Only one instance of {} is allowed at any time.'.format(self.__class__.__name__))

self.__class__.instance = self

@classmethod
def wrap(cls, fn):
@wraps(fn)
Expand All @@ -181,16 +186,11 @@ def wrapper(instance, *args, **kwargs):
return wrapper

def __enter__(self, *_):
if self.__class__.instance is not None:
raise RuntimeError('Only one instance of {} is allowed at any time.'.format(self.__class__.__name__))

self.__class__.instance = self
self.start()
return self

def __exit__(self, *_):
self.exit()
self.__class__.instance = None

def run(self):
p = ADB.exec_cmd('logcat', stdout=subprocess.PIPE)
Expand All @@ -213,6 +213,7 @@ def run(self):
Logger.debug('ADB logcat process terminated')

def exit(self):
self.__class__.instance = None
self.asked_to_stop = True
self.join()

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='magneto',
version='0.31',
version='0.31.1',
description='Magneto - Test Automation for Android',
author='EverythingMe',
author_email='automation@everything.me',
Expand Down

0 comments on commit 22f9c68

Please sign in to comment.