Skip to content

Instantly share code, notes, and snippets.

View adiroiban's full-sized avatar
🇺🇦
Slava Ukraini!

Adi Roiban adiroiban

🇺🇦
Slava Ukraini!
  • VGR, La Gomera
  • 10:25 (UTC +01:00)
View GitHub Profile
with nested(
patch(
'chevah.server.commons.commands.copyfile',
),
patch(
'chevah.server.commons.commands.generate_ssh_key',
return_value=(0, 'message'),
),
patch.object(
local_filesystem,
@adiroiban
adiroiban / remote_proxy.yml
Created March 15, 2013 10:06
Idea of describing salt state for proxy minion
#
# Define remote system config as a pillar
#
gateway:
host: hostname
port: 22
protocol: ssh | telnet # uses scp/ssh or rcp/rsh
ssh_key: "/path/on/local/minion"
server_fingerpring: '34:32:a4:32:32:32:a4:32:a4'
@adiroiban
adiroiban / reuse_threadpool.py
Last active December 15, 2015 05:29
Example to write test using multiple deferred in the same test.
class TestDatabaseHandlerSQLite(ServerTestCase):
"""
Integration tests for the SQLite database log handler.
"""
def setUp(self):
super(TestDatabaseHandlerSQLite, self).setUp()
self.pool = DBConnectionPool('sqlite://:memory:')
self.handler = DatabaseHandler(self.pool, capacity=1)
self.handler._scheduler = Clock()
@adiroiban
adiroiban / .gitconfig
Created March 22, 2013 09:21
My .gitconfig
[user]
name = Adi Roiban
email = adi.roiban@chevah.com
[alias]
ae = !"~/.local/opt/Sublime\\ Text\\ 2/sublime_text" ~/.gitconfig
st = status -s
ci = commit -a
cis = commit
push = push --tags
@adiroiban
adiroiban / tst.py
Last active December 15, 2015 10:19
dbpool
def __init__(self, url, pool_size_min=3, pool_size_max=8):
self._url = url
self._db_config = DBConfiguration(url)
self._pool = ConnectionPool(
self._db_config.driver_name,
cp_min=pool_size_min,
cp_max=pool_size_max,
**self._db_config.driver_arguments,
)
@adiroiban
adiroiban / in.py
Last active December 15, 2015 19:09
Describe an object persisted in DB using interfaces and schema.
class IDBEventEntry(IDBTable):
message_id = schema.db.Integer(name='event_id', description='Some docstring here', lenght=12)
class DBObject(TwistarDBObject):
def getColums():
"""
Return all db columns.
"""
@adiroiban
adiroiban / gist:5442928
Created April 23, 2013 11:44
Reactor stop with exit code.
def _exit(self, exit_code=0):
"""
Helper method for testing.
Use os._exit() to avoid re-raising SystemExit error.
When reactor is running add a hook to be called after reactor stop.
This is mocked in tests since we can not addSystemEventTrigger
multiple times for the same reactor.
try:
from chevah import altceva
altceva
except ImportError:
altceva = None
altceva
(1375-win-envir~)$ paver lint
---> brink.pavement_commons.lint
./make-windows-environment.js
21: E:0131: Single-quoted string preferred over double-quoted string.
23: E:0131: Single-quoted string preferred over double-quoted string.
23: E:0131: Single-quoted string preferred over double-quoted string.
37: E:0131: Single-quoted string preferred over double-quoted string.
40: E:0131: Single-quoted string preferred over double-quoted string.
48: E:0131: Single-quoted string preferred over double-quoted string.
61: E:0013: No semicolon is required to end a code block
@adiroiban
adiroiban / test.py
Created July 3, 2013 15:17
Chained
deferrer_connection = doConnection()
deferred_connection.addCallback(lambda result: getSchemaDeferred())
deferrer_connection.addCallback(cbStartFlushing)
deferrer_connection.addErrback(ebDisableLogger)
deferrer_connection.addErrback(ebConvertUnknownErrors)