It has been a hectic 2019 for me. I had some encumbrances that I needed to tackle; however, I turned the page and arose anew.

Just dropping this important gem. It may come in handy for verbose/hackish logs.

Every serious user of a UNIX or Linux operating system knows standard streams, i.e. input, standard output and standard error. They are known as pipes. They are commonly abbreviated as stdin, stdout, stderr.  The standard input (stdin) is normally connected to the keyboard, while the standard error and standard output go to the terminal (or window) in which you are working.
These data streams can be accessed from Python via the objects of the sys module with the same names, i.e. sys.stdin, sys.stdout and sys.stderr.

I am currently working on a code evaluation application. I wanted to build an app that I could stand behind. It took a long time… Longer than I thought.  I am sure it will work out. Need to spend time in front of the screen. Dedicate more time to this blog. No excuses.

Until next time.

Use this for Gunicorn.service code:

Notice the separation of the access log. Rather than override the previous log, we create a totally separate one. This will produce a different result and reflect the production website and not the development one.

Reboot all servers after changes (nginx, gunicorn) when in doubt.

A strongly-typed programming language is one in which each type of data (such as integer, character, hexadecimal, packed decimal, and so forth) is predefined as part of the programming language and all constants or variables defined for a given program must be described with one of the data types. Certain operations may be allowable only with certain data types. The language compiler enforces the data typing and use compliance. An advantage of strong data typing is that it imposes a rigorous set of rules on a programmer and thus guarantees a certain consistency of results. A disadvantage is that it prevents the programmer from inventing a data type not anticipated by the developers of the programming language and it limits how “creative” one can be in using a given data type.

 

This word suggested by: Reg Harbeck.
Last updated on: Dec 03, 1999

Following the Python TDD study track, I came across an older reference(but still relevant) explanation of what a context manager is. I will do a full write up when I have a chance.

Python 2.5 : The ‘with’ statement

https://docs.python.org/release/2.5/whatsnew/pep-343.html

== Have to spend a whole day to rewrite this explanation ==

Writing Context Managers

Under the hood, the ‘with‘ statement is fairly complicated. Most people will only use ‘with‘ in company with existing objects and don’t need to know these details, so you can skip the rest of this section if you like. Authors of new objects will need to understand the details of the underlying implementation and should keep reading.

A high-level explanation of the context management protocol is:

  • The expression is evaluated and should result in an object called a context manager”. The context manager must have __enter__() and __exit__() methods.
  • The context manager’s __enter__() method is called. The value returned is assigned to VAR. If no 'as VAR' clause is present, the value is simply discarded.
  • The code in BLOCK is executed.
  • If BLOCK raises an exception, the __exit__(typevaluetraceback) is called with the exception details, the same values returned by sys.exc_info(). The method’s return value controls whether the exception is re-raised: any false value re-raises the exception, and True will result in suppressing it. You’ll only rarely want to suppress the exception, because if you do the author of the code containing the ‘with‘ statement will never realize anything went wrong.
  • If BLOCK didn’t raise an exception, the __exit__() method is still called, but typevalue, and traceback are all None.

Let’s think through an example. I won’t present detailed code but will only sketch the methods necessary for a database that supports transactions.

(For people unfamiliar with database terminology: a set of changes to the database are grouped into a transaction. Transactions can be either committed, meaning that all the changes are written into the database, or rolled back, meaning that the changes are all discarded and the database is unchanged. See any database textbook for more information.)

Let’s assume there’s an object representing a database connection. Our goal will be to let the user write code like this:

The transaction should be committed if the code in the block runs flawlessly or rolled back if there’s an exception. Here’s the basic interface for DatabaseConnection that I’ll assume:

The __enter__() method is pretty easy, having only to start a new transaction. For this application the resulting cursor object would be a useful result, so the method will return it. The user can then add as cursor to their ‘with‘ statement to bind the cursor to a variable name.

The __exit__() method is the most complicated because it’s where most of the work has to be done. The method has to check if an exception occurred. If there was no exception, the transaction is committed. The transaction is rolled back if there was an exception.

In the code below, execution will just fall off the end of the function, returning the default value of NoneNone is false, so the exception will be re-raised automatically. If you wished, you could be more explicit and add a return statement at the marked location.

  ls -lah

via Explain Shell

postgreSQL :

Nginx:

Django:

Add this first to settings.py

then check here:

Gunicorn:

Use the command cat  or tail  to see the output.

grep -rnw “superlists.settings” -e “DJANGO_SETTINGS”

Explanation of flags:

To configure fabric to connect to remote hosts using SSH keyfiles on Amazon EC2 instances.

add the following after REPO_URL (If you are following OBTTG Tutorial : Chapter 11):