Permalink
Browse files

Don't run while in debug mode.

svn path=/plone.phonehome/trunk/; revision=49957
  • Loading branch information...
1 parent 5e26f2c commit 9cd60dae3adf42c4a04d21758197d26ba006b523 Eric Steele committed May 21, 2011
Showing with 54 additions and 36 deletions.
  1. +8 −0 CHANGES.txt
  2. +0 −1 TODO.txt
  3. +45 −34 plone/phonehome/__init__.py
  4. +1 −1 setup.py
View
@@ -3,12 +3,20 @@ CHANGES
=======
+1.0a3 - 2011-05-21
+------------------
+
+- Don't check in when running in Zope debug mode.
+ [esteele]
+
+
1.0a2 - 2011-05-21
------------------
- Ignore ConflictErrors when adding the plonephonehomeid.
[esteele]
+
1.0a1 - 2011-05-21
------------------
View
@@ -1,3 +1,2 @@
- * Don't run when in fg mode
* Don't run during bin/instance adduser
@@ -11,45 +11,56 @@
logger = logging.getLogger('plone.phonehome')
+def getDebugModeStatus():
+ # TODO Does this cover all options?
+ try:
+ from Products.Five.fiveconfigure import debug_mode
+ return debug_mode
+ except ImportError:
+ from App.config import getConfiguration
+ return getConfiguration().debug_mode
+
def initialize(context):
- # build environment description
- workingset = [(dist.project_name, dist.version) for dist in
- pkg_resources.working_set]
- workingset.sort()
+ # Don't run if Zope is running in Debug Mode.
+ if not getDebugModeStatus():
+ # build environment description
+ workingset = [(dist.project_name, dist.version) for dist in
+ pkg_resources.working_set]
+ workingset.sort()
- out = StringIO.StringIO()
- writerow = csv.writer(out).writerow
+ out = StringIO.StringIO()
+ writerow = csv.writer(out).writerow
- [writerow(row) for row in workingset]
+ [writerow(row) for row in workingset]
- ws = out.getvalue()
- wshash = hashlib.md5(ws).hexdigest()
+ ws = out.getvalue()
+ wshash = hashlib.md5(ws).hexdigest()
- # checker.setWorkingsetInfo(ws, wshash)
+ # checker.setWorkingsetInfo(ws, wshash)
- # Check for existing uid, otherwise, create a new one
- import Zope2
- app = Zope2.app()
- uid = getattr(app,'plonephonehomeid', None)
- if not uid:
- uid = uuid.uuid1().hex
- app.plonephonehomeid = uid
- try:
- import transaction
- transaction.commit()
- except ConflictError:
- pass # Ignore
+ # Check for existing uid, otherwise, create a new one
+ import Zope2
+ app = Zope2.app()
+ uid = getattr(app,'plonephonehomeid', None)
+ if not uid:
+ uid = uuid.uuid1().hex
+ app.plonephonehomeid = uid
+ try:
+ import transaction
+ transaction.commit()
+ except ConflictError:
+ pass # Ignore
- # Phone home
- timeout = socket.getdefaulttimeout()
- socket.setdefaulttimeout(CALL_TIMEOUT)
- logger.info("Connecting to plone.phonehome service.")
- try:
- checker.checkVersions(uid, ws, wshash)
- except ConnectionProblem, e:
- logger.warning("plone.phonehome connection failed with error: %s" % e)
- else:
- logger.info("Connection complete.")
- finally:
- socket.setdefaulttimeout(timeout)
+ # Phone home
+ timeout = socket.getdefaulttimeout()
+ socket.setdefaulttimeout(CALL_TIMEOUT)
+ logger.info("Connecting to plone.phonehome service.")
+ try:
+ checker.checkVersions(uid, ws, wshash)
+ except ConnectionProblem, e:
+ logger.warning("plone.phonehome connection failed with error: %s" % e)
+ else:
+ logger.info("Connection complete.")
+ finally:
+ socket.setdefaulttimeout(timeout)
View
@@ -1,7 +1,7 @@
import os
from setuptools import setup, find_packages
-version = '1.0a2'
+version = '1.0a3'
setup(name='plone.phonehome',

0 comments on commit 9cd60da

Please sign in to comment.