_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q258600 | DeploySatchel.manifest_filename | validation | def manifest_filename(self):
"""
Returns the path to the manifest file.
"""
r = self.local_renderer
tp_fn = r.format(r.env.data_dir + '/manifest.yaml')
return tp_fn | python | {
"resource": ""
} |
q258601 | DeploySatchel.get_current_thumbprint | validation | def get_current_thumbprint(self, components=None):
"""
Returns a dictionary representing the current configuration state.
Thumbprint is of the form:
{
component_name1: {key: value},
component_name2: {key: value},
...
}
... | python | {
"resource": ""
} |
q258602 | DeploySatchel.get_previous_thumbprint | validation | def get_previous_thumbprint(self, components=None):
"""
Returns a dictionary representing the previous configuration state.
Thumbprint is of the form:
{
component_name1: {key: value},
component_name2: {key: value},
...
}
... | python | {
"resource": ""
} |
q258603 | DeploySatchel.lock | validation | def lock(self):
"""
Marks the remote server as currently being deployed to.
"""
self.init()
r = self.local_renderer
if self.file_exists(r.env.lockfile_path):
raise exceptions.AbortDeployment('Lock file %s exists. Perhaps another deployment is currently underwa... | python | {
"resource": ""
} |
q258604 | DeploySatchel.unlock | validation | def unlock(self):
"""
Unmarks the remote server as currently being deployed to.
"""
self.init()
r = self.local_renderer
if self.file_exists(r.env.lockfile_path):
self.vprint('Unlocking %s.' % r.env.lockfile_path)
r.run_or_local('rm -f {lockfile_pat... | python | {
"resource": ""
} |
q258605 | DeploySatchel.fake | validation | def fake(self, components=None):#, set_satchels=None):
"""
Update the thumbprint on the remote server but execute no satchel configurators.
components = A comma-delimited list of satchel names to limit the fake deployment to.
set_satchels = A semi-colon delimited list of key-value pairs... | python | {
"resource": ""
} |
q258606 | DeploySatchel.get_component_funcs | validation | def get_component_funcs(self, components=None):
"""
Calculates the components functions that need to be executed for a deployment.
"""
current_tp = self.get_current_thumbprint(components=components) or {}
previous_tp = self.get_previous_thumbprint(components=components) or {}
... | python | {
"resource": ""
} |
q258607 | DeploySatchel.preview | validation | def preview(self, components=None, ask=0):
"""
Inspects differences between the last deployment and the current code state.
"""
ask = int(ask)
self.init()
component_order, plan_funcs = self.get_component_funcs(components=components)
print('\n%i changes found f... | python | {
"resource": ""
} |
q258608 | DeploySatchel.push | validation | def push(self, components=None, yes=0):
"""
Executes all satchel configurators to apply pending changes to the server.
"""
from burlap import notifier
service = self.get_satchel('service')
self.lock()
try:
yes = int(yes)
if not yes:
... | python | {
"resource": ""
} |
q258609 | DjangoSatchel.get_settings | validation | def get_settings(self, site=None, role=None):
"""
Retrieves the Django settings dictionary.
"""
r = self.local_renderer
_stdout = sys.stdout
_stderr = sys.stderr
if not self.verbose:
sys.stdout = StringIO()
sys.stderr = StringIO()
t... | python | {
"resource": ""
} |
q258610 | DjangoSatchel.createsuperuser | validation | def createsuperuser(self, username='admin', email=None, password=None, site=None):
"""
Runs the Django createsuperuser management command.
"""
r = self.local_renderer
site = site or self.genv.SITE
self.set_site_specifics(site)
options = ['--username=%s' % username... | python | {
"resource": ""
} |
q258611 | DjangoSatchel.loaddata | validation | def loaddata(self, path, site=None):
"""
Runs the Dango loaddata management command.
By default, runs on only the current site.
Pass site=all to run on all sites.
"""
site = site or self.genv.SITE
r = self.local_renderer
r.env._loaddata_path = path
... | python | {
"resource": ""
} |
q258612 | DjangoSatchel.manage | validation | def manage(self, cmd, *args, **kwargs):
"""
A generic wrapper around Django's manage command.
"""
r = self.local_renderer
environs = kwargs.pop('environs', '').strip()
if environs:
environs = ' '.join('export %s=%s;' % tuple(_.split('=')) for _ in environs.spl... | python | {
"resource": ""
} |
q258613 | DjangoSatchel.load_django_settings | validation | def load_django_settings(self):
"""
Loads Django settings for the current site and sets them so Django internals can be run.
"""
r = self.local_renderer
# Save environment variables so we can restore them later.
_env = {}
save_vars = ['ALLOW_CELERY', 'DJANGO_SETT... | python | {
"resource": ""
} |
q258614 | DjangoSatchel.shell | validation | def shell(self):
"""
Opens a Django focussed Python shell.
Essentially the equivalent of running `manage.py shell`.
"""
r = self.local_renderer
if '@' in self.genv.host_string:
r.env.shell_host_string = self.genv.host_string
else:
r.env.she... | python | {
"resource": ""
} |
q258615 | DjangoSatchel.syncdb | validation | def syncdb(self, site=None, all=0, database=None, ignore_errors=1): # pylint: disable=redefined-builtin
"""
Runs the standard Django syncdb command for one or more sites.
"""
r = self.local_renderer
ignore_errors = int(ignore_errors)
post_south = self.version_tuple >= (... | python | {
"resource": ""
} |
q258616 | DjangoSatchel.manage_async | validation | def manage_async(self, command='', name='process', site=ALL, exclude_sites='', end_message='', recipients=''):
"""
Starts a Django management command in a screen.
Parameters:
command :- all arguments passed to `./manage` as a single string
site :- the site to run the c... | python | {
"resource": ""
} |
q258617 | DjangoSatchel.get_media_timestamp | validation | def get_media_timestamp(self, last_timestamp=None):
"""
Retrieves the most recent timestamp of the media in the static root.
If last_timestamp is given, retrieves the first timestamp more recent than this value.
"""
r = self.local_renderer
_latest_timestamp = -1e99999999... | python | {
"resource": ""
} |
q258618 | DatabaseSatchel.set_root_login | validation | def set_root_login(self, r):
"""
Looks up the root login for the given database on the given host and sets
it to environment variables.
Populates these standard variables:
db_root_password
db_root_username
"""
# Check the legacy password locati... | python | {
"resource": ""
} |
q258619 | DatabaseSatchel.database_renderer | validation | def database_renderer(self, name=None, site=None, role=None):
"""
Renders local settings for a specific database.
"""
name = name or self.env.default_db_name
site = site or self.genv.SITE
role = role or self.genv.ROLE
key = (name, site, role)
self.vpri... | python | {
"resource": ""
} |
q258620 | DatabaseSatchel.get_free_space | validation | def get_free_space(self):
"""
Return free space in bytes.
"""
cmd = "df -k | grep -vE '^Filesystem|tmpfs|cdrom|none|udev|cgroup' | awk '{ print($1 \" \" $4 }'"
lines = [_ for _ in self.run(cmd).strip().split('\n') if _.startswith('/')]
assert len(lines) == 1, 'Ambiguous d... | python | {
"resource": ""
} |
q258621 | DatabaseSatchel.load_db_set | validation | def load_db_set(self, name, r=None):
"""
Loads database parameters from a specific named set.
"""
r = r or self
db_set = r.genv.db_sets.get(name, {})
r.genv.update(db_set) | python | {
"resource": ""
} |
q258622 | DatabaseSatchel.loadable | validation | def loadable(self, src, dst):
"""
Determines if there's enough space to load the target database.
"""
from fabric import state
from fabric.task_utils import crawl
src_task = crawl(src, state.commands)
assert src_task, 'Unknown source role: %s' % src
dst_... | python | {
"resource": ""
} |
q258623 | RaspberryPiSatchel.assume_localhost | validation | def assume_localhost(self):
"""
Sets connection parameters to localhost, if not set already.
"""
if not self.genv.host_string:
self.genv.host_string = 'localhost'
self.genv.hosts = ['localhost']
self.genv.user = getpass.getuser() | python | {
"resource": ""
} |
q258624 | RaspberryPiSatchel.init_raspbian_disk | validation | def init_raspbian_disk(self, yes=0):
"""
Downloads the latest Raspbian image and writes it to a microSD card.
Based on the instructions from:
https://www.raspberrypi.org/documentation/installation/installing-images/linux.md
"""
self.assume_localhost()
yes = int... | python | {
"resource": ""
} |
q258625 | RaspberryPiSatchel.init_ubuntu_disk | validation | def init_ubuntu_disk(self, yes=0):
"""
Downloads the latest Ubuntu image and writes it to a microSD card.
Based on the instructions from:
https://wiki.ubuntu.com/ARM/RaspberryPi
For recommended SD card brands, see:
http://elinux.org/RPi_SD_cards
Note,... | python | {
"resource": ""
} |
q258626 | RaspberryPiSatchel.init_raspbian_vm | validation | def init_raspbian_vm(self):
"""
Creates an image for running Raspbian in a QEMU virtual machine.
Based on the guide at:
https://github.com/dhruvvyas90/qemu-rpi-kernel/wiki/Emulating-Jessie-image-with-4.1.x-kernel
"""
r = self.local_renderer
r.comment('Inst... | python | {
"resource": ""
} |
q258627 | RaspberryPiSatchel.create_raspbian_vagrant_box | validation | def create_raspbian_vagrant_box(self):
"""
Creates a box for easily spinning up a virtual machine with Vagrant.
http://unix.stackexchange.com/a/222907/16477
https://github.com/pradels/vagrant-libvirt
"""
r = self.local_renderer
r.sudo('adduser --disabled-passwo... | python | {
"resource": ""
} |
q258628 | RaspberryPiSatchel.configure_hdmi | validation | def configure_hdmi(self):
"""
Configures HDMI to support hot-plugging, so it'll work even if it wasn't
plugged in when the Pi was originally powered up.
Note, this does cause slightly higher power consumption, so if you don't need HDMI,
don't bother with this.
http://ra... | python | {
"resource": ""
} |
q258629 | RaspberryPiSatchel.configure_camera | validation | def configure_camera(self):
"""
Enables access to the camera.
http://raspberrypi.stackexchange.com/questions/14229/how-can-i-enable-the-camera-without-using-raspi-config
https://mike632t.wordpress.com/2014/06/26/raspberry-pi-camera-setup/
Afterwards, test with:
... | python | {
"resource": ""
} |
q258630 | RaspberryPiSatchel.fix_lsmod_for_pi3 | validation | def fix_lsmod_for_pi3(self):
"""
Some images purporting to support both the Pi2 and Pi3 use the wrong kernel modules.
"""
r = self.local_renderer
r.env.rpi2_conf = '/etc/modules-load.d/rpi2.conf'
r.sudo("sed '/bcm2808_rng/d' {rpi2_conf}")
r.sudo("echo bcm2835_rng ... | python | {
"resource": ""
} |
q258631 | ServiceManagementSatchel.pre_deploy | validation | def pre_deploy(self):
"""
Runs methods services have requested be run before each deployment.
"""
for service in self.genv.services:
service = service.strip().upper()
funcs = common.service_pre_deployers.get(service)
if funcs:
print('Ru... | python | {
"resource": ""
} |
q258632 | ServiceManagementSatchel.deploy | validation | def deploy(self):
"""
Applies routine, typically application-level changes to the service.
"""
for service in self.genv.services:
service = service.strip().upper()
funcs = common.service_deployers.get(service)
if funcs:
print('Deploying... | python | {
"resource": ""
} |
q258633 | ServiceManagementSatchel.post_deploy | validation | def post_deploy(self):
"""
Runs methods services have requested be run before after deployment.
"""
for service in self.genv.services:
service = service.strip().upper()
self.vprint('post_deploy:', service)
funcs = common.service_post_deployers.get(serv... | python | {
"resource": ""
} |
q258634 | ServiceManagementSatchel.configure | validation | def configure(self):
"""
Applies one-time settings changes to the host, usually to initialize the service.
"""
print('env.services:', self.genv.services)
for service in list(self.genv.services):
service = service.strip().upper()
funcs = common.service_conf... | python | {
"resource": ""
} |
q258635 | ApacheSatchel.enable_mods | validation | def enable_mods(self):
"""
Enables all modules in the current module list.
Does not disable any currently enabled modules not in the list.
"""
r = self.local_renderer
for mod_name in r.env.mods_enabled:
with self.settings(warn_only=True):
self.... | python | {
"resource": ""
} |
q258636 | ApacheSatchel.optimize_wsgi_processes | validation | def optimize_wsgi_processes(self):
"""
Based on the number of sites per server and the number of resources on the server,
calculates the optimal number of processes that should be allocated for each WSGI site.
"""
r = self.local_renderer
#r.env.wsgi_processes = 5
... | python | {
"resource": ""
} |
q258637 | ApacheSatchel.create_local_renderer | validation | def create_local_renderer(self):
"""
Instantiates a new local renderer.
Override this to do any additional initialization.
"""
r = super(ApacheSatchel, self).create_local_renderer()
# Dynamically set values based on target operating system.
os_version = self.os_v... | python | {
"resource": ""
} |
q258638 | ApacheSatchel.install_auth_basic_user_file | validation | def install_auth_basic_user_file(self, site=None):
"""
Installs users for basic httpd auth.
"""
r = self.local_renderer
hostname = self.current_hostname
target_sites = self.genv.available_sites_by_host.get(hostname, None)
for _site, site_data in self.iter_sites... | python | {
"resource": ""
} |
q258639 | ApacheSatchel.sync_media | validation | def sync_media(self, sync_set=None, clean=0, iter_local_paths=0):
"""
Uploads select media to an Apache accessible directory.
"""
# Ensure a site is selected.
self.genv.SITE = self.genv.SITE or self.genv.default_site
r = self.local_renderer
clean = int(clean)
... | python | {
"resource": ""
} |
q258640 | ApacheSatchel.configure_modevasive | validation | def configure_modevasive(self):
"""
Installs the mod-evasive Apache module for combating DDOS attacks.
https://www.linode.com/docs/websites/apache-tips-and-tricks/modevasive-on-apache
"""
r = self.local_renderer
if r.env.modevasive_enabled:
self.install_packa... | python | {
"resource": ""
} |
q258641 | ApacheSatchel.configure_modsecurity | validation | def configure_modsecurity(self):
"""
Installs the mod-security Apache module.
https://www.modsecurity.org
"""
r = self.local_renderer
if r.env.modsecurity_enabled and not self.last_manifest.modsecurity_enabled:
self.install_packages()
# Write mo... | python | {
"resource": ""
} |
q258642 | ApacheSatchel.configure_modrpaf | validation | def configure_modrpaf(self):
"""
Installs the mod-rpaf Apache module.
https://github.com/gnif/mod_rpaf
"""
r = self.local_renderer
if r.env.modrpaf_enabled:
self.install_packages()
self.enable_mod('rpaf')
else:
if self.last_man... | python | {
"resource": ""
} |
q258643 | ApacheSatchel.maint_up | validation | def maint_up(self):
"""
Forwards all traffic to a page saying the server is down for maintenance.
"""
r = self.local_renderer
fn = self.render_to_file(r.env.maintenance_template, extra={'current_hostname': self.current_hostname})
r.put(local_path=fn, remote_path=r.env.mai... | python | {
"resource": ""
} |
q258644 | SupervisorSatchel.restart | validation | def restart(self):
"""
Supervisor can take a very long time to start and stop,
so wait for it.
"""
n = 60
sleep_n = int(self.env.max_restart_wait_minutes/10.*60)
for _ in xrange(n):
self.stop()
if self.dryrun or not self.is_running():
... | python | {
"resource": ""
} |
q258645 | SupervisorSatchel.deploy_services | validation | def deploy_services(self, site=None):
"""
Collects the configurations for all registered services and writes
the appropriate supervisord.conf file.
"""
verbose = self.verbose
r = self.local_renderer
if not r.env.manage_configs:
return
#
# tar... | python | {
"resource": ""
} |
q258646 | GitSatchel.clone | validation | def clone(self, remote_url, path=None, use_sudo=False, user=None):
"""
Clone a remote Git repository into a new directory.
:param remote_url: URL of the remote repository to clone.
:type remote_url: str
:param path: Path of the working copy directory. Must not exist yet.
... | python | {
"resource": ""
} |
q258647 | GitSatchel.add_remote | validation | def add_remote(self, path, name, remote_url, use_sudo=False, user=None, fetch=True):
"""
Add a remote Git repository into a directory.
:param path: Path of the working copy directory. This directory must exist
and be a Git working copy with a default remote to fetch from.
... | python | {
"resource": ""
} |
q258648 | GitSatchel.fetch | validation | def fetch(self, path, use_sudo=False, user=None, remote=None):
"""
Fetch changes from the default remote repository.
This will fetch new changesets, but will not update the contents of
the working tree unless yo do a merge or rebase.
:param path: Path of the working copy direct... | python | {
"resource": ""
} |
q258649 | GitSatchel.pull | validation | def pull(self, path, use_sudo=False, user=None, force=False):
"""
Fetch changes from the default remote repository and merge them.
:param path: Path of the working copy directory. This directory must exist
and be a Git working copy with a default remote to pull from.
... | python | {
"resource": ""
} |
q258650 | GitTrackerSatchel.get_logs_between_commits | validation | def get_logs_between_commits(self, a, b):
"""
Retrieves all commit messages for all commits between the given commit numbers
on the current branch.
"""
print('REAL')
ret = self.local('git --no-pager log --pretty=oneline %s...%s' % (a, b), capture=True)
if self.ver... | python | {
"resource": ""
} |
q258651 | GitTrackerSatchel.get_current_commit | validation | def get_current_commit(self):
"""
Retrieves the git commit number of the current head branch.
"""
with hide('running', 'stdout', 'stderr', 'warnings'):
s = str(self.local('git rev-parse HEAD', capture=True))
self.vprint('current commit:', s)
return s | python | {
"resource": ""
} |
q258652 | VagrantSatchel.ssh_config | validation | def ssh_config(self, name=''):
"""
Get the SSH parameters for connecting to a vagrant VM.
"""
r = self.local_renderer
with self.settings(hide('running')):
output = r.local('vagrant ssh-config %s' % name, capture=True)
config = {}
for line in output.sp... | python | {
"resource": ""
} |
q258653 | VagrantSatchel.version | validation | def version(self):
"""
Get the Vagrant version.
"""
r = self.local_renderer
with self.settings(hide('running', 'warnings'), warn_only=True):
res = r.local('vagrant --version', capture=True)
if res.failed:
return None
line = res.splitlines()... | python | {
"resource": ""
} |
q258654 | VagrantSatchel.vagrant | validation | def vagrant(self, name=''):
"""
Run the following tasks on a vagrant box.
First, you need to import this task in your ``fabfile.py``::
from fabric.api import *
from burlap.vagrant import vagrant
@task
def some_task():
run('echo h... | python | {
"resource": ""
} |
q258655 | VagrantSatchel.vagrant_settings | validation | def vagrant_settings(self, name='', *args, **kwargs):
"""
Context manager that sets a vagrant VM
as the remote host.
Use this context manager inside a task to run commands
on your current Vagrant box::
from burlap.vagrant import vagrant_settings
with va... | python | {
"resource": ""
} |
q258656 | VagrantSatchel.base_boxes | validation | def base_boxes(self):
"""
Get the list of vagrant base boxes
"""
return sorted(list(set([name for name, provider in self._box_list()]))) | python | {
"resource": ""
} |
q258657 | VagrantSatchel.install_from_upstream | validation | def install_from_upstream(self):
"""
Installs Vagrant from the most recent package available from their homepage.
"""
from burlap.system import get_arch, distrib_family
r = self.local_renderer
content = urlopen(r.env.download_url).read()
print(len(content))
... | python | {
"resource": ""
} |
q258658 | distrib_id | validation | def distrib_id():
"""
Get the OS distribution ID.
Example::
from burlap.system import distrib_id
if distrib_id() != 'Debian':
abort(u"Distribution is not supported")
"""
with settings(hide('running', 'stdout')):
kernel = (run('uname -s') or '').strip().lower(... | python | {
"resource": ""
} |
q258659 | distrib_release | validation | def distrib_release():
"""
Get the release number of the distribution.
Example::
from burlap.system import distrib_id, distrib_release
if distrib_id() == 'CentOS' and distrib_release() == '6.1':
print(u"CentOS 6.2 has been released. Please upgrade.")
"""
with settings... | python | {
"resource": ""
} |
q258660 | distrib_family | validation | def distrib_family():
"""
Get the distribution family.
Returns one of ``debian``, ``redhat``, ``arch``, ``gentoo``,
``sun``, ``other``.
"""
distrib = (distrib_id() or '').lower()
if distrib in ['debian', 'ubuntu', 'linuxmint', 'elementary os']:
return DEBIAN
elif distrib in ['re... | python | {
"resource": ""
} |
q258661 | supported_locales | validation | def supported_locales():
"""
Gets the list of supported locales.
Each locale is returned as a ``(locale, charset)`` tuple.
"""
family = distrib_family()
if family == 'debian':
return _parse_locales('/usr/share/i18n/SUPPORTED')
elif family == 'arch':
return _parse_locales('/e... | python | {
"resource": ""
} |
q258662 | CelerySatchel.force_stop | validation | def force_stop(self):
"""
Forcibly terminates all Celery processes.
"""
r = self.local_renderer
with self.settings(warn_only=True):
r.sudo('pkill -9 -f celery')
r.sudo('rm -f /tmp/celery*.pid') | python | {
"resource": ""
} |
q258663 | CelerySatchel.set_permissions | validation | def set_permissions(self):
"""
Sets ownership and permissions for Celery-related files.
"""
r = self.local_renderer
for path in r.env.paths_owned:
r.env.path_owned = path
r.sudo('chown {celery_daemon_user}:{celery_daemon_user} {celery_path_owned}') | python | {
"resource": ""
} |
q258664 | CelerySatchel.create_supervisor_services | validation | def create_supervisor_services(self, site):
"""
This is called for each site to render a Celery config file.
"""
self.vprint('create_supervisor_services:', site)
self.set_site_specifics(site=site)
r = self.local_renderer
if self.verbose:
print('r.en... | python | {
"resource": ""
} |
q258665 | BuildBotSatchel.check_ok | validation | def check_ok(self):
"""
Ensures all tests have passed for this branch.
This should be called before deployment, to prevent accidental deployment of code
that hasn't passed automated testing.
"""
import requests
if not self.env.check_ok:
return
... | python | {
"resource": ""
} |
q258666 | HostSatchel.is_present | validation | def is_present(self, host=None):
"""
Returns true if the given host exists on the network.
Returns false otherwise.
"""
r = self.local_renderer
r.env.host = host or self.genv.host_string
ret = r._local("getent hosts {host} | awk '{{ print $1 }}'", capture=True) or... | python | {
"resource": ""
} |
q258667 | HostSatchel.purge_keys | validation | def purge_keys(self):
"""
Deletes all SSH keys on the localhost associated with the current remote host.
"""
r = self.local_renderer
r.env.default_ip = self.hostname_to_ip(self.env.default_hostname)
r.env.home_dir = '/home/%s' % getpass.getuser()
r.local('ssh-keyg... | python | {
"resource": ""
} |
q258668 | HostSatchel.find_working_password | validation | def find_working_password(self, usernames=None, host_strings=None):
"""
Returns the first working combination of username and password for the current host.
"""
r = self.local_renderer
if host_strings is None:
host_strings = []
if not host_strings:
... | python | {
"resource": ""
} |
q258669 | HostSatchel.needs_initrole | validation | def needs_initrole(self, stop_on_error=False):
"""
Returns true if the host does not exist at the expected location and may need
to have its initial configuration set.
Returns false if the host exists at the expected location.
"""
ret = False
target_host_present... | python | {
"resource": ""
} |
q258670 | HostSatchel.initrole | validation | def initrole(self, check=True):
"""
Called to set default password login for systems that do not yet have passwordless
login setup.
"""
if self.env.original_user is None:
self.env.original_user = self.genv.user
if self.env.original_key_filename is None:
... | python | {
"resource": ""
} |
q258671 | HostnameSatchel.get_public_ip | validation | def get_public_ip(self):
"""
Gets the public IP for a host.
"""
r = self.local_renderer
ret = r.run(r.env.get_public_ip_command) or ''
ret = ret.strip()
print('ip:', ret)
return ret | python | {
"resource": ""
} |
q258672 | HostnameSatchel.configure | validation | def configure(self, reboot=1):
"""
Assigns a name to the server accessible from user space.
Note, we add the name to /etc/hosts since not all programs use
/etc/hostname to reliably identify the server hostname.
"""
r = self.local_renderer
for ip, hostname in self... | python | {
"resource": ""
} |
q258673 | partitions | validation | def partitions(device=""):
"""
Get a partition list for all disk or for selected device only
Example::
from burlap.disk import partitions
spart = {'Linux': 0x83, 'Swap': 0x82}
parts = partitions()
# parts = {'/dev/sda1': 131, '/dev/sda2': 130, '/dev/sda3': 131}
r ... | python | {
"resource": ""
} |
q258674 | getdevice_by_uuid | validation | def getdevice_by_uuid(uuid):
"""
Get a HDD device by uuid
Example::
from burlap.disk import getdevice_by_uuid
device = getdevice_by_uuid("356fafdc-21d5-408e-a3e9-2b3f32cb2a8c")
if device:
mount(device,'/mountpoint')
"""
with settings(hide('running', 'warnings',... | python | {
"resource": ""
} |
q258675 | ismounted | validation | def ismounted(device):
"""
Check if partition is mounted
Example::
from burlap.disk import ismounted
if ismounted('/dev/sda1'):
print ("disk sda1 is mounted")
"""
# Check filesystem
with settings(hide('running', 'stdout')):
res = run_as_root('mount')
for... | python | {
"resource": ""
} |
q258676 | query | validation | def query(query, use_sudo=True, **kwargs):
"""
Run a MySQL query.
"""
func = use_sudo and run_as_root or run
user = kwargs.get('mysql_user') or env.get('mysql_user')
password = kwargs.get('mysql_password') or env.get('mysql_password')
options = [
'--batch',
'--raw',
... | python | {
"resource": ""
} |
q258677 | create_user | validation | def create_user(name, password, host='localhost', **kwargs):
"""
Create a MySQL user.
Example::
import burlap
# Create DB user if it does not exist
if not burlap.mysql.user_exists('dbuser'):
burlap.mysql.create_user('dbuser', password='somerandomstring')
"""
w... | python | {
"resource": ""
} |
q258678 | database_exists | validation | def database_exists(name, **kwargs):
"""
Check if a MySQL database exists.
"""
with settings(hide('running', 'stdout', 'stderr', 'warnings'), warn_only=True):
res = query("SHOW DATABASES LIKE '%(name)s';" % {
'name': name
}, **kwargs)
return res.succeeded and (res == nam... | python | {
"resource": ""
} |
q258679 | create_database | validation | def create_database(name, owner=None, owner_host='localhost', charset='utf8',
collate='utf8_general_ci', **kwargs):
"""
Create a MySQL database.
Example::
import burlap
# Create DB if it does not exist
if not burlap.mysql.database_exists('myapp'):
b... | python | {
"resource": ""
} |
q258680 | MySQLSatchel.conf_path | validation | def conf_path(self):
"""
Retrieves the path to the MySQL configuration file.
"""
from burlap.system import distrib_id, distrib_release
hostname = self.current_hostname
if hostname not in self._conf_cache:
self.env.conf_specifics[hostname] = self.env.conf_defau... | python | {
"resource": ""
} |
q258681 | MySQLSatchel.prep_root_password | validation | def prep_root_password(self, password=None, **kwargs):
"""
Enters the root password prompt entries into the debconf cache
so we can set them without user interaction.
We keep this process separate from set_root_password() because we also need to do
this before installing the bas... | python | {
"resource": ""
} |
q258682 | MySQLSatchel.drop_views | validation | def drop_views(self, name=None, site=None):
"""
Drops all views.
"""
r = self.database_renderer
result = r.sudo("mysql --batch -v -h {db_host} "
#"-u {db_root_username} -p'{db_root_password}' "
"-u {db_user} -p'{db_password}' "
"--execute=\"SEL... | python | {
"resource": ""
} |
q258683 | tic_single_object_crossmatch | validation | def tic_single_object_crossmatch(ra, dec, radius):
'''This does a cross-match against the TIC catalog on MAST.
Speed tests: about 10 crossmatches per second. (-> 3 hours for 10^5 objects
to crossmatch).
Parameters
----------
ra,dec : np.array
The coordinates to cross match against, al... | python | {
"resource": ""
} |
q258684 | normalized_flux_to_mag | validation | def normalized_flux_to_mag(lcdict,
columns=('sap.sap_flux',
'sap.sap_flux_err',
'sap.sap_bkg',
'sap.sap_bkg_err',
'pdc.pdcsap_flux',
... | python | {
"resource": ""
} |
q258685 | get_time_flux_errs_from_Ames_lightcurve | validation | def get_time_flux_errs_from_Ames_lightcurve(infile,
lctype,
cadence_min=2):
'''Reads TESS Ames-format FITS light curve files.
MIT TOI alerts include Ames lightcurve files. This function gets the finite,
nonzero times, f... | python | {
"resource": ""
} |
q258686 | _pkl_periodogram | validation | def _pkl_periodogram(lspinfo,
plotdpi=100,
override_pfmethod=None):
'''This returns the periodogram plot PNG as base64, plus info as a dict.
Parameters
----------
lspinfo : dict
This is an lspinfo dict containing results from a period-finding
f... | python | {
"resource": ""
} |
q258687 | _pkl_magseries_plot | validation | def _pkl_magseries_plot(stimes, smags, serrs,
plotdpi=100,
magsarefluxes=False):
'''This returns the magseries plot PNG as base64, plus arrays as dict.
Parameters
----------
stimes,smags,serrs : np.array
The mag/flux time-series arrays along with... | python | {
"resource": ""
} |
q258688 | find_lc_timegroups | validation | def find_lc_timegroups(lctimes, mingap=4.0):
'''Finds gaps in the provided time-series and indexes them into groups.
This finds the gaps in the provided `lctimes` array, so we can figure out
which times are for consecutive observations and which represent gaps
between seasons or observing eras.
Pa... | python | {
"resource": ""
} |
q258689 | normalize_magseries | validation | def normalize_magseries(times,
mags,
mingap=4.0,
normto='globalmedian',
magsarefluxes=False,
debugmode=False):
'''This normalizes the magnitude time-series to a specified value.
This is used ... | python | {
"resource": ""
} |
q258690 | get_snr_of_dip | validation | def get_snr_of_dip(times,
mags,
modeltimes,
modelmags,
atol_normalization=1e-8,
indsforrms=None,
magsarefluxes=False,
verbose=True,
transitdepth=None,
... | python | {
"resource": ""
} |
q258691 | estimate_achievable_tmid_precision | validation | def estimate_achievable_tmid_precision(snr, t_ingress_min=10,
t_duration_hr=2.14):
'''Using Carter et al. 2009's estimate, calculate the theoretical optimal
precision on mid-transit time measurement possible given a transit of a
particular SNR.
The relation used i... | python | {
"resource": ""
} |
q258692 | given_lc_get_transit_tmids_tstarts_tends | validation | def given_lc_get_transit_tmids_tstarts_tends(
time,
flux,
err_flux,
blsfit_savpath=None,
trapfit_savpath=None,
magsarefluxes=True,
nworkers=1,
sigclip=None,
extra_maskfrac=0.03
):
'''Gets the transit start, middle, and end times for transits in... | python | {
"resource": ""
} |
q258693 | given_lc_get_out_of_transit_points | validation | def given_lc_get_out_of_transit_points(
time, flux, err_flux,
blsfit_savpath=None,
trapfit_savpath=None,
in_out_transit_savpath=None,
sigclip=None,
magsarefluxes=True,
nworkers=1,
extra_maskfrac=0.03
):
'''This gets the out-of-transit light curve point... | python | {
"resource": ""
} |
q258694 | _pycompress_sqlitecurve | validation | def _pycompress_sqlitecurve(sqlitecurve, force=False):
'''This just compresses the sqlitecurve. Should be independent of OS.
'''
outfile = '%s.gz' % sqlitecurve
try:
if os.path.exists(outfile) and not force:
os.remove(sqlitecurve)
return outfile
else:
... | python | {
"resource": ""
} |
q258695 | _pyuncompress_sqlitecurve | validation | def _pyuncompress_sqlitecurve(sqlitecurve, force=False):
'''This just uncompresses the sqlitecurve. Should be independent of OS.
'''
outfile = sqlitecurve.replace('.gz','')
try:
if os.path.exists(outfile) and not force:
return outfile
else:
with gzip.open(sq... | python | {
"resource": ""
} |
q258696 | _gzip_sqlitecurve | validation | def _gzip_sqlitecurve(sqlitecurve, force=False):
'''This just compresses the sqlitecurve in gzip format.
FIXME: this doesn't work with gzip < 1.6 or non-GNU gzip (probably).
'''
# -k to keep the input file just in case something explodes
if force:
cmd = 'gzip -k -f %s' % sqlitecurve
e... | python | {
"resource": ""
} |
q258697 | _gunzip_sqlitecurve | validation | def _gunzip_sqlitecurve(sqlitecurve):
'''This just uncompresses the sqlitecurve in gzip format.
FIXME: this doesn't work with gzip < 1.6 or non-GNU gzip (probably).
'''
# -k to keep the input .gz just in case something explodes
cmd = 'gunzip -k %s' % sqlitecurve
try:
subprocess.check... | python | {
"resource": ""
} |
q258698 | _validate_sqlitecurve_filters | validation | def _validate_sqlitecurve_filters(filterstring, lccolumns):
'''This validates the sqlitecurve filter string.
This MUST be valid SQL but not contain any commands.
'''
# first, lowercase, then _squeeze to single spaces
stringelems = _squeeze(filterstring).lower()
# replace shady characters
... | python | {
"resource": ""
} |
q258699 | _smartcast | validation | def _smartcast(castee, caster, subval=None):
'''
This just tries to apply the caster function to castee.
Returns None on failure.
'''
try:
return caster(castee)
except Exception as e:
if caster is float or caster is int:
return nan
elif caster is str:
... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.