Recent Python Posts from Tech Monger :///feeds/python/ 2021-04-30T17:03:17.691104Z Werkzeug Generate Executable Binary From Python Program - Pyinstaller https://techmonger.github.io/82/pyinstaller-script-to-binary 2021-04-30T17:03:17.691104Z 2021-04-30T14:40:21.328054Z Tech Monger <p class="lead"> As a python developer you might want to ship your code to other platforms where python interpreter is not installed. In such event you would need to rely on the binary execution. You can use <code>pyinstaller</code> to achieve your aim; where you can convert your python code to executable binary. Check ODBC Connectivity from Python https://techmonger.github.io/78/odbc-test-pyodbc 2020-11-03T17:08:45.194955Z 2020-11-02T16:52:05.869541Z Tech Monger <p class="lead">If you are connecting to the <abbr title="Open Database Connectivity">ODBC</abbr> database then it is necessary to test connection before creating ODBC data source inisde <code>ODBC.INI</code> file. Below we will create simple python script which initiate ODBC connection with details provided inside ODBC.ini file and output if connection is working or failing.</p> How Password Hashing Works in Ubuntu Linux https://techmonger.github.io/74/linux-password-hashing 2019-07-06T14:12:28.378608Z 2019-07-06T12:42:06.108035Z Tech Monger <p class="lead"> If you ever wondered where and how user passwords are stored in linux file system then this post will answer most of your questions. Below we will discuss password hashing in ubuntu but many other linux distributions follow this pattern. Below read assumes that you have basic familiarity with hash function like md5 or sha-256. How to use Jinja2 in Python without Flask https://techmonger.github.io/69/jinja2-render-html 2019-01-05T05:50:09.136214Z 2019-01-04T18:43:27.606962Z Tech Monger <p class="lead"> Due to various reasons you might want to render dynamic html content outside of your web application. For example to create the html email body. Also you might want to use jinja2 with web framework which does not have inbuilt support for it. Below we will explain how to use jinja2 as standalone utility in python script with the help of an <a href="#example">example code</a>. Change TOR IP Address with Python using STEM https://techmonger.github.io/68/tor-new-ip-python 2018-12-25T17:02:26.558297Z 2018-12-25T14:37:43.102142Z Tech Monger <p> If you are using TOR inside python script then you may find need to renew IP Address. In this tutorial we will change IP address using <code>stem</code> package. We will use TOR controller file <code>torrc</code> to communicate with TOR. Solving Scrapy User timeout caused connection failure https://techmonger.github.io/65/troubleshoot-scrapy-user-timeout 2018-11-20T07:06:50.542649Z 2018-11-19T18:00:39.563913Z Tech Monger <p class="lead">If the website you are scraping is not responding to your requests then your spider would report failure due to request timeout and throw following error.</p> Custom Validation Messages with WTForms https://techmonger.github.io/64/wtf-custom-validation-hack 2018-11-11T09:18:28.423182Z 2018-11-11T07:56:08.911691Z Tech Monger <p class="lead"> While using WTF or Flask-WTF for the form validation you would often find yourself adding custom validation messages according to the requirement of your web application. You can always use WTF's <code>ValidationError</code> API however in this tutorial we will show you clever hack to add validation messages during page rendering. We will show <a href="#example">example code</a> with <a href="/tag/flask" title="Flask Tutorials">flask</a> but you can use this method with any other framework which is using WTF for form validation. Scrapy Get Redirect URLs and Request URL https://techmonger.github.io/63/scrapy-redirect-urls 2018-11-10T07:16:38.730746Z 2018-11-09T13:46:24.517791Z Tech Monger <p class="lead"> If you ever wanted to figure out all the redirect urls that scrapy spider hopped on or what is the currently requested URL by the spider then you easily get that using following <a href="#example">example code</a>. Scrapy Random Fake User Agent Example https://techmonger.github.io/62/example-scrapy-fake-user-agent 2018-10-19T19:16:03.373783Z 2018-10-19T18:30:06.053868Z Tech Monger <p class="lead"> If sites you are crawling with scrapy dont respond to your request then you should use randomly generated user agent in your request. Scrapy Fake User Agent is one of the open source and useful extension which will help you evade bot detection programs easily. Faster TNSPING in Python with Queue and Threads https://techmonger.github.io/56/faster-tnsping-python 2018-09-20T10:23:44.699240Z 2018-09-20T10:11:50.627193Z Tech Monger <p class="lead"> Previously we have seen how can we implement TNSPING command in python and process tnsping response to make programmatic decisions. But that approach may not be optimal when you have large set of net service names to check. In this tutorial we will implement concurrent version of TNSPING checker in python with help of Threads and Queues. Producer Consumer Model in Python https://techmonger.github.io/55/producer-consumer-python 2018-09-20T10:26:35.181279Z 2018-09-18T19:23:36.256250Z Tech Monger <p class="lead"> In this tutorial we will learn how to write python code that provides solution to the classic producer consumer problem with the help of an <a href="#example">example</a>. We will make use of inbuilt python features such as <a href="#thread">Thread</a> and <a href="#queue">Queue</a>.