Skip to content

Instantly share code, notes, and snippets.

@jfindlay
jfindlay / watch_equivalent.sls
Last active May 1, 2019 18:46
Equivalent of `service.running`+`watch`
# Watch version
my-file-watch:
file.managed:
- name: /etc/file.conf
- source: salt://file.conf
my-service-watch:
service.running:
- name: my-service
- watch:
- file: my-file-watch
@jfindlay
jfindlay / shell_requisite_test.sls
Last active April 10, 2019 07:08
Salt Requisite Tests for `cmd` State
# The `cmd` state implements its own `onlyif` and `unless` requisites. This sls demonstrates how they are interpreted.
{%- if grains['kernel'] == 'Linux' %}
echo onlyif true:
cmd.run:
- onlyif:
- '[ "a" = "a" ]'
echo onlyif false:
cmd.run:
- onlyif:
jmoney-main ~ master # pip search salt
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/search.py", line 43, in run
    pypi_hits = self.search(query, options)
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/search.py", line 60, in search
    hits = pypi.search({'name': query, 'summary': query}, 'or')
  • Is it possible to get IntA.__new__ to return an object of type IntA without calling __new__ on the parent class?
  • Is this situation unique to integer or builtin types?
>>> class IntA(int):
...  def __new__(cls, i=0):
...   return i
...
>>> class IntB(int):
...  def __new__(cls, i=0):
... return int.__new__(cls, i)

Why are only the properties defined in __init__ listed in the __dict__ attribute of an instance of the class?

Python 3.4.3 (default, Jan 11 2016, 09:37:52)
[GCC 4.9.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> class C(object):
...     prop_1 = 'value 1'
...     def __init__(self):
...         self.prop_2 = 'value 2'
... def set_prop_3(self):
# ID == name
/file/one: # ID and name
file.absent:
# ID != name
remove file one: # ID
file.absent:
- name: /file/one # name