05 Jan 2013 Matteo Mattei python py2exe tk When I have to develop background console applications in Python that have to be executed in Windows, I usually use py2exe and Inno Setup for creating installer. However the big issue is always how to report and show errors to the users. My preferred solution is to keep the application as a pure console application (no graphical), set the py2exe application as a window application and handle the errors with graphical messagebox.
And since the Tk library is included in the Python standard library, it is worth using it.
Lines 10 and 11 are needed to don’t show the main Tk window in background. Updated with support for both python 2.7 and python 3.x
08 Dec 2012 Matteo Mattei python pyside The tool to transform myapplication.ui generated with qt-designer in myapplication_ui.py, is called pyside-uic (if you use PySide, or pyuic if you use PyQt). Its usage is straightforward:
Linux:
pyside-uic myapplication.ui > myapplication_ui.py
Windows:
C:\python27\scripts\pyside-uic.exe myapplication.ui > myapplication_ui.py
But can happen the following error:
Traceback (most recent call last):
File "C:\Python27\Scripts\pyside-uic-script.py", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
To fix the problem you need to intall setuptools from http://pypi.python.org/pypi/setuptools Now to use the generated file you need to add the following code to your application:
17 May 2012 Matteo Mattei svn ldap server ubuntu If you need to configure a svn server on Linux with LDAP authentication, webdav and insert specific directory restrictions you can follow these instructions.
- You need to install subversion and apache in your Linux server (I will omit this part).
-
You need to configure webdav to access svn over http and configure LDAP access.
Make sure to have the following apache modules installed and configured:
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule dav_module modules/mod_dav.so
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
LoadModule authn_alias_module modules/mod_authn_alias.so
Assumptions:
- I am usual to configure subversion in /srv/svn folder.
- The users allowed to access the SVN have to belong to the LDAP group CN=SVN-AUTHORIZATION,OU=Groups GSO,DC=test,DC=example,DC=com
Edit /etc/apache2/mods-enabled/dav_svn.conf (this is valid for Ubuntu. Maybe in other distributions this file is placed somewhere else) and make sure to have the following lines:
<Location /svn/>
# Enable svn over webdav
DAV svn
# Set parent path for multiple repositories
SVNParentPath /srv/svn/
# Set authentication type
AuthType Basic
# Set authentication name
AuthName "FLR Subversion Repository"
# Set authorization (permissions) file
AuthzSVNAccessFile /etc/apache2/dav_svn.authz
# Allow to list the parent path
SVNListParentPath On
# Use LDAP for authentication
AuthBasicProvider ldap
# LDAP server is authoritative (so is the final step for autentication)
AuthzLDAPAuthoritative On
# LDAP bind user
AuthLDAPBindDN "CN=svnbind,OU=Users OS,DC=test,DC=example,DC=com"
# LDAP bind password
AuthLDAPBindPassword mypassword
# LDAP URL
AuthLDAPUrl "ldap://ldap_ip_address:389/DC=test,DC=example,DC=com?sAMAccountName?sub?(&(&(objectClass=user)(objectCategory=person))(memberof=CN=SVN-AUTHORIZATION,OU=Groups GSO,DC=test,DC=example,DC=com))"
# A valid user is required
Require valid-user
</Location>
-
Create the permission file /etc/apache2/dav_svn.authz It will have the following content based on your needing:
[groups]
admin = matteo
group1 = user1, user2, user3
group2 = user2
group3 = user4
###################################
[/]
* = r
@admin = rw
###################################
[repository1:/]
* = rw
###################################
[repository2:/]
* =
@admin = rw
@group1 = rw
###################################
[repository3:/]
* =
@admin = rw
@group2 = rw
@group1 = r
###################################
[repository4:/]
* = r
@admin = rw
[repository4:/trunk/sources]
* = r
@admin = rw
@group3 = rw
###################################</pre>
Now restart apache with
/etc/init.d/apache2 restart
-
Create repositories. As root issue the following commands:
cd /srv/svn
svnadmin create repository1
chown www-data.www-data -R repository1
svnadmin create repository2
chown www-data.www-data -R repository2
svnadmin create repository3
chown www-data.www-data -R repository3
svnadmin create repository4
chown www-data.www-data -R repository4
You are now ready to use your new subversion repository with LDAP account, webdav access and custom user/group directory restrictions.
20 Mar 2012 Matteo Mattei virtualization tricks vmware If your virtual machine created with VMware Player becomes very slow and takes a long time to complete some operations it’s time to improve its performance! Close your VM, and open the *.vmx file with a text editor. Then add at the end of the file the following lines:
mainMem.useNamedFile = "FALSE"
sched.mem.pshare.enable = "FALSE"
MemTrimRate = 0
MemAllowAutoScaleDown = "FALSE"
prefvmx.useRecommendedLockedMemSize = "TRUE"
prefvmx.minVmMemPct = "100"
Make sure to not duplicate the keywords (in case you already have some lines set) otherwise the VM will not start. The above lines totally reserve the memory requested by the VM to the guest system and avoid to continuously ask to the host (and so to the swap file) for new memory chunks.
Try yourself and give me a feedback!
26 Nov 2011 Matteo Mattei linux mysql php apc tricks If you are running PhpMyAdmin and APC, it can happens that you get some errors like these:
PHP Fatal error: Call to undefined function PMA_log_user() in /usr/share/webapps/phpMyAdmin/libraries/common.inc.php on line 914
PHP Fatal error: Call to undefined function PMA_select_language() in /usr/share/webapps/phpMyAdmin/libraries/auth/cookie.auth.lib.php on line 220
PHP Fatal error: Call to undefined function pma_generate_common_url() in /usr/share/webapps/phpMyAdmin/libraries/header_meta_style.inc.php on line 48
PHP Fatal error: Call to undefined function PMA_DBI_connect() in /srv/http/librolandia.it/test/phpmyadmin/libraries/common.inc.php on line 916
PHP Fatal error: Class 'PMA_Error_Handler' not found in /path/to/phpMyAdmin/libraries/common.inc.php on line 58
PHP Fatal error: Call to undefined function PMA_getenv() in /path/to/phpMyAdmin/libraries/common.inc.php on line 143
If this is the case, you need to make some little changes to disable apc in your phpmyadmin virtual host:
Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"
<Directory "/usr/share/webapps/phpMyAdmin">
AllowOverride All
Options FollowSymlinks
Order allow,deny
Allow from all
php_admin_value open_basedir "/srv/:/tmp/:/usr/share/webapps/:/etc/webapps:/usr/share/pear/"
php_admin_value apc.enabled 0
</Directory>
And also modify your apc filter in php.ini under the APC section:
[APC]
apc.filter="-/usr/share/webapps/phpMyAdmin/.*"
Now restart Apache and you phpMyAdmin should work regularly.