uWSGI

Summary Python server used for serving Django web requests at ICTC Solution Delivery Commands Restart service uwsgi-emperor status service uwsgi-emperor restart Installation Emperor - name: Install uWSGI emperor apt: name=uwsgi-emperor state=present - name: Configure uWSGI emperor template: src: emperor.ini.j2 dest: /etc/uwsgi-emperor/emperor.ini owner: root group: root mode: 0644 notify: Restart uWSGI Emperor - name: Create log directory file: path: /var/log/uwsgi/vassals state: directory owner: root group: root notify: Restart uWSGI Emperor - name: Enable app server configuration (uWSGI emperor) template: src: uwsgi....

June 5, 2022 · 4 min · Jaaved Khan

Curl vs Python Requests SSL verification

curl vs Having only the intermediate CA in the trust store is not sufficient for validation of the certificate, at least not with the current versions of Python. This feature would require the use of the OpenSSL flag X509_V_FLAG_PARTIAL_CHAIN for verification, which is neither currently exposed by Python nor set by default. Contrary to this curl sets this flag by default in newer versions and thus works.

April 4, 2022 · 1 min · Jaaved Khan

Storing Pillow Image object to Django FileField(ImageField)

Requirement Image object in Pillow to File Object in Django and save them as FileField and FieldFile Methods From Stackoverflow ref: link import StringIO from django.core.files.uploadedfile import InMemoryUploadedFile # Create a file-like object to write thumb data (thumb data previously created # using PIL, and stored in variable 'thumb') thumb_io = StringIO.StringIO() thumb.save(thumb_io, format='JPEG') # Create a new Django file-like object to be used in models as ImageField using # InMemoryUploadedFile....

April 4, 2022 · 1 min · Jaaved Khan

File Object in Python

5 Related: Open function python Synonyms: File like objects Streams Related: Difference between File and Stream? Summary(jak): These are just like another object with standard methods or interfaces- read(), write(), etc - . They allow interactions with underlying resource through the standard interface. File object https://docs.python.org/3/glossary.html#term-file-object An object exposing a file-oriented API (with methods such as read() or write()) to an underlying resource. Depending on the way it was created, a file object can mediate access to a real on-disk file or to another type of storage or communication device (for example standard input/output, in-memory buffers, sockets, pipes, etc....

April 4, 2022 · 2 min · Jaaved Khan

Regular Expressions

Python suspendedfc position ease box interval due front 2.5 0 0 2021-05-11T07:42:36Z ref \w (word character) matches **any single letter, number or underscore (same as [a-zA-Z0-9_])***. Match object A Match Object is an object containing information about the search and the result. This object is returned by `re.search()`, `re.match()`, `re.findall()`. Has propterties and methods `.span()` returns a tuple containing the start-, and end positions of the match....

March 27, 2022 · 3 min · jaavedkhan