text
stringlengths
0
828
raise GanetiApiError(""Can't work with Ganeti RAPI version %d"" %
version)
logging.info(""Accessing Ganeti RAPI, version %d"" % version)
self.version = version
try:
features = self.request(""get"", ""/2/features"")
except NotOkayError, noe:
if noe.code == 404:
# Okay, let's calm down, this is totally reasonable. Certain
# older Ganeti RAPIs don't have a list of features.
features = []
else:
# No, wait, panic was the correct thing to do.
raise
logging.info(""RAPI features: %r"" % (features,))
self.features = features"
1805,"def _create_driver(self, **kwargs):
""""""
Create webdriver, assign it to ``self.driver``, and run webdriver
initiation process, which is usually used for manual login.
""""""
if self.driver is None:
self.driver = self.create_driver(**kwargs)
self.init_driver_func(self.driver)"
1806,"def get_html(self,
url,
params=None,
cache_cb=None,
**kwargs):
""""""
Get html of an url.
""""""
url = add_params(url, params)
cache_consumed, value = self.try_read_cache(url)
if cache_consumed:
html = value
else:
self._create_driver()
self.driver.get(url)
html = self.driver.page_source
if self.should_we_update_cache(html, cache_cb, cache_consumed):
self.cache.set(
url, html,
expire=kwargs.get(""cache_expire"", self.cache_expire),
)
return html"
1807,"def deserialize_time(data):
""""""Return a time instance based on the values of the data param""""""
parsed = parser.parse(data)
return parsed.time().replace(tzinfo=parsed.tzinfo)"
1808,"def freeze():
'''
Show arguments to require() to recreate what has been installed
'''
installations = {}
for dist in get_installed_distributions():
req = pip.FrozenRequirement.from_dist(dist, [], find_tags=False)
installations[req.name] = req
return [str(installation).rstrip() for installation in
sorted(installations.values(), key=lambda x: x.name.lower())]"
1809,"def require(*args, **kwargs):
'''
Install a set of packages using pip
This is designed to be an interface for IPython notebooks that
replicates the requirements.txt pip format. This lets notebooks
specify which versions of packages they need inside the notebook
itself.
This function is the general-purpose interface that lets
the caller specify any version string for any package.
'''
# If called with no arguments, returns requirements list
if not args and not kwargs:
return freeze()
# Construct array of requirements
requirements = list(args)
extra = ['{}{}'.format(kw, kwargs[kw]) for kw in kwargs]
requirements.extend(extra)
args = ['install', '-q']
args.extend(requirements)
pip.main(args)"
1810,"def handle(self, *args, **options):
""""""
Compares current database with a migrations.
Creates a temporary database, applies all the migrations to it, and
then dumps the schema from both current and temporary, diffs them,
then report the diffs to the user.
""""""
self.db = options.get(""database"", DEFAULT_DB_ALIAS)
self.current_name = connections[self.db].settings_dict[""NAME""]
self.compare_name = options.get(""db_name"")