GitPython
Installation
The easy way is to use one of the utilities provided by Python's
setuptools
. If you don't have setuptools
, you can install them with:
{% highlight bash %} sudo apt-get install python-setuptools {% endhighlight %}
...or with:
{% highlight bash %} sudo yum install python-setuptools {% endhighlight %}
... depending on your platform. You can then install GitPython with:
{% highlight bash %} sudo easy_install GitPython {% endhighlight %}
After that, it will be available for you to import and use:
{% highlight python %} import git {% endhighlight %}
Usage
Initialize a Repository Object
If you have a local directory that has already been initialized as a
Git repository (hint: it should contain a .git
subdirectory), then
you can simply create an object of it:
{% highlight python %} import git repo = git.Repo('/home/marios/repositories/test-repo') {% endhighlight %}
See Also
VMware Transparent Page Sharing
Transparent Page Sharing is a memory-saving technique employeed by VMware ESXi hosts, that runs as a background job on the host and removes duplicates pages of memory, by first comparing a hash of the contents of each page, and then comparing pages the hash of which is identical bit by bit.
VMware Memory Balloning
Memory Balloning is a memory reclamation technique employeed by VMware ESXi hosts, that is triggered by high memory utilization on the host and aims to reclaim unused memory on some VMs, for use in others that require it.
Read more
VMware Acronyms
This is a list of acronyms that I come across while reading VMware documentation.
- TPS
- Transparent Page Sharing is a memory-saving technique that runs as a background job on the host, and deduplicates the contents of RAM on the hypervisor, page by page. Read more on TPS...
MySQL Fabric
A series of articles at the MySQL Performance Blog on MySQL Fabric:
ISO Date Format in Apache Logs
Apache's mod_log_config
module (installed by default on CentOS 6) allows for the CustomLog
directive, which in
turn takes a log format specification. This post shows how to use ISO format for Apache logs.
web.py Subapplications
To better organize your source code in a web.py application, you can break it
down in subapplications. Those subapplications will be imported as Python
modules in your main web.py script (which, in the below examples is
index.py
).
Troubleshooting
AttributeError: 'module' object has no attiribute ...
If you get the error:
AttributeError: 'module' object has no attribute 'app'
...then you might be running into Python naming collissions. Check if you have
given one of your subapplications the same name as an existing Python module.
For example, you shouldn't name a subapplication user
, since that is an
existing Python module.
ImportError: No module named ...
If you get the error:
ImportError: No module named subapp
... (where subapp
is the name of your subapplication), then Python cannot
import
the subapplication as a module. As a first step, create an empty file
named __init__.py
in the same directory as your subapplication, and try
again. If you still get that error, and assuming your subapplications are in
the same directory as your main application, you can try this ugly hack in the
very beginning of your main application script:
import inspect
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))))