split file and check streaming http://linux.die.net/man/1/split
split -d -l 300 file.txt prefix
python mims_files.py
grep X321 MS*txt | cut -f1 | cut -c11-
galera mariadb clustering
http://nicolargo.github.io/glances/
http://www.domalgebra.com/index.html
RETURN SQL table as json in python
http://stackoverflow.com/questions/3286525/return-sql-table-as-json-in-python
http://geert.vanderkelen.org/column-info-using-connector-python/
http://geert.vanderkelen.org/connectorpython-custom-cursors/
apple.abe@soliant.local
https://versions.soliantconsulting.com/stash/login?next=/profile
http://habrahabr.ru/company/yandex/blog/242795/ PyTest
Angular: populate table from JSON
http://www.reddit.com/r/angularjs/comments/221qj3/best_practice_when_calling_a_json_api_to_populate/
Testing HTTP
https://curlbuilder.com/
https://news.ycombinator.com/item?id=9425992 CURL
http://dumpsterventures.com/jason/httpry/
http://www.reddit.com/r/javascript/comments/2bgaxw/alternatives_to_the_chrome_app_postman/
http://isbullsh.it/2012/06/Rest-api-in-python/
http://orchestrate.io/blog/2014/03/13/howto-test-http-apis-like-orchestrate/
http://blazemeter.com/blog/testing-soaprest-web-services-using-jmeter
https://github.com/basicallydan/interfake
http://luckymarmot.com/paw PAW Mac REST API TEST
https://github.com/kevin1024/vcrpy
http://www.reddit.com/r/Python/comments/258m68/vcrpy_automatically_mock_your_http_interactions/
http://blog.getpostman.com/index.php/2014/05/12/meet-newman-a-command-line-companion-for-postman/
https://news.ycombinator.com/item?id=7716444
Python -m SimpleHTTPServer {port} #defaut: listen to port 8000
Flask listen to port 5000
Flask+Angular
~/Angular/mmm/View.py:
69 class View(flask.views.MethodView):
70 def get(self):
71: return render_template('main.html')
~/Angular/mmm/static/js/navtabs.directive.js:
5 restrict: 'E',
6 replace: true,
7: templateUrl: '../static/navtabs.html',
8 scope: {
9 pageName: '='
/Users/mlubinsky/Angular/mmm/static/js/app.js:
9 $routeProvider
10 .when('/', {
11: templateUrl: '../static/summary.html',
12 controller: 'SummaryController'
13 })
14 .when('/channels', {
15: templateUrl: '../static/channels.html',
16 controller: 'ChannelsController'
17 })
18 .when('/search', {
19: templateUrl: '../static/search.html',
20 controller: 'SearchController'
21 })
22 .when('/map', {
23: templateUrl: '../static/map.html',
24 controller: 'MapController'
25 })
26 .when('/login', {
27: templateUrl: '../static/login.html',
28 controller: 'LoginController'
29 })
Install brew from http://brew.sh/
brew git
brew python
Result:
ls /usr/local/Cellar/
gdbm pkg-config readline git python sqlite
pip install glances
which ansible
TESTING - SOLIANT
https://workbench.soliantconsulting.com/browse/ABEQA
https://whiteboard.soliantconsulting.com/display/appbatt/Environments Test Env#3
https://whiteboard.soliantconsulting.com/display/appbatt/Platform+daemonization+commands
http://bdmscapsd001.apple.com:10081/ZendServer/ admin/password
RabbitMQ admin/admin
http://192.168.40.20:15672/#/queues
http://bdmscapsd003.apple.com:15672/#/ RabbitMQ ?
My Mac
http://localhost:8888/MAMP/?language=English MAMP
http://localhost:8888 Zend 2
MAMP: by default, Apache runs on Port 8888 and MySQL on Port 8889 (root / root)
configParser
http://docs.python.org/2/library/configparser.html
installing Mongo
http://www.journaldev.com/2330/how-to-install-mongodb-on-mac-os-x-and-run-as-service
brew install mongodb
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/mongodb-2.4.9.mavericks.bottle.tar.gz
==> Pouring mongodb-2.4.9.mavericks.bottle.tar.gz
==> Caveats
To have launchd start mongodb at login:
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
Then to load mongodb now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
mongod
==> Summary
/usr/local/Cellar/mongodb/2.4.9: 18 files, 271M
CODE TO TRAVERSE MONGO COLLECTIONS
from pymongo import MongoClient
con = MongoClient('localhost', 27017)
print(con.database_names()) # [u'db', u'db_name', u'local']
con.db.collection.insert({'foo': 'bar'}, w=1)
coll = con.db_name.collection_name
docs = [{"_id" : 1, "foo" : "HELLO"}, {"_id" : 2, "Blah" : "Bloh"}]
for doc in docs:
coll.save(doc)
db_names = con.database_names()
for db_name in db_names:
print "->db_name: ", db_name,
print "->con: ", con[db_name]
# find list of all collections
col_names = con[db_name].collection_names()
for col_name in col_names:
print " --col_name: ",col_name
print " --count: ", con[db_name][col_name].count()
for item in con[db_name][col_name].find():
print " item: ", item
Output
[u'db', u'db_name', u'local']
->db_name: db ->con: Database(MongoClient('localhost', 27017), u'db')
--col_name: system.indexes
--count: 1
item: {u'ns': u'db.collection', u'name': u'_id_', u'key': {u'_id': 1}, u'v': 1}
--col_name: collection
--count: 1
item: {u'_id': ObjectId('52edcb085b199c0da48bc396'), u'foo': u'bar'}
->db_name: db_name ->con: Database(MongoClient('localhost', 27017), u'db_name')
--col_name: system.indexes
--count: 1
item: {u'ns': u'db_name.collection_name', u'name': u'_id_', u'key': {u'_id': 1}, u'v': 1}
--col_name: collection_name
--count: 2
item: {u'_id': 1, u'foo': u'HELLO'}
item: {u'Blah': u'Bloh', u'_id': 2}
->db_name: local ->con: Database(MongoClient('localhost', 27017), u'local')
--col_name: startup_log
--count: 1
item: {u'hostname': u'Michaels-MacBook-Pro-5.local', u'pid': 3425, u'startTimeLocal': u'Sat Feb 1 20:17:01.846', u'cmdLine': {u'logpath': u'/usr/local/var/log/mongodb/mongo.log', u'config': u'/usr/local/etc/mongod.conf', u'logappend': u'true', u'bind_ip': u'127.0.0.1', u'dbpath': u'/Users/mlubinsky/MONGODATA'}, u'startTime': datetime.datetime(2014, 2, 2, 4, 17, 1), u'_id': u'Michaels-MacBook-Pro-5.local-1391314621846', u'buildinfo': {u'bits': 64, u'javascriptEngine': u'V8', u'version': u'2.4.9', u'gitVersion': u'nogitversion', u'versionArray': [2, 4, 9, 0], u'debug': False, u'compilerFlags': u'-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -O3 -m64', u'maxBsonObjectSize': 16777216, u'sysInfo': u'Darwin minimavericks.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49', u'loaderFlags': u'-fPIC -pthread -rdynamic -m64', u'allocator': u'tcmalloc'}}
PYTHON TESTING
http://lists.idyll.org/pipermail/testing-in-python/
http://www.drdobbs.com/article/print?articleId=240165163&siteSectionName=testing
http://www.jeffknupp.com/blog/2013/12/09/improve-your-python-understanding-unit-testing/
http://dustinrcollins.com/post/62564949954/testing-python-command-line-apps
http://blog.safaribooksonline.com/2013/12/05/flask-with-mock-and-nose/
http://packages.python.org/Attest/
http://docs.python.org/2/library/unittest.html
http://pythontesting.net/framework/unittest/unittest-introduction/
http://eli.thegreenplace.net/2014/04/02/dynamically-generating-python-test-cases/
В python 2.7 в unittest добавили много новых интересных вещей:
- дополнительные проверки (assert*),
- декораторы, позволяющие пропустить отдельный тест (@skip, @skipIf) или
обозначить сломанные тесты, о которых разработчику известно (@expectedFailure)
$ python -m unittest -h
Usage: python -m unittest [options] [tests]
Options:
-h, --help Show this message
-v, --verbose Verbose output
-q, --quiet Minimal output
-f, --failfast Stop on first failure
-c, --catch Catch control-C and display results
-b, --buffer Buffer stdout and stderr during test runs
Examples:
python -m unittest test_module - run tests from test_module
python -m unittest module.TestClass - run tests from module.TestClass
python -m unittest module.Class.test_method - run specified test method
[tests] can be a list of any number of test modules, classes and test
methods.
Alternative Usage: python -m unittest discover [options]
Options:
-v, --verbose Verbose output
-f, --failfast Stop on first failure
-c, --catch Catch control-C and display results
-b, --buffer Buffer stdout and stderr during test runs
-s directory Directory to start discovery ('.' default)
-p pattern Pattern to match test files ('test*.py' default)
-t directory Top level directory of project (default to
start directory)
For test discovery all test modules must be importable from the top
level directory of the project.
http://stackoverflow.com/questions/4891671/how-do-i-use-the-unittest-setupclass-method
http://pythontesting.net/framework/unittest/unittest-fixtures/
http://gahcep.github.io/blog/2013/02/10/qa-in-python-unittest/
import unittestclass Test(unittest.TestCase): @classmethod def setUpClass(cls): cls._connection = createExpensiveConnectionObject() @classmethod def tearDownClass(cls): cls._connection.destroy()
def setUpModule(): createConnection() def tearDownModule(): closeConnection()
https://nose.readthedocs.org/en/latest/
http://pythontesting.net/framework/nose/nose-introduction/
http://pythontesting.net/framework/nose/nose-fixture-reference/
sudo pip install nose
nose автоматически собирает тесты из файлов начинающихся на test_,
он достаточно умен чтобы заглянуть в папочку tests, если такая присутствует,
может показать покрытие кода тестами (модуль coverage).
Имеет удобный режим, когда запускаются только не прошедшие в прошлый прогон тесты
https://pypi.python.org/pypi/nose-testconfig
How to use assert:
https://mail.python.org/pipermail/python-list/2013-November/660401.html
$ cat t0.py
import unittest
from unnecessary_math import multiply
#http://www.voidspace.org.uk/python/articles/introduction-to-unittest.shtml
class TestUM(unittest.TestCase):
@classmethod
def setUpClass(cls):
print "setUpClass"
@classmethod
def tearDownClass(cls):
print "tearDownClass"
def setUp(self):
unittest.TestCase.setUp(self)
print "setUp"
def tearDown(self):
unittest.TestCase.tearDown(self)
print "tearDown"
def test_numbers_3_4(self):
self.assertEqual( multiply(3,4), 12)
def test_strings_a_3(self):
self.assertEqual( multiply('a',3), 'aaa')
if __name__ == '__main__':
unittest.main()
$ python t0.py -v
setUpClass
test_numbers_3_4 (__main__.TestUM) ... setUp
tearDown
ok
test_strings_a_3 (__main__.TestUM) ... setUp
tearDown
ok
tearDownClass