text stringlengths 0 828 |
|---|
if klass in self.PRIMITIVE_TYPES: |
return self.__deserialize_primitive(data, klass) |
elif klass == object: |
return self.__deserialize_object(data) |
elif klass == datetime.date: |
return self.__deserialize_date(data) |
elif klass == datetime.datetime: |
return self.__deserialize_datatime(data) |
else: |
return self.__deserialize_model(data, klass)" |
4498,"def update_params_for_auth(self, headers, querys, auth_settings): |
""""""Updates header and query params based on authentication setting. |
:param headers: Header parameters dict to be updated. |
:param querys: Query parameters tuple list to be updated. |
:param auth_settings: Authentication setting identifiers list. |
"""""" |
if self.auth_token_holder.token is not None: |
headers[Configuration.AUTH_TOKEN_HEADER_NAME] = self.auth_token_holder.token |
else: |
headers['Authorization'] = self.configuration.get_basic_auth_token()" |
4499,"def start(self, service): |
"""""" |
Start the service, catching and logging exceptions |
"""""" |
try: |
map(self.start_class, service.depends) |
if service.is_running(): |
return |
if service in self.failed: |
log.warning(""%s previously failed to start"", service) |
return |
service.start() |
except Exception: |
log.exception(""Unable to start service %s"", service) |
self.failed.add(service)" |
4500,"def start_class(self, class_): |
"""""" |
Start all services of a given class. If this manager doesn't already |
have a service of that class, it constructs one and starts it. |
"""""" |
matches = filter(lambda svc: isinstance(svc, class_), self) |
if not matches: |
svc = class_() |
self.register(svc) |
matches = [svc] |
map(self.start, matches) |
return matches" |
4501,"def stop_class(self, class_): |
""Stop all services of a given class"" |
matches = filter(lambda svc: isinstance(svc, class_), self) |
map(self.stop, matches)" |
4502,"def log_root(self): |
"""""" |
Find a directory suitable for writing log files. It uses sys.prefix |
to use a path relative to the root. If sys.prefix is /usr, it's the |
system Python, so use /var/log. |
"""""" |
var_log = ( |
os.path.join(sys.prefix, 'var', 'log') |
.replace('/usr/var', '/var') |
) |
if not os.path.isdir(var_log): |
os.makedirs(var_log) |
return var_log" |
4503,"def _get_more_data(self, file, timeout): |
"""""" |
Return data from the file, if available. If no data is received |
by the timeout, then raise RuntimeError. |
"""""" |
timeout = datetime.timedelta(seconds=timeout) |
timer = Stopwatch() |
while timer.split() < timeout: |
data = file.read() |
if data: |
return data |
raise RuntimeError(""Timeout"")" |
4504,"def _run_env(self): |
"""""" |
Augment the current environment providing the PYTHONUSERBASE. |
"""""" |
env = dict(os.environ) |
env.update( |
getattr(self, 'env', {}), |
PYTHONUSERBASE=self.env_path, |
PIP_USER=""1"", |
) |
self._disable_venv(env) |
return env" |
4505,"def _disable_venv(self, env): |
"""""" |
Disable virtualenv and venv in the environment. |
"""""" |
venv = env.pop('VIRTUAL_ENV', None) |
if venv: |
venv_path, sep, env['PATH'] = env['PATH'].partition(os.pathsep)" |
4506,"def create_env(self): |
"""""" |
Create a PEP-370 environment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.