Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: server/site_host_attributes.py

Issue 3454023: autotest: Test new meta files in crash directory (Closed) Base URL: http://git.chromium.org/git/autotest.git
Patch Set: Fix bug Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging, os, utils 5 import logging, os, utils
6 6
7 # Host attributes are specified a strings with the format: 7 # Host attributes are specified a strings with the format:
8 # <key>{,<value>}? 8 # <key>{,<value>}?
9 # 9 #
10 # A machine may have a list of strings for attributes like: 10 # A machine may have a list of strings for attributes like:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 class HostAttributes(object): 71 class HostAttributes(object):
72 72
73 73
74 def __init__(self, host): 74 def __init__(self, host):
75 """ 75 """
76 Create an instance of HostAttribute for the given hostname. 76 Create an instance of HostAttribute for the given hostname.
77 We look up the host in both the hardcoded configuration and 77 We look up the host in both the hardcoded configuration and
78 the AFE models if they can be found. 78 the AFE models if they can be found.
79 """ 79 """
80 self._add_attributes(_DEFAULT_ATTRIBUTES) 80 self._add_attributes(_DEFAULT_ATTRIBUTES)
81 if private_host_attributes is not None:
82 logging.info('Using your private_host_attributes file')
81 if host in private_host_attributes: 83 if host in private_host_attributes:
84 logging.info('Using private_host_attributes file for %s' % host)
82 self._add_attributes(private_host_attributes[host]) 85 self._add_attributes(private_host_attributes[host])
83 if has_models: 86 if has_models:
84 host_obj = models.Host.valid_objects.get(hostname=host) 87 host_obj = models.Host.valid_objects.get(hostname=host)
85 self._add_attributes([label.name for label in 88 self._add_attributes([label.name for label in
86 host_obj.labels.all()]) 89 host_obj.labels.all()])
87 for key, value in self.__dict__.items(): 90 for key, value in self.__dict__.items():
88 logging.info('Host attribute: %s => %s', key, value) 91 logging.info('Host attribute: %s => %s', key, value)
89 92
90 93
91 def _add_attributes(self, attributes): 94 def _add_attributes(self, attributes):
92 for attribute in attributes: 95 for attribute in attributes:
93 splitnames = attribute.split(',') 96 splitnames = attribute.split(',')
94 value = ','.join(splitnames[1:]) 97 value = ','.join(splitnames[1:])
95 if len(splitnames) == 1: 98 if len(splitnames) == 1:
96 continue 99 continue
97 if value == 'True': 100 if value == 'True':
98 value = True 101 value = True
99 elif value == 'False': 102 elif value == 'False':
100 value = False 103 value = False
101 elif splitnames[1] == 'string' and len(splitnames) > 2: 104 elif splitnames[1] == 'string' and len(splitnames) > 2:
102 value = ','.join(splitnames[2:]) 105 value = ','.join(splitnames[2:])
103 else: 106 else:
104 logging.info('Non-attribute string "%s" is ignored' % attribute) 107 logging.info('Non-attribute string "%s" is ignored' % attribute)
105 continue 108 continue
106 setattr(self, splitnames[0], value) 109 setattr(self, splitnames[0], value)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698