Chapters 4-6
Case study: Turtle
So Python has many "magic" methods, marked by double underscores surrounding the name. (for this reason, they're also sometimes called "dunder" methods.) Rake Ketter's guide on the subject is the best you'll find, it's very clear. We're just going to address __init__
here.
So __init__
is basically a method that gets called when you create a new "instance" of a class. Let's examine this with dogs...
# So first we're going to create a new "Dog" object. A dog knows it's name and how to bark.
class Dog(object):
def __init__(self, name, woof): # __init__ takes a couple variables, and `self`...
self.name = name # and assigns them as properties of "self".
root@mesos-master-dev:~/marathon# docker attach $(docker run -d -p 8080:8080 mesosphere/marathon --master zk://192.168.1.104:2181/mesos --zk_hosts 192.168.1.104:2181 --hostname 192.168.1.104:2181) | |
Nov 22, 2013 2:28:55 PM mesosphere.marathon.MarathonModule provideCandidate | |
INFO: Registering in Zookeeper with hostname:192.168.1.104:2181 | |
2013-11-22 14:28:55,184:12(0x7fb30aa83700):ZOO_INFO@log_env@658: Client environment:zookeeper.version=zookeeper C client 3.3.4 | |
2013-11-22 14:28:55,184:12(0x7fb30aa83700):ZOO_INFO@log_env@662: Client environment:host.name=6985af9a3528 | |
2013-11-22 14:28:55,184:12(0x7fb30aa83700):ZOO_INFO@log_env@669: Client environment:os.name=Linux | |
2013-11-22 14:28:55,184:12(0x7fb30aa83700):ZOO_INFO@log_env@670: Client environment:os.arch=3.8.0-29-generic | |
2013-11-22 14:28:55,184:12(0x7fb30aa83700):ZOO_INFO@log_env@671: Client environment:os.version=#42~precise1-Ubuntu SMP Wed Aug 14 16:19:23 UTC 2013 | |
2013-11-22 14:28:55,185:12(0x7fb30aa83700):ZOO_INFO@log_env@679: Client environment:user.name=(nul |
POST analytics-2013.11.06/_search | |
{ | |
"query": {"match_all": {}}, | |
"facets": { | |
"tags": { | |
"terms": { | |
"field": "params.tag", | |
"size": 10 | |
} | |
} |
So:
Figures from Wolfram Alpha
{% set root = salt["pillar.get"]("git-remote:location", "/opt/git-remote") %} | |
git: | |
pkg.installed: | |
- pkgs: | |
- git-core | |
git-remote-directory: | |
file.directory: | |
- name: {{ root }} | |
- user: root |
git-remote: | |
root: /opt/git-remote | |
repos: | |
- name: salt-repo | |
hooks: | |
post-receive: | | |
#!/bin/bash | |
echo "-------- pulling to /srv/salt --------" | |
test -d /srv/salt || mkdir -p /srv/salt |
# create the repo | |
salty-repo: | |
file.directory: | |
- name: /opt/git-remote/salty | |
- require: | |
- file: git-remote-directory | |
cmd.run: | |
- name: "git init /opt/git-remote/salty --bare" | |
- unless: "test -e /opt/git-remote/salty/HEAD" |