Test automation or: How I Learned to Stop Worrying and Love Async __init__

octopus_main_page

Morning everybody… I recommend reading this part of the blog only in the morning with a cup of dark and strong coffee. I’ll show you some new cases, and howto’s to help you automate routines in the developer’s life. There will be an example of my fails and win on different scenarios. The poor code I’ll include also. Very beginning Firstly – I’ll try to make this thread in English. And maybe later when I have time – to make Ukrainian and Russian translations, I’ll make them. “Octopus” story has started from a small plugin for Sublime Text editor. Later it will be ported to Atom. I’ve started developing “Octopus” on spring-summer 2016, and I’ve not finished it yet! New functionsShort Read more…

Python – Django Celery – кейс длиною в вечность.

Вкратце: когда добавляешь пачку тасок на Celery worker’ы, случается так, что парочка из них отваливается или засыпает или еще чего. Долго не доходили руки поправить это недоразумение, поэтому я просто рестартовал все воркеры раз в пару дней или прямо перед началом проверки рутины, в общем очень сложно было поймать и воспроизвести тот случай, когда без каких-либо ошибок воркер просто молчал. И наконец дошоли руки запилить кривофикс, время покажет насколько он толковый, суть в следующем: В сразу после момента определения свободного воркера  – запускать app.control.heartbeat() и app.control.ping(timeout=10) и если ответ пришел (в виде [{‘alpha@host’: {‘ok’: ‘pong’}}]) – значит воркер готов и можно передавать ему таску, пачку тасков, рутину и тп. Если ответ пришел отличным от этого – даем ошибку и ничего не запускаемShort Read more…

Django + Python 3.4 + WAMP Apache 2.4.23 + Pycharm

Finally worked instance for hosting DEV site code on python and ability to resolve is as “on live” web server just on my laptop. A lot of different configurations changed but this is one working for me, and maybe can help you also. Better use EVERYTHING 32 bit for Window, you will suffer if you try to find some needed wheels for python 64bit on Windows 7 64bit.   WAMP Apache 2.4.23 Download: wampserver3.0.6_x86_apache2.4.23_mysql5.7.14_php5.6.25-7.0.10 Here NOTE: Install all needed C++ Redistr. packages which are listed in WAMP install guide! Download mod_wsgi.so Here or Here (for everythin 32 bit and python 3.4 on Win7 you need: mod_wsgi-py34-VC10.so) NOTE: Use mod_wsgi version which corresponds your python version! (Above in links you can find more info, justShort Read more…

Gjango, Pycharm – static files Windows

This topic for those who broke his mind trying to understand how to make Pycharm run Django with static files I’ve made it, but be carefull it can break your mind too! The settings I use the most portable way to configure settings – so I can move it into centos web server without paths changes Win\Unix (I HOPE). There are common DIRs BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # BASE DIR: D:\Projects\CODE\WEB\sites\www\smm_tools\smm_site PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)) # PROJECT_ROOT:     D:\Projects\CODE\WEB\sites\www\smm_tools\smm_site\main_code STATIC_ROOT = os.path.join(BASE_DIR, ‘static’) #Static root:      D:\Projects\CODE\WEB\sites\www\smm_tools\smm_site\static STATIC_URL = ‘/static/’ Looks like ot works, but in really weird way: static files are working fine web page as template is loading some scc and js are loading and some are notShort Read more…

Django fast hints

Here some fast hints to remember: Migration: cd ~/myproject python manage.py makemigrations python manage.py migrate   Alias /static/ “/var/www/smm_tools/site/”   Read more…

Django static files

How to find where def. static stores? [root@test smm_py]# python3 manage.py findstatic css/base.css admin/js/core.js No matching file found for ‘css/base.css’. Found ‘admin/js/core.js’ here: /usr/local/lib/python3.4/site-packages/django/contrib/admin/static/admin/js/core.js Then move it into the folder you need. Then update django’s.conf file: Alias /static/ “/var/www/smm_tools/site/” And check the settings.py: 103 # Static files (CSS, JavaScript, Images) 104 # https://docs.djangoproject.com/en/1.8/howto/static-files/ 105 106 STATIC_URL = ‘/static/’ https://docs.djangoproject.com/en/1.8/howto/static-files/   Read more…

Django + Python3.4 + Mysql(MariaDB)

Just hint for future me: [root@test smm_py]# vim settings.py [root@test smm_py]# python manage.py makemigrations import MySQLdb as Database ImportError: No module named ‘MySQLdb’ django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named ‘MySQLdb’ [root@test smm_py]# pip install mysql-python3 Collecting mysql-python Downloading MySQL-python-1.2.5.zip (108kB) 100% || 110kB 812kB/s ImportError: No module named ‘ConfigParser’ —————————————- Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-t64nwwtb/mysql-python [root@test smm_py]# easy_install mysql-python ImportError: No module named ‘ConfigParser’ ImportError: No module named ‘ConfigParser’ [root@test smm_py]# pip3 install ConfigParser Collecting ConfigParser _KEYCRE = re.compile(ur”%\(([^)]+)\)s”) SyntaxError: invalid syntax —————————————- [root@test smm_py]# pip3.4 install –allow-external mysql-connector-python mysql-connector-python Collecting mysql-connector-python Downloading http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip (277kB) 100% || 278kB 3.7MB/s Successfully built mysql-connector-python Successfully installed mysql-connector-python-2.0.4 [root@test smm_py]# vim /smm_py/settings.py 76 77 DATABASESShort Read more…

Django + apache2 + mod_wsgi

This is conf file to allow apache run Django applications. # Web site at /var/www/smm_tools # Python scripts at /var/www/smm_tools/smm_py #LoadModule wsgi_module /usr/lib64/httpd/modules/mod_wsgi.so <VirtualHost *:80> ServerName smm.www.trianglesis.org.ua ServerAlias www.smm.www.trianglesis.org.ua ServerAdmin it@www.trianglesis.org.ua DocumentRoot /var/www/smm_tools/ ErrorLog “|/usr/sbin/rotatelogs /var/log/smm_tools/cargo.error.%Y-%m-%d.log 86400” CustomLog “|/usr/sbin/rotatelogs /var/log/smm_tools/cargo.access.%Y-%m-%d.log 86400” combined ServerSignature On Alias /css/ “/var/www/smm_tools/site/css” Alias /js/ “/var/www/smm_tools/site/js/” Alias /templates/ “var/www/smm_tools/site/templates/” Alias /fonts/ “/var/www/smm_tools/fonts/” #WSGIScriptAlias / /var/www/smm_tools/smm_tools.wsgi #WSGIPythonPath /var/www/smm_tools <Directory /var/www/smm_tools/smm_py/smm_py> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess smm_tools python-path=/var/www/smm_tools/smm_py:/usr/local/lib/python3.4/site-packages/ WSGIProcessGroup smm_tools WSGIScriptAlias / /var/www/smm_tools/smm_py/smm_py/wsgi.py </VirtualHost> Use these links: https://www.digitalocean.com/community/tutorials/how-to-run-django-with-mod_wsgi-and-apache-with-a-virtualenv-python-environment-on-a-debian-vps https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04 https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ Don’t forget to use correct IPs – domains, and addresses. Especially if proxy pass is used.     Read more…