Commit cfdf4601 authored by peletskyi's avatar peletskyi Committed by Commit bot

Added log messages for cases of failure of open files in policy_testserver.py.

Improved logging in chrome code in case of error in policy fetching.

BUG=489230

Review URL: https://codereview.chromium.org/1140333002

Cr-Commit-Position: refs/heads/master@{#330350}
parent f7ff218f
...@@ -79,6 +79,7 @@ except ImportError: ...@@ -79,6 +79,7 @@ except ImportError:
try: try:
import json import json
except ImportError: except ImportError:
logging.error('Could not import json')
json = None json = None
import asn1der import asn1der
...@@ -91,12 +92,14 @@ import cloud_policy_pb2 as cp ...@@ -91,12 +92,14 @@ import cloud_policy_pb2 as cp
try: try:
import chrome_extension_policy_pb2 as ep import chrome_extension_policy_pb2 as ep
except ImportError: except ImportError:
logging.error('Could not import chrome_extension_policy_pb2')
ep = None ep = None
# Device policy is only available on Chrome OS builds. # Device policy is only available on Chrome OS builds.
try: try:
import chrome_device_policy_pb2 as dp import chrome_device_policy_pb2 as dp
except ImportError: except ImportError:
logging.error('Could not import chrome_device_policy_pb2')
dp = None dp = None
# ASN.1 object identifier for PKCS#1/RSA. # ASN.1 object identifier for PKCS#1/RSA.
...@@ -986,12 +989,12 @@ class PolicyTestServer(testserver_base.BrokenPipeHandlerMixIn, ...@@ -986,12 +989,12 @@ class PolicyTestServer(testserver_base.BrokenPipeHandlerMixIn,
""" """
policy = {} policy = {}
if json is None: if json is None:
print 'No JSON module, cannot parse policy information' logging.error('No JSON module, cannot parse policy information')
else : else :
try: try:
policy = json.loads(open(self.policy_path).read(), strict=False) policy = json.loads(open(self.policy_path).read(), strict=False)
except IOError: except IOError:
print 'Failed to load policy from %s' % self.policy_path logging.error('Failed to load policies from %s' % self.policy_path)
return policy return policy
def RegisterDevice(self, device_id, machine_id, type): def RegisterDevice(self, device_id, machine_id, type):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment