Александр Брюндтзвельт - гений, филантроп, 100 гривен в кармане. Этот блог - "сток" моих мыслей и заметок. Достаточно одного взгляда на него, чтобы понять, что такой же бардак творится у меня в голове. Если вам этот бардак интересен - милости прошу.

WSGI mod, Python, Django, Celery and a nice fella virtualenv

Here I’ll show how to use Python (3.8.0 in the current example, but legit for latest 3.+ versions, not for os.name == ‘NT’) and virtualenv to setup WGSI enabled website on Django (or any) with implemented Celery + Flower + RabbitMQ. This example is my own path used for automated test framework: Octopus (not available now, but have dev branch opened: Lobster) Here only configurations and setup for Python 3.8.0, virtualenv, WSGI, Django, Celery (worker and beat services), Flower and that’s it. Later I’ll show Django + Celery configuration when they run together (sort of). You may want to install Python at first: Read When your modern and fancy python is installed, we’ll make a virtual environment for our website.Short Read more…

Centos Python Installation Guide with no Pain

Install Python on Centos 7 with make altinstall and without pain. Read more…

Test design and implementation.

Test design Our test system has a pretty simple configuration, so I do not want to bother you with the detailed description of it. Simply – it’s just a standalone execution of a test.py file with all requirements (test setup and tear down) in local internal test utility. Helper local utility has a usual amount of preparation functions, test data loading and some other configurations. In the very end of test loading, it just compares a node-set result of “real” scan (software and hardware nodes in a database after the scan) with predefined node-set (from test.py). Node set we usually expect at the end of the test should be added by the developer when product discovery pattern is ready orShort Read more…

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…

Python 3 showing progressbar while subprocess.Popen

Have an interesting case I want to share and save for future. One small problem in this system: https://github.com/trianglesis/BMC_TPL_IDE is showing when some process is running and was not hanged up. Sometimes we need to run a huge amount of checks and tests and would be great to know if something hangs before killing it mannually. I used different scenarios and mostly a module pregressbar2, and this is what I finally can compose: Make worker which will execute job sorf of randomly: import time import random print(“START SOMETHING”) for i in range(5): sec = random.randint(1, 3) print(“Sleeping for: %d” % sec) time.sleep(sec) print(“Making job, line: %d” % i) print(“END SOMETHING”) Make process executor: import sys import subprocess import progressbar # DrawShort Read more…

VK_execute

Для всех страждущих наконец выкладываю нормальные примеры использования VK Script: https://github.com/triaglesis/vk_execute Там все мои примеры и по работе и просто тестовые. Самый быстрый вот такого плана, без внутреннего парсинга. Как только добавляешь внутрь вк скрипта какой-то проверочный код – КПД резко падает. Мой совет – вк_скрипт только для сбора всего “сырого” – дальше обрабатывать уже на сереверной стороне. var posts_cnt; var posts; var post_list = []; var offset_posts = Args.global_offset_posts; offset_posts = parseInt(offset_posts); // var offset_posts = 0; var run_count = 0; var iter_count = 20; while (iter_count > run_count ) {posts = API.wall.get( {“owner_id”:(Args.owner_id), “domain”:(Args.domain), “offset”:(offset_posts), “count”:”100″, “filter”:”all”, “extended”:”0″, “v”:”5.42″} ); post_list.push(posts.items); offset_posts = offset_posts + 100; run_count = run_count + 1; posts_cnt = posts.count; }; return {“posts_cnt”: posts_cnt,Short Read more…

Django, Apache2, Sublime Text 3 build system and developing process.

At first be sure that you are using this path to run pure apache: http://www.trianglesis.org.ua/django-python-3-4-wamp-apache-2-4-23-pycharm This topic for those who wants to develop ON THE FLY with python and django and do not want to manually restart dev server each time when code changes AND you don’t like built in python web-server and want to run your dev site as it should run on apache. Sublime Text 3 I use it for fast code changing and writting because PyCharm can’t work fine with multiline carrets, for example. Also PyCharm is too heavy when you want just copy&paste some features and see how it work on web. So my PyCharm will be used for debug purposes. I hope you know what isShort 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…